Recognizing character "-"
Posted: Sun Feb 28, 2021 2:49 am
I'm playing with a morse code stack just to renew some coding skills,few as they may be.
I have an entry field where I put in some text, in this case "test".
I have another button that(using cps) that translates the letters to "-" or "." and puts it into fld "bla". This works ok.
I have audioclips for dit and dah imported into the stack.
I have a button that should play these dits or dahs audioclips as they are needed, but I seem to be having some trouble with playing them. I am wondering if the character "-" has some sort of strange reaction in LC.
Here is the script of the button that is supposed to do this:
on mouseUp
put fld "bla" into thebox -- the fld with the text "test" in this case
repeat for each char thechar in thebox
if thechar is "-" then put 1 after x--play ac "dah.wav" --I switched playing the ac to putting a digit instead
wait 4 ticks
if thechar is "." then put 2 after x--play ac "dit.wav"--I switched playing the ac to putting a digit instead
wait 4 ticks
end repeat
put x -- I keep getting 2222 rather than 1 2 2 2 2 1
end mouseUp
--These are the dits and dahs in fld "bla" _ . ... _
--Is this something with the "-" character?
I have an entry field where I put in some text, in this case "test".
I have another button that(using cps) that translates the letters to "-" or "." and puts it into fld "bla". This works ok.
I have audioclips for dit and dah imported into the stack.
I have a button that should play these dits or dahs audioclips as they are needed, but I seem to be having some trouble with playing them. I am wondering if the character "-" has some sort of strange reaction in LC.
Here is the script of the button that is supposed to do this:
on mouseUp
put fld "bla" into thebox -- the fld with the text "test" in this case
repeat for each char thechar in thebox
if thechar is "-" then put 1 after x--play ac "dah.wav" --I switched playing the ac to putting a digit instead
wait 4 ticks
if thechar is "." then put 2 after x--play ac "dit.wav"--I switched playing the ac to putting a digit instead
wait 4 ticks
end repeat
put x -- I keep getting 2222 rather than 1 2 2 2 2 1
end mouseUp
--These are the dits and dahs in fld "bla" _ . ... _
--Is this something with the "-" character?