Storing user input in array var / String handling
..sd
Posts: 2
Hi there,
Thank you very much for reading my post. I hope that someone of you out there can help me with this. I discussed it with my teacher, who could not quite help me. My issue is as follows:
I would like to store user input (through DEBUGIN) in an array var. However, I may not create an array that contains over 11 value's. Running "Array VAR Word(x)" with x>11 returns an error. However, I would like to be able to store about 30 values, preferably without having to switch var name while looping through the value's again. Is there a way in which I can make "Array VAR Word(30)" work?
If not, I could also use string handling features to reach my goal. For this, I will need to append the user input to a var, and then read out the var's content digit by digit (each user input is one digit, 1 through 9). The appending shouldn't be a problem, the looping through every single digit is. Is there a function which can help me with this?
If you do not quite understand, the source code included below might help you. It is ofcourse not working, for the first line will return an error. It basically shows what I'm about to do, but very much simplified. I hope someone can help me. Thank you in advance!
Cheers,
Coen
Thank you very much for reading my post. I hope that someone of you out there can help me with this. I discussed it with my teacher, who could not quite help me. My issue is as follows:
I would like to store user input (through DEBUGIN) in an array var. However, I may not create an array that contains over 11 value's. Running "Array VAR Word(x)" with x>11 returns an error. However, I would like to be able to store about 30 values, preferably without having to switch var name while looping through the value's again. Is there a way in which I can make "Array VAR Word(30)" work?
If not, I could also use string handling features to reach my goal. For this, I will need to append the user input to a var, and then read out the var's content digit by digit (each user input is one digit, 1 through 9). The appending shouldn't be a problem, the looping through every single digit is. Is there a function which can help me with this?
If you do not quite understand, the source code included below might help you. It is ofcourse not working, for the first line will return an error. It basically shows what I'm about to do, but very much simplified. I hope someone can help me. Thank you in advance!
Cheers,
Coen
array VAR Word(30) counter VAR Byte FOR counter=0 TO 29 DEBUGIN DEC array(counter) NEXT FOR counter=0 TO 29 IF (array(counter) = 1) THEN PULSOUT 12, 750-125: PULSOUT 13, 750+25 IF (array(counter) = 2) THEN PULSOUT 12, 750-125: PULSOUT 13, 750+125 IF (array(counter) = 3) THEN PULSOUT 12, 750-25: PULSOUT 13, 750+125 IF (array(counter) = 4) THEN PULSOUT 12, 750-125 IF (array(counter) = 6) THEN PULSOUT 13, 750+125 IF (array(counter) = 7) THEN PULSOUT 12, 750+25: PULSOUT 13, 750-125 IF (array(counter) = 8) THEN PULSOUT 12, 750+125: PULSOUT 13, 750-125 IF (array(counter) = 9) THEN PULSOUT 12, 750+125: PULSOUT 13, 750-25 NEXT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax