whiskeyd
Member in Training
That that is is, that that is not is not, that that is not is not that that is.
Posts: 23
|
Post by whiskeyd on Feb 17, 2023 19:06:58 GMT
Can SUB and FUNCTION routines be used in JB rather than branch labels?
|
|
|
Post by Rod on Feb 17, 2023 19:14:49 GMT
Yes, easily. There are demos that ship with just BASIC that uses subs and functions. The help file discusses branch label and sub handlers, also functions.
|
|
whiskeyd
Member in Training
That that is is, that that is not is not, that that is not is not that that is.
Posts: 23
|
Post by whiskeyd on Feb 17, 2023 20:59:13 GMT
Thank you. One more question, can SUBs be defined for event handlers?
|
|
|
Post by plus on Feb 17, 2023 23:39:03 GMT
Yes, welcome to the forum!
|
|
|
Post by jarychk on Feb 18, 2023 0:10:52 GMT
Thank you. One more question, can SUBs be defined for event handlers? Although YES, a person may wish instead not to, simply for his personal comfort in using that style. For myself, I like to take a section of code and place it past the END statement of program; and put code to run the subroutine and then continue onward from there. I just don't have the comfort in turning controls' codes into subroutines. YOU might become comfortable with doing it (and some people ARE comfortable doing it.)
|
|
whiskeyd
Member in Training
That that is is, that that is not is not, that that is not is not that that is.
Posts: 23
|
Post by whiskeyd on Feb 18, 2023 19:11:43 GMT
I am much more comfortable with SUBs and FUNCTIONs then branch labels and GOSUB
|
|
|
Post by Rod on Feb 18, 2023 19:39:58 GMT
Then you only need to be aware that arrays are global in Just BASIC You can also create global variables. But do not pass arrays or global variables to subs or functions as parameters. Simply use the globals within the sub or function.
|
|
xcoder
Member in Training
Posts: 56
|
Post by xcoder on Nov 8, 2024 20:37:59 GMT
print "##### Main #####"
call thisOne
alpha = thatOne()
bravo$ = thisTwo$()
print bravo$
delta = thatTwo()
print delta
print:print
print "End of Main"
End
sub thisOne '''returns nothing
print "hello sub procedure"
end sub
function thatOne() '''returns nothing
print "function thatOne"
end function
function thisTwo$() ''''returns a string
thisTwo$ = "function thatTwo"
end function
function thatTwo() '''returns a variable
thatTwo = 2 * 200
end function
insert coprint "##### Main #####" call thisOne alpha = thatOne() bravo$ = thisTwo$() print bravo$ delta = thatTwo() print delta print:print print "End of Main" End
sub thisOne '''returns nothing print "hello sub procedure" end sub function thatOne() '''returns nothing print "function thatOne" end function function thisTwo$() ''''returns a string thisTwo$ = "function thatTwo" end function function thatTwo() '''returns a variable thatTwo = 2 * 200 end function de here
|
|