2014-03-27 42 views
0

問題的背景信息:我正在寫一個文本冒險遊戲,玩家在每個路口/問題處有多條路徑可供選擇。BBC基本變量

問題:我試圖從另一個路徑使用一個變量,這個變量可能沒有被調用。無論如何要先調用這個變量或跳過一行代碼?

這是我的代碼的部分我講的

38  input "What do you do? 'A' to continue, 'B' to run away" , BAB$ 
    39  if BAB$ == "A" then 
    40  if BCP$ == "B" then 
    41   print "The hunters see you return" 
    42   print "When they ask if you found the prisoner, you respond by saying that you havent seen him" 
    43   print "The hunters decide that this venture isnt worth it, and decide to leave, taking you with them" 
    44   wait 30 
    45   print "You escape shortly after the rest of the group leaves the area" 
    46   print "You are now a free man" 
    47   wait 200 
    48   clear 
    49   cls 
    50   goto 100 
    51  else 
    52   goto 55 
    53  endif 

對我的措辭有任何疑問?請問!

回答

1

最簡單的回答這個問題,只是初始化變量在程序的啓動:

BAB$ = "" 
BCP$ = "" 

這樣一來,當你打40行,無論是BCP $會有的「值」或有其他價值。

+0

非常感謝!這幫助了我一大堆!把我從幾個小時擔心我能做的錯誤 – Rayner

+0

當你對此有點熟悉時 - 查閱程序和功能(如果你使用的是BBC基本版),因爲這會使你的代碼更加清晰,那些討厭的GOTO。 – Justin