Finding something in a table field

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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Finding something in a table field

Post by richmond62 » Thu Apr 02, 2020 10:37 am

Table search.png
-

Code: Select all

on mouseUp
   set itemDelimiter to TAB
   ask "Search item?  "
   put it into SX
   put 1 into ELEVATOR
   repeat until ELEVATOR > 20
      put 1 into LATERAL
      repeat until LATERAL > 20
         put (item LATERAL of line ELEVATOR of fld "tf")  into XS
         if  (quotes & XS & quotes) = (quotes & SX & quotes) then
            put (SX && "in cell" && LATERAL & "," & ELEVATOR) into fld "rez"
         end if
         add 1 to LATERAL
      end repeat
      add 1 to ELEVATOR
   end repeat
end mouseUp
Well; I had fun anyway. 8)

Deleted stack as there is an "upgraded" (read "side-graded") version attached to the next posting.
Last edited by richmond62 on Thu Apr 02, 2020 11:29 am, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Finding something in a table field

Post by richmond62 » Thu Apr 02, 2020 11:28 am

Table search 2.png
-
This Virus lockdown will make even types like me desperate to attract attention. 8)
Attachments
Find the square.livecode.zip
Here's the stack.
(1.77 KiB) Downloaded 175 times

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Finding something in a table field

Post by mrcoollion » Thu Apr 02, 2020 1:16 pm

Another way to do it
Put into a button and test. This one also looks for parts of the text.

Code: Select all

on mouseUp
   set itemDelimiter to TAB
   ask "Search item?  "
   put it into SX
   put lineOffset (SX,fld "tf") into ELEVATOR
   put itemOffset (SX,line ELEVATOR of fld "tf") into LATERAL
   put (SX && "in cell" && LATERAL & "," & ELEVATOR) into fld "rez"
end mouseUp
Here is a version that also includes a choice between whole match or not.
Find the square-2.zip
(1.66 KiB) Downloaded 158 times
Thanks had some fun with it :D

Regards,

Paul

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”