|
Post by rikky on May 2, 2020 13:09:56 GMT 1
Hello. I'm making a thinking error, but I cannot understand what. I am trying to shuff the rows up. So here is an example program: DECLARE row$ ASSOC STRING counter = 0
tekst$ = "one" & NL$ & "two" & NL$ & "three" & NL$
FOR line$ IN CHOP$(tekst$) STEP NL$ INCR counter row$(STR$(counter)) = line$ NEXT
PRINT PRINT "NRKEYS(row$): " & STR$(NRKEYS(row$)) PRINT
FOR i = 1 TO NRKEYS(row$) PRINT STR$(i) & " - " & row$(STR$(i)) NEXT i
i = 1
PRINT PRINT "row$(" & STR$(i) & ") = " & row$(STR$(i)) PRINT "row$(" & STR$(i+1) & ") = " & row$(STR$(i+1)) PRINT
PRINT "row$(" & STR$(i+1) & ") = row$(" & STR$(i) & "):" PRINT "row$(" & STR$(i+1) & ") = " & row$(STR$(i))
row$(STR$(i+1)) = row$(STR$(i))
PRINT
FOR i = 1 TO NRKEYS(row$) PRINT STR$(i) & " - " & row$(STR$(i)) NEXT i
PRINT PRINT "huh?, should be:" PRINT "1 - " & row$("1") PRINT "2 - " & row$("1") PRINT "3 - " & row$("3")
Rik.
|
|
|
Post by Pjot on May 2, 2020 14:58:04 GMT 1
Thanks Rik, Well, you're bumping into the same spot which I thought I had fixed before (see your post here). The check I added back then only prevents functions on the right side of the '=' to mess up the C code. It did not check if an associative variable - which also uses the '(' and ')' symbols - was used. So this is my bad, it should have been fixed correctly in the first place, I should have thought of this possibility of course. Anyway, I have updated the code by now verifying if the left side of the '=' has empty brackets. If so, then it refers to a full assoc array assignment, if not, it is a single element assignment. Hope this issue now is really really solved <sigh> Best regards Peter PS fix is available in fossil.
|
|