Need help creating a sub and transferring parameters
I finally got my serial LCD in and I am messing around with some of my own functions to use it. Right now, I am attempting to create a sub that I can pass 3 parameters to it. The first parameter will be a string or just one character. The second parameter will be a number 0 or 1 and the third parameter will be a number 1 through 16. I have no idea what to set the SUB to : my_sub SUB 3? Would each parameter be _WPARAM12 and/or _PARAM#?
Comments
If the first parameter is a character, then __PARAMCNT will be 3, the character will be in __PARAM1, the 0 or 1 will be in __PARAM2 and the 1-16 will be in __PARAM3.
If the first parameter is a string, then __PARAMCNT will be 4, the string address will be in __WPARAM12, the 0 or 1 will be in __PARAM3, and the 1-16 will be in __PARAM4.
You would define the subroutine as
LCDOut SUB 3,4
SUB LCDOut
· IF __PARAMCNT = 3 THEN
··· ' Handle character sent
· ELSE
··· ' Handle string sent
· ENDIF
ENDSUB
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
·The next time you need a hero don't look up in the sky...Look in the mirror.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe
When all else fails.....procrastinate!
I have 2 chips that are synced together. One sends data, the other receives. I have a sub called SEND_BYTE that should be used as SEND_BYTE byte1, byte2, byte3. When I use the sub, only byte3 is sent. The other 2 are not sent for some reason. If I simply put the SEROUT commands in the Main, they all send perfectly. I need help figuring what to set the SUB as and if the PARAM values are correct.
Here is my code :
Thanks for the help in advance!
Post Edited (eagletalontim) : 1/11/2009 3:08:50 PM GMT
The solution is to store params passed to a sub in temp variables so they are not destroyed before you have a chance to use them. Most of the SX/B code posted by JonnyMac and others follow this structure, e.g.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
EDIT...
I did change the params to be loaded into variables like you suggested. it works perfect now [noparse]:)[/noparse]