Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! Passing records!!

Status
Not open for further replies.

adeal

Programmer
May 15, 2002
4
CA
Hey, I would like to know th code for passing a a record from one sub program to another sub program.

Type Person
Name AS STRING *12
Age AS INTEGER
Money AS INTEGER
END TYPE

DIM MALE AS Person

How would I pass something hat that?

Thanks in advance.
 
Try:

Checkperson MALE

SUB Checkperson (Oneperson AS Person)

'your code here

END SUB
 
[tt]COMMON SHARED /People/ MALE AS Person, FEMALE AS Person[/tt]
VCA.gif
 
Also good, but COMMON is usually used to pass variables from one program to another
 
how can you do this without "Globalizing it"
 
Globalizing it would be more prudent if your apps will need to have access to the same data from different modules.

If, however, you plan on using the data in only one module, you should make it 'locally' global

See & test the following example for yourself. It may help you get a better grasp on your delima.


TYPE Person
IsMale AS INTEGER
FirstName AS STRING * 20
END TYPE

DIM Human AS Person

DECLARE SUB EnterMe (WholeThing AS Person)
DECLARE SUB CheckMe (WholeThing AS Person)

EnterMe Human
CheckMe Human

END



SUB CheckMe (WholeThing AS Person)
PRINT
PRINT "++++++++++++++ In CheckMe sub now +++++++++++++"
PRINT
PRINT "The name "; WholeThing.FirstName
IF WholeThing.IsMale THEN
PRINT "This is a MALE"
ELSE
PRINT "This is a FEMALE"
END IF
PRINT
END SUB



SUB EnterMe (WholeThing AS Person)
CLS
PRINT "++++++++++++++ In EnterMe sub now +++++++++++++"
PRINT
INPUT "First Name: "; WholeThing.FirstName
INPUT "Is this Man: (1=y,0=n) "; WholeThing.IsMale
END SUB


If you plan on sharing this data across other modules you create later on, then use ALT255's suggestion. --MiggyD

Never be afraid to try something new. Remember that amateurs built the Ark. Professionals built the Titanic.
 
what would te CALL statment look like?
 
If you look at the first response I gave, you'll see the syntax to do what MiggyD said. To use the word CALL (which isn't really necessary), using the example I gave, you'd use:

CALL Checkperson(Male)

or you can just use my first example:

Checkperson Male
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top