Benajah wrote: ↑Sat Feb 15, 2020 2:06 am
I was looking for a way to send the LiveCode file in the forum but have not found the proper way to do it.
I tried to attach the file but it was greyed out.
Being new to the forum, with only 2 posts at present, you will not have the ability to post links or attach items. Shortly, though, about 8 posts from now, you will 'graduate' to a level where you will be able to attach items.
As a side note, not a criticism, you *can* post scripting code within a 'code' block, which will condense the amount of space it takes up by wrapping it using the following button above your posting area -
A few notes about your script in comments in below snippet -
Code: Select all
on mouseUp
-- set the useUnicode to true # temporarily disabled as unicode isn't needed for this demo...
ask file "Choose where you wish to export your text"
/*
if the result = "cancel"
then exit mouseUp
*/
# instead of testing for cancel this way, I would see if the result is *not* cancel, like so...
if the result is not "Cancel" then put the effective htmlText of fld "Main" into url("file:" & it & ".htm")
end mouseUp
This is enough to save the file so that it looks like this in a text editor -
Here is the code I tried for the read button. I don't know how to read a file properly. I tried to use this other code from the forums. I am obviously using ask file incorrectly because it seems to create or overwrite a file.
That is correct, ask when you want to save the file, answer when you want to open a file.
To re-open the file, you simply put the url back into the field, in this case I made a second field, but you can re-use your original field.
Code: Select all
on mouseUp
# try 'answer' file, not ask, to open a file...
answer file "which file would you like to load"
if it is not "" then set the htmltext of fld "subMain" to url("file:" & it)
end mouseUp
I've attached this rather small demo, tested and working on 'nix, for you to test out.
*Edit - I have included no error checking at all in the above code snippets, but highly suggest that you should *always* use error checking even for simple operations like the code listed above.