Page 1 of 1
Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 6:19 am
by mrcoollion
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
Re: Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 8:26 am
by jmburnod
Hi Paul,
Did you use Find/replace tools ?
Best regards
Jean-Marc
Re: Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 9:36 am
by richmond62
Re: Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 10:22 am
by mrcoollion
I need to do this via code (scripting). It is part of an application (stack) i am developing.
Re: Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 11:32 am
by jmburnod
I need to do this via code (scripting)
In this case you may use a loop for each stack, cds and controls.
Jean-Marc
Re: Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 1:25 pm
by dunbarx
Hi.
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
...
Craig Newman
Re: Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 1:41 pm
by richmond62
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
Re: Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 1:59 pm
by mrcoollion
Re: Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 5:22 pm
by mrcoollion
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
Re: Find a string in a stack card object script code
Posted: Tue Jul 03, 2018 5:50 pm
by mrcoollion
I cracked the code
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
Re: Find a string in a stack card object script code
Posted: Wed Jul 04, 2018 12:59 am
by dunbarx
Hi.
The part 'get the script of control tControl' is what I was looking for.
This goes way back to HC days.
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
Re: Find a string in a stack card object script code
Posted: Wed Jul 04, 2018 7:11 am
by mrcoollion
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