I came across the RED language the other day and spent (more or less literally) the last 24 hours of “learning” this. I have exhausted my Google skills, trying to find a solution to a simple problem that just dodges my skills and logic, so I hope someone here can lead me to the path to righteousness.
As the name implies, I tried to parse a simple line (any line of random text, really), get an individual char (acter) s, and then tried to save them in a variable. (Another line / array / any type)
The best I could do was use the code:
alpha: charset [#"a" - #"z"] testString: "this is just random rambling to test parsing!"
as prerequisites and something like this when (trying) to parse:
probe parse teststring [copy text to alpha (append text2 to-integer(to-char text)) to end]
Saves ascii code (first letter) ascii for text2 and runs the script several times in a row, correctly adds (the same first character) ASCII code several times in a row:
CONSOLE OUTPUT
>> probe parse teststring [copy text to alpha (append text2 to-integer(to-char text)) to end] true == true >> probe text2 "34" == "34" >> probe parse teststring [copy text to alpha (append text2 to-integer(to-char text)) to end] true == true >> probe text2 "3434" == "3434"
Obviously, my parsing does not actually “loop” the individual characters of the string or save them correctly when doing this. Maybe my parsing really takes the whole line from TO to END, and I'm trying to convert this to ASCII code then, or is something else going on here?
ANY help would be greatly appreciated since I cannot advance with my RED training before solving this dilemma and understanding how parsing really works in RED.
source share