no, LC server is another branch of Livecode, a CGI server software like PHP etc.
If a command/function is available in HTML5 then html5 is listed under OS, see screenshot: Sorry, I mixed this with the "Platforms" info.
Best
Klaus
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
no, LC server is another branch of Livecode, a CGI server software like PHP etc.
It works well across a network! I think can make something useful from this. Thank you Bernd.mbossiere wrote: ↑Tue Jan 30, 2024 4:27 pmThanks. Yes, I agree - it's ugly but this would be fine in some circumstances. I will try it across a network. So the black band acts like Msg box - very handy to know (As I said, I'm new to this type of deployment)bn wrote: ↑Tue Jan 30, 2024 1:34 pmHi Marc,
I played around with the problem of the user copying a value from the field. I could not get it directly.
A very ugly workaround is to "put" the content of the field.
This puts it into the black area below your stack. From there you are able to copy the value.Code: Select all
on mouseUp get secsToMyLongStamp(the secs) put it into fld 1 put it ## puts 'it' into the black area below your stack end mouseUp
It is not nice but at least a way to get at the value.
Kind regards
Bernd
I tested locally (local host) so I do not know if that hack works across the network. There are many security precautions in browsers against a lot of stuff.
No, that's the strange part.. I didn't include anything (not intentionally anyway) and as I mentioned I made sure the were no stacks "in use) as well.
Thanks Bernd. So it was. Not sure how I put that in there, but there is was!
Sorry that I'm late to the party, but I bring the javascript workaround for this. You can put this code in your stack script:
Code: Select all
command copyText pText
if the platform is not "web" then
set the clipboardData["text"] to pText
else
replace "\" with "\\" in pText ## Escape backslashes
replace quote with ("\" & quote) in pText ## Escape double quotes
replace cr with "\r" in pText ## Escape linebreaks
do "navigator.clipboard.writeText(" & quote & pText & quote & ");" as "javascript"
wait 2 secs with messages ## Let retarded Chrome catch up...
end if
answer "The text has been copied to the clipboard."
end copyText
Code: Select all
get secsToMyLongStamp(the secs)
copyText it
Very excited when I saw this! I tried to execute the above, but not sure I did it right. In the LC IDE is works (I get your response from within copyText, "The text has been copied to the clipboard") so I compiled and uploaded the stack, but when I try it there it succeeds to put the date as expected into fld 1 but there is no response from copyText - nor does the formatted date appear in the clipboard. What am I doing wrong?SWEdeAndy wrote: ↑Wed Jan 31, 2024 9:20 pm
Sorry that I'm late to the party, but I bring the javascript workaround for this. You can put this code in your stack script:Now, instead of (or in parallel with) outputting your value to fld 1, you doCode: Select all
command copyText pText if the platform is not "web" then set the clipboardData["text"] to pText else replace "\" with "\\" in pText ## Escape backslashes replace quote with ("\" & quote) in pText ## Escape double quotes replace cr with "\r" in pText ## Escape linebreaks do "navigator.clipboard.writeText(" & quote & pText & quote & ");" as "javascript" wait 2 secs with messages ## Let retarded Chrome catch up... end if answer "The text has been copied to the clipboard." end copyText
My handler does more than you currently need, so you can delete the lines beginning with "replace" if you want. But if you, or anyone, want to be able to put more complex text into the clipboard then you'll need those lines.Code: Select all
get secsToMyLongStamp(the secs) copyText it
The 'if the platform is not "web" then' part is not strictly necessary either, but prevents errors if the handler is invoked in other environments than web deployment.
You can of course also remove or alter the answer dialog that confirms the copy action. I've found it necessary, for my purposes, to add a slight delay ("wait 2 secs with messages") before proceeding with other script actions, especially when using Chrome, to allow the javascript time to execute, but that may depend on the amount of text being copied (it was a big chunk in my project), so that too may be optional. You'll have to test it out.
and by eliminating the call to a separate function, it seems to work! Quite impressive and opens up many ideas for me.on mouseUp
get secsToMyLongStamp(the secs)
put it into fld 1 -- this is just for user to see what's in clipboard
replace "\" with "\\" in it ## Escape backslashes
replace quote with ("\" & quote) in it ## Escape double quotes
replace cr with "\r" in it ## Escape linebreaks
do "navigator.clipboard.writeText(" & quote & it & quote & ");" as "javascript"
wait 2 secs with messages ## Let retarded Chrome catch up...
answer "The text has been copied to the clipboard."
end mouseUp
This may help:
When testing your stack and doing a test deployment from the IDE, it works as expected, including the answer dialog. I'm using LiveCode 10.0.0 dp 7.
Thank you Andreas. Very helpful yet again. I was indeed using LC9 not LC10 Preview but will make the switch and try these things again and report back. I saw no reason to use LC10 until now as it is still beta but knowing about WASM changes the picture. I'm excited to investigate this.SWEdeAndy wrote: ↑Fri Feb 02, 2024 8:57 pm
When testing your stack and doing a test deployment from the IDE, it works as expected, including the answer dialog. I'm using LiveCode 10.0.0 dp 7.
When looking at your html code with the browser developer tool however, it seems that you have used LiveCode 9.6.11 for web deployment?
Unfortunately, that is old tech and a dead end in web development with LiveCode. Using LC 10+ is the way to go, as it uses WebAssembly (WASM) as deployment tech which greatly expands the possibilities to run LC stacks almost completely out-of-the-box in the web browser. One significant thing it can use, which the old tech can't, is the wait command. And since my copying code utilises the wait command, that is quite likely the cause of your web deployment failing to execute code after the wait line. I you keep deploying to web with LC9 you must avoid all use of 'wait'.
Why it helped part of the code to function better by moving it directly into the button script I don't know. Might be another LC9 failure. But since the original version, with a separate handler in the stack script, works fine with LC10, I won't investigating that further. I'm afraid I can only really help with LC10 web deployments.
These things are much more difficult to do due to security barriers. The browser never has access to local files unless the user allows permission, and that is anyway normally limited to uploading/downloading a file, if I understand correctly. Reading from and writing to a local file the way a desktop standalone can do will probably never be allowed for a browser (for good reasons too).mbossiere wrote: ↑Thu Feb 01, 2024 4:45 pmSWEdeAndy, I'd also be very curious if you have any similar workarounds concerning file I/O (writing to and from local files on a Mac/Linux/Windows etc) -- and/or the ability to accept clipboard data from a user (incoming). File I/O - even just text - would be magic!