is this possible??

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

smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

is this possible??

Post by smash »

i have a field that i enter say a name "bob smith". and when i press a button, it transfer this name to a table.
is there a way, that if i enter this name in again, that it could search for the name, and if it finds the name "bob smith" in this table, it could but another bob smith name either 7 rows before or after (what ever row is available) ???
is this possible ??
cheers
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus »

Hi smash,

I am not sure, but maybe you are looking for something like this:

Code: Select all

...
if fld "Your Table field here" contains "Bob Smith" then
  ## Do whatever you want, there is already a bob Smith in the field
end if
...
Or if you need the line number:

Code: Select all

...
put lineoffset("Bob Smith",fld "Your Table field here") into already_there
if already_there = 0 then
  ## No Bob Smith in field
else
  ## Bob Smith is already there in line number "already_there" :)
end if
...
Hope that helps.

Best

Klaus
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark »

Dear Smash,

Store the data in a custom property and add a search field to your stack. In the keyUp handler of the search field, include a script that takes the custom property and filters out the relevant data. Put the filtered data into another field. That's all.

Code: Select all

on keyUp
  put the cData of this cd into myList
  filter myList (with the text of me & "*")
  put myList into fld "Results"
end keyUp
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash »

hi klaus
this is my script for putting them into the "Enties" table
on mouseUp
set the opaque of me to false

local theCardName
put "Entries" into theCardName
put the label of me after theCardName



if (field "HorsesName" is not empty) and (field "RidersName" is not empty) then
add 1 to field "BridleNumber"
put field "BridleNumber" & tab & field "HorsesName" & tab & field "RidersName" & return after field "Entries" of card "Entries5"


else
answer "You have not completed the entry details correctly"

end if

end mouseUp
now the problem is, there can be upto 600 new names for each show (this is like an entry form)
so i kind of need something that would "search" to see if the name is allready in there, and go 7 rows down or up (what ever row is empty after 7 rows)

would really appreciate some help.

hi mark, i dont have a custom property for storing data, as this is more like an entry form, so it would change with every useage.
i hope the script i put up, explains what i am trying to do.
thank you both for your replies
would really love to try and solve this
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark »

So.... smash... create that custom property if you don't have it. If it really makes no sense to use a custom property, then use avariable. The idea behind this method still is the same.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash »

So.... smash... create that custom property if you don't have it. If it really makes no sense to use a custom property, then use avariable. The idea behind this method still is the same.

Best,

Mark
sorry mark, but i just dont understand what a custom property is or how to create one.
could you be so kind to explain it to me
cheers
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark »

Dear Smash,

Please, read page 229 and further of the user guide.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash »

Dear Smash,

Please, read page 229 and further of the user guide.

Best,

Mark
ummm thanks mark, but in all honesty, that "user guide" might as well be in chinese. i just have never been able to work out anything from that guide :oops: :oops: :oops:
sorry, but i still dont understand
is there another way to explain it to me ???
cheers
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus »

Hi smash,
smash wrote:...
now the problem is, there can be upto 600 new names for each show (this is like an entry form)
so i kind of need something that would "search" to see if the name is allready in there, and go 7 rows down or up (what ever row is empty after 7 rows)

would really appreciate some help.
I already gave a solution on how to find something in a field!
Please read my post especially the second proposal with lineoffset, which will give you the number of the line where the name (or whatever) is in the field!
If "lineoffset" = 0 then the name is not in the field!

So you have the line number and you can count up or down from there until you find an empty line or whatever you want to.


Best

Klaus
smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash »

sorry klaus,
i can not get either script to work, as i can not use a name of a person as such in the script.
i will try to explain a bit better.
i have several text fields
example "riders name" and "horses name" and a button that transfers these two fields into a table.
the rider may enter 2 horses.
so i need the rider to be transtered to the table at least 7 rows difference, in the same table;
eg
tammy smith ......... black beauty
>
>
>
>
tammy smith .........snowy

now there could say 30 riders, riding 2 horses each
so it could look like this
tammy smith .....black beauty
joe black .......silver
dot taylor......casper
tammy smith ....snowy
joe black ........tonto
dot taylor .......dusty

does that make any sense klaus ??
cheers
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus »

What about replacing
"Bob Smith"
with
field "RiderName"
in the script?

Does that eventually work? ;)
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder »

Smash, I'm not sure I quite get what you're trying to do, but I think Mark has the right idea here, i.e., if your data is in field "AllTheData" then

put field "AllTheData" into myVariable
filter myVariable with "Tammy Smith" & *

will leave you just those two lines in myVariable.

Does that help?
smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash »

hi klaus,
LOL yes i did make sure i but in my fields LOL
i have tried many senerios
another one i tried
put lineoffset("RidersName",fld "Entries") into already_there
if already_there = true then
lineskip =7

but they all causes the button not to work.

thank you mwieder, but i cant put the "actual" name into the script, as i dont know it, and their is no way i can store "data" as such.
it is like a contest, so i have no idea on who would be entering (if that makes sense).
once the contest is over, you start again.
this is so frustrating.
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark »

Dear Smash,

Just create a new stack to experiment with. Create three fields: "Data", "Results" and "Search". The search field should be one line high, the other fields should have several lines and should be scrolling fields.

Set the script of field "Search" to:

Code: Select all

on keyUp
  put fld "Data" into myList
  filter myList (with the text of me & "*")
  put myList into fld "Results"
end keyUp
Put the following data into field "Data":

Aaron
Bernard
Chloe
Chris
Cindy
Dart Vader

Now type a C in field "Search". You will see that the results field now contains:

Chloe
Chris
Cindy

Type an h after the C and you will see that the Results field contains

Chloe
Chris

It works!

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus »

Hi smash,
put lineoffset("RidersName",fld "Entries") into already_there
if already_there = true then
Of course you must write:

Code: Select all

put lineoffset(FIELD "RidersName",fld "Entries") into already_there 
if already_there <> 0 then


Please, please, please go to the Revolution Dictionary and check the appropriate entries if you are not sure!
"lineoffset" will return the NUMBER of the line where the string was found or 0 (ZERO) if nothing was found.
I think this was unambiguous in my script!

And we still have no idea what you mean with 7 lines up or down???
Do you want to replace the date 7 lines up or down or what?
Post Reply