Action! › and› BBS Express! PRO› Tutorial›› by› Thomas M. Johnson ››› Available from ›› Villa Video's Bargain Cellar › (414) 265-5149 › ExpressNet Node X11 ››Action! is copyright of ACS, OSS, ICD.›BBS Express! PRO is copyright Orion›Micro Systems.› ›This tutorial is copyright Thomas M.›Johnson.››This tutorial can be distributed under›the following conditions:› 1) It is free.› 2) All of the above› information is intact.››--------------------------------------››Now its time to learn about PROCs.›What is a PROC? We already know about›PROC main() but what else is there?››A PROC is an independent block of›code that can be called. Ideally,›a PROC should use only local variables›and not global. We'll get into that ›in a minute.››You define a PROC the same way you›define main(). ››PROC my_proc()›› local variables›› statements››RETURN› ››The "my_proc" can be any name that›isn't already used by the Action!›system.››For you BASIC programmers, a PROC is›like a GOSUB. But much more powerful.››PrintE and the most of the other›routines we've looked at so far are›PROCs that are built in to the Action!›cartridge.››Let's take a look at a sample.››PROC my_proc()›› BYTE a›› a=10 › PutE()› PrintBE(a)› ›RETURN››PROC main()›› BYTE a›› a=5› PutE()› PrintBE(a)› my_proc()› PutE()› PrintBE(a)››RETURN››Can you guess what will be printed?›The output will look like this:››5›10›5››First 'a' is set to 5 in main().›Remember that the last PROC is always›the first one run. The value of›'a' is then printed. Then when the›computer gets to the line "my_proc()"›it goes up to the spot where ›"PROC my_proc()" is and starts running›there. ››Ok, now we have another 'BYTE a'›and we already declared a BYTE a.›These 2 "a's" are as different as›apples and oranges. They are local›to the PROC they were declared in.››So 'a' is set to 10 and is printed.›When the RETURN statement is executed,›the computer goes to the next line›after the call to the PROC. In this›case it will print 'a' again.››And it prints 5. But in my_proc we›set a=10. Once again, these are›2 different variables because each›can only be used by the PROC it is›defined in.››A even more powerful feature of PROCs›it the ability to pass it parameters.›Parameters and local variables allow›PROCs to not know or care anything›about the outside program. A PROC›will have a specific task and it›won't care what called it or why.›Take a look at APROG.701 for an›example.››The call to the PROC in main() looks›like "square(num)". Action! takes›whatever num is equal to and places›in the variable "number" in›PROC square(BYTE number).››You can have a number of parameters›and they can be any type. You can›even mix types. To pass 2 BYTEs and›1 CARD to a PROC use this:››PROC m(BYTE a,b CARD c)››and the call would look like:››m(10,30,5000)››There are commas between like variable›types and a space between different›types.››You can have PROCs call other PROCs.›It's important to understand the use›of local variables and PROCs. Even›more so of the PROCs. Next time›we will cover FUNCs, which are similar›to PROCs, and the opposite of local›variables, globals.››