methods with arguments in Pbasic?
christiand
Posts: 7
Hi! I am looking for a command in Pbasic similar to methods in Java, where I can send in an argument.
I found GOSUB, but it doesn't seem I can send in an argument to it. This is what I want to do.
This is how it would look in java:
Is there anything similar in Pbasic?
regards / Christian
I found GOSUB, but it doesn't seem I can send in an argument to it. This is what I want to do.
' {$STAMP BS2} ' {$PBASIC 2.5}
sData VAR Byte DO SERIN 16, 16468, [noparse][[/noparse]DEC sData]
GO_SUB method(sData) 'send variable sData to other instance of program
method(sData): move motor to position sData 'pseudo-code
LOOP
This is how it would look in java:
moveMotor(100);
moveMotor (int pos) { motorPosition = pos; }
Is there anything similar in Pbasic?
regards / Christian
Comments
T1 VAR BYTE
sData VAR Byte
DO
· SERIN 16, 16468, [noparse][[/noparse]DEC sData]
· T1 = sData
· GOSUB MoveMotor ' (t1)· ' The 'tick' being a comment.
LOOP
sub MoveMotor
· MotorPosition = T1
· return