Go to Post According to my father the hint should be released sometime next week, but he's never been the most trustworthy source of info.... - Lil' Lavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-02-2003, 15:02
maDGag maDGag is offline
Registered User
#0334
 
Join Date: Dec 2002
Location: Brooklyn, NY
Posts: 14
maDGag is an unknown quantity at this point
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
  #2   Spotlight this post!  
Unread 16-02-2003, 16:33
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,557
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
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.
  #3   Spotlight this post!  
Unread 16-02-2003, 23:27
ChrisA's Avatar
ChrisA ChrisA is offline
Registered User
#0857 (Superior Roboworks)
Team Role: College Student
 
Join Date: Feb 2002
Location: Michigan Tech
Posts: 157
ChrisA is on a distinguished road
Send a message via AIM to ChrisA
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'.
__________________
Programmer
----------------
Team#857
Superior Roboworks

WildStang Alum
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:39.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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