Page 1 of 2

Standalone not working with script only stack

Posted: Mon Feb 17, 2020 8:01 pm
by kaveh1000
Hi folks. I am trying to put together a minimal stack to try out this excellent suggestion by Jacqueline to encrypt Script only Stacks (SoS's) on the fly:

http://lists.runrev.com/pipermail/use-l ... 58018.html

But I am falling at the first hurdle, before encryption. Please see attached minimal stack, consisting of a stack "Testing encryption", with stack script:

Code: Select all

on preopenstack
   put specialFolderPath("resources") into tLibraryPath
   put tLibraryPath & "/" & "ScriptOnlyStack.livecodescript" into tPath
   open stack tPath
   start using stack tPath
end preopenstack
and one button with script:

Code: Select all

on mouseup
   showtext
end mouseup
The script only stack has one handler:

Code: Select all

on showtext
   answer "Text coming from script-only stack"
end showtext
This works fine, showing that the SoS is being accessed. But when I create a standalone, the button does not work. I have added the SoS in the Copy files area of the Standalone Application settings.

Can someone tell me what elementary mistake I am making?

Kaveh

Re: Standalone not working with script only stack

Posted: Mon Feb 17, 2020 10:07 pm
by LiveCode_Panos
Hello Kaveh,

What happens in your example is that you have "Search for Inclusions", but the call

Code: Select all

answer "Text coming from script-only stack"
in in the script-only stack that is included in the Copy Files. The standalone builder only checks the main stack for possible inclusions - not the stacks included in the Copy Files. Since the main stack has no call to the "answer" command, it does not add the "Answer Dialog" inclusion to the standalone.

You have to choose "Select Inclusions" and check the "Answer Dialog".

Hope this helps.

Kind regards,
Panos
--

Re: Standalone not working with script only stack

Posted: Mon Feb 17, 2020 10:30 pm
by kaveh1000
Thank you so much Panos. I think it was not that obvious and I don't feel too silly. I would not have thought of that. Yup, it works. :-)

Kaveh

Re: Standalone not working with script only stack

Posted: Mon Feb 17, 2020 11:55 pm
by kaveh1000
OK, I now have a working minimal stack, using a Script-only stack. I have modified the stack script, according to Jacqueline's recipe, namely

Code: Select all

on preopenstack
   put specialFolderPath("resources") into tLibraryPath
   put tLibraryPath & "/" & "ScriptOnlyStack.livecodescript" into tPath
   open stack tPath
   start using stack tPath
end preopenstack

on standaloneSaved 
   set the scriptonly of stack "ScriptOnlyStack.livecodescript" to false
   set the mainstack of stack "ScriptOnlyStack.livecodescript" to "Testing encryption"
   set the password of stack "Testing encryption" to "hi"
end standaloneSaved
The Standalone is created, but I can still see the unencrypted SoS in the Package Contents in the mac version. Any ideas please?

Kaveh

Re: Standalone not working with script only stack

Posted: Tue Feb 18, 2020 10:02 am
by LiveCode_Panos
Hello Kaveh,

You probably have to do these changes (i.e. the encryption) in the "savingStandalone" handler, and revert them in the "standaloneSaved" handler.

The "savingStandalone" message is sent just before the standalone creation begins, and the "standaloneSaved" is sent when the standalone is ready.

Kind regards,
Panos
--

Re: Standalone not working with script only stack

Posted: Tue Feb 18, 2020 11:29 am
by kaveh1000
Oops. Silly error. Let me try and report back. Thanks again Panos and great to see you on the forum. :-)

Re: Standalone not working with script only stack

Posted: Tue Feb 18, 2020 1:23 pm
by kaveh1000
OK, I had actually done this correctly before. Please see updated stack with

Code: Select all

standaloneSaved
changed to

Code: Select all

savingStandalone
but with the same result, namely SoS viewable unencrypted.

Re: Standalone not working with script only stack

Posted: Sun Apr 05, 2020 10:16 pm
by hrcap
Evening Kaveh

did you have any luck with encrypting the SOS's?


Many Thanks

Re: Standalone not working with script only stack

Posted: Sun Apr 05, 2020 10:26 pm
by kaveh1000
No. Thanks for asking. Really need a solution to this. Any help or hints appreciated.

Kaveh

Re: Standalone not working with script only stack

Posted: Fri Apr 10, 2020 6:25 pm
by kaveh1000
Hi all

I tried to run this stack again, in order to get an encrypted stack. I am uploading the latest version. The stack script of the main file is:

Code: Select all

on preopenstack
   put specialFolderPath("resources") into tLibraryPath
   put tLibraryPath & "/" & "ScriptOnlyStack.livecodescript" into tPath
   open stack tPath
   start using stack tPath
end preopenstack

on savingStandalone 
   set the scriptonly of stack "ScriptOnlyStack.livecodescript" to false
   set the mainstack of stack "ScriptOnlyStack.livecodescript" to "Testing encryption"
   set the password of stack "Testing encryption" to "hi"
   answer the password of stack "Testing encryption"
end savingStandalone
When I step through the savingStandalone handler, the script does not perform the first line, i.e.

Code: Select all

   set the scriptonly of stack "ScriptOnlyStack.livecodescript" to false
and jumps to the end statement. I cannot work out why. Any ideas please?

Kaveh

Re: Standalone not working with script only stack

Posted: Sat Apr 11, 2020 5:35 pm
by jacque
I just noticed that the dictionary entry for scriptonly has an example of how to password protect a scriptonly stack. I'd guess that that you wouldn't need to decrypt it when using it either.

Re: Standalone not working with script only stack

Posted: Sat Apr 11, 2020 6:17 pm
by kaveh1000
Thanks. I tried that, i.e. without your suggestion of removing the standalone property, but still not encrypted...

Re: Standalone not working with script only stack

Posted: Sun Apr 12, 2020 5:22 pm
by jacque
There's the old-fashioned way I suppose. When you're ready to build, encrypt the text file yourself with the "encrypt" command and save it to disk. Include it in the standalone. When you want to use it, decrypt it and save the file to the user's temporary folder using tempname to get the right file path. Open it from there and immediately delete the temporary file as soon as the stack is in memory.

The temp file will only be on disk for milliseconds, in an obscure location usually not ever seen by users.

Re: Standalone not working with script only stack

Posted: Sun Apr 12, 2020 7:14 pm
by bogs
Some times the old ways work best eh :D

Re: Standalone not working with script only stack

Posted: Thu Dec 03, 2020 12:50 pm
by Bernard
kaveh1000 wrote:
Fri Apr 10, 2020 6:25 pm
When I step through the savingStandalone handler, the script does not perform the first line, i.e.

Code: Select all

   set the scriptonly of stack "ScriptOnlyStack.livecodescript" to false
and jumps to the end statement. I cannot work out why. Any ideas please?

Kaveh
Isn't the problem here that the file extension should not be included as part of the stack name?

i.e.
set the scriptonly of stack "ScriptOnlyStack" to false
not
set the scriptonly of stack "ScriptOnlyStack.livecodescript" to false