Fields of Joy... but Start of Line? (='.'=)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Fields of Joy... but Start of Line? (='.'=)

Post by Mariasole » Thu May 30, 2013 4:33 pm

Ciao a tutti!!!!

I am continuing to study the basics of LiveCode! :) (but not the English language!... sorry)
I'm stuck on another problem from beginner ... :(
I have a list of strings in a field (fString) to be compared (exactly!, case sensitive...) with a list of another field (fWordOk).
A textbook problem, right? For a newbie... ;)

Here is the example...


field fString content

aaaaaaa
bbbbbbb
Aaaaaaa
bbbbbbB
aaaA
lkjlkjlkjlk
Cat
aaa


field fWordOk content

aaaaaaa
bbbbbbb
Aaaaaaa
bbbbbbB
aaaa

Here is the simple ;) code:

Code: Select all

on mouseUp
            
repeat for each line tLine in field "fString"

   set the caseSensitive to true
   set the wholeMatches to true
   
answer tLine

                 IF (tLine & return) is not in field "fWordOk" THEN


                     answer "the word |" & tLine & "| does not exist !!!"
                     
                  ELSE

                                          answer "the word |" & tLine & "| exist !!!"
                     
                                       end if
                      
                     
                     end repeat
                     
end mouseUp



And here is the result!:


aaaaaaa -----------> exist !!! :)
bbbbbbb -----------> exist !!! :)
Aaaaaaa -----------> exist !!! :)
bbbbbbB -----------> exist !!! :)
aaaA -----------> does not exist !!! :)
lkjlkjlkjlk -----------> does not exist !!! :)
Cat -----------> does not exist !!! :)

but...

aaa -----------> exist !!! :( :( :( (=*.*=)

My "elegant" :) solution in PigCode is:

Code: Select all


 IF (STARTOFLINE & tLine & return) is not in field "fWordOk" THEN...

But... what is the translation of the STARTOFLINE command from PigCode to LiveCode? :)


Thanks again to everyone!!
Grazie a tutti e baci!!!!!!

Mariasole

(='.'=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Fields of Joy... but Start of Line? (='.'=)

Post by SparkOut » Thu May 30, 2013 9:00 pm

Ciao Mariasole,
Using a slightly different approach, but again a very useful demonstration of the versatile chunking and text handling capabilities of LiveCode:

Code: Select all

repeat for each line tLine in field "fString"
      set the caseSensitive to true
      set the wholeMatches to true
      answer tLine
      if tLine is not among the lines of field "fWordOk" then
         answer "the word |" & tLine & "| does not exist !!!"
      else
         answer "the word |" & tLine & "| exist !!!"
      end if
   end repeat
How does that work for you?

Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Re: Fields of Joy... but Start of Line? (='.'=)

Post by Mariasole » Mon Jun 03, 2013 3:32 pm

Thanks SparkOut!
I tried your solution! And it works! Thank you for teaching me again the simplicity of LiveCode! :)
A tagline of LiveCode brand might just be "sic et simpliciter"!!! ;)

Grazie SparkOut!!!

Baci!!!

Mariasole (='.'=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

Post Reply