Page 1 of 1
Looping through the lines of a list field
Posted: Thu Jan 29, 2009 1:26 am
by AlexAdams
How do I hilite a line in a list field programmatically? I want to loop through the lines of a list, performing a series of tasks based on the contents of each line. I'm trying the following code and it is not working:
repeat with i=1 to the number lines of field "recordsList"
set the hilitedline of field "recordsList" to i
put the hilitedline of field "recordsList" into rowNumber
put item 6 of line rowNumber of field "recordsList" into recordName
--send messages and do stuff
end repeat
I am getting the error from the line:
set the hilitedline of field "recordsList" to i
Error message:
executing at 4:25:24 PM
Type Chunk: no such object
Object btnHighLightGraphicsSet
Line set the hilitedline of field "recordsList" to i
Hint recordsList
Hope you can help,
Posted: Thu Jan 29, 2009 9:50 am
by Mark
Hi Alex,
Apparently, you have no field ObjectsList. Check the name of the field, make sure that your script can find it. You might want to tell Revolution the location of the field:
fld "Objects List" of card 2 of stack "Some Stack"
Now, why do you want to select the lines of the field? You could do this in a much faster, different way.
Code: Select all
repeat for each line myObject in fld "Objects List"
-- do something with myObject here
end repeat
Additionally, this is a little peculiar:
Code: Select all
set the hilitedline of field "recordsList" to i
put the hilitedline of field "recordsList" into rowNumber
Why don't you use i instead of rowNumber? You don't need the variable rowNumber here.
Best regards,
Mark
Posted: Thu Jan 29, 2009 9:55 am
by Klaus
Hi Alex,
in addition to what Mark said, you can only "set the hilitedline(s) of fld x" if the target field has set its LISTBEHAVIOUR to true!
That's probably why you got this error.
Best
Klaus
Posted: Thu Jan 29, 2009 10:07 am
by Mark
Hi Klaus,
That's possible, but wouldn't an error "can't set this property" be more appropriate? I'm not sure what to think of it, because Rev is a bit peculiar sometimes.
Best,
Mark
Posted: Thu Jan 29, 2009 10:29 am
by Klaus
Hi Mark,
I just tested this (set the hilitedline of a non listfield) and did not get any error at all!
So looks like my presumption was wrong
Best
Klaus
Posted: Thu Jan 29, 2009 5:25 pm
by AlexAdams
Thanks guys. I got it to work. The problem was that I had a couple of go to commands in the "do some other stuff" part of the code and the loop didn't remember everything it should when the process returned to it. I now leave the go to out and just send a message to the stack that has the handler. Once the basic process was working I cleaned up the code, much like some of the suggestions below. I don't use hilitedLine for a test. I don't set it during the process.
You guys are great. Very helpful. It's good to be finally using Revolution after having the Enterprise version installed on several machines here for years. We finally started a project that could not conceivable be done using anything else. This is a major project, so I looking forward to gaining expertise in Rev.
Best,