Re: Get a handler from a script

2006-03-23 Thread David Burgun


On 22 Mar 2006, at 13:55, Wouter wrote:


Hi David,


On 22 Mar 2006, at 12:53, David Burgun wrote:


Hi,

Nice Script!

There is just one thing I don't understand?

What are the:

get  "/*" & i

Statements for?



/* this is a comment
as is this */function whatever
return "something"
end whatever

This is to force the tokenizing.
The script is parsed line by line.
The first line of the block comment will be eliminated by token 1  
to - 1 of  i
But the first token of  the  second line of the block comment will  
be the first word --> "as"
By adding a "/*" in front of that line the first token will be  
"function"




Thanks a lot!

All the Best
Dave

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-22 Thread Wouter

Hi David,


On 22 Mar 2006, at 12:53, David Burgun wrote:


Hi,

Nice Script!

There is just one thing I don't understand?

What are the:

get  "/*" & i

Statements for?



/* this is a comment
as is this */function whatever
return "something"
end whatever

This is to force the tokenizing.
The script is parsed line by line.
The first line of the block comment will be eliminated by token 1 to  
- 1 of  i
But the first token of  the  second line of the block comment will be  
the first word --> "as"
By adding a "/*" in front of that line the first token will be  
"function"




Thanks a lot
All the Best
Dave



Greetings,
Wouter
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-22 Thread David Burgun

Hi,

Nice Script!

There is just one thing I don't understand?

What are the:

get  "/*" & i

Statements for?

Thanks a lot
All the Best
Dave


On 21 Mar 2006, at 14:45, Wouter wrote:


on Sun Mar 19 16:12:57 CST 2006 Geoff Canyon wrote:


/* this is a comment
as is this */on mouseUp
   answer "yes"
end mouseUp



Another problem with this kind of commenting is shown in the  
following cases:


/* this is a comment
as is this */-function whatever
return "something"
end whatever

/* this is a comment
as is this */--function whatever
return "something"
end whatever

Both will compile without throwing an error.
Only the second one is a valid comment

Greetings,
Wouter

PS another little update (beware of the mail line wraps):

function retrieveActiveHandlers pScript
  put true into tFlag
  repeat for each line i in pScript
if char 1 to 2 of word 1 of i = "/*"  then
  put false into tFlag
else if tFlag and token 1 of i is among the items of  
"on,function,setprop,getprop" then  put token 1 to -1 of  i & cr  
after tList

else if tFlag = false then
  if (char 1 of word 1 of i is "#" or  char 1 of word 1 of i is  
"-" ) and "*/" is in i then

put true into tFlag
get  "/*" &i
if tFlag and token 1 of it is among the items of  
"on,function,setprop,getprop" then

  put token 1 to -1 of  it & cr after tList
end if
  else
repeat for each token j in i
  if j is "*/"  then
put true into tFlag
get  "/*" &i
if tFlag and token 1 of it is among the items of  
"on,function,setprop,getprop" then

  put token 1 to -1 of  it & cr after tList
  exit repeat
end if
  end if
end repeat
  end if
end if --
  end repeat
  return tList
end retrieveActiveHandlers

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-21 Thread J. Landman Gay

Dick Kriesel wrote:

On 3/20/06 9:30 PM, "Mark Wieder" <[EMAIL PROTECTED]> wrote:



The best solution I've come up with for removing block comments is

put the script of SomeObject into tScript
put token 1 to -1 of tScript into tScript




This sounded really cool, but I can't get it to work. :(


Really? What isn't it doing? For me it removes all comments that are
outside handlers (which is where my block comments are)...



That technique appears to me to work for block comments and line comments
that appear in the script either before the first compilable code or after
the last compilable code.  But it overlooks block and line comments that are
interspersed within the compilable code, and undelimited comments outside
handlers.


That was it. I had put a block comment in the middle of the script.

--
Jacqueline Landman Gay | [EMAIL PROTECTED]
HyperActive Software   | http://www.hyperactivesw.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-21 Thread Wouter

on Sun Mar 19 16:12:57 CST 2006 Geoff Canyon wrote:


/* this is a comment
as is this */on mouseUp
   answer "yes"
end mouseUp



Another problem with this kind of commenting is shown in the  
following cases:


/* this is a comment
as is this */-function whatever
return "something"
end whatever

/* this is a comment
as is this */--function whatever
return "something"
end whatever

Both will compile without throwing an error.
Only the second one is a valid comment

Greetings,
Wouter

PS another little update (beware of the mail line wraps):

function retrieveActiveHandlers pScript
  put true into tFlag
  repeat for each line i in pScript
if char 1 to 2 of word 1 of i = "/*"  then
  put false into tFlag
else if tFlag and token 1 of i is among the items of  
"on,function,setprop,getprop" then  put token 1 to -1 of  i & cr  
after tList

else if tFlag = false then
  if (char 1 of word 1 of i is "#" or  char 1 of word 1 of i is  
"-" ) and "*/" is in i then

put true into tFlag
get  "/*" &i
if tFlag and token 1 of it is among the items of  
"on,function,setprop,getprop" then

  put token 1 to -1 of  it & cr after tList
end if
  else
repeat for each token j in i
  if j is "*/"  then
put true into tFlag
get  "/*" &i
if tFlag and token 1 of it is among the items of  
"on,function,setprop,getprop" then

  put token 1 to -1 of  it & cr after tList
  exit repeat
end if
  end if
end repeat
  end if
end if --
  end repeat
  return tList
end retrieveActiveHandlers

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-21 Thread Alex Tweedly

Dick Kriesel wrote:


On 3/21/06 2:37 AM, "Alex Tweedly" <[EMAIL PROTECTED]> wrote:

 


I suspect you have a different idea for what handler 'a' will do - in
fact, it *always" ask the time.
   



You suspected correctly, Alex.  Thanks for finding another mistake.  That
example only shows that the list of tokens is insufficient to reproduce the
_appearance_ of the handler.

Despite that weak example, the point was that the list of tokens is
insufficient to reproduce the _semantics_ of the handler, and therefore not
useful to "get a handler from a script."  Here's a better-chosen example of
two handlers with different semantics but the same tokens for the bodies of
the handlers:

 


But the interesting thing is that if you do something like
  token K1 to K2 of someScript
then it gives you the complete text between the char position of token 
K1 and the char position of token K2


I've uploaded a stack to revonline (username alextweedly, name 
FindHandler, category programming) which does this.
Moderately tested  but not thoroughly. (btw - only for handlers - 
extension to functions, setprop, etc.. is easy)


The essence of the (short) version is



function findhandler pScript, pHandler
put 0 into tStart
put 0 into tEnd
put 0 into i
put token 1 to -1 of pScript into pScript
repeat for each token t in pScript
add 1 to i
if t = "on" then
if token i+1 of pScript = pHandler then
put i into tStart
end if
end if
if t = "end" then
if token i+1 of pScript = pHandler then
put i into tEnd
if tStart > 0 then exit repeat
end if
end if
end repeat
if tStart = 0 or tEnd = 0 then  return ""

-- to simply return the handler text

return token tStart to tEnd+1 of pScript

end findhandler


Note that this fails to return any closing, trailing comment. For 
example, if the last line had been



   end findhandler-- end of function to do something


it would not have included the comment.

The stack includes another version which returns the line numbers of the 
start and end lines of the handler, and therefore allows you to include 
such trailing comments. It does not handle trailing, multi-line, block 
comments :-( but I'd regard a format like


  


end findhandler   /* some comment

  in here */


as particularly bad style.


NB This is still only a 99.99% solution. It will fail in the case where 
there is a multi-line block comment which includes a complete, EXACT 
copy of the handler being sought, and which precedes the handler in 
question. Since it must be an exact copy, then if you use this to 
duplicate the handler somewhere else, it will give the correct result 
anyway :-)



--
Alex Tweedly   http://www.tweedly.net

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.6/286 - Release Date: 20/03/2006
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-21 Thread Wouter

on Sun Mar 19 16:12:57 CST 2006 Geoff Canyon wrote:


Unfortunately for anyone attempting this task, this is a perfectly
valid script:

/* this is a comment
as is this */on mouseUp
   answer "yes"
end mouseUp


This style of commenting shows rev's inability to parse for handler  
names there after.

Have a look at the handler list field of the revscripteditor.
Take a multi handler script and comment the second handler like  
mentioned by Geoff above.
On reopening the same script in the editor, only the first handler  
will show in the handler list field.


Greetings,
Wouter
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-21 Thread Dick Kriesel
On 3/21/06 2:37 AM, "Alex Tweedly" <[EMAIL PROTECTED]> wrote:

> I suspect you have a different idea for what handler 'a' will do - in
> fact, it *always" ask the time.

You suspected correctly, Alex.  Thanks for finding another mistake.  That
example only shows that the list of tokens is insufficient to reproduce the
_appearance_ of the handler.

Despite that weak example, the point was that the list of tokens is
insufficient to reproduce the _semantics_ of the handler, and therefore not
useful to "get a handler from a script."  Here's a better-chosen example of
two handlers with different semantics but the same tokens for the bodies of
the handlers:

on a
  put "foo" into bar
  return bar
end a

on b
  put "foo" into bar
  return "bar"
end b

> I'll answer about the comments separately,when I've had more time  to
> think about it.

I'm looking forward to it.

-- Dick



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-21 Thread Alex Tweedly
I'll answer about the comments separately,when I've had more time  to 
think about it.

But - this one is quick ...

Dick Kriesel wrote:



But tokenizing seems unrelated to the challenge of getting a handler from a
script, because it can lose the control structure of a handler.  For
example, consider the following handlers, whose bodies yield the same list
of tokens:

on a
 if the seconds mod 2 = 0 then ask the date;ask the time
end a

on b
 if the seconds mod 2 = 0 then ask the date
 ask the time
end b

 


Those two bodies have the *same* meaning.

I suspect you have a different idea for what handler 'a' will do - in 
fact, it *always" ask the time.


To see this more clearly, try


on mouseUp
  if true then put "this" after msg; put "that" &cr after msg
  if false then put "this" after msg; put "that" &cr after msg
end mouseUp



--
Alex Tweedly   http://www.tweedly.net



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.6/286 - Release Date: 20/03/2006

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-21 Thread Dick Kriesel
On 3/20/06 9:30 PM, "Mark Wieder" <[EMAIL PROTECTED]> wrote:

>>> The best solution I've come up with for removing block comments is
>>> 
>>> put the script of SomeObject into tScript
>>> put token 1 to -1 of tScript into tScript
>>> 
> 
>> This sounded really cool, but I can't get it to work. :(
> 
> Really? What isn't it doing? For me it removes all comments that are
> outside handlers (which is where my block comments are)...

That technique appears to me to work for block comments and line comments
that appear in the script either before the first compilable code or after
the last compilable code.  But it overlooks block and line comments that are
interspersed within the compilable code, and undelimited comments outside
handlers.

In contrast, a repeat loop through the tokens of the script does not see any
line comments anywhere in the script, and does not see the first lines of
any block comments.  In comparison, neither technique removes undelimited
comments outside handlers.

But tokenizing seems unrelated to the challenge of getting a handler from a
script, because it can lose the control structure of a handler.  For
example, consider the following handlers, whose bodies yield the same list
of tokens:

on a
  if the seconds mod 2 = 0 then ask the date;ask the time
end a

on b
  if the seconds mod 2 = 0 then ask the date
  ask the time
end b

Now that I'm considering the variety of valid circumstances for comments,
doomsayers Geoff, Alex, and David are sounding right about this challenge.
But there _ought_ to be a way...

I'd really like to be able to search selected scripts while optionally
ignoring all comments.

-- Dick


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-20 Thread Mark Wieder
Jacque-

>> The best solution I've come up with for removing block comments is
>> 
>> put the script of SomeObject into tScript
>> put token 1 to -1 of tScript into tScript
>> 

> This sounded really cool, but I can't get it to work. :(

Really? What isn't it doing? For me it removes all comments that are
outside handlers (which is where my block comments are)...

-- 
 -Mark Wieder
  [EMAIL PROTECTED]

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-20 Thread J. Landman Gay

Mark Wieder wrote:

Geoff-

Sunday, March 19, 2006, 5:12:04 PM, you wrote:



This would still be subject to failure if, anywhere in the script, /*
or */ appeared _not_ as block comment delimiters, but as part of a  
string.



The best solution I've come up with for removing block comments is

put the script of SomeObject into tScript
put token 1 to -1 of tScript into tScript



This sounded really cool, but I can't get it to work. :(

--
Jacqueline Landman Gay | [EMAIL PROTECTED]
HyperActive Software   | http://www.hyperactivesw.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-20 Thread Mark Wieder
Geoff-

Sunday, March 19, 2006, 5:12:04 PM, you wrote:

> This would still be subject to failure if, anywhere in the script, /*
> or */ appeared _not_ as block comment delimiters, but as part of a  
> string.

The best solution I've come up with for removing block comments is

put the script of SomeObject into tScript
put token 1 to -1 of tScript into tScript

-- 
-Mark Wieder
 [EMAIL PROTECTED]

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-20 Thread Wouter

A little update.
And beware of the mail wraps

On 20 Mar 2006, at 10:50, Wouter wrote:

-snip-


/* this is a comment
#as is this */function removeBlockComments pText   --toggle the #
put true into tFlag
repeat for each line i in pText
  if char 1 to 2 of word 1 of i = "/*"  then
put false into tFlag
  end if
if tFlag and token 1 of i is among the items of  
"on,function,setprop,getprop" then put token 1 to -1 of  i & cr after  
tList


  else if tFlag = false then
if char 1 of word 1 of i is "#" and "*/" is in i then
  put true into tFlag
  get  "/*" &i
  if tFlag and token 1 of it is among the items of  
"on,function,setprop,getprop" then

put token 1 to -1 of  it & cr after tList
next repeat
  end if
end if
repeat for each token j in i
  if j is "*/"  then
put true into tFlag
get  "/*" &i
if tFlag and token 1 of it is among the items of  
"on,function,setprop,getprop" then

  put token 1 to -1 of  it & cr after tList
  exit repeat
end if
  end if
end repeat
  end if
end repeat
return tList
end removeBlockComments



Greetings,
Wouter


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-20 Thread Martin Baxter

David Burgun wrote:

Hi,

Yes, this really is the problem. In order to parse and identify a 
function/handler 100% correctly you need to do most (if not all) of the 
work of the TranScript Parser in the Script Compiler. In the past I've 
written any number of language parsers and I know it is non-trivial to 
get it 100% right. The best solution IMO would be to add code to RunRev 
that allows the script to find out if a handler/function is defined or 
not. One way would be to add a function that checks for the existence of 
a hanlder/function  (without looking at the text of the script), another 
would be to hold an array of functions/handlers as a property of the 
Object.


Back in my Hypercard days I had a large project that included a script 
locator handler. I bypassed all of the issues of parsing for actual 
handlers by adding metadata as comments in a consistent format at the 
top of each handler. This was then very simple to extract.


Just food for thought.

Martin Baxter
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-20 Thread David Burgun

Hi,

Yes, this really is the problem. In order to parse and identify a  
function/handler 100% correctly you need to do most (if not all) of  
the work of the TranScript Parser in the Script Compiler. In the past  
I've written any number of language parsers and I know it is non- 
trivial to get it 100% right. The best solution IMO would be to add  
code to RunRev that allows the script to find out if a handler/ 
function is defined or not. One way would be to add a function that  
checks for the existence of a hanlder/function  (without looking at  
the text of the script), another would be to hold an array of  
functions/handlers as a property of the Object. For instance if the  
script compiler built two arrays and stored them as a property of the  
object:


functionArray["FuncrtionName"] = StartLine,EndLine
handlerArray["HandlerName"] = StartLine,EndLine

Where StartLine is the line number in the script that contains  the  
"on" or "function" text.
Where LineLine is the line number is the script that contains  the  
"end" text.


I should imagine it is possible to parse the script and get it 100%  
correct using TranScript, but:


1.  It is likely to be quite a bit of work to code/test.
2.  If the underlying script syntax is changed it could break.
3.  It is likely be very slow and impact performance badly unless you  
are very careful about how/when it was used. One way would be to run  
some code at preOpenStack time that scanned through the scripts of  
objects in the stack and built the arrays described above.


I was quite shocked when I discovered that the ability to check for  
the existence of a function/handler was not actually built into to  
RunRev when so much other information about objects is present.


All the Best
Dave

On 20 Mar 2006, at 01:12, Geoff Canyon wrote:

I feel like the harbinger of doom here (with Alex as my able  
partner in doomsaying) but:


This would still be subject to failure if, anywhere in the script, / 
* or */ appeared _not_ as block comment delimiters, but as part of  
a string.


gc

On Mar 19, 2006, at 4:22 PM, Dick Kriesel wrote:


On 3/19/06 3:41 PM, "Alex Tweedly" <[EMAIL PROTECTED]> wrote:


You should try that script on itself :-)
The "/*" in the first 'offset' line, and the "*/" in the second  
'offset'

line are (incorrectly) recognized as a block comment, with fairly
disastrous results.


I did, and verified that it removed the comment.  I didn't notice  
that it

also eviscerated the function!  A trivial fix avoids that problem:

on mouseUp
  put removeBlockComments(the script of me)
end mouseUp

/* this is a comment
as is this */function removeBlockComments pText
put pText into tText
put offset("/" & "*",tText) into tOffset
if tOffset > 0 then
  delete char tOffset to tOffset + offset("*" & "/",tText,tOffset)  
+ 1 \

  of tText
  put removeBlockComments(tText) into tText
end if
return tText
end removeBlockComments


I suspect that proper recognition of block comments
isn't as easy as it might seem - need to handle all forms of string
delimiter, which themselves may be inside comments.


Since I don't recognize that need, would you elaborate on it, please?

Thanks for catching my oversight, Alex.

-- Dick


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-20 Thread David Burgun

Hi,

I think the original poster wanted to copy a function/handler from  
one Script to another. I was taking the more general case of wanting  
to know if a function/handler is defined in a script so it can be  
called and not cause an error if it is not defined.


All the Best
Dave

On 20 Mar 2006, at 02:38, Mark Smith wrote:

Are we trying to establish the existence of a handler or to get the  
text of a handler? And are we including handlers that are commented  
out?


Mark

On 20 Mar 2006, at 02:01, Dick Kriesel wrote:


On 3/19/06 5:12 PM, "Geoff Canyon" <[EMAIL PROTECTED]> wrote:


I feel like the harbinger of doom here (with Alex as my able partner
in doomsaying) but:

This would still be subject to failure if, anywhere in the  
script, /*

or */ appeared _not_ as block comment delimiters, but as part of a
string.


www.usingenglish.com/reference/idioms/fools+rush+in+where+angels 
+fear+to+tre

ad.html

Imagine we first remove comments that start with "--" and then  
start looking
for block comments.  If a "/*" follows an even number of quotes,  
it starts a
block comment.  If it follows an odd number of quotes, it's  
embedded in a
string.  After a "/*" starts a block comment, then the next "*/"  
ends the

comment.  Right?

Or do the angels see even more of the devil in the details?

-- Dick


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-20 Thread Wouter


On 20 Mar 2006, at 02:12, Geoff Canyon wrote:

I feel like the harbinger of doom here (with Alex as my able  
partner in doomsaying) but:


This would still be subject to failure if, anywhere in the script, / 
* or */ appeared _not_ as block comment delimiters, but as part of  
a string.


gc



-snip-

and what about this first draft ?:

on mouseUp
  put removeBlockComments(the script of me) into fld 1
end mouseUp

/* this is a comment
#as is this */function removeBlockComments pText   --toggle the #
put true into tFlag
repeat for each line i in pText
  if char 1 to 2 of word 1 of i = "/*"  then
put false into tFlag
  end if
  if tFlag and token 1 of i is among the items of  
"on,function,setprop,getprop" then put  i & cr after tList

  else if tFlag = false then
if char 1 of word 1 of i is "#" and "*/" is in i then
  put true into tFlag
  get  "/*" &i
  if tFlag and token 1 of it is among the items of  
"on,function,setprop,getprop" then

put token 1 to -1 of  it & cr after tList
next repeat
  end if
end if
repeat for each token j in i
  if j is "*/"  then
put true into tFlag
get  "/*" &i
if tFlag and token 1 of it is among the items of  
"on,function,setprop,getprop" then

  put token 1 to -1 of  it & cr after tList
  exit repeat
end if
  end if
end repeat
  end if
end repeat
return tList
end removeBlockComments

greetings,
Wouter
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-20 Thread Mark Smith
I don't think so -- the same problems with strangely placed block  
comments apply, and you'll still have to establish whether the  
handler name (with or without on, function, getprop, setprop and end)  
occurs as part of a comment, or as a recursive call to itself


Mark


On 20 Mar 2006, at 03:53, [EMAIL PROTECTED] wrote:

I don't know about the complications of block comments, etc, but  
can't all the complexites of dealing with of handlers, functions,  
getProp, and setProp be sidestepped by looking for "end" &&  
 -- or am I missing something? Does that simplify any  
of the other problems?


Peter M. Brigham
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread pmbrig
I don't know about the complications of block comments, etc, but can't all the 
complexites of dealing with of handlers, functions, getProp, and setProp be 
sidestepped by looking for "end" &&  -- or am I missing something? 
Does that simplify any of the other problems?

Peter M. Brigham
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread wouter


On 19 Mar 2006, at 21:51, Mark Wieder wrote:

-snip-


Here's a line I learned from Jerry Daniels:

filter tScript with "[ofsgOFSG][nueNUE][ ntNT]*"


Will also keep lines which start with "set" and "sen" like in:
set the itemdelimiter to tab
send "mouseup" to me

or lines which start with a combination of those characters
like in:
   sendSomeCommand paramX
   suntanLotion skincomplex


-Mark Wieder
 [EMAIL PROTECTED]


Greetings,
Wouter
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Mark Smith
Are we trying to establish the existence of a handler or to get the  
text of a handler? And are we including handlers that are commented out?


Mark

On 20 Mar 2006, at 02:01, Dick Kriesel wrote:


On 3/19/06 5:12 PM, "Geoff Canyon" <[EMAIL PROTECTED]> wrote:


I feel like the harbinger of doom here (with Alex as my able partner
in doomsaying) but:

This would still be subject to failure if, anywhere in the script, /*
or */ appeared _not_ as block comment delimiters, but as part of a
string.


www.usingenglish.com/reference/idioms/fools+rush+in+where+angels 
+fear+to+tre

ad.html

Imagine we first remove comments that start with "--" and then  
start looking
for block comments.  If a "/*" follows an even number of quotes, it  
starts a
block comment.  If it follows an odd number of quotes, it's  
embedded in a
string.  After a "/*" starts a block comment, then the next "*/"  
ends the

comment.  Right?

Or do the angels see even more of the devil in the details?

-- Dick


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Dick Kriesel
On 3/19/06 5:12 PM, "Geoff Canyon" <[EMAIL PROTECTED]> wrote:

> I feel like the harbinger of doom here (with Alex as my able partner
> in doomsaying) but:
> 
> This would still be subject to failure if, anywhere in the script, /*
> or */ appeared _not_ as block comment delimiters, but as part of a
> string.

www.usingenglish.com/reference/idioms/fools+rush+in+where+angels+fear+to+tre
ad.html

Imagine we first remove comments that start with "--" and then start looking
for block comments.  If a "/*" follows an even number of quotes, it starts a
block comment.  If it follows an odd number of quotes, it's embedded in a
string.  After a "/*" starts a block comment, then the next "*/" ends the
comment.  Right?

Or do the angels see even more of the devil in the details?

-- Dick


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Geoff Canyon
I feel like the harbinger of doom here (with Alex as my able partner  
in doomsaying) but:


This would still be subject to failure if, anywhere in the script, /*  
or */ appeared _not_ as block comment delimiters, but as part of a  
string.


gc

On Mar 19, 2006, at 4:22 PM, Dick Kriesel wrote:


On 3/19/06 3:41 PM, "Alex Tweedly" <[EMAIL PROTECTED]> wrote:


You should try that script on itself :-)
The "/*" in the first 'offset' line, and the "*/" in the second  
'offset'

line are (incorrectly) recognized as a block comment, with fairly
disastrous results.


I did, and verified that it removed the comment.  I didn't notice  
that it

also eviscerated the function!  A trivial fix avoids that problem:

on mouseUp
  put removeBlockComments(the script of me)
end mouseUp

/* this is a comment
as is this */function removeBlockComments pText
put pText into tText
put offset("/" & "*",tText) into tOffset
if tOffset > 0 then
  delete char tOffset to tOffset + offset("*" & "/",tText,tOffset)  
+ 1 \

  of tText
  put removeBlockComments(tText) into tText
end if
return tText
end removeBlockComments


I suspect that proper recognition of block comments
isn't as easy as it might seem - need to handle all forms of string
delimiter, which themselves may be inside comments.


Since I don't recognize that need, would you elaborate on it, please?

Thanks for catching my oversight, Alex.

-- Dick


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Dick Kriesel
On 3/19/06 3:41 PM, "Alex Tweedly" <[EMAIL PROTECTED]> wrote:

> You should try that script on itself :-)
> The "/*" in the first 'offset' line, and the "*/" in the second 'offset'
> line are (incorrectly) recognized as a block comment, with fairly
> disastrous results.

I did, and verified that it removed the comment.  I didn't notice that it
also eviscerated the function!  A trivial fix avoids that problem:

on mouseUp
  put removeBlockComments(the script of me)
end mouseUp

/* this is a comment
as is this */function removeBlockComments pText
put pText into tText
put offset("/" & "*",tText) into tOffset
if tOffset > 0 then
  delete char tOffset to tOffset + offset("*" & "/",tText,tOffset) + 1 \
  of tText
  put removeBlockComments(tText) into tText
end if
return tText
end removeBlockComments

> I suspect that proper recognition of block comments
> isn't as easy as it might seem - need to handle all forms of string
> delimiter, which themselves may be inside comments.

Since I don't recognize that need, would you elaborate on it, please?

Thanks for catching my oversight, Alex.

-- Dick


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Alex Tweedly

Dick Kriesel wrote:



Here's a way:

on mouseUp
 put removeBlockComments(the script of me)
end mouseUp

/* this is a comment
as is this */function removeBlockComments pText
put pText into tText
put offset("/*",tText) into tOffset
if tOffset > 0 then
 delete char tOffset to tOffset + offset("*/",tText,tOffset) + 1 of tText
 put removeBlockComments(tText) into tText
end if
return tText
end removeBlockComments
 


You should try that script on itself :-)
The "/*" in the first 'offset' line, and the "*/" in the second 'offset' 
line are (incorrectly) recognized as a block comment, with fairly 
disastrous results. I suspect that proper recognition of block comments 
isn't as easy as it might seem - need to handle all forms of string 
delimiter, which themselves may be inside comments.



--
Alex Tweedly   http://www.tweedly.net



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.5/284 - Release Date: 17/03/2006

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Dick Kriesel
On 3/19/06 2:12 PM, "Geoff Canyon" <[EMAIL PROTECTED]> wrote:

> Checking the first word of each line is (I believe) certain, and is
> still reasonably fast (takes less than twice as long as the filter
> command in informal testing).
> 
> Unfortunately for anyone attempting this task, this is a perfectly
> valid script:
> 
> /* this is a comment
> as is this */on mouseUp
>answer "yes"
> end mouseUp
> 
> I don't know of a good way around that, so I have ignored it thus
> far ;-)

Here's a way:

on mouseUp
  put removeBlockComments(the script of me)
end mouseUp

/* this is a comment
as is this */function removeBlockComments pText
put pText into tText
put offset("/*",tText) into tOffset
if tOffset > 0 then
  delete char tOffset to tOffset + offset("*/",tText,tOffset) + 1 of tText
  put removeBlockComments(tText) into tText
end if
return tText
end removeBlockComments

-- Dick


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Geoff Canyon


On Mar 19, 2006, at 8:12 AM, Richard Gaskin wrote:

Since "on" or "function" must be the first word in a line to be an  
active command or function, you could simply add return to your  
evaluation to weed out comments:


  if cr&"on handlerName" is in cr&the script of myObject then


If there is a leading space on the line this won't find it.


On Mar 19, 2006, at 12:51 PM, Mark Wieder wrote:

Here's a line I learned from Jerry Daniels:

filter tScript with "[ofsgOFSG][nueNUE][ ntNT]*"


This won't either.

Of course, any well-formatted script won't have spaces before a  
handler definition, but that doesn't stop the script from compiling.  
Checking the first word of each line is (I believe) certain, and is  
still reasonably fast (takes less than twice as long as the filter  
command in informal testing).


Unfortunately for anyone attempting this task, this is a perfectly  
valid script:


/* this is a comment
as is this */on mouseUp
  answer "yes"
end mouseUp

I don't know of a good way around that, so I have ignored it thus  
far ;-)


gc
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Mark Wieder
David-

Sunday, March 19, 2006, 5:18:27 AM, you wrote:

> This this will work if the Hander is NOT commented out, but will fail
> with an error if the handler IS commented out. Also if you have a  
> comment in a Script that just happens to contain "on HandlerName"  
> then the "if" will succeed even though there is no handler defined.

Here's a line I learned from Jerry Daniels:

filter tScript with "[ofsgOFSG][nueNUE][ ntNT]*"

If necessary you can say:

replace space & space with space in tScript

Then you just check for the handler you're looking for:

if lineOffset("on" && HandlerName, tScript) is not zero then...

-- 
-Mark Wieder
 [EMAIL PROTECTED]

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Richard Gaskin

David Burgun wrote:


The problem is that if you are doing something like this:

if the script of myObject contains "on HandlerName" then
  send HandlerName to myObject
end if


Since "on" or "function" must be the first word in a line to be an 
active command or function, you could simply add return to your 
evaluation to weed out comments:


  if cr&"on handlerName" is in cr&the script of myObject then


--
 Richard Gaskin
 Managing Editor, revJournal
 ___
 Rev tips, tutorials and more: http://www.revJournal.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Geoff Canyon


On Mar 19, 2006, at 5:18 AM, David Burgun wrote:


The problem is that if you are doing something like this:

if the script of myObject contains "on HandlerName" then
  send HandlerName to myObject
end if


The code I posted earlier guarantees that

on handlername

exists in the script, not commented, at the beginning of a line. I  
believe that guarantees that it is a valid handler.


Here it is:

put 0 into tLineNumber
put false into tEnteredHandler
repeat for each line L in tText -- tText is the script
  add 1 to tLineNumber
  if word 1 of L is among the items of "on,function,getprop,setprop"  
and \

word 2 of L is tHandlerName then
put tLineNumber into tStartLineNumber
put true into tEnteredHandler
  end if
  if tEnteredHandler and \
word 1 of L is "end" and \
word 2 of L is tHandlerName then
put tLineNumber into tEndLineNumber
exit repeat
  end if
end repeat

-- if tEnteredHandler is false, we didn't find the handler
-- if tEnteredHandler is true, tStartLineNumber is where it starts,
-- tEndLineNumber is where it ends

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread Mark Smith
This might be dealt with better with a 'try...catch' structure. I  
don't know much about the error numbers that Rev produces, but


try
  cmdName
catch tError
  put tError
end try

where I know handler cmdName is commented out consistently produces  
this error string:

573,3,1,cmdName

This may or may not be useful in the context you described, but  
perhaps offers another way of testing for the existence or  
availability of a handler.



Mark


On 19 Mar 2006, at 13:18, David Burgun wrote:


Hi,

The problem is that if you are doing something like this:

if the script of myObject contains "on HandlerName" then
  send HandlerName to myObject
end if

This this will work if the Hander is NOT commented out, but will  
fail with an error if the handler IS commented out. Also if you  
have a comment in a Script that just happens to contain "on  
HandlerName" then the "if" will succeed even though there is no  
handler defined.


I had a problem that took me ages to figure out. In a script I had  
something like the following:


--on Update make sure the field is not selected

which meant that:

if the script of myObject contains "on Update" then

succeeded, but the send statement failed since there wasn't really  
a handler called "update" defined. Checking for "end Update" *may*  
have worked, as long as there was not a line that read something like:


send Update to myObject

Also checking for "end Update" slows the whole process down.

What would be nice is the ability to check if a (real) handler  
exists not just that the script contains text that looks like a  
handler defintion. Something like this would be good:


if exists(handler "Update" in script of myObject) then

Which would make it 100% foolproof.

All the Best
Dave

On 17 Mar 2006, at 12:19, Mark Smith wrote:

Commenting would only affect things if the wholeMatches is set to  
true - normally, lineOffset will get the right line even if it's  
commented out, no?


Mark

On 17 Mar 2006, at 12:06, David Burgun wrote:


Hi,

Of course none of the solutions so far work if the function is  
commented out. To make the code 100% foolproof is a lot of work.  
I was doing something similar and found that comments made life  
really difficult.


All the Best
Dave

On 17 Mar 2006, at 11:42, Robert Brenstein wrote:


Perhaps using

set the wholematches to true
put lineOffset("on" && pHandlerName, pScript) into tStart
if tStart is 0 then put lineOffset("function" && pHandlerName,  
pScript) into

tStart
put (lineOffset("end" && pHandlerName, pScript) +1 into tEnd


answer tStart & cr & tEnd

Jim Ault
Las Vegas



Unfortunately, wholematches can't be used, at least for the  
first lineoffset, because there are likely some parameters  
further in that line. The alternative to lineOffset is to use  
regex.


A truly generic function would need to know whether it searches  
for command or function, because it is possible to have one of  
each with the same name.


Robert


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-19 Thread David Burgun

Hi,

The problem is that if you are doing something like this:

if the script of myObject contains "on HandlerName" then
  send HandlerName to myObject
end if

This this will work if the Hander is NOT commented out, but will fail  
with an error if the handler IS commented out. Also if you have a  
comment in a Script that just happens to contain "on HandlerName"  
then the "if" will succeed even though there is no handler defined.


I had a problem that took me ages to figure out. In a script I had  
something like the following:


--on Update make sure the field is not selected

which meant that:

if the script of myObject contains "on Update" then

succeeded, but the send statement failed since there wasn't really a  
handler called "update" defined. Checking for "end Update" *may* have  
worked, as long as there was not a line that read something like:


send Update to myObject

Also checking for "end Update" slows the whole process down.

What would be nice is the ability to check if a (real) handler exists  
not just that the script contains text that looks like a handler  
defintion. Something like this would be good:


if exists(handler "Update" in script of myObject) then

Which would make it 100% foolproof.

All the Best
Dave

On 17 Mar 2006, at 12:19, Mark Smith wrote:

Commenting would only affect things if the wholeMatches is set to  
true - normally, lineOffset will get the right line even if it's  
commented out, no?


Mark

On 17 Mar 2006, at 12:06, David Burgun wrote:


Hi,

Of course none of the solutions so far work if the function is  
commented out. To make the code 100% foolproof is a lot of work. I  
was doing something similar and found that comments made life  
really difficult.


All the Best
Dave

On 17 Mar 2006, at 11:42, Robert Brenstein wrote:


Perhaps using

set the wholematches to true
put lineOffset("on" && pHandlerName, pScript) into tStart
if tStart is 0 then put lineOffset("function" && pHandlerName,  
pScript) into

tStart
put (lineOffset("end" && pHandlerName, pScript) +1 into tEnd


answer tStart & cr & tEnd

Jim Ault
Las Vegas



Unfortunately, wholematches can't be used, at least for the first  
lineoffset, because there are likely some parameters further in  
that line. The alternative to lineOffset is to use regex.


A truly generic function would need to know whether it searches  
for command or function, because it is possible to have one of  
each with the same name.


Robert


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-18 Thread Geoff Canyon


On Mar 17, 2006, at 9:18 PM, Geoff Canyon wrote:


So change the statement below to:

  if (word 1 of L is among the items of \
  "on,function,getprop,setprop,--on,--function,--getprop,--setprop"  
and...etc.) \

  or (word 1 of L is "--" and \
  word 2 of L is among the items of "on,function,getprop,setprop"  
and...etc.)



I rewrote this to handle numerous options. This has been lightly tested.

It should handle all three forms of comments: -- # /*...*/

It should handle all cases where there isn't intervening text, so:

--on myHandler
# function myFunction

/*getProp myProp
end myProp*/

/* setProp myProp
end myProp */

The script editor _hates_ the structure I used. If you format this in  
the script editor, the indentation will be all out of whack. I've  
corrected it here I think (for clarity).


  put 0 into tLineNumber
  put false into tEnteredHandler
  repeat for each line L in tText -- tText is the script
  add 1 to tLineNumber
  get word 1 of L
  if it is among the items of "--,#,/*" then
  put 3 into tHandlerWord
  get word 2 of L
  else
  put 2 into tHandlerWord
  end if
  if char 1 of it is "#" then delete char 1 of it
  if char 1 to 2 of it is among the items of "--,/*" then delete  
char 1 to 2 of it

  if tEnteredHandler and it is "end" then
  get word tHandlerWord of L
  if char -2 to -1 of it is "*/" then delete char -2 to -1  
of it

  if it is tHandlerName then
  put tLineNumber into tEndLineNumber
  exit repeat
  end if
  else if it is among the items of "on,function,getprop,setprop"  
and \

 word tHandlerWord of L is tHandlerName then
  put tLineNumber into tStartLineNumber
  put true into tEnteredHandler
  end if
  end repeat

As before:

-- if tEnteredHandler is false, we didn't find the handler
-- if tEnteredHandler is true, tStartLineNumber is where it starts,
-- tEndLineNumber is where it ends
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-17 Thread Geoff Canyon
Do you want them even though they are commented, or do you not want  
them?


For Navigator I don't care about commented handlers although I  
suppose maybe I should.


Since a comment relieves you of syntax requirements, this line is  
perfectly legitimate:


-- I've commented out this handler: on doSomething

I'm going to ignore such handlers, since they're just annoying. ;-)

That leaves two possibilities:

 -- on doSomething
 --on doSomething

So change the statement below to:

  if (word 1 of L is among the items of \
  "on,function,getprop,setprop,--on,--function,--getprop,--setprop"  
and...etc.) \

  or (word 1 of L is "--" and \
  word 2 of L is among the items of "on,function,getprop,setprop"  
and...etc.)


regards,

Geoff


On Mar 17, 2006, at 9:09 AM, Mark Smith wrote:

Lucid and thorough, as usual. And we'd all forgotten about 'Prop'  
handlers.
However, to nitpick, and raise a question from earlier in the  
thread, what about handlers that are commented out?


hmmm..not as simple as it might seem...

Mark

On 17 Mar 2006, at 16:16, Geoff Canyon wrote:



On Mar 16, 2006, at 5:25 PM, Thomas McGrath III wrote:

But, I would like to get just one of the handlers from a script  
via script:put handler "FooBar" of the script of card "Foo"  
into tBar


Most of the solutions presented so far make assumptions. For  
example, there can be more than one space between "on" and the  
handler name.


In Navigator I use this to retrieve a list of the handler names:

repeat for each line L in tText -- tText is the script
  if word 1 of L is among the items of  
"on,function,getprop,setprop" then

put L & cr after tMenuText
  end if
end repeat

So to get the handler you would be doing something like:

put 0 into tLineNumber
put false into tEnteredHandler
repeat for each line L in tText -- tText is the script
  add 1 to tLineNumber
  if word 1 of L is among the items of  
"on,function,getprop,setprop" and \

word 2 of L is tHandlerName then
put tLineNumber into tStartLineNumber
put true into tEnteredHandler
  end if
  if tEnteredHandler and \
word 1 of L is "end" and \
word 2 of L is tHandlerName then
put tLineNumber into tEndLineNumber
exit repeat
  end if
end repeat

-- if tEnteredHandler is false, we didn't find the handler
-- if tEnteredHandler is true, tStartLineNumber is where it starts,
-- tEndLineNumber is where it ends

regards,

Geoff
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-17 Thread Jim Ault
Also consider there is more than one way to legally comment out lines of
code.  The author should choose and be consistent.

I used to have a routine in HCard that would find all the
"on,  function,  --on , --function" handlers & "global" declaration lines in
a stack script container and build a directory at the top of that script
container for all stacksinuse.  This way I could print the first page and
have them documented.

As you may recall, HCard had a 32K script container limit and the workaround
was to do several 'stacksinuse' to build a working library.

-- comment
# comment

/*
... block of comments
on thisFunction val

end thisFunction val

on thisOther val

end thisOther val
*/

If I were to do this on a consistent basis, I would copy each of my stacks
into 'mysearchscript' folder, then use BBEdit file search and RegEx to Find
All in that folder of stacks, then scan the search result, double clicking
the hit line to go to that code.  This works because the scripts in a stack
are visible.  What you do not get is what object has the code, and you do
get a few false or ghost hits.

Jim Ault
Las Vegas

On 3/17/06 9:09 AM, "Mark Smith" <[EMAIL PROTECTED]> wrote:

> Lucid and thorough, as usual. And we'd all forgotten about 'Prop'
> handlers.
> However, to nitpick, and raise a question from earlier in the thread,
> what about handlers that are commented out?
> 
> hmmm..not as simple as it might seem...
> 
> Mark
> 
> On 17 Mar 2006, at 16:16, Geoff Canyon wrote:
> 
>> 
>> On Mar 16, 2006, at 5:25 PM, Thomas McGrath III wrote:
>> 
>>> But, I would like to get just one of the handlers from a script
>>> via script:put handler "FooBar" of the script of card "Foo"
>>> into tBar
>> 
>> Most of the solutions presented so far make assumptions. For
>> example, there can be more than one space between "on" and the
>> handler name.
>> 
>> In Navigator I use this to retrieve a list of the handler names:
>> 
>> repeat for each line L in tText -- tText is the script
>>   if word 1 of L is among the items of
>> "on,function,getprop,setprop" then
>> put L & cr after tMenuText
>>   end if
>> end repeat
>> 
>> So to get the handler you would be doing something like:
>> 
>> put 0 into tLineNumber
>> put false into tEnteredHandler
>> repeat for each line L in tText -- tText is the script
>>   add 1 to tLineNumber
>>   if word 1 of L is among the items of
>> "on,function,getprop,setprop" and \
>> word 2 of L is tHandlerName then
>> put tLineNumber into tStartLineNumber
>> put true into tEnteredHandler
>>   end if
>>   if tEnteredHandler and \
>> word 1 of L is "end" and \
>> word 2 of L is tHandlerName then
>> put tLineNumber into tEndLineNumber
>> exit repeat
>>   end if
>> end repeat
>> 
>> -- if tEnteredHandler is false, we didn't find the handler
>> -- if tEnteredHandler is true, tStartLineNumber is where it starts,
>> -- tEndLineNumber is where it ends
>> 
>> regards,
>> 
>> Geoff
>> ___
>> use-revolution mailing list
>> use-revolution@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-17 Thread Mark Smith
Lucid and thorough, as usual. And we'd all forgotten about 'Prop'  
handlers.
However, to nitpick, and raise a question from earlier in the thread,  
what about handlers that are commented out?


hmmm..not as simple as it might seem...

Mark

On 17 Mar 2006, at 16:16, Geoff Canyon wrote:



On Mar 16, 2006, at 5:25 PM, Thomas McGrath III wrote:

But, I would like to get just one of the handlers from a script  
via script:put handler "FooBar" of the script of card "Foo"  
into tBar


Most of the solutions presented so far make assumptions. For  
example, there can be more than one space between "on" and the  
handler name.


In Navigator I use this to retrieve a list of the handler names:

repeat for each line L in tText -- tText is the script
  if word 1 of L is among the items of  
"on,function,getprop,setprop" then

put L & cr after tMenuText
  end if
end repeat

So to get the handler you would be doing something like:

put 0 into tLineNumber
put false into tEnteredHandler
repeat for each line L in tText -- tText is the script
  add 1 to tLineNumber
  if word 1 of L is among the items of  
"on,function,getprop,setprop" and \

word 2 of L is tHandlerName then
put tLineNumber into tStartLineNumber
put true into tEnteredHandler
  end if
  if tEnteredHandler and \
word 1 of L is "end" and \
word 2 of L is tHandlerName then
put tLineNumber into tEndLineNumber
exit repeat
  end if
end repeat

-- if tEnteredHandler is false, we didn't find the handler
-- if tEnteredHandler is true, tStartLineNumber is where it starts,
-- tEndLineNumber is where it ends

regards,

Geoff
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-17 Thread Geoff Canyon


On Mar 16, 2006, at 5:25 PM, Thomas McGrath III wrote:

But, I would like to get just one of the handlers from a script via  
script:put handler "FooBar" of the script of card "Foo" into tBar


Most of the solutions presented so far make assumptions. For example,  
there can be more than one space between "on" and the handler name.


In Navigator I use this to retrieve a list of the handler names:

repeat for each line L in tText -- tText is the script
  if word 1 of L is among the items of "on,function,getprop,setprop"  
then

put L & cr after tMenuText
  end if
end repeat

So to get the handler you would be doing something like:

put 0 into tLineNumber
put false into tEnteredHandler
repeat for each line L in tText -- tText is the script
  add 1 to tLineNumber
  if word 1 of L is among the items of "on,function,getprop,setprop"  
and \

word 2 of L is tHandlerName then
put tLineNumber into tStartLineNumber
put true into tEnteredHandler
  end if
  if tEnteredHandler and \
word 1 of L is "end" and \
word 2 of L is tHandlerName then
put tLineNumber into tEndLineNumber
exit repeat
  end if
end repeat

-- if tEnteredHandler is false, we didn't find the handler
-- if tEnteredHandler is true, tStartLineNumber is where it starts,
-- tEndLineNumber is where it ends

regards,

Geoff
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-17 Thread Mark Smith
Commenting would only affect things if the wholeMatches is set to  
true - normally, lineOffset will get the right line even if it's  
commented out, no?


Mark

On 17 Mar 2006, at 12:06, David Burgun wrote:


Hi,

Of course none of the solutions so far work if the function is  
commented out. To make the code 100% foolproof is a lot of work. I  
was doing something similar and found that comments made life  
really difficult.


All the Best
Dave

On 17 Mar 2006, at 11:42, Robert Brenstein wrote:


Perhaps using

set the wholematches to true
put lineOffset("on" && pHandlerName, pScript) into tStart
if tStart is 0 then put lineOffset("function" && pHandlerName,  
pScript) into

tStart
put (lineOffset("end" && pHandlerName, pScript) +1 into tEnd


answer tStart & cr & tEnd

Jim Ault
Las Vegas



Unfortunately, wholematches can't be used, at least for the first  
lineoffset, because there are likely some parameters further in  
that line. The alternative to lineOffset is to use regex.


A truly generic function would need to know whether it searches  
for command or function, because it is possible to have one of  
each with the same name.


Robert
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-17 Thread David Burgun

Hi,

Of course none of the solutions so far work if the function is  
commented out. To make the code 100% foolproof is a lot of work. I  
was doing something similar and found that comments made life really  
difficult.


All the Best
Dave

On 17 Mar 2006, at 11:42, Robert Brenstein wrote:


Perhaps using

set the wholematches to true
put lineOffset("on" && pHandlerName, pScript) into tStart
if tStart is 0 then put lineOffset("function" && pHandlerName,  
pScript) into

tStart
put (lineOffset("end" && pHandlerName, pScript) +1 into tEnd


answer tStart & cr & tEnd

Jim Ault
Las Vegas



Unfortunately, wholematches can't be used, at least for the first  
lineoffset, because there are likely some parameters further in  
that line. The alternative to lineOffset is to use regex.


A truly generic function would need to know whether it searches for  
command or function, because it is possible to have one of each  
with the same name.


Robert
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-17 Thread Robert Brenstein

Perhaps using

set the wholematches to true
put lineOffset("on" && pHandlerName, pScript) into tStart
if tStart is 0 then put lineOffset("function" && pHandlerName, pScript) into
tStart
put (lineOffset("end" && pHandlerName, pScript) +1 into tEnd


answer tStart & cr & tEnd

Jim Ault
Las Vegas



Unfortunately, wholematches can't be used, at least for the first 
lineoffset, because there are likely some parameters further in that 
line. The alternative to lineOffset is to use regex.


A truly generic function would need to know whether it searches for 
command or function, because it is possible to have one of each with 
the same name.


Robert
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-16 Thread Jim Ault
Perhaps using 

set the wholematches to true
put lineOffset("on" && pHandlerName, pScript) into tStart
if tStart is 0 then put lineOffset("function" && pHandlerName, pScript) into
tStart
put (lineOffset("end" && pHandlerName, pScript) +1 into tEnd


answer tStart & cr & tEnd

Jim Ault
Las Vegas

On 3/16/06 7:04 PM, "Mark Smith" <[EMAIL PROTECTED]> wrote:

> The reason I think Roberts is more the ticket is that it deals with
> the case where you have a handler 'jumpHigh' as well as a handler
> 'jump' later in the script -- this means we need to check for the end
> of the handler name - which could be a space if there are parameters,
> or cr if not.
> 
> We can avoid checking that for the 'end' line by using the third
> parameter to lineOffset -- lines to skip, so a revised version might
> be:
> 
> function extractHandlerFromScript pScript,pHandlerName
>   put lineOffset("on" && pHandlerName & space, pScript) into tHandlerBegin
>   if tHandlerBegin is 0 then put lineOffset("on" && pHandlerName & cr,
> pScript) into tFooBar1
> -- this deals with either space or cr at the end of the handler name
> -- and we don't need to check for 'function' since it contains 'on'
> 
>   if tHandlerBegin is 0 then return empty
>   put lineOffset("end" && pHandlerName,pScript,tHandlerBegin) into tHandlerEnd
>   if pHandlerEnd is 0 then return empty 
>   return line tHandlerBegin to tHandlerEnd of pScript
> end extractHandlerFromScript
> 
> Cheers,
> 
> Mark
> 
> On 17 Mar 2006, at 02:48, Thomas McGrath III wrote:
> 
> Mark and Robert,
> 
> I needed to check for functions as well. So I adapted the script from
> Mark into this:
> 
> function getHandlers hName,tControl
> put the script of card tControl into tScript
> put tScript
> get lineOffset("on " & hName,tScript)
> if it = 0 then
> get lineOffset("function " & hName,tScript)
> end if
> if it = 0 then return "not found"
> put it into startLine
> get lineOffset("end " & hName,tScript)
> return line startLine to it of tScript
> end getHandlers
> 
> Thank you so much for your help,
> 
> Tom
> 
> 
> On Mar 16, 2006, at 9:16 PM, Mark Smith wrote:
> 
> Not tested, but something like this should work:
> 
> function getHandler hName,tControl
>   put the script of control tControl into tScript
>   get lineOffset("on " & hName,tScript)
>   if it = 0 then return "not found"
>   put it into startLine
>   get lineOffset("end " & hName,tScript)
>   return line startLine to it of tScript
> end getHandler
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-16 Thread Robert Brenstein

The reason I think Roberts is more the ticket is that it deals with
the case where you have a handler 'jumpHigh' as well as a handler
'jump' later in the script -- this means we need to check for the end
of the handler name - which could be a space if there are parameters,
or cr if not.

We can avoid checking that for the 'end' line by using the third
parameter to lineOffset -- lines to skip, so a revised version might
be:

function extractHandlerFromScript pScript,pHandlerName
  put lineOffset("on" && pHandlerName & space, pScript) into tHandlerBegin
  if tHandlerBegin is 0 then put lineOffset("on" && pHandlerName & cr,
pScript) into tFooBar1
-- this deals with either space or cr at the end of the handler name
-- and we don't need to check for 'function' since it contains 'on'

  if tHandlerBegin is 0 then return empty
  put lineOffset("end" && pHandlerName,pScript,tHandlerBegin) into tHandlerEnd
  if pHandlerEnd is 0 then return empty
  return line tHandlerBegin to tHandlerEnd of pScript
end extractHandlerFromScript

Cheers,

Mark



Great improvements, Mark.

Robert
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-16 Thread Mark Wieder
Tom-

Thursday, March 16, 2006, 5:25:12 PM, you wrote:

> But, I would like to get just one of the handlers from a script via
> script:put handler "FooBar" of the script of card "Foo" into tBar

Here's a simplified version of what I do:

-- pHandler is the name of the handler to extract
-- pScript is the entire script text
function FindHandler pHandler, pScript
  local tStart, tEnd

  put lineOffset("on" && pHandler, pScript) into tStart
  put lineOffset("end" && pHandler, pScript) into tEnd
  return line tStart to tEnd of pScript
end FindHandler

-- 
-Mark Wieder
 [EMAIL PROTECTED]

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-16 Thread Mark Smith

Sorry, using the third parameter to lineOffset means we have to do this:

  return line tHandlerBegin to (tHandlerBegin +  tHandlerEnd) of  
pScript


On 17 Mar 2006, at 03:04, Mark Smith wrote:



  return line tHandlerBegin to tHandlerEnd of pScript




___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution



Re: Get a handler from a script

2006-03-16 Thread Mark Smith
The reason I think Roberts is more the ticket is that it deals with
the case where you have a handler 'jumpHigh' as well as a handler
'jump' later in the script -- this means we need to check for the end
of the handler name - which could be a space if there are parameters,
or cr if not.

We can avoid checking that for the 'end' line by using the third
parameter to lineOffset -- lines to skip, so a revised version might
be:

function extractHandlerFromScript pScript,pHandlerName
  put lineOffset("on" && pHandlerName & space, pScript) into tHandlerBegin
  if tHandlerBegin is 0 then put lineOffset("on" && pHandlerName & cr,
pScript) into tFooBar1
-- this deals with either space or cr at the end of the handler name
-- and we don't need to check for 'function' since it contains 'on'

  if tHandlerBegin is 0 then return empty
  put lineOffset("end" && pHandlerName,pScript,tHandlerBegin) into tHandlerEnd
  if pHandlerEnd is 0 then return empty 
  return line tHandlerBegin to tHandlerEnd of pScript
end extractHandlerFromScript

Cheers,

Mark

On 17 Mar 2006, at 02:48, Thomas McGrath III wrote:

Mark and Robert,

I needed to check for functions as well. So I adapted the script from
Mark into this:

function getHandlers hName,tControl
put the script of card tControl into tScript
put tScript
get lineOffset("on " & hName,tScript)
if it = 0 then
get lineOffset("function " & hName,tScript)
end if
if it = 0 then return "not found"
put it into startLine
get lineOffset("end " & hName,tScript)
return line startLine to it of tScript
end getHandlers

Thank you so much for your help,

Tom


On Mar 16, 2006, at 9:16 PM, Mark Smith wrote:

Not tested, but something like this should work:

function getHandler hName,tControl
  put the script of control tControl into tScript
  get lineOffset("on " & hName,tScript)
  if it = 0 then return "not found"
  put it into startLine
  get lineOffset("end " & hName,tScript)
  return line startLine to it of tScript
end getHandler
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-16 Thread Thomas McGrath III

Mark and Robert,

I needed to check for functions as well. So I adapted the script from  
Mark into this:


function getHandlers hName,tControl
put the script of card tControl into tScript
put tScript
get lineOffset("on " & hName,tScript)
if it = 0 then
get lineOffset("function " & hName,tScript)
end if
if it = 0 then return "not found"
put it into startLine
get lineOffset("end " & hName,tScript)
return line startLine to it of tScript
end getHandlers

Thank you so much for your help,

Tom


On Mar 16, 2006, at 9:16 PM, Mark Smith wrote:


Not tested, but something like this should work:

function getHandler hName,tControl
  put the script of control tControl into tScript
  get lineOffset("on " & hName,tScript)
  if it = 0 then return "not found"
  put it into startLine
  get lineOffset("end " & hName,tScript)
  return line startLine to it of tScript
end getHandler

Cheers,

Mark

On 17 Mar 2006, at 01:25, Thomas McGrath III wrote:


Hello friends,

I know how to get the script from an objects script via script: 
put the script of card "Foo" into tBar


But, I would like to get just one of the handlers from a script  
via script:put handler "FooBar" of the script of card "Foo"  
into tBar


Anyone know how to do this easily?

Thanks

Tom


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-16 Thread Mark Smith
This is more the ticket - except I don't think we need to deal with  
'on' and 'function' separately, lineOffset picks up  the 'on' in  
'function'.


Cheers,

Mark



something like (not tested; watch line wraps)

put extractHandlerFromScript(the script of cd "Foo","FooBar") into  
tBar


function extractHandlerFromScript pScript,pHandlerName
  put lineOffset("on" && pHandlerName & space, pScript) into  
tHandlerBegin
  if tHandlerBegin is 0 then put lineOffset("on" && pHandlerName &  
cr, pScript) into tFooBar1
  if tHandlerBegin is 0 then put lineOffset("function" &&  
pHandlerName & space, pScript) into tFooBar1
  if tHandlerBegin is 0 then put lineOffset("function" &&  
pHandlerName & cr, pScript) into tFooBar1

  if tHandlerBegin is 0 then return empty
  put lineOffset("end" && pHandlerName & cr, pScript) into tHandlerEnd
  if tHandlerEnd is 0 then put lineOffset("end" && pHandlerName &  
space, pScript) into tHandlerEnd

  if tHandlerEnd is 0 then return empty
  return line tHandlerBegin to tHandlerEnd of pScript
end extractHandlerFromScript

If formatting is not so regular, you may need to account for  
multiple spaces between on/function/end and handler name.


Robert
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-16 Thread Mark Smith

Not tested, but something like this should work:

function getHandler hName,tControl
  put the script of control tControl into tScript
  get lineOffset("on " & hName,tScript)
  if it = 0 then return "not found"
  put it into startLine
  get lineOffset("end " & hName,tScript)
  return line startLine to it of tScript
end getHandler

Cheers,

Mark

On 17 Mar 2006, at 01:25, Thomas McGrath III wrote:


Hello friends,

I know how to get the script from an objects script via script: 
put the script of card "Foo" into tBar


But, I would like to get just one of the handlers from a script via  
script:put handler "FooBar" of the script of card "Foo" into tBar


Anyone know how to do this easily?

Thanks

Tom


Thomas J McGrath III
[EMAIL PROTECTED]

Lazy River Software™ - http://www.lazyriversoftware.com

Lazy River Metal Art™ - http://www.lazyriversoftware.com/metal.html

Meeting Wear™ - http://www.cafepress.com/meetingwear

Semantic Compaction Systems - http://www.minspeak.com

SCIconics, LLC - http://www.sciconics.com/sciindex.html







___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Get a handler from a script

2006-03-16 Thread Robert Brenstein

Hello friends,

I know how to get the script from an objects script via script:
put the script of card "Foo" into tBar

But, I would like to get just one of the handlers from a script via 
script:put handler "FooBar" of the script of card "Foo" into tBar


Anyone know how to do this easily?

Thanks

Tom


Thomas J McGrath III
[EMAIL PROTECTED]



something like (not tested; watch line wraps)

put extractHandlerFromScript(the script of cd "Foo","FooBar") into tBar

function extractHandlerFromScript pScript,pHandlerName
  put lineOffset("on" && pHandlerName & space, pScript) into tHandlerBegin
  if tHandlerBegin is 0 then put lineOffset("on" && pHandlerName & 
cr, pScript) into tFooBar1
  if tHandlerBegin is 0 then put lineOffset("function" && 
pHandlerName & space, pScript) into tFooBar1
  if tHandlerBegin is 0 then put lineOffset("function" && 
pHandlerName & cr, pScript) into tFooBar1

  if tHandlerBegin is 0 then return empty
  put lineOffset("end" && pHandlerName & cr, pScript) into tHandlerEnd
  if tHandlerEnd is 0 then put lineOffset("end" && pHandlerName & 
space, pScript) into tHandlerEnd

  if tHandlerEnd is 0 then return empty
  return line tHandlerBegin to tHandlerEnd of pScript
end extractHandlerFromScript

If formatting is not so regular, you may need to account for multiple 
spaces between on/function/end and handler name.


Robert
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Get a handler from a script

2006-03-16 Thread Thomas McGrath III

Hello friends,

I know how to get the script from an objects script via script: 
put the script of card "Foo" into tBar


But, I would like to get just one of the handlers from a script via  
script:put handler "FooBar" of the script of card "Foo" into tBar


Anyone know how to do this easily?

Thanks

Tom


Thomas J McGrath III
[EMAIL PROTECTED]

Lazy River Software™ - http://www.lazyriversoftware.com

Lazy River Metal Art™ - http://www.lazyriversoftware.com/metal.html

Meeting Wear™ - http://www.cafepress.com/meetingwear

Semantic Compaction Systems - http://www.minspeak.com

SCIconics, LLC - http://www.sciconics.com/sciindex.html







___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution