Collecting parameter values from functions
Is there a simple way to step through and collect the parameter values from a function without calling each parameter by name?
Post Edited By Moderator (Bean (Hitt Consulting)) : 5/13/2008 3:17:15 PM GMT
Post Edited By Moderator (Bean (Hitt Consulting)) : 5/13/2008 3:17:15 PM GMT

Comments
Could you post some code showing what you are doing now ?
P.S. I added a subject to your post for you.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?
www.iElectronicDesigns.com
·
Show us an example...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?
www.iElectronicDesigns.com
·
‘incrementing through parameters
For Index = 0 TO 2
tmp1 = parameterinterator(Index)
IF tmp1 = ON
‘close dome
ENDIF
ENDFOR
‘I appreciate that if the three function parameters had been assigned to variables outside ‘the function call that I would not need any parameters and could reach outside the ‘function to get their values. Of course then they would need to be in an array or some ‘other device to allow iteration.
‘
‘I suppose this answers my question of how to proceed
SUB CHK_DM_CLS 'Where state.0, state.1, and state.2 are the parameters 'You can also clone the state of a set of input pins to state by 'doing this: state = RB, or you can substitute RB for state altogether tmp1 = __PARAM1 FOR index = 0 TO 2 IF tmp1.0 = 1 THEN 'Close dome ENDIF tmp1 >> 1 NEXT ENDSUBThis subroutine closes the dome if any of the lower three state bits are "on." It shifts through each bit since you can't use a variable as a bitIndex.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Paul
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?
www.iElectronicDesigns.com
·
I thought you could use a variable as a bitIndex as:
state byte
tmp1 byte
FUNCTION_CALL state
FOR bitIndex = 0 TO 2
tmp1 = state.bitIndex
IF tmp1 = 1 THEN CLOSE_DOME
NEXT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Paul
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?
www.iElectronicDesigns.com
·
data1 VAR Word tmpW1 VAR Word tmpW2 VAR Word tmpB1 VAR Byte tmpB2 VAR Byte I VAR Byte J VAR Byte value VAR Byte Check SUB BITVAL FUNC 1, 2, 3 'Thanks to JonnyMac for these cool functions! ' Use: value = BITVAL someVal, position ' -- "someVal" can be a byte or word FUNC BITVAL IF __PARAMCNT = 2 THEN ' byte passed? tmpW1 = __PARAM1 ' get byte value tmpB1 = __PARAM2 ' get bit position ELSE ' word passed tmpW1 = __WPARAM12 ' word was passed tmpB1 = __PARAM3 ' get bit position ENDIF tmpB2 = 0 ' assume cleared IF tmpB1 >= 0 THEN ' position value legal? IF tmpB1 <= 15 THEN tmpW2 = 1 << tmpB1 ' create bit mask tmpW2 = tmpW2 & tmpW1 ' clear other bits IF tmpW2 > 0 THEN ' if not zero tmpB2 = 1 ' bit was 1 ENDIF ENDIF ENDIF RETURN tmpB2 ENDFUNC Check: For I = 0 to 15 value = BITVAL data1, I IF value = 1 THEN 'Do something here ELSE 'Do something different here ENDIF NEXT