Page 1 of 1

Any Idea?

Posted: Thu May 15, 2025 3:12 am
by lewisbaggins
Hi everyone,
I'm currently working on a project in LiveCode on Windows 10, targeting a desktop application, and I've encountered what seems to be a bug. Specifically, when I try to open a file using the open file command, the application either freezes or returns an error stating that the file cannot be opened, even though the path is valid and the file exists. To reproduce the issue, I create a button that runs a script to open a text file located in the Documents folder. I use open file "C:/Users/MyUser/Documents/t***.txt" for read, but as soon as the script executes, LiveCode hangs or throws an error. I expected the file to open normally so I could read its contents into a field, but instead the app becomes unresponsive or fails to access the file. I’ve double-checked file permissions, tested with different paths and file names, and even tried running LiveCode as administrator, but the problem persists. Has anyone experienced this or found a workaround? Any help would be greatly appreciated. Thanks in advance!

Re: Any Idea?

Posted: Thu May 15, 2025 12:50 pm
by stam
You should probably post the actual code used.

Most of us would not use the open file command (which should be followed by for <action> (such as read/write/append).

If you just want to put a text file into a field the use the put URL(“file:” & <filepath>) command

Re: Any Idea?

Posted: Thu May 15, 2025 1:32 pm
by dunbarx
What Stam said.

I am not a Windows user, but please do post the relevant code. And does this work OK with a different version of Windows?

Craig

Re: Any Idea?

Posted: Thu May 15, 2025 5:52 pm
by bobcole
To open a file, use the launch command.
Here is a sample script (I put the file is my Public folder).

Code: Select all

on mouseUp pButtonNumber
   launch document "/Users/myName/Public/Test.txt"
   
   --Or, try something like this:
   --launch "/Users/myName/Public/Test.html" with "/Applications/Safari.app"
end mouseUp
This should work.
Bob

Re: Any Idea?

Posted: Thu May 15, 2025 6:00 pm
by stam
Think the OP wanted to open a file for use within LiveCode(?)
If it’s just opening the file with the system default app then yeah, that’s it.
But don’t think that’s what the OP was asking for (?)

Re: Any Idea?

Posted: Thu May 15, 2025 9:21 pm
by bobcole
Well then how about trying:

Code: Select all

start using stack "myStack" 
instead?
Bob

Re: Any Idea?

Posted: Thu May 15, 2025 10:26 pm
by bobcole
No, that won't do it either.
I think your comment about put the text into a field is correct:

Code: Select all

put URL(“file:” & <filepath>)
That should give the OP what is needed.
Bob

Re: Any Idea?

Posted: Thu May 15, 2025 11:11 pm
by FourthWorld
Lengthy blocks of unformatted text mixing code and description from an account created hours before this first and only post may be a human behavior, but is frequently what bot behavior looks like.

Dear OP: add some meaningful line breaks to your post and I'll help. Ignore this request long enough and I'll delete this thread, since of course by that time you clearly wouldn't need an answer anyway.