I'm trying to get a GOTO to work.
Code: Select all
PRINT "Logon Name"; : INPUT L$
IF L$ = "austin" THEN
PRINT "Hello Austin."
ELSE PRINT "Logon Name Incorrect."
GOTO 1
END IF
Regards,
Austin
Code: Select all
PRINT "Logon Name"; : INPUT L$
IF L$ = "austin" THEN
PRINT "Hello Austin."
ELSE PRINT "Logon Name Incorrect."
GOTO 1
END IF
Code: Select all
1 PRINT "Logon Name"; : INPUT L$
IF L$ = "austin" THEN
PRINT "Hello Austin."
ELSE
PRINT "Logon Name Incorrect."
GOTO 1
END IF
Code: Select all
CorrectName = 0
DO
PRINT "Logon Name"; : INPUT L$
IF L$ = "austin" THEN
PRINT "Hello Austin."
CorrectName = 1
ELSE
PRINT "Logon Name Incorrect."
END IF
LOOP UNTIL CorrectName = 1
Code: Select all
GOTO BEGIN
Code: Select all
begin:
blah
blah
blah
GOTO begin
Hi Austin, welcome to the forum.Austin wrote:Hello Everyone!
I'm trying to get a GOTO to work.
Regards,Code: Select all
PRINT "Logon Name"; : INPUT L$ IF L$ = "austin" THEN PRINT "Hello Austin." ELSE PRINT "Logon Name Incorrect." GOTO 1 END IF
Austin
Code: Select all
dim scr$(10,10) ' create an array to hold data
for x = 1 to 10
for y = 1 to 10
read s$
if len(s$) > 1 then scr$(x,y) = chr(val(s$)) else scr$(x,y) = s$
next y
next x
data 179,179,179,179,179,179,179,179,179,179
data 179,032,032,032,032,G ,032,032,032,032
data 179,032,032,032,032,032,032,032,032,179
data 179,032,032,032,032,032,032,032,032,179
data 179,032,032,032,032,032,032,032,032,179
data 179,032,032,032,032,032,032,032,032,179
data 179,032,032,032,032,032,032,032,032,179
data 179,032,032,032,032,032,032,032,032,179
data 179,032,032,032,032,P ,032,032,032,179
data 179,179,179,179,179,179,179,179,179,179
Code: Select all
for y=1 to 10
for x = 1 to 10
print scr$(x,y);
if scr$(x,y) = "P" then px = x:py=y
next x
print " "
next y
Code: Select all
gameover = 0
while gameover = 0
input "Enter your move ";m$
m$=ucase$(left$(m$,1))
select case m$
case "N"
if y >1 then ' player is moving off-screen
if scr$(x,y-1) = " " then
swap scr$(x,y-1),scr$(x,y)
end if
if scr$(x,y-1) = "G" then
gosub general
end if
end if
case "S"
if y <10 then ' check player going off screen
if scr$(x,y+1) = " " then
swap scr$(x,y+1),scr(x,y)
end if
if scr$(x,y+1) = "G" then
gosub general
end if
end if
case "E"
if x > 1 then
if scr(x-1,y) = " " then
swap scr$(x-1,y),scr$(x,y)
end if
if scr(x+1,y) = "G" then
gosub general
end if
end if
case "W"
if x < 10 then
if scr$(x+1,y) = " " then
swap scr$(x+1,y), scr$(x.y)
end if
if scr$(x+1y) = "G" then
gosub general
end if
end if
case else ' to be done if no cases above match
print "I don't understand that move"
end select
wend
system
general:
put code for processing general interaction with player here!
return
' this part could also be coded as a subroutine!
Code: Select all
DIM scr$(10, 10)' create an array to hold data
FOR x = 1 TO 10
FOR y = 1 TO 10
READ s$
IF LEN(s$) > 1 THEN scr$(x, y) = CHR$(VAL(s$)) ELSE scr$(x, y) = s$
NEXT y
NEXT x
DATA 177,177,177,177,177,177,177,177,177,177
DATA 177,032,032,032,032,032,032,032,032,177
DATA 177,032,177,177,177,177,177,177,032,177
DATA 177,032,177,032,G ,177,032,177,032,177
DATA 177,032,177,032,032,177,032,032,032,177
DATA 177,032,032,032,177,177,032,032,177,177
DATA 177,177,177,177,177,032,032,032,032,177
DATA 177,032,032,032,032,032,032,032,177,177
DATA 177,032,032,032,032,P ,032,032,032,177
DATA 177,177,177,177,177,177,177,177,177,177
gameover = 0
WHILE gameover = 0
FOR x = 1 TO 10
FOR y = 1 TO 10
PRINT scr$(x, y);
IF scr$(x, y) = "P" THEN px = x: py = y
NEXT y
PRINT " "
NEXT x
x = px: y = py
INPUT "Enter your move "; m$
m$ = UCASE$(LEFT$(m$, 1))
SELECT CASE m$
CASE "W"
IF y > 1 THEN ' player is moving off-screen
IF scr$(x, y - 1) = " " THEN
SWAP scr$(x, y - 1), scr$(x, y)
END IF
IF scr$(x, y - 1) = "G" THEN
GOSUB general
END IF
END IF
CASE "E"
IF y < 10 THEN ' check player going off screen
IF scr$(x, y + 1) = " " THEN
SWAP scr$(x, y + 1), scr$(x, y)
END IF
IF scr$(x, y + 1) = "G" THEN
GOSUB general
END IF
END IF
CASE "N"
IF x > 1 THEN
IF scr$(x - 1, y) = " " THEN
SWAP scr$(x - 1, y), scr$(x, y)
END IF
IF scr$(x - 1, y) = "G" THEN
GOSUB general
END IF
END IF
CASE "S"
IF x < 10 THEN
IF scr$(x + 1, y) = " " THEN
SWAP scr$(x + 1, y), scr$(x, y)
END IF
IF scr$(x + 1, y) = "G" THEN
GOSUB general
END IF
END IF
CASE "Q"
SYSTEM
CASE ELSE ' to be done if no cases above match
PRINT "I don't understand that move"
END SELECT
WEND
SYSTEM
general:
gameover = 1
RETURN
' this part could also be coded as a subroutine!