Re: Creating Stack via script help?

2004-11-21 Thread Sarah Reichelt
On 20 Nov 2004, at 4:02 pm, J. Landman Gay wrote:
I usually use create card rather than clone. I suppose this is 
personal preference, but it seems cleaner to me. A newly created card 
will automatically include the background (provided the group's 
backgroundBehavior is set to true,) so unless you need to copy over 
specific card properties, create works fine. If you've set up a 
bunch of card properties that you want to retain though, then cloning 
is one way to carry them over and you could use that instead. Another 
(possibly preferable) way to set up card properties is by setting 
properties in the templatecard before creating new cards.

Using create card rather than clone can be really important if you 
are using groups. I recently rescued a stack for someone when it was 
taking about 7 seconds to go to the next card with no apparent messages 
in the way. The stack had over 400 cards and it was a data stack with 
each card containing the same objects. Although the objects were mostly 
in groups (2 groups per card) they were not set as background groups 
and the cards had all been made using the clone command.

The main effect of this was that there were over 800 separate groups in 
the message passing hierarchy which seemd to be what was delaying 
everything! The stack size was over 21 MB, loading  saving took for 
ever and it was really unresponsive.

By re-building the stack with just 3 background groups and using 
create card to make the cards, I got the stack size down to 1.9 MB 
(after importing all the data) and with the normal instant response 
times to clicks and arrow keys.

Cheers,
Sarah
___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating Stack via script help?

2004-11-20 Thread John Patten
 
Thanks Jacqueline!

Rev's a great product, but I think its real strength is in the communitty of 
users that use it! The users on this list are the best!

Thanks Again!

John Patten :-)


On Saturday, November 20, 2004, at 00:04AM, [EMAIL PROTECTED] wrote:



Message: 14
Date: Sat, 20 Nov 2004 00:01:21 -0600
From: J. Landman Gay [EMAIL PROTECTED]
Subject: Re: Creating Stack via script help?
To: How to use Revolution [EMAIL PROTECTED]
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=us-ascii; format=flowed

On 11/19/04 4:09 PM, John Patten wrote:

 I?m attempting to create a script, ?fishing through many of the
 similar questions in the archive.
 
 I?ve been getting all kinds of strange results. I can get it to work,
 sort of,  but it seems to create multiple instances of the new stack
 at times.  And when I go into the Application Browser I see even more
 of my inept attempts at getting this to work.

I don't see anything in your script that would cause multiple stacks to 
be created, so what I suspect is happening in that you aren't deleting 
your previous trials before starting a new one. Closing a stack won't 
necessarily delete it from memory; you must specifically remove it. You 
can do that by choosing Close and remove from memory from the File 
menu, or by right-clicking the stack in the app browser and choosing the 
same thing from the contextual menu.

  Here?s what I?ve been trying to do:
 
 On mouseDown
 Ask file ?Save stack as:? --set path and filename for new stack
 Put it into theNewStackname
 Ask ?How many questions/cards??
 Put it into x
 Create stack theNewStackName with background ?quizTemplate?
 Set the defaultstack to theNewStackName
 Put 1 into y
  Repeat x
 Clone this card  
  Put y into cd fld ?TheCardNumber? --assuming that when you clone a card 
 it becomes current card
  Add 1 to y
  End repeat
 Put ?? into x
 Put ?? iinto y
 Put ?? into theNewStackname
 End mousedown

I'll have a go at this. First, I'd not trigger the action on a mousedown 
event; that prevents the user from changing their mind. Using mouseup is 
usually preferable, because it allows the user to click down on a 
button, change their mind, and slide off again without committing to the 
action. So I'd do this:

on mouseUp
   ask file Save stack as: -- get path
   if it =  then exit mouseup -- no name entered, or clicked cancel
   Put it into theStackPath
   ask How many questions/cards?
   if it =  then exit mouseup -- let them back out here too
   Put it into x

The ask file command returns a path (note it does not save the file to 
disk; it just gives you back a path) but you probably don't want the 
whole thing in the stack's title bar, so I'd extract a shorter name from 
the path to use as the stack name itself:

  set the itemDelimiter to /
  put last item of theStackPath into theNewStackName -- get a short name
  create stack theNewStackName with background quizTemplate
  set the defaultstack to theNewStackName

Now to make the cards. Creating the stack already made one card, so we 
need one less than the user specified when running the repeat loop. We 
don't need to set a counting variable (y in your script) because we 
can use a built-in counter in the repeat loop itself. We do need to put 
a 1 into the field on the first card though, since we won't start 
counting until card 2:

  put 1 into fld theCardNumber -- on first card
  repeat with count = 2 to x -- we already have the first card, so start 
with 2
create card
put count into fld theCardNumber
  end repeat

I usually use create card rather than clone. I suppose this is 
personal preference, but it seems cleaner to me. A newly created card 
will automatically include the background (provided the group's 
backgroundBehavior is set to true,) so unless you need to copy over 
specific card properties, create works fine. If you've set up a bunch 
of card properties that you want to retain though, then cloning is one 
way to carry them over and you could use that instead. Another (possibly 
preferable) way to set up card properties is by setting properties in 
the templatecard before creating new cards.

Finally, the stack hasn't been saved to disk yet. We have a file path 
chosen by the user, but we haven't done anything with it. So the last 
steps are to save the stack to disk:

  set the filename of this stack to theStackPath
  save this stack
end mouseUp

That's all you need to do, the handler can end here. You don't need to 
clean up any variables or memory, because local variables are 
automatically poofed out of existence when the handler ends. There isn't 
anything left to clean up. (This isn't true of script-local variables or 
global variables, but your handler doesn't have those.)

The final script looks like this then:

on mouseUp
   ask file Save stack as: -- get path from user
   if it =  then exit mouseup -- escape clause
   put it into theStackPath -- store path here for later
   ask How many

Creating Stack via script help?

2004-11-19 Thread John Patten
Hi All!

Does someone have an example of a recommended strategy for creating a stack 
from a standalone via a script?

I?m attempting to create a script, ?fishing through many of the similar 
questions in the archive.

I?ve been getting all kinds of strange results. I can get it to work, sort of,  
but it seems to create multiple instances of the new stack at times.  And when 
I go into the Application Browser I see even more of my inept attempts at 
getting this to work.  Here?s what I?ve been trying to do:

On mouseDown
Ask file ?Save stack as:? --set path and filename for new stack
Put it into theNewStackname
Ask ?How many questions/cards??
Put it into x
Create stack theNewStackName with background ?quizTemplate?
Set the defaultstack to theNewStackName
Put 1 into y
 Repeat x
Clone this card  
 Put y into cd fld ?TheCardNumber? --assuming that when you clone a card it 
becomes current card
 Add 1 to y
 End repeat
Put ?? into x
Put ?? iinto y
Put ?? into theNewStackname
End mousedown

At times it appears that I get two new stacks, can?t really explain because I?m 
unclear what?s happening. It will create the new stack, but then it doesn?t 
appear to have created the cards after the new stack has been created??? (Also 
probably because I've been going at creating the script via trial and 
error...lots of error :-)

Eventually, I would like to create the new stack from a standalone, so I?m also 
concerned that there will be other issues I need to be aware of when doing this 
from a standalone? True? If so, like what?

What I would like to happen, is a new stack is created via  a script with the 
name, as determined by the end user, and with the number of cards.  It doesn?t 
seem like it should be too difficult but I think I?m getting tripped up on 
naming the new stack, setting the defaultstack for cloning of the cards in the 
new stack, and then determining what settings need to be set for purging, or 
cleaning up after the new stack is created?

Anybody have an example?

Thank you!
John Patten
Tech Dept
SBCUSD

___
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Creating Stack via script help?

2004-11-19 Thread J. Landman Gay
On 11/19/04 4:09 PM, John Patten wrote:
I?m attempting to create a script, ?fishing through many of the
similar questions in the archive.
I?ve been getting all kinds of strange results. I can get it to work,
sort of,  but it seems to create multiple instances of the new stack
at times.  And when I go into the Application Browser I see even more
of my inept attempts at getting this to work.
I don't see anything in your script that would cause multiple stacks to 
be created, so what I suspect is happening in that you aren't deleting 
your previous trials before starting a new one. Closing a stack won't 
necessarily delete it from memory; you must specifically remove it. You 
can do that by choosing Close and remove from memory from the File 
menu, or by right-clicking the stack in the app browser and choosing the 
same thing from the contextual menu.

 Here?s what I?ve been trying to do:

On mouseDown
Ask file ?Save stack as:? --set path and filename for new stack
Put it into theNewStackname
Ask ?How many questions/cards??
Put it into x
Create stack theNewStackName with background ?quizTemplate?
Set the defaultstack to theNewStackName
Put 1 into y
 Repeat x
Clone this card  
 Put y into cd fld ?TheCardNumber? --assuming that when you clone a card it becomes current card
 Add 1 to y
 End repeat
Put ?? into x
Put ?? iinto y
Put ?? into theNewStackname
End mousedown
I'll have a go at this. First, I'd not trigger the action on a mousedown 
event; that prevents the user from changing their mind. Using mouseup is 
usually preferable, because it allows the user to click down on a 
button, change their mind, and slide off again without committing to the 
action. So I'd do this:

on mouseUp
  ask file Save stack as: -- get path
  if it =  then exit mouseup -- no name entered, or clicked cancel
  Put it into theStackPath
  ask How many questions/cards?
  if it =  then exit mouseup -- let them back out here too
  Put it into x
The ask file command returns a path (note it does not save the file to 
disk; it just gives you back a path) but you probably don't want the 
whole thing in the stack's title bar, so I'd extract a shorter name from 
the path to use as the stack name itself:

 set the itemDelimiter to /
 put last item of theStackPath into theNewStackName -- get a short name
 create stack theNewStackName with background quizTemplate
 set the defaultstack to theNewStackName
Now to make the cards. Creating the stack already made one card, so we 
need one less than the user specified when running the repeat loop. We 
don't need to set a counting variable (y in your script) because we 
can use a built-in counter in the repeat loop itself. We do need to put 
a 1 into the field on the first card though, since we won't start 
counting until card 2:

 put 1 into fld theCardNumber -- on first card
 repeat with count = 2 to x -- we already have the first card, so start 
with 2
   create card
   put count into fld theCardNumber
 end repeat

I usually use create card rather than clone. I suppose this is 
personal preference, but it seems cleaner to me. A newly created card 
will automatically include the background (provided the group's 
backgroundBehavior is set to true,) so unless you need to copy over 
specific card properties, create works fine. If you've set up a bunch 
of card properties that you want to retain though, then cloning is one 
way to carry them over and you could use that instead. Another (possibly 
preferable) way to set up card properties is by setting properties in 
the templatecard before creating new cards.

Finally, the stack hasn't been saved to disk yet. We have a file path 
chosen by the user, but we haven't done anything with it. So the last 
steps are to save the stack to disk:

 set the filename of this stack to theStackPath
 save this stack
end mouseUp
That's all you need to do, the handler can end here. You don't need to 
clean up any variables or memory, because local variables are 
automatically poofed out of existence when the handler ends. There isn't 
anything left to clean up. (This isn't true of script-local variables or 
global variables, but your handler doesn't have those.)

The final script looks like this then:
on mouseUp
  ask file Save stack as: -- get path from user
  if it =  then exit mouseup -- escape clause
  put it into theStackPath -- store path here for later
  ask How many questions/cards?
  if it =  then exit mouseup -- let them back out here too
  Put it into x -- store card count
  set the itemDelimiter to /
  put last item of theStackPath into theNewStackName -- get a short name
  create stack theNewStackName with background quizTemplate
  set the defaultstack to theNewStackName
  put 1 into fld theCardNumber -- on first card
  repeat with count = 2 to x -- start creating at 2nd card
create card -- automatically adopts background
put count into fld theCardNumber -- current card is latest one
  end repeat
  set the filename of this stack to