finding in script

Alex Tweedly alex at tweedly.net
Sun Jan 2 07:04:30 EST 2005


Ernst M. Reicher wrote:

> Hi,
> as an unexperienced hobby programmer I often have to seach in scripts 
> and doesn´t really know where in the stack(s).
>
> Using HC there was a basic command called searchscript - worked perfect
>
> Then using MC I modified the HC thing and it worked pretty.
>
> At first trial my modification didn´t work in Rev so I tried to use 
> the built in searchdialog.
>
> By default it searches in name, script and text - DONT DO THAT - if 
> you have a big stack it will last for hours!!!!!
>
> Only checking "script" works satisfactory and it lists the 
> searchresults although it lists repetitions and therefore the list 
> could get long...
>
> But then you have to go to each founditem manually by opening the 
> application browser and so on.
>
> Is that called comfortable programming????

When I'm first investigating a new stack, I like to browse around in the 
source of the scripts. For this, I have a small script (see below) that 
I use to create a text-only version of all scripts in a stack.  I often 
find it easier to search, or even to read through, this form in a 
favourite text editor rather than using Rev's rather primitive editor.

Once I have basic familiarity with the structure, it's better to stick 
within the IDE - occasionally I'll refer to the .txt files I created at 
this stage if some handler isn't where I expected it to be.  I do think 
the script editor should have better features to help with this (no 
reason it couldn't take me directly to the source, by right-clicking on 
a handler name (similar to the documentation lookup for built-in 
commands); if there were multiple possible matches, a drop-down list to 
allow selection would solve that.

In the meantime, ...

on ExportScripts pStackName
  ask file "Export scripts as:"
  put it into tFilename
  put tFilename after msg
 
  set the defaultStack to pStackName
  repeat with j = 1 to the number of controls on this stack
    put "...." & the name of control j & cr after msg
  end repeat
 
  put empty into tVar
  repeat with j = 1 to the number of controls on this stack
    put "...." & the name of control j & cr after tVar
    get the script of control j
    put it  & cr & cr after tVar
  end repeat
  repeat with j = 1 to the number of cards on this stack
    put "...." & the name of card j & cr after tVar
    get the script of card j
    put it  & cr & cr after tVar
  end repeat
  put "Stack script ..." & cr after tVar
  get the script of this stack
  put it  & cr & cr after tVar
 
  put tVar into URL ("file:" & tFilename)
  put it
end ExportScripts

I can think of half a dozen ways it could be improved - but it's close 
enough, for my use, that I've never got round to doing any of the 
improvements.

-- Alex.


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.7 - Release Date: 30/12/2004



More information about the use-livecode mailing list