Re: Script local variables

2014-02-24 Thread Peter W A Wood
A quick update on the problem that I experienced with initialisation of script 
locals. Mark Waddingham posted the following comment on the bug report that I 
made:

START COMMENT
I think I know what is happening here - when the stack is being saved as a 
standalone, the stack is closed and reopened in the IDE. I suspect that this 
process is failing to run the openStack handler. Therefore, after saving the 
standalone, the stack in the IDE is not in the same state as the standalone is 
after starting up.

Indeed, if you 'revert to saved' in the IDE after saving as standalone the 
openStack handler is run.
END COMMENT

He has kindly corrected the title of my bug report - 
http://quality.runrev.com/show_bug.cgi?id=11832

Now I'm going to change the script local variables to constants which Jacque 
was kind enough to introduce to me in a previous comment on this thread. If 
only I'd known about them in the beginning, I wouldn't have stumbled across 
this possible bug.

Regards

Peter

On 24 Feb 2014, at 03:09, J. Landman Gay wrote:

 On 2/23/14, 12:17 PM, Bob Sneidar wrote:
 Could it be that editing the script resets the script local
 variables? This is true in Applescript properties. Editing and saving
 the script resets the properties to their defaults.
 
 Don't think so, that was one of my first tests when I tried to reproduce the 
 problem. I'm going with script error as the culprit for now.
 
 -- 
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.com
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


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


Re: Script local variables

2014-02-23 Thread Graham Samuel
I've just read that bit of the dictionary and I'm equally surprised. I also 
think I  must have completely misunderstood it, because I can't see how it can 
work. The value of a script local variable (unless it's predefined using an '=' 
construction) is undefined until a script is run, and is then only defined when 
an executing script puts something into the variable. A script can only be run 
when the program is executing. When the program containing the script quits, 
any information in variables, global or local, is lost because one can't 
normally save an executable stack outside the IDE (yes, I know about splash 
stacks and such, but the principle is correct). So next time the script is 
compiled, we **must** be back at square one, and the value of local variables 
**cannot** be maintained. What's wrong with this thinking?

Puzzled

Graham

On 23 Feb 2014, at 03:58, J. Landman Gay jac...@hyperactivesw.com wrote:

 On 2/22/14, 8:42 PM, Mark Wieder wrote:
 Scott-
 
 Saturday, February 22, 2014, 6:26:31 PM, you wrote:
 
 Uh, oh -- I do this all the time.
 
 Is this really not supposed to work?
 
 It sometimes works, but it's not legal syntax.
 I don't know of any particular reason why not, but it's not.
 
 
 They must have changed it when you and I weren't looking. Variable 
 assignments are even listed in the examples in the dictionary entry for 
 local. I may have to read the whole dictionary again to see what else I've 
 missed.
 
 I may also have found a clue to disappearing locals. The same entry says 
 this: If variable preservation is turned on, script locals retain their 
 values when the script is re-compiled, unless there is an error in the 
 script.
 
 I'm quite sure I've produced enough errors to have destroyed a few script 
 locals in my time, so maybe that's what's wrong. I'll try to pay more 
 attention.
 
 -- 
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.com
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


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


Re: Script local variables

2014-02-23 Thread Mark Wieder
Jacque-

Saturday, February 22, 2014, 6:58:35 PM, you wrote:

 They must have changed it when you and I weren't looking. Variable
 assignments are even listed in the examples in the dictionary entry for
 local. I may have to read the whole dictionary again to see what else
 I've missed.

OK - I stand corrected. My memory is the same as yours, and I could
swear that sometime in the distant past someone even corrected me when
I attempted to do this. But I just dusted off my copy of the RR 2.0
hardcopy dictionary, and it has the same examples.

-- 
-Mark Wieder
 ahsoftw...@gmail.com

This communication may be unlawfully collected and stored by the National 
Security Agency (NSA) in secret. The parties to this email do not 
consent to the retrieving or storing of this communication and any 
related metadata, as well as printing, copying, re-transmitting, 
disseminating, or otherwise using it. If you believe you have received 
this communication in error, please delete it immediately.


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


Re: Script local variables

2014-02-23 Thread Bob Sneidar
Could it be that editing the script resets the script local variables? This is 
true in Applescript properties. Editing and saving the script resets the 
properties to their defaults. 

Bob


On Feb 22, 2014, at 10:56 , J. Landman Gay jac...@hyperactivesw.com wrote:

 On 2/22/14, 12:17 PM, Peter Haworth wrote:
 I think this is dependant on the Variable Preservation setting on the
 Preferences Script Editor tab.
 
 It is, but there's a bug in it somewhere. I use script locals extensively and 
 they always worked until somewhere around version 6.x. After that the values 
 were occasionally lost. Every subsequent version has made the problem worse, 
 and now I lose them so often that I've had to add a reload of the values to 
 almost every handler I'm debugging.
 
 Since I can't find a consistent recipe (sometimes they do work) I haven't 
 reported it yet, but it's making my life difficult. All I know is that it 
 happens some time after I change a script, but not every time, so I'm at a 
 loss.
 
 -- 
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.com
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


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


Re: Script local variables

2014-02-23 Thread J. Landman Gay

On 2/23/14, 12:17 PM, Bob Sneidar wrote:

Could it be that editing the script resets the script local
variables? This is true in Applescript properties. Editing and saving
the script resets the properties to their defaults.


Don't think so, that was one of my first tests when I tried to reproduce 
the problem. I'm going with script error as the culprit for now.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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


Re: Script local variables

2014-02-23 Thread J. Landman Gay

On 2/23/14, 4:30 AM, Graham Samuel wrote:

I've just read that bit of the dictionary and I'm equally surprised.
I also think I  must have completely misunderstood it, because I
can't see how it can work. The value of a script local variable
(unless it's predefined using an '=' construction) is undefined until
a script is run, and is then only defined when an executing script
puts something into the variable. A script can only be run when the
program is executing. When the program containing the script quits,
any information in variables, global or local, is lost because one
can't normally save an executable stack outside the IDE (yes, I know
about splash stacks and such, but the principle is correct). So next
time the script is compiled, we **must** be back at square one, and
the value of local variables **cannot** be maintained. What's wrong
with this thinking?


Since I just discovered this, I'm trying to figure it out too. There 
must be a difference between declaring a constant and declaring a 
variable. So the only thing I can think of is that a script local 
variable can be altered by different handlers in the script, where a 
constant cannot. I.e., the value declaration is a starting point but 
isn't a fixed immutable value the way a constant is.


I haven't tried it yet, maybe someone else can confirm.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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


Re: Script local variables

2014-02-23 Thread Peter Haworth
On Sun, Feb 23, 2014 at 11:09 AM, J. Landman Gay
jac...@hyperactivesw.comwrote:

 Don't think so, that was one of my first tests when I tried to reproduce
 the problem. I'm going with script error as the culprit for now.


I confirm that a script compile error wipes out the contents of any script
local variables in the script, at least in a very simple test I did.

Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Script local variables

2014-02-23 Thread Peter Haworth
On Sun, Feb 23, 2014 at 11:14 AM, J. Landman Gay
jac...@hyperactivesw.comwrote:

 I haven't tried it yet, maybe someone else can confirm.


Yes, you can change the value of a script local variable in the way you
described

What's really interesting though is that the value of a script local
variable assigned in this way is NOt wiped out by a script compile error.It
feels like the value is assigned to the variable each and every time a
handler in the script is executed.



Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Script local variables

2014-02-23 Thread Peter Haworth
Sorry, hit send too soon.  Her's a more detailed version.

In a card script, I have

local sVar=xyz

function getVar
   return sVar
end getVar

command changeVar
   put abc into sVar
end changeVar

In button A on the card, I have:

on mouseUp
   put getVar()
end mouseUp

In button B on the card, I have

on mouseUp
   changeVar
end mouseUp

I click button A and xyz appears in the message box.

I click button B, then button A and abc appears in the message box.  So
you can change the value of script local variables with values assigned in
this way.

Here's the interesting part.  I deliberately caused a script compile error
in the card script, corrected it, and recompiled, then clicked button B,
and xyz appeared in the message box.

So it appears that script compile errors don't wipe out the original value
assigned to a script local variable in this way, but not any subsequent
changes made to it.  I guess that makes sense because it seems like the
value is assigned to the script local variable every time a handler in the
script is executed.




Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html


On Sun, Feb 23, 2014 at 12:52 PM, Peter Haworth p...@lcsql.com wrote:


 On Sun, Feb 23, 2014 at 11:14 AM, J. Landman Gay jac...@hyperactivesw.com
  wrote:

 I haven't tried it yet, maybe someone else can confirm.


 Yes, you can change the value of a script local variable in the way you
 described

 What's really interesting though is that the value of a script local
 variable assigned in this way is NOt wiped out by a script compile error.It
 feels like the value is assigned to the variable each and every time a
 handler in the script is executed.



 Pete
 lcSQL Software http://www.lcsql.com
 Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
 SQLiteAdmin http://www.lcsql.com/sqliteadmin.html

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


Re: Script local variables

2014-02-23 Thread Bob Sneidar
Right, otherwise CONSTANT would just be another name for VARIABLE. 

Bob


On Feb 23, 2014, at 11:14 , J. Landman Gay jac...@hyperactivesw.com wrote:

 On 2/23/14, 4:30 AM, Graham Samuel wrote:
 I've just read that bit of the dictionary and I'm equally surprised.
 I also think I  must have completely misunderstood it, because I
 can't see how it can work. The value of a script local variable
 (unless it's predefined using an '=' construction) is undefined until
 a script is run, and is then only defined when an executing script
 puts something into the variable. A script can only be run when the
 program is executing. When the program containing the script quits,
 any information in variables, global or local, is lost because one
 can't normally save an executable stack outside the IDE (yes, I know
 about splash stacks and such, but the principle is correct). So next
 time the script is compiled, we **must** be back at square one, and
 the value of local variables **cannot** be maintained. What's wrong
 with this thinking?
 
 Since I just discovered this, I'm trying to figure it out too. There must be 
 a difference between declaring a constant and declaring a variable. So the 
 only thing I can think of is that a script local variable can be altered by 
 different handlers in the script, where a constant cannot. I.e., the value 
 declaration is a starting point but isn't a fixed immutable value the way a 
 constant is.
 
 I haven't tried it yet, maybe someone else can confirm.
 
 -- 
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.com
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


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


Re: Script local variables

2014-02-23 Thread Graham Samuel
I see that I have misunderstood the context of this 'feature' (if that's what 
it is). It refers to a situation where one runs a script in the IDE, finds an 
error, corrects it and runs it again. It's entirely an IDE thing, isn't it? 
Compilation can happen outside the IDE, for example where a splash stack 
invokes other stacks containing scripts, but the developer doesn't see this 
directly so can't mess with the script and go again. I was thinking in a wider 
context, where the stack gets removed completely from the machine and then is 
brought back. That isn't what it's about. 

Not quite so puzzled

Graham
 
On 23 Feb 2014, at 20:09, J. Landman Gay jac...@hyperactivesw.com wrote:

 On 2/23/14, 12:17 PM, Bob Sneidar wrote:
 Could it be that editing the script resets the script local
 variables? This is true in Applescript properties. Editing and saving
 the script resets the properties to their defaults.
 
 Don't think so, that was one of my first tests when I tried to reproduce the 
 problem. I'm going with script error as the culprit for now.
 
 -- 
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.com
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


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


Re: Script local variables

2014-02-22 Thread Paul Hibbert
Hi Bill,

Sometimes there are other considerations as to when to use variables or custom 
properties, I didn't suggest custom props here because I understand that they 
may still be visible in the IDE in password protected stacks, as these 
variables were important to the integrity of the app it didn't make sense in 
this case.

I may be wrong on this, but it did crop up in a discussion a while ago and so 
far I haven't taken it far enough to test it, it's just one of those odd things 
that stuck in my memory. Could be a worthwhile exercise though. Has anyone 
tested this?

Paul

On 2014-02-22, at 8:04 AM, Earthednet-wp proth...@earthednet.org wrote:

 Mats' posting on encryption difficulties got me thinking about local 
 variables. Are they supposed to persist after the script is done executing, 
 so that the next time a handler within that script is called, they can be 
 expected to hold previously set values? I notice that they don't. Or would 
 this be a task for custom properties?
 Bill
 
 William Prothero
 http://es.earthednet.org
 
 On Feb 22, 2014, at 2:54 AM, Peter W A Wood peterwaw...@gmail.com wrote:
 
 Many thanks to Roger Eller, Jan Schenkel, Bill Vlahos and Paul Hibbert (off 
 list) for helping me identify and workaround the issues I encountered.
 
 Paul pointed out three things: I didn't the use the text of Field ...; how 
 to overcome not being able to copy text from a field in an OS X standalone; 
 and the final problem that was related to script local variables.
 
 Using the text of Field ... instead of Field ... helped to more 
 accurately copy and paste data. (I ended up displaying the encrypted data in 
 Hex anyway.) 
 
 I had found that I couldn't copy from a Field in an OS X standalone. Paul 
 provide a script with group handlers to get around the problem. I have 
 submitted a bug report which has been accepted - 
 http://quality.runrev.com/show_bug.cgi?id=11830
 
 At this stage, I was still getting inconsistent results when encrypting data 
 in the IDE or a standalone. Then Paul noticed how I was initialising the 
 encryption parameters, namely the script local variables tPassword, tSalt, 
 tIV:
 
   openStack
 put  into Field Encrypted
 put 12345678123456781234567812345678 into tPassword
 put 12345678123456781234567812345678 into tSalt
 put 12345678123456781234567812345678 into tIV
   end openStack
 
   on encryptMSG
 ...
   end encryptMSG
 
   on decryptMSG
 ...
   end decryptMSG
 
 He changed this to re-setting the three script local fields each time they 
 were used:
 
   on openStack
 put  into Field Encrypted
   end openStack
 
   command setPassCodes
 put 12345678123456781234567812345678 into tPassword
 put 12345678123456781234567812345678 into tSalt
 put 12345678123456781234567812345678 into tIV
   end setPassCodes
 
   on encryptMSG
 setPassCodes
 ...
   end encryptMSG
 
   on decryptMSG
 setPassCodes
 ...
   end decryptMSG
 
 After making this change, I now get identical results when encrypting data 
 with the stack in the IDE or as a standalone.
 
 I have also entered a bug report for this - 
 http://quality.runrev.com/show_bug.cgi?id=11832 - I feel there is a bug but 
 not in the encrypt/decrypt functions, it's in the handling of script local 
 variables.
 
 Once again, thanks for all the help.
 
 Kind regards
 Peter
 http://LiveCode1001.blogspot.com
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


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


Re: Script local variables

2014-02-22 Thread André Bisseret
Bonjour,

From liveCode Dictionnary:
The value of a local variable is retained only while the handler is running. 
When the handler exits, the value of the local variable is lost.

The value of a script local variable is retained between handlers,

For more information have a look at local in the dictionnary

Best regards

André


Le 22 févr. 2014 à 17:04, Earthednet-wp a écrit :

 Mats' posting on encryption difficulties got me thinking about local 
 variables. Are they supposed to persist after the script is done executing, 
 so that the next time a handler within that script is called, they can be 
 expected to hold previously set values? I notice that they don't. Or would 
 this be a task for custom properties?
 Bill
 
 William Prothero
 http://es.earthednet.org
 
 On Feb 22, 2014, at 2:54 AM, Peter W A Wood peterwaw...@gmail.com wrote:
 
 Many thanks to Roger Eller, Jan Schenkel, Bill Vlahos and Paul Hibbert (off 
 list) for helping me identify and workaround the issues I encountered.
 
 Paul pointed out three things: I didn't the use the text of Field ...; how 
 to overcome not being able to copy text from a field in an OS X standalone; 
 and the final problem that was related to script local variables.
 
 Using the text of Field ... instead of Field ... helped to more 
 accurately copy and paste data. (I ended up displaying the encrypted data in 
 Hex anyway.) 
 
 I had found that I couldn't copy from a Field in an OS X standalone. Paul 
 provide a script with group handlers to get around the problem. I have 
 submitted a bug report which has been accepted - 
 http://quality.runrev.com/show_bug.cgi?id=11830
 
 At this stage, I was still getting inconsistent results when encrypting data 
 in the IDE or a standalone. Then Paul noticed how I was initialising the 
 encryption parameters, namely the script local variables tPassword, tSalt, 
 tIV:
 
   openStack
 put  into Field Encrypted
 put 12345678123456781234567812345678 into tPassword
 put 12345678123456781234567812345678 into tSalt
 put 12345678123456781234567812345678 into tIV
   end openStack
 
   on encryptMSG
 ...
   end encryptMSG
 
   on decryptMSG
 ...
   end decryptMSG
 
 He changed this to re-setting the three script local fields each time they 
 were used:
 
   on openStack
 put  into Field Encrypted
   end openStack
 
   command setPassCodes
 put 12345678123456781234567812345678 into tPassword
 put 12345678123456781234567812345678 into tSalt
 put 12345678123456781234567812345678 into tIV
   end setPassCodes
 
   on encryptMSG
 setPassCodes
 ...
   end encryptMSG
 
   on decryptMSG
 setPassCodes
 ...
   end decryptMSG
 
 After making this change, I now get identical results when encrypting data 
 with the stack in the IDE or as a standalone.
 
 I have also entered a bug report for this - 
 http://quality.runrev.com/show_bug.cgi?id=11832 - I feel there is a bug but 
 not in the encrypt/decrypt functions, it's in the handling of script local 
 variables.
 
 Once again, thanks for all the help.
 
 Kind regards
 Peter
 http://LiveCode1001.blogspot.com
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


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


Re: Script local variables

2014-02-22 Thread Thierry Douez
2014-02-22 17:04 GMT+01:00 Earthednet-wp proth...@earthednet.org:
 Mats' posting on encryption difficulties got me thinking about local 
 variables. Are they supposed to persist after the script is done executing, 
 so that the next time a handler within that script is called, they can be 
 expected to hold previously set values? I notice that they don't. Or would 
 this be a task for custom properties?

Hi,

Create a simple stack, a field and a button with this script:

on mouseUp
   testlocal
   testlocal2
end mouseUp

on testlocal
   local x1
   add 1 to x1
   put x1:   x1 cr after fld 1
end testlocal

local x2

on testlocal2
   add 1 to x2
   put x2:   x2 cr after fld 1
end testlocal2


This should clarify your concern...

Regards,

Thierry


Thierry Douez - http://sunny-tdz.com
Maker of sunnYperl - sunnYmidi - sunnYmage - sunnYpdf

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


Re: Script local variables

2014-02-22 Thread Paul Hibbert
That was part of the problem, the value wasn't being retained, maybe for 
different reasons.

The original stack script set the variable values on openStack, then a button 
script called the stack script handlers to do the encryption, this is where I 
saw the possibility for the dis-connection, because portions of the stack 
script were being accessed at separate times.

Another way to achieve the same result in this case would be to declare the 
script variables with values in the stack script.

e.g.:

local tPassword = 12345678123456781234567812345678
local tSalt = 12345678123456781234567812345678
local tIV = 12345678123456781234567812345678

Often there are many different ways to achieve the same goal, the best way 
isn't always the most obvious at the time, but that's the beauty of this type 
of list.

Paul

On 2014-02-22, at 9:53 AM, André Bisseret andre.bisse...@wanadoo.fr wrote:

 Bonjour,
 
 From liveCode Dictionnary:
 The value of a local variable is retained only while the handler is running. 
 When the handler exits, the value of the local variable is lost.
 
 The value of a script local variable is retained between handlers,
 
 For more information have a look at local in the dictionnary
 
 Best regards
 
 André
 
 
 Le 22 févr. 2014 à 17:04, Earthednet-wp a écrit :
 
 Mats' posting on encryption difficulties got me thinking about local 
 variables. Are they supposed to persist after the script is done executing, 
 so that the next time a handler within that script is called, they can be 
 expected to hold previously set values? I notice that they don't. Or would 
 this be a task for custom properties?
 Bill
 
 William Prothero
 http://es.earthednet.org
 
 On Feb 22, 2014, at 2:54 AM, Peter W A Wood peterwaw...@gmail.com wrote:
 
 Many thanks to Roger Eller, Jan Schenkel, Bill Vlahos and Paul Hibbert (off 
 list) for helping me identify and workaround the issues I encountered.
 
 Paul pointed out three things: I didn't the use the text of Field ...; 
 how to overcome not being able to copy text from a field in an OS X 
 standalone; and the final problem that was related to script local 
 variables.
 
 Using the text of Field ... instead of Field ... helped to more 
 accurately copy and paste data. (I ended up displaying the encrypted data 
 in Hex anyway.) 
 
 I had found that I couldn't copy from a Field in an OS X standalone. Paul 
 provide a script with group handlers to get around the problem. I have 
 submitted a bug report which has been accepted - 
 http://quality.runrev.com/show_bug.cgi?id=11830
 
 At this stage, I was still getting inconsistent results when encrypting 
 data in the IDE or a standalone. Then Paul noticed how I was initialising 
 the encryption parameters, namely the script local variables tPassword, 
 tSalt, tIV:
 
  openStack
put  into Field Encrypted
put 12345678123456781234567812345678 into tPassword
put 12345678123456781234567812345678 into tSalt
put 12345678123456781234567812345678 into tIV
  end openStack
 
  on encryptMSG
...
  end encryptMSG
 
  on decryptMSG
...
  end decryptMSG
 
 He changed this to re-setting the three script local fields each time they 
 were used:
 
  on openStack
put  into Field Encrypted
  end openStack
 
  command setPassCodes
put 12345678123456781234567812345678 into tPassword
put 12345678123456781234567812345678 into tSalt
put 12345678123456781234567812345678 into tIV
  end setPassCodes
 
  on encryptMSG
setPassCodes
...
  end encryptMSG
 
  on decryptMSG
setPassCodes
...
  end decryptMSG
 
 After making this change, I now get identical results when encrypting data 
 with the stack in the IDE or as a standalone.
 
 I have also entered a bug report for this - 
 http://quality.runrev.com/show_bug.cgi?id=11832 - I feel there is a bug but 
 not in the encrypt/decrypt functions, it's in the handling of script local 
 variables.
 
 Once again, thanks for all the help.
 
 Kind regards
 Peter
 http://LiveCode1001.blogspot.com
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your 
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, 

Re: Script local variables

2014-02-22 Thread Peter Haworth
I think this is dependant on the Variable Preservation setting on the
Preferences Script Editor tab.

I use script local variables a lot in conjunction with handlers to access
them from other objects instead of custom properties.  I started doing it
because custom properties are visible to users in password protected stacks
whereas script local variables are not.

Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html


On Sat, Feb 22, 2014 at 8:04 AM, Earthednet-wp proth...@earthednet.orgwrote:

 Mats' posting on encryption difficulties got me thinking about local
 variables. Are they supposed to persist after the script is done executing,
 so that the next time a handler within that script is called, they can be
 expected to hold previously set values? I notice that they don't. Or would
 this be a task for custom properties?
 Bill

 William Prothero
 http://es.earthednet.org

  On Feb 22, 2014, at 2:54 AM, Peter W A Wood peterwaw...@gmail.com
 wrote:
 
  Many thanks to Roger Eller, Jan Schenkel, Bill Vlahos and Paul Hibbert
 (off list) for helping me identify and workaround the issues I encountered.
 
  Paul pointed out three things: I didn't the use the text of Field ...;
 how to overcome not being able to copy text from a field in an OS X
 standalone; and the final problem that was related to script local
 variables.
 
  Using the text of Field ... instead of Field ... helped to more
 accurately copy and paste data. (I ended up displaying the encrypted data
 in Hex anyway.)
 
  I had found that I couldn't copy from a Field in an OS X standalone.
 Paul provide a script with group handlers to get around the problem. I have
 submitted a bug report which has been accepted -
 http://quality.runrev.com/show_bug.cgi?id=11830
 
  At this stage, I was still getting inconsistent results when encrypting
 data in the IDE or a standalone. Then Paul noticed how I was initialising
 the encryption parameters, namely the script local variables tPassword,
 tSalt, tIV:
 
 openStack
   put  into Field Encrypted
   put 12345678123456781234567812345678 into tPassword
   put 12345678123456781234567812345678 into tSalt
   put 12345678123456781234567812345678 into tIV
 end openStack
 
 on encryptMSG
   ...
 end encryptMSG
 
 on decryptMSG
   ...
 end decryptMSG
 
  He changed this to re-setting the three script local fields each time
 they were used:
 
 on openStack
   put  into Field Encrypted
 end openStack
 
 command setPassCodes
   put 12345678123456781234567812345678 into tPassword
   put 12345678123456781234567812345678 into tSalt
   put 12345678123456781234567812345678 into tIV
 end setPassCodes
 
 on encryptMSG
   setPassCodes
   ...
 end encryptMSG
 
 on decryptMSG
   setPassCodes
   ...
 end decryptMSG
 
  After making this change, I now get identical results when encrypting
 data with the stack in the IDE or as a standalone.
 
  I have also entered a bug report for this -
 http://quality.runrev.com/show_bug.cgi?id=11832 - I feel there is a bug
 but not in the encrypt/decrypt functions, it's in the handling of script
 local variables.
 
  Once again, thanks for all the help.
 
  Kind regards
  Peter
  http://LiveCode1001.blogspot.com
 
 
 
  ___
  use-livecode mailing list
  use-livecode@lists.runrev.com
  Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
  http://lists.runrev.com/mailman/listinfo/use-livecode

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

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


Re: Script local variables

2014-02-22 Thread J. Landman Gay

On 2/22/14, 12:17 PM, Peter Haworth wrote:

I think this is dependant on the Variable Preservation setting on the
Preferences Script Editor tab.


It is, but there's a bug in it somewhere. I use script locals 
extensively and they always worked until somewhere around version 6.x. 
After that the values were occasionally lost. Every subsequent version 
has made the problem worse, and now I lose them so often that I've had 
to add a reload of the values to almost every handler I'm debugging.


Since I can't find a consistent recipe (sometimes they do work) I 
haven't reported it yet, but it's making my life difficult. All I know 
is that it happens some time after I change a script, but not every 
time, so I'm at a loss.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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


Re: Script local variables

2014-02-22 Thread Peter Haworth
Hi Jacque,
I've definitely seen values disappear after compiling the script for a long
time but didn't worry abut it too much since that only happens during
development not in production versions.

Like you, I haven't been able to come up with a recipe to reliably
reproduce it.


Pete
lcSQL Software http://www.lcsql.com
Home of lcStackBrowser http://www.lcsql.com/lcstackbrowser.html and
SQLiteAdmin http://www.lcsql.com/sqliteadmin.html


On Sat, Feb 22, 2014 at 10:56 AM, J. Landman Gay
jac...@hyperactivesw.comwrote:

 On 2/22/14, 12:17 PM, Peter Haworth wrote:

 I think this is dependant on the Variable Preservation setting on the
 Preferences Script Editor tab.


 It is, but there's a bug in it somewhere. I use script locals extensively
 and they always worked until somewhere around version 6.x. After that the
 values were occasionally lost. Every subsequent version has made the
 problem worse, and now I lose them so often that I've had to add a reload
 of the values to almost every handler I'm debugging.

 Since I can't find a consistent recipe (sometimes they do work) I haven't
 reported it yet, but it's making my life difficult. All I know is that it
 happens some time after I change a script, but not every time, so I'm at a
 loss.

 --
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.com


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

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


Re: Script local variables

2014-02-22 Thread Peter W A Wood
Hi Jacque

On 23 Feb 2014, at 02:56, J. Landman Gay wrote:

 It is, but there's a bug in it somewhere. I use script locals extensively and 
 they always worked until somewhere around version 6.x. After that the values 
 were occasionally lost. Every subsequent version has made the problem worse, 
 and now I lose them so often that I've had to add a reload of the values to 
 almost every handler I'm debugging.

 Since I can't find a consistent recipe (sometimes they do work) I haven't 
 reported it yet, but it's making my life difficult. All I know is that it 
 happens some time after I change a script, but not every time, so I'm at a 
 loss.

With everyone's help, I think that I have found a recipe that demonstrates the 
problem. Perhaps somebody else could try it. I build a simple stack with a 
scrolling field (Field) and a button (Button). The stack script is this:

local tMyScriptLocal1
local tMyScriptLocal2 = ghijk
local tMyScriptLocal3

on openStack
   put abcde into tMyScriptLocal1
end openStack

command initLocal3
   put lmnop into tMyScriptLocal3
end initLocal3

on buttonClick
   initLocal3
   put tMyScriptLocal1  linefeed after Field Field
   put tMyScriptLocal2  linefeed after Field Field
   put tMyScriptLocal3  linefeed after Field Field
end buttonClick

The Button script is this:

on mouseUp
   buttonClick
end mouseUp

If you run the script in the IDE, a button click will display:

abcde
ghijk
lmnop

Now Save As Standalone and then click the button again. It will display:


ghijk
lmnop

If somebody can confirm this behaviour, I will submit it to the QA Centre 
(either adding it to the existing report or adding a new one).

Regards

Peter


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


Re: Script local variables

2014-02-22 Thread J. Landman Gay

On 2/22/14, 6:49 PM, Peter W A Wood wrote:


local tMyScriptLocal1
local tMyScriptLocal2 = ghijk
local tMyScriptLocal3


I'm not sure it's a fair test. As far as I know, you can't assign a 
value to a script local that way, though you can if it's a constant. 
Actually, I'm kind of surprised it works in the IDE.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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


Re: Script local variables

2014-02-22 Thread Scott Rossi
Uh, oh -- I do this all the time.

Is this really not supposed to work?

Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design




On 2/22/14 6:04 PM, J. Landman Gay jac...@hyperactivesw.com wrote:


local tMyScriptLocal1
local tMyScriptLocal2 = ghijk
local tMyScriptLocal3

I'm not sure it's a fair test. As far as I know, you can't assign a
value to a script local that way, though you can if it's a constant.
Actually, I'm kind of surprised it works in the IDE.



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


Re: Script local variables

2014-02-22 Thread Mark Wieder
Scott-

Saturday, February 22, 2014, 6:26:31 PM, you wrote:

 Uh, oh -- I do this all the time.

 Is this really not supposed to work?

It sometimes works, but it's not legal syntax.
I don't know of any particular reason why not, but it's not.

-- 
-Mark Wieder
 ahsoftw...@gmail.com

This communication may be unlawfully collected and stored by the National 
Security Agency (NSA) in secret. The parties to this email do not 
consent to the retrieving or storing of this communication and any 
related metadata, as well as printing, copying, re-transmitting, 
disseminating, or otherwise using it. If you believe you have received 
this communication in error, please delete it immediately.


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


Re: Script local variables

2014-02-22 Thread J. Landman Gay
Well, I didn't *think* it was allowed. I confess I never used script 
locals that way. If I need to assign a permanent value, I use a constant:


  constant kVar = 1234

If the IDE accomodates script locals with assignments, then maybe 
something changed. Apparently it doesn't work in standalones.


Or maybe this is a clue to the larger issue of lost script locals.


On 2/22/14, 8:26 PM, Scott Rossi wrote:

Uh, oh -- I do this all the time.

Is this really not supposed to work?

Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design




On 2/22/14 6:04 PM, J. Landman Gay jac...@hyperactivesw.com wrote:



local tMyScriptLocal1
local tMyScriptLocal2 = ghijk
local tMyScriptLocal3


I'm not sure it's a fair test. As far as I know, you can't assign a
value to a script local that way, though you can if it's a constant.
Actually, I'm kind of surprised it works in the IDE.




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




--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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


Re: Script local variables

2014-02-22 Thread J. Landman Gay

I take it back. The dictionary says you can do it. Whaddya know.


On 2/22/14, 8:26 PM, Scott Rossi wrote:

Uh, oh -- I do this all the time.

Is this really not supposed to work?

Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design




On 2/22/14 6:04 PM, J. Landman Gay jac...@hyperactivesw.com wrote:



local tMyScriptLocal1
local tMyScriptLocal2 = ghijk
local tMyScriptLocal3


I'm not sure it's a fair test. As far as I know, you can't assign a
value to a script local that way, though you can if it's a constant.
Actually, I'm kind of surprised it works in the IDE.




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




--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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


Re: Script local variables

2014-02-22 Thread J. Landman Gay

On 2/22/14, 8:42 PM, Mark Wieder wrote:

Scott-

Saturday, February 22, 2014, 6:26:31 PM, you wrote:


Uh, oh -- I do this all the time.



Is this really not supposed to work?


It sometimes works, but it's not legal syntax.
I don't know of any particular reason why not, but it's not.



They must have changed it when you and I weren't looking. Variable 
assignments are even listed in the examples in the dictionary entry for 
local. I may have to read the whole dictionary again to see what else 
I've missed.


I may also have found a clue to disappearing locals. The same entry says 
this: If variable preservation is turned on, script locals retain their 
values when the script is re-compiled, unless there is an error in the 
script.


I'm quite sure I've produced enough errors to have destroyed a few 
script locals in my time, so maybe that's what's wrong. I'll try to pay 
more attention.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

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