Repeat and lines of text
Posted: Wed Sep 02, 2015 7:01 am
Hello All
Another block for me on basic coding. Thank you in advance for being so patient!
Following a previous post I am reworking my text fields as suggested by Klaus. I have a more efficient setup that will make it a lot easier to modify the text fields without having to re-write every line of code.
I have one field that the user ‘clicks’ on a line of text - field “Condition” - to select what condition they want to know how about
Another field has a comma delimited list of information - field “CodeBreaker” e.g. - 24,2,Difficulty turning to one direction,
This information is linked to another field “Correction” that has comma delimited text e.g. - Correction 4: Hamstrings,11,12,13,14, 24,
I want to click on 'Difficulty turning to one direction’ in field “Condition” - (a number of conditions could be selected)
… that will detect that this relates to item 2 of field “Codebreaker” as it has a code of 24 (the 2 is irrelevant for this process, but is used to order another section)
… this relates to line - Correction 4: Hamstrings,11,12,13,14, 24, of field “Correction” - because of the 24 being in this line
I will then combine "Correction 4: Hamstrings" and "Difficulty turning to one direction” elsewhere.
However I am stumped on the first step of getting the condition to find the match with the ‘CodeBreaker”
This is my code for the field “Condition”. The selection line of the script is working fine, so the field “Answer” has lines of text.
put the selection into field “answer” - - so I can see what is going on
repeat for each line theline in field "answer"
if line of theline is among the lines of field "CodeBreaker" then
put this line of field "CodeBreaker" into anothervariable - - the syntax of this line is wrong. I have exhausted my range possible ways to write this, but I know there is a way … there always is with LiveCode
end if
end repeat
Any suggestions will be gratefully received.
regards
Greg
Another block for me on basic coding. Thank you in advance for being so patient!
Following a previous post I am reworking my text fields as suggested by Klaus. I have a more efficient setup that will make it a lot easier to modify the text fields without having to re-write every line of code.
I have one field that the user ‘clicks’ on a line of text - field “Condition” - to select what condition they want to know how about
Another field has a comma delimited list of information - field “CodeBreaker” e.g. - 24,2,Difficulty turning to one direction,
This information is linked to another field “Correction” that has comma delimited text e.g. - Correction 4: Hamstrings,11,12,13,14, 24,
I want to click on 'Difficulty turning to one direction’ in field “Condition” - (a number of conditions could be selected)
… that will detect that this relates to item 2 of field “Codebreaker” as it has a code of 24 (the 2 is irrelevant for this process, but is used to order another section)
… this relates to line - Correction 4: Hamstrings,11,12,13,14, 24, of field “Correction” - because of the 24 being in this line
I will then combine "Correction 4: Hamstrings" and "Difficulty turning to one direction” elsewhere.
However I am stumped on the first step of getting the condition to find the match with the ‘CodeBreaker”
This is my code for the field “Condition”. The selection line of the script is working fine, so the field “Answer” has lines of text.
put the selection into field “answer” - - so I can see what is going on
repeat for each line theline in field "answer"
if line of theline is among the lines of field "CodeBreaker" then
put this line of field "CodeBreaker" into anothervariable - - the syntax of this line is wrong. I have exhausted my range possible ways to write this, but I know there is a way … there always is with LiveCode
end if
end repeat
Any suggestions will be gratefully received.
regards
Greg