Transfer to/ from html5 standalone and text file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 17
- Joined: Thu Mar 26, 2020 8:23 pm
Transfer to/ from html5 standalone and text file
Hi,
Long time LC user, needing to move reliable stacks & projects to web apps (thanks, C-19!). Here are some of my travails, can someone point me in the right direction, please?
I want to send the content of a variable (the output) from one stack (html5 standalone) to text file. For context, I'm using LC Hosting service, with full permissions assigned, and I have confirmed that the filepath is correct. I have tried a number of 'put', 'post', 'get' and 'write' commands, with no luck, with and without "open file URL for write", and/or "Load....", etc.
So, can someone help with the frustration? Why do these not work? Like everything else these days, deadlines matter...
1. Via 'put' : Put "NewContent" into line 1 of URL ["http://...txt"]
2. the POST hole: Post "NewContent" to line 2 of URL ["http://....txt"]
3. the open/write/close sequence:
open file URL ["http://....txt"] for text write
write "NewContent" to file URL ["http://....txt"] at EOF
close file URL ["http://....txt"]
4. The finish line: Of course, once I get the data in the text file, I want to retrieve it (via another stack), but nothing other than "Answer" has allowed me to access anything in the text file.
Thanx in advance!
L P B
Long time LC user, needing to move reliable stacks & projects to web apps (thanks, C-19!). Here are some of my travails, can someone point me in the right direction, please?
I want to send the content of a variable (the output) from one stack (html5 standalone) to text file. For context, I'm using LC Hosting service, with full permissions assigned, and I have confirmed that the filepath is correct. I have tried a number of 'put', 'post', 'get' and 'write' commands, with no luck, with and without "open file URL for write", and/or "Load....", etc.
So, can someone help with the frustration? Why do these not work? Like everything else these days, deadlines matter...
1. Via 'put' : Put "NewContent" into line 1 of URL ["http://...txt"]
2. the POST hole: Post "NewContent" to line 2 of URL ["http://....txt"]
3. the open/write/close sequence:
open file URL ["http://....txt"] for text write
write "NewContent" to file URL ["http://....txt"] at EOF
close file URL ["http://....txt"]
4. The finish line: Of course, once I get the data in the text file, I want to retrieve it (via another stack), but nothing other than "Answer" has allowed me to access anything in the text file.
Thanx in advance!
L P B
Re: Transfer to/ from html5 standalone and text file
Hi L P B,
not sure, but try with just the relative (to your HTML5 runtime) pathname and FILE:
Best
Klaus
not sure, but try with just the relative (to your HTML5 runtime) pathname and FILE:
Code: Select all
...
put "NewContent" into line 1 of URL("file:your_data_file_here.txt")
## the result = EMPTY on success!
## so maybe this gives a hint what happened
if the result <> EMPTY then
answer "Error:" && the result
end if
...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9833
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Transfer to/ from html5 standalone and text file
Browsers do not allow unfettered access to the user's file system. Think about what could happen if they did.
Does this app really need to be confined to a browser window?
Does this app really need to be confined to a browser window?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Transfer to/ from html5 standalone and text file
Hm, I thought he wanted to let the HTML5 runtime write a file on the SERVER!?
Not?
Not?
-
- Posts: 17
- Joined: Thu Mar 26, 2020 8:23 pm
Re: Transfer to/ from html5 standalone and text file
Yes, it's on the server, not on the client/user's file system.
Thanks,
L P B
Thanks,
L P B
-
- VIP Livecode Opensource Backer
- Posts: 9833
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Transfer to/ from html5 standalone and text file
What is on the server to receive the data?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Transfer to/ from html5 standalone and text file
OK, then try my script above.LeProfBard wrote: ↑Sun Apr 19, 2020 6:03 pmYes, it's on the server, not on the client/user's file system.
Thanks,
L P B
"write permission" in that folder presumed!
-
- Posts: 17
- Joined: Thu Mar 26, 2020 8:23 pm
Re: Transfer to/ from html5 standalone and text file
Hi Klaus (and FourthWorld--I've read and appreciated comments from both of you in many of the forums over the years, too)
No progress: the script apparently ran, but nothing was delivered to the text file, and there was no error code returned.
FourthWorld: you asked earlier 'what's on the server to receive the data?' A: simple text file. Same folder.
Thanks, L P B
No progress: the script apparently ran, but nothing was delivered to the text file, and there was no error code returned.
FourthWorld: you asked earlier 'what's on the server to receive the data?' A: simple text file. Same folder.
Thanks, L P B
-
- VIP Livecode Opensource Backer
- Posts: 9833
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Transfer to/ from html5 standalone and text file
Sorry, I wasn't clear: what software is running on the server to handle the write? And how does it handle authentication?LeProfBard wrote: ↑Mon Apr 20, 2020 3:16 amFourthWorld: you asked earlier 'what's on the server to receive the data?' A: simple text file. Same folder.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 720
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: Transfer to/ from html5 standalone and text file
Maybe publishing your desktop application as is, instead of making it a web version is an idea.
https://smartbear.com/blog/develop/take ... in-15-min/
https://smartbear.com/blog/develop/take ... in-15-min/
-
- Posts: 17
- Joined: Thu Mar 26, 2020 8:23 pm
Re: Transfer to/ from html5 standalone and text file
Hi Richard,
Thanks for asking your question, it pointed me in the right direction. I was first able to set up the 'write to text file' via PHP, but I'm pursuing it in .lc, just not quite there.
Thanks to all for your responses.
Thanks for asking your question, it pointed me in the right direction. I was first able to set up the 'write to text file' via PHP, but I'm pursuing it in .lc, just not quite there.
Thanks to all for your responses.
-
- VIP Livecode Opensource Backer
- Posts: 46
- Joined: Sun Jun 15, 2008 4:51 pm
- Location: Albany, NY
Re: Transfer to/ from html5 standalone and text file
I just started a new thread before I saw your just posted response in this thread. See: https://forums.livecode.com/viewtopic.php?f=120&t=33981
If you can share about the PHP or .lc, we would all be thankful!
If you can share about the PHP or .lc, we would all be thankful!
-
- Posts: 17
- Joined: Thu Mar 26, 2020 8:23 pm
Re: Transfer to/ from html5 standalone and text file
Hi Wally,
Sure. Here's what worked for me in PHP. I'm still hacking away on finding the LC equivalents, though.
<?php
$chiffre = ($_POST["nextNumber"]) ."\n"; //receives new number, adds CR
$file = 'numbers.txt';
file_put_contents($file, $chiffre, FILE_APPEND | LOCK_EX); // Appends, locks file from multiple write attempts
?>
Sure. Here's what worked for me in PHP. I'm still hacking away on finding the LC equivalents, though.
<?php
$chiffre = ($_POST["nextNumber"]) ."\n"; //receives new number, adds CR
$file = 'numbers.txt';
file_put_contents($file, $chiffre, FILE_APPEND | LOCK_EX); // Appends, locks file from multiple write attempts
?>
-
- Posts: 17
- Joined: Thu Mar 26, 2020 8:23 pm
Re: Transfer to/ from html5 standalone and text file
oh, BTW, I ended up using tsNetPost with callbacks, as per :
http://lessons.livecode.com/m/4071/l/69 ... -callbacks
L P B
http://lessons.livecode.com/m/4071/l/69 ... -callbacks
L P B
-
- VIP Livecode Opensource Backer
- Posts: 46
- Joined: Sun Jun 15, 2008 4:51 pm
- Location: Albany, NY
Re: Transfer to/ from html5 standalone and text file
L P B,
Thanks for the info.
The LiveCode user guide says:
"Two important unsupported features are unlikely to be added in the near future:
operations that need to pause the script while something happens (e.g. wait 10 )
externals (including revdb)"
Isn't tsNetPost part of an external?
Thanks for the info.
The LiveCode user guide says:
"Two important unsupported features are unlikely to be added in the near future:
operations that need to pause the script while something happens (e.g. wait 10 )
externals (including revdb)"
Isn't tsNetPost part of an external?