Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UH little help guys
#3
(08-31-2024, 05:32 AM)Petr Wrote: Hi. There is a difference between calling a part of a program that is labeled SUB and END SUB and between calling GOSUB and RETURN. A significant difference is also that variables that are not globally shared have no value or the same as in the part of the program between SUB and END SUB, if variable the same name in not declared as SHARED or is not used as parameter in SUB .

Sub example:

Code: (Select All)

'SUB use

Dim Shared PName As String 'try delete me and run it again!

NameIn
Print "Name:"; PName$

Sub NameIn
    Input "input name:"; PName$
End Sub

GoSub example:

Code: (Select All)

'GoSUB use

GoSub NameIn
Print "Name:"; PName$
End

NameIn:
Input "input name:"; PName$
Return

Your code:

Code: (Select All)

Dim money As Integer
Dim strength As Integer
Dim speed As Integer
Dim babes As Integer
Dim balls As Integer
Dim cash As Integer
Dim directions As Integer


'intro
Screen 0
Color 4, 0
Locate 8, 38
Print "The World"
Locate 8, 38
Print "Is Loading"
_Delay 5

'opening
Cls
Print "You finally got released from Prison at Kulai Headquarters"
Print "you looked at the sky and the people below it, you began"
Print "wondering, that you can become rich and powerfull"
Print "so you began your journey."
_Delay 10
'GoSub 10
MainPart


Sub MainPart
    Cls
    Print "Whats your name?"
    Input name$
    Sleep 2
    Cls
    Print "You are outside of Kulai Headquarters,"
    Print "Where will you go?"
    Print "(NORTH)"
    Print "(SOUTH)"
End Sub


Sub Options (directions)
    If x = north Then
        Print "You Found A Market of Stores"
    ElseIf x = south Then
        Print "You went to Kulai Headquarters"
    End If
End Sub

ah i got it, thanks bro
[Image: giphy.gif]
Reply


Messages In This Thread
UH little help guys - by WriterHash - 08-31-2024, 04:13 AM
RE: UH little help guys - by Petr - 08-31-2024, 05:32 AM
RE: UH little help guys - by WriterHash - 08-31-2024, 05:49 AM
RE: UH little help guys - by Petr - 08-31-2024, 05:51 AM
RE: UH little help guys - by WriterHash - 08-31-2024, 07:44 AM



Users browsing this thread: 4 Guest(s)