Re: Parameters of pending messages -- is 'it' volatile?

2006-06-27 Thread Ben Rubinstein

On 26/6/06 23:16, Erik Hansen wrote:

one question, is 'it' volatile?


get the result -- should be the message id
put tMessage into gaMessageID2message[it]


or:
put the result into esto
put tMessage into gaMessageID2message[esto]

'it' is more concise, is it really as safe?


Hang on, isn't that discussion going on somewhere else in this forest?

The answer is yes.

'it' is a handy local variable, avaliable for any use, also set by some 
built-in commands, of which get is one.  The only ways that 'it' is unsafe 
are if you forget about this, and expect the value to be preserved across one 
of the commands that changes it.  If you're unsure, don't use it; but you can 
always use it in consecutive commands, as above.


You can think of it like lighting cigarettes in the trenchs of World War I: 
the rule was that they could use one match to light two cigarettes, but if 
they used the same match to light a third, they were at risk from a sniper. 
If you set it in one statement, and use it in the next statement, that's 
always going to be safe.  By the third statement, you have to consider whether 
the second statement might have changed it.



thanks for the applicable cognition.

:/

20 years we've had this darn company name, and still the jokes - but not much 
longer.  In a couple of months we're changing it.  You won't have our (old) 
stupid company name to kick around much longer.  Nosirree.


  Ben Rubinstein   |  Email: [EMAIL PROTECTED]
  Cognitive Applications Ltd   |  Phone: +44 (0)1273-821600
  http://www.cogapp.com|  Fax  : +44 (0)1273-728866

___
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: Parameters of pending messages -- is 'it' volatile?

2006-06-26 Thread Erik Hansen

this is a keeper.  
one question, is 'it' volatile?

 get the result -- should be the message id
 put tMessage into gaMessageID2message[it]

or:
put the result into esto
put tMessage into gaMessageID2message[esto]

'it' is more concise, is it really as safe?

thanks for the applicable cognition.

Erik Hansen

--- Ben Rubinstein [EMAIL PROTECTED] wrote:

 On 25/6/06 19:42, Peter T Evensen wrote:
  Is there any way to get the parameters that
 were passed to pending
  messages?
 
  What I want to do is suspend pending messages
 when a stack is suspended
  and then reinstate them when the stack is
 resumed.  I just realized
  pendingMessages() only gives the message
 name, not any of the parameters.
 
  Any help would be appreciated!
 
 I think the best you can do is store the
 parameters (or whatever useful info
 you need to key on) in a global or script-local
 array, keyed on the message ID.
 
 If you're doing this a lot, you might want to
 buffer it by using your own
 handler wrapped round the send command, eg
 
 on mySend tMessage, tDestination, tWhen
global gaMessageID2message
do send tMessage to  tDestination 
 in  tWhen
get the result -- should be the message id
put tMessage into gaMessageID2message[it]
 end mySend
 
 Your normal use could be something like:
 
   mySend foo bar, me, 3 seconds
 
 then when you're suspended, something like this
   put the pendingMessages into
 gSuspendedMessages
  repeat for each line tRec in
 gSuspendedMessages
 cancel message id (item 1 of tRec)
   end repeat
 
 
 and when you're resumed:
   repeat for each line tRec in
 gSuspendedMessages
 put item 1 of tRec into iOldMessageID
 put (some calculation based on item 2 of
 tRec) into tWhen
 mySend gaMessageID2message[iOldMessageID],
 (item, 4 of tRec), tWhen
  end repeat
 
 NB all the above typed into email, not Rev, and
 some of it pseudo-code...
 
 Obviously, depending on your actual situation
 you may be able to do something
 more elegant, eg if this only applies for
 something with a long and ugly
 destination expression, it might be easier not
 to have to make that into a
 properly quoted up string.
 
 HTH,
 
Ben Rubinstein   |  Email:
 [EMAIL PROTECTED]
Cognitive Applications Ltd   |  Phone: +44
 (0)1273-821600
http://www.cogapp.com|  Fax  : +44
 (0)1273-728866

[EMAIL PROTECTED]http://www.erikhansen.org

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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