Find string "xxx" in field yyy OF THIS CARD
André Bisseret
andre.bisseret at wanadoo.fr
Fri Feb 3 05:07:23 EST 2012
Bonjour Francis,
In order to restrict the find string to a specific card, the following seems working :
on mouseUp
local tCardsList,
-------
put the cardNames of this stack into tCardsList
repeat for each line tCd in tCardsList
set the dontSearch of tCd to true
end repeat
set the dontSearch of this cd to false -- or of cd n
find string "xxx" -- searching in all fields in the card
end mouseUp
It is possible to restrict the find to a certain field provided that this field is not in a group whose background behavior is true
I mean a field which would have the same name but a different id on each card;
then the following seems possible :
on mouseUp
local tCardsList,
-------
put the cardNames of this stack into tCardsList
repeat for each line tCd in tCardsList
set the dontSearch of fld "fldInfo" of tCd to true
end repeat
set the dontSearch of fld "fldInfo" of this cd to false
find string "xxx" in fld "fldInfo"
if the result is "not found" then answer "pas sur cette carte"
end mouseUp
Kenavo from Grenoble
André
Le 2 févr. 2012 à 21:39, Francis Nugent Dixon a écrit :
> Hi from beautiful Brittany,
>
> Thanks to all for suggestions. I finished up by trying my own
> workaround.
>
> BUT, I don't know why the syntax "of this card" and
> "of card xx" is accepted in the find command, but doesn't work.
>
> Would that be a real bug ?
>
> Secondly, the string I am looking for is in practically
> every record of my stack, and I treat the cards one at
> a time. I'm doing some complex (painful) syntax analysis
> on tons of data in text files, to create a stack of cards.
>
> So I look for various character strings with a value after them.
>
> Thirdly, when I have "found" the strings, I use the "foundChunk"
> command to set the strings to "empty" (i.e. remove them completely).
> This aids the continuation of my data analysis. I need this command.
>
> So I have solved the problem by using the "offset" command, and
> using the result + the length of the offset string to build a
> "findChunk" string "char xx to yy of field zzz" and then I have
> the ammunition to zap the field.
>
> I had many of these "find string" commands for many different
> values, and wanted the minimum of change to my scripts
> (written over many days) so that my scripts would work.
>
> Yes ! (Sigh) - I tried solving this with a function, but it had
> so many facets, that I finally resolved the problems inline.
>
> So I replaced the following multiple instances of commands:
>
> find string "xxx" in field yyy of this card
> if the result = "not found" then exit mouseUp
> put the foundchunk into SaveChunk
> -- Do stuff with the data
> do "put empty into " & SaveChunk
>
> with four other commands :
>
> put offSet("xxx",field yyy) into HoldStart
> if HoldStart = 0 then exit mouseUp
> put the length of "xxx" into HoldStop
> put "char " & HoldStart & " to " & HoldStop & " of field zzz" into SaveChunk
> do "put empty into " & SaveChunk
>
> Minimum Modification - maximum satisfaction !
>
> But I'm sure lots of you guys can better my ineficient code !
>
> -Francis
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list