Hi all.
I would like to support multiple statements in line for end-users. Currently i have figured two ways to do this. In my previous project (osBasic) i tested both. First was very easy, but slow. Second was fast, but way harder to produce.
In first way, line was readed and stored fully in array$(x) and parsed from there. That caused looping through the line when finding next statement and made it slow. On the other hand, it was easy to loop through the string until seperator (
was found. I had quot() function with what i was able to track was : inside of quots or not.
Second way was that i stored each statement seperately in array. This way, it was very easy to move on next statement, just by increasing curStatement by 1. This caused problem to follow up in which line the statement was. Only way i could figure it out was to create seperate array to track lines, and in lineArray() i stored number of the statement which was first in that line.
In cases where there were multiple statements in line, rest of the statements had not pointer in which line the statement was. I needed to loop through the lineArray() until lineArray(x) was >= than curStatement and lineArray(x+1) was <= than curStatement.
Second way is better, though it is more complex.
To avoid this, i could store statements in 2-dimensional array, where statements(x, 1) is the statement and statements(x, 2) is the line number where statements locates.
For this, i need language which allows me to create user types and define the first cell as string and second cell as integer. That is not a problem though. I could also use regular string array, and use known basic function VAL() to track line number even if it is stored as string.
Since i am not pro. and i have done 99% of codings from my own imagination, i would appreciate offered ideas before i start to build the engine.
Thanks, E.K.Virtanen