Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   subs/functions (http://www.chiefdelphi.com/forums/showthread.php?t=18041)

maDGag 16-02-2003 15:02

subs/functions
 
can i pass stuff to subs ?

are there functions in PBASIC

i suppose global vars modified in sub works, but it's messy

Joe Ross 16-02-2003 16:33

there are no functions in pbasic. The closest you have is subroutines accessed by gosub. You can not pass parameters to subroutines and so, you must use global variables.

If you wanted to get fancy, you could use part of the scratchpad memory as a stack, and push function parameters onto it just like a c compiler does, but you are asking for trouble, and it would take time.

ChrisA 16-02-2003 23:27

Subroutines work just like regular code. If you go into a subroutine, it will flow straight from the code previous to the gosub command right into the subroutine. The only thing, I believe, that you cannot do is continue if statements into the subroutine. Any variables you have in that bank will still be present and any constants will also be accessible.

Subroutines are commonly used to share equations among multiple parts of the code.

I'm not sure what exactly you are asking. Maybe you could rephrase your question.

Quote:

Originally posted by maDGag
i suppose global vars modified in sub works, but it's messy
I'm not sure how you find it 'messy'.


All times are GMT -5. The time now is 17:53.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi