[HELP] revCopyFile in standalone

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
Zax
Posts: 155
Joined: Mon May 28, 2007 10:12 am
Location: France

[HELP] revCopyFile in standalone

Post by Zax » Sun Sep 24, 2017 2:27 pm

Hello,

"revCopyFile" command crashes in a standalone environment (it works fine in development environment), though I don't use this command during startup. This command is called after the user opens a substack as modal dialog.

Quoted from LiveCode dictionary:
Note: In a standalone application the Common library is implemented as a hidden group and made available when the group receives its first openBackground message. During the first part of the application's startup process, before this message is sent, the revCopyFile command is not yet available. This may affect attempts to use this command in startup, preOpenStack, openStack, or preOpenCard handlers in the main stack. Once the application has finished starting up, the library is available and the revCopyFile command can be used in any handler.
Is there a way to force this Common library?
I used LC community 8.14, and then tried with 8.16 but I encountered the same crash.

Thanks for your help.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5402
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: [HELP] revCopyFile in standalone

Post by jacque » Sun Sep 24, 2017 4:39 pm

The Common library is included with every standalone automatically. It's always there.

What version of LC are you using and what platform are you building for? I have a project where revMail is crashing for one user on a new Android phone. It isn't repeatable and only happens for this one user so far. RevMail is also part of the Common library.

It would help if you can show us the exact line of script you're using for the command.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Zax
Posts: 155
Joined: Mon May 28, 2007 10:12 am
Location: France

Re: [HELP] revCopyFile in standalone

Post by Zax » Tue Sep 26, 2017 8:41 am

Sorry for the dealy of my answer, I was AFK.

I just performed several tests and it seems not to be the revCopyFile command that doesn't work, but rather from where it is called... :(

First test: a single button on the main card on my main stack:

Code: Select all

on mouseUp
   get "revCopyFile test ***" & return & "Choose a file to copy"
   answer file it
   put it into sourceFile
   if sourceFile <> "" then
      put sourceFile into pathFile
      set itemDelimiter to "/"
      delete last item of pathFile
      put "/" after pathFile
      get copyTheFile(sourceFile,pathFile)
      if it <> "" then answer "copyTheFile: failed" & return & it
   end if
end mouseUp

function copyTheFile sourceFile,pathFile
   answer "copyTheFile:" & return & sourceFile & return & pathFile
   revCopyFile sourceFile,pathFile
   return the result
end copyTheFile
It works

Now if I move the copyTheFile function in the script of my main stack, it also works (as expected).

In my stack, revCopyFile command is called from a confirm dialog, made with a modal substack, in order to have a checkbox to let the user choose if he wants to make a backup copy of a file to be modified. This script located in a substack's button calls the copyTheFile function located in the script of my main stack, and it crashes in a standalone compiled with LC community 8.14 or 8.16!
It works in developement environment.
It also worked in an old standalone version of my stack, compiled as standalone with an old LC version (maybe 6.xx ?).

But now, if the copyTheFile function is not longer located in the main stack, but located in the same object that calls the function, it works! I don't understand why :(


EDIT: when I say "It crashes", I mean a real crash with an error report. Something like:
Type: Handler: can't find handler
Object: stack '[...] myStack'
Line: revCopyFile sourceFile,pathFile
Line Num: 730
Hint: revCopyFile

Comments:

MaxV
Posts: 1576
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: [HELP] revCopyFile in standalone

Post by MaxV » Fri Sep 29, 2017 4:48 pm

You created a function called copyTheFile, that function must be:
  • in the same object where is the the line calling it, or
  • in the same card, or
  • in the same stack
See http://livecode.wikia.com/wiki/Message_path

But you placed that function in another stack (the main stack). So you should create a message called copyTheFile in the mainstack and use or send or call, like:

Code: Select all

send "copyTheFile sourceFile,pathFile" to stack "nameOfMainStack"
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Zax
Posts: 155
Joined: Mon May 28, 2007 10:12 am
Location: France

Re: [HELP] revCopyFile in standalone

Post by Zax » Fri Sep 29, 2017 9:28 pm

MaxV wrote:You created a function called copyTheFile, that function must be:
  • in the same object where is the the line calling it, or
  • in the same card, or
  • in the same stack
Thank you for your reply, but I think all user defined commands and functions located in the main stack's script or in any stack "in use" will be trapped.
The crash is not due to the call to the user defined function copyTheFile() , but to revCopyFile built-in command.

Furthermore, I only encountered my problem in the standalone version of my LC project. All is working fine in the development environment.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5402
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: [HELP] revCopyFile in standalone

Post by jacque » Fri Sep 29, 2017 10:31 pm

Zax wrote: Thank you for your reply, but I think all user defined commands and functions located in the main stack's script or in any stack "in use" will be trapped.
The crash is not due to the call to the user defined function copyTheFile() , but to revCopyFile built-in command.

Furthermore, I only encountered my problem in the standalone version of my LC project. All is working fine in the development environment.
What you're seeing isn't really a crash, it's an error report. A crash would cause the standalone to quit suddenly.

Note that only the stack script for stacks in use will be in the message hierarchy. Other scripts in the in-use stack will not see the message. Since it works in the IDE, I'll assume the message path is correct but you can check that the revCommon library exists in the standalone by putting a temporary button in the stack with this script:

Code: Select all

on mouseup
  answer there is a stack "revcommonlibrary"
end mouseup
Build the standalone and click the button. The answer dialog will say "true" if the library exists. If it does, then the problem is in the message path. If you get "false" back then it looks like a bug to me.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bwmilby
Posts: 299
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: [HELP] revCopyFile in standalone

Post by bwmilby » Sat Sep 30, 2017 12:24 am

jacque wrote:The Common library is included with every standalone automatically. It's always there.

What version of LC are you using and what platform are you building for? I have a project where revMail is crashing for one user on a new Android phone. It isn't repeatable and only happens for this one user so far. RevMail is also part of the Common library.

It would help if you can show us the exact line of script you're using for the command.
Except for mobile... it isn't included (which is why geometry manager doesn't work).
RevMail for mobile doesn't need the code in the common library though. You may want to try to copy the 2 revmail commands into the problem stack and then they could be loaded as needed to get around the issue (as a temporary fix).
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

Zax
Posts: 155
Joined: Mon May 28, 2007 10:12 am
Location: France

Re: [HELP] revCopyFile in standalone

Post by Zax » Sat Sep 30, 2017 12:23 pm

jacque wrote:What you're seeing isn't really a crash, it's an error report. A crash would cause the standalone to quit suddenly.
You're right, sorry for this error.
jacque wrote:

Code: Select all

on mouseup
  answer there is a stack "revcommonlibrary"
end mouseup
Build the standalone and click the button. The answer dialog will say "true" if the library exists. If it does, then the problem is in the message path. If you get "false" back then it looks like a bug to me.
I made the test and obviously it answers "true".
I also put the test answer there is a stack "revcommonlibrary" in my function copyTheFile, just before calling revCopyFile, and it also answers "true".

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5402
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: [HELP] revCopyFile in standalone

Post by jacque » Sat Sep 30, 2017 4:34 pm

Okay, so it's a message path issue. I've lost track of where your handler is now in the hierarchy. Did you say you were calling it from a modal dialog? And the modal is called from a substack?

While all LC messages will pass through the mainstack, it's sometimes necessary to specifically put the mainstack in use if you want it to catch custom messages. Try that next.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Zax
Posts: 155
Joined: Mon May 28, 2007 10:12 am
Location: France

Re: [HELP] revCopyFile in standalone

Post by Zax » Sat Sep 30, 2017 7:15 pm

I tried start using the main stack but it doesn't solve the problem.
I made a dirty hotfix by repeating my user defined function that call revCopyFile every time I need.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”