Find a string in a stack card object script code
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 719
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Find a string in a stack card object script code
How can i find a string in the code of a open stack.
I want to find all instances of a specific command in a stack.
E.g. Every Stack, Card en Object preferable with linenumber I used the command 'answer' in.
Regards,
Paul
I want to find all instances of a specific command in a stack.
E.g. Every Stack, Card en Object preferable with linenumber I used the command 'answer' in.
Regards,
Paul
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Find a string in a stack card object script code
Hi Paul,
Did you use Find/replace tools ?
Best regards
Jean-Marc
Did you use Find/replace tools ?
Best regards
Jean-Marc
https://alternatic.ch
-
- Livecode Opensource Backer
- Posts: 9285
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
-
- Posts: 719
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: Find a string in a stack card object script code
I need to do this via code (scripting). It is part of an application (stack) i am developing.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Find a string in a stack card object script code
In this case you may use a loop for each stack, cds and controls.I need to do this via code (scripting)
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9578
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Find a string in a stack card object script code
Hi.
The script of any control, card or stack is a property of that object. So as Jean-Marc indicated, you can (Pseudo):
Craig Newman
The script of any control, card or stack is a property of that object. So as Jean-Marc indicated, you can (Pseudo):
Code: Select all
repeat for each stack tStack in listOfStacks
repeat for each cd tCd in stack tStack
repeat foe each control tControl in cd tCard in stack tStack
get the script of control tControl
if yourString is in it then processAway --or you might use one of the offsets or a find
...
-
- Livecode Opensource Backer
- Posts: 9285
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Find a string in a stack card object script code
Well, I'd get a list of all the controls to start with:
Code: Select all
on mouseUp
put the number of controls into KONT
put 1 into X
repeat until X> KONT
put the name of control X into line X of fld "oList"
add 1 to X
end repeat
end mouseUp
-
- Posts: 719
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: Find a string in a stack card object script code
Great
The part 'get the script of control tControl' is what I was looking for.
Really a lot of thanks to you all for helping me out here
The part 'get the script of control tControl' is what I was looking for.
Really a lot of thanks to you all for helping me out here
-
- Posts: 719
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: Find a string in a stack card object script code
Another question (maybe worth a new thread)
When I call a function from object x in card y of stack z but this function is situated in the main stack or even another sub-stack, Is there a way to find out where the function has been used or called from (without putting this in the functions parameters)?
When I put the following statements in the function situated in the main stack:
'This seems to work 'put the short name of current stack into tCurrentStack'
This seems to work 'put the short name of current card into tCurrentCard'
This does NOT work 'put the short name of current control into tCurrentControl'
Regards,
Paul
When I call a function from object x in card y of stack z but this function is situated in the main stack or even another sub-stack, Is there a way to find out where the function has been used or called from (without putting this in the functions parameters)?
When I put the following statements in the function situated in the main stack:
'This seems to work 'put the short name of current stack into tCurrentStack'
This seems to work 'put the short name of current card into tCurrentCard'
This does NOT work 'put the short name of current control into tCurrentControl'
Regards,
Paul
-
- Posts: 719
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: Find a string in a stack card object script code
I cracked the code
This works:
This works:
Code: Select all
put the short name of current stack into tCurrentStack
put the short name of current card into tCurrentCard
put the short name of the target into tCurrentControl
-
- VIP Livecode Opensource Backer
- Posts: 9578
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Find a string in a stack card object script code
Hi.
It is not commonly known, or appreciated, that the script of an object is a property, and not a container.
You cannot "put" a new line into a script, or modify it directly. You have to extract it into a variable, change it within that variable, and then (re)set the property in its entirely.
Why this is so is still a mystery.
Craig
This goes way back to HC days.The part 'get the script of control tControl' is what I was looking for.
It is not commonly known, or appreciated, that the script of an object is a property, and not a container.
You cannot "put" a new line into a script, or modify it directly. You have to extract it into a variable, change it within that variable, and then (re)set the property in its entirely.
Why this is so is still a mystery.
Craig
-
- Posts: 719
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: Find a string in a stack card object script code
Thanks for the information Craig .
Luckily I do not need to change any script. I just needed to get information from the script to do my thing.
Regards,
Paul
Luckily I do not need to change any script. I just needed to get information from the script to do my thing.
Regards,
Paul