Script local variables

Paul Hibbert paulhibbert at mac.com
Sat Feb 22 12:45:09 EST 2014


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 <prothero at 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 <peterwawood at 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 at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list