Page 1 of 2
can't edit cell in stand alone app
Posted: Sun Feb 06, 2011 4:31 pm
by pmc
Hi Everybody
I have done a little app with a field text (please see attached picture). Now it works as normal when working in Rev but when I compile it into a standalone app, the text fields are not editable.

I have only changed the tab stops (to 120) and the text height (to 18) of the table field. I am using Windows Vista. What is wrong? Thanks in advance for help.
Re: can't edit cell in stand alone app
Posted: Mon Feb 07, 2011 2:18 pm
by doc
Hello pmc,
I just built a test app here on this end and the executable is plenty editable. Of course you cannot save data directly to an executable, so if that's what you are describing, you will need to take a different approach.
Have a look at the table properties and compare them to the image I've attached.
-Doc-
Re: can't edit cell in stand alone app
Posted: Tue Feb 08, 2011 2:16 am
by pmc
Hi Doc
Yes, that's right....what I meant was that I can't save the data which I have enter in the cell. Sorry, if i sound confusing.

I am surprised at this

. Rev should have incorporate this basic script into the field object instead of us having to script all this. Where do I find all basic scripts like 'saving', 'print', 'copy and paste' because I am having problem with these basic issue. I have done an app but it doesn't really work and this is frustrating.
Re: can't edit cell in stand alone app
Posted: Tue Feb 08, 2011 3:47 am
by doc
Hello again,
Rev should have incorporate this basic script into the field object instead of us having to script all this.
Scripting solutions is a mandatory effort, just by nature of what you are doing and LiveCode makes the majority of it very easy to learn and do. Be thankful that you aren't using a much lower level programming language.
Okay... as far as copy/cut/paste routines go, have a look in the dictionary for these terms:
copy Command
paste Command
cut Command
clipboard
clipboardData
Saving data to a file? Have a look at these:
ask file
URL
Finally, since you cannot save data directly to the executable program running in memory, you will have to decide one of several methods to save your data into a text file or separate stack. Here are some good resources that describe your options:
Saving data from your standalone application (Important info!):
http://livecodejournal.com/tutorials/sa ... ution.html
http://www.sonsothunder.com/devres/revo ... stk001.htm
That should get you pointed in the right direction and you are always welcomed to ask more questions around here if you need further assistance.
-Doc-
Re: can't edit cell in stand alone app
Posted: Wed Feb 09, 2011 5:55 am
by pmc
I tried Method 1, (from Sarah)it isn't working at all.....only created more individual Rev stacks. Method 4 looks good but from paragraph 2 onwards, I can't keep up with what she is describing. Should I make identical copies of the stacks or just an empty stack? Is she saying that I must have a clone of all the stacks? That means for all the stacks which is editable and savable, I need to clone these stacks?.....and put them in another folder..?
Re: can't edit cell in stand alone app
Posted: Wed Feb 09, 2011 6:57 am
by doc
Hello again pmc,
Let's slow it down just a second before going any further. (We may be making this entirely too complicated.)
If you are just dealing with tabular data and especially if you want to reuse it in a different program such as a spreadsheet like excel, then you don't need to worry with splash stacks and all of the other variations. I've attached a very simple stack that you can try out to see if it will fit your needs. Create an executable with it, enter some data and save it.
The resulting file is a plain tab delimited text file, with can be opened with a text editor or spreadsheet. Simple and easy, if that is all you need. If you need something more sophisticated, we can go from there.
-Doc-
Re: can't edit cell in stand alone app
Posted: Wed Feb 09, 2011 11:16 am
by pmc
Hi
Thanks Doc. You are very helpful.
The thing is, when I reopen the app, the data should be save in the app....something like the MS spreadsheet, you know.......you do you editing, you close it....then the program ask you whether you want to save what you have edit or have change....then you either say 'yes' or 'no'.....and if you say 'yes'...then the next time you open the app, what you have done previously is the shown on the cells, etc. A very simple procedure but difficult to get in Rev.
Re: can't edit cell in stand alone app
Posted: Wed Feb 09, 2011 1:01 pm
by BvG
it is not difficult at all. BUt you need to do code, because that's what you do in Live
Code. You do understand that necessity, right?
Code: Select all
on savestuff
put field "tabular shit" into url ("file:" & "tabular shit.tab")
end savestuff
on retrievestuff
put url ("file:" & "tabular shit.tab") into field "tabular shit"
end retrievestuff
Re: can't edit cell in stand alone app
Posted: Wed Feb 09, 2011 1:43 pm
by doc
A very simple procedure but difficult to get in Rev.
It's really not difficult at all.

You can trigger the open or save procedures in any number of different ways... in the sample attached I'm using button clicks from the user:
Opening a file:
Code: Select all
on mouseUp
answer file "Select the file" with type "TXT|txt"
put it into tFile
put url ("file:" & tFile) into fld "DataTable"
end mouseUp
Saving a file:
Code: Select all
on mouseUp
do AskToSave
end mouseUp
on AskToSave
answer "Do you wish to save the file" with "Yes" or "No"
if it is "Yes" then
do SaveTheFile
else
----do whatever else or exit
----have a look at closeStackRequest in dictionary
end if
end AskToSave
on SaveTheFile
ask file "Save file:"
if it <> "" then
put the text of fld "DataTable" into url("file:" & it)
end if
end SaveTheFile
If that doesn't do what you need, then you'll have to figure out which of the other methods you wish to implement. None of them are any more difficult that what you see here though.
Best regards,
-Doc-
Re: can't edit cell in stand alone app
Posted: Wed Feb 09, 2011 2:10 pm
by Klaus
Hi doc,
no "do" (and "else") neccessary, since you are calling a handler!
Code: Select all
on mouseUp
AskToSave
end mouseUp
on AskToSave
answer "Do you wish to save the file" with "Yes" or "No"
if it is "Yes" then
SaveTheFile
end if
end AskToSave
on SaveTheFile
ask file "Save file:"
if it <> "" then
put the text of fld "DataTable" into url("file:" & it)
end if
end SaveTheFile
@pmc
Please check these stacks, looks like you are missing some basics:
http://www.runrev.com/developers/lesson ... nferences/
Best
Klaus
Re: can't edit cell in stand alone app
Posted: Wed Feb 09, 2011 4:08 pm
by pmc
Hi BvG, Doc and Klaus,
Thank you very much. I appreciate your help and time. Actually, I like to have my app 'save the file' very much like what the RevCode's 'Save' does (When we save what we are doing in RevCode, ie. from Menu..File>Save). It just save the file....with a very quick splash screen that you can't see what's happening. I can't seems to figure out how to do this very simple task.
In line 16 onwards, it looks like it is a "Save file As.." kind of thing, similar like what the RevCode's "Save As...." does (When we choose from Menu...File>Save As..).
Also, in line 9,10 & 11, (do close Stack..).....it isn't working. When I click on the "No", it just return to the stack instead of shutting down.
Re: can't edit cell in stand alone app
Posted: Wed Feb 09, 2011 4:17 pm
by BvG
you can't force things by issuing built in messages like "closeStack". However, "close stack" should work fine. Also remember to set the unfortunately named "destroyStack" to true. Furthermore, the IDE might intercept your closing the stack. So in a standalone it might work. Finally, take a look at the "quit" command.
Re: can't edit cell in stand alone app
Posted: Thu Feb 10, 2011 12:45 pm
by pmc
Hi...disaster!
Can't figure out. I think I should create a clone stack for saving the data and then when I open the app, it actually opens the cloned stack....is this right? And when I save again, it actually rewrite to this 'clone stack'. Is this how it works?
Another thing.....how do i use a button to place an image into an image area? I use this but it isn't showing up at the image area:
on mouseUp
answer file "Select an image:" with type "Images|jpg,png,gif|"
put it into tFilename
if tFilename = empty then
exit mouseup
if tFilename=1 then
put it into image "userimage"
end if
end if
end mouseUp
Re: can't edit cell in stand alone app
Posted: Thu Feb 10, 2011 1:14 pm
by Klaus
Hi pmc,
you really should check the stacks I showed you in my earlier mail.
You are missing almost every basic you need!
Please check my comments:
pmc wrote:...
Code: Select all
on mouseUp
answer file "Select an image:" with type "Images|jpg,png,gif|"
### This will give you a FILENAME!
### You know what a filename is?
put it into tFilename
if tFilename = empty then
exit mouseup
## At this point the script is finished, so the next line will never be executed!
if tFilename=1 then
## See above, a FILENAME is never a number!
put it into image "userimage"
end if
end if
end mouseUp
Try this:
Code: Select all
on mouseUp
answer file "Select an image:" with type "Images|jpg,png,gif|"
put it into tFilename
if tFilename = empty then
## User hit CANCEL!
exit mouseup
END IF
set the FILENAME of image "userimage" to tFilename
end mouseUp
Best
Klaus
Re: can't edit cell in stand alone app
Posted: Fri Feb 11, 2011 4:23 am
by pmc
Hi Klaus
Thanks. The thing is that I can't grasp this scripting concept. It is so difficult to understand the concept. In Rev's dictionary, filename is list as 'property'. What the heck is a 'property'?

To me, a 'property' is an asset, something like a house that you brought or a car and things like that...you know. And now, I want to import an 'image' and image is an 'object'

and a 'button' is also an object......and also, 'image' can also be 'property'......how do you know which to use and how to link all this together is a total mystery and probably only reserved for rocket scientists.
'set the FILENAME of image "userimage" to tFilename'
How do you make sense out of the sentence above? In English term, it just make no sense at all. If you say something like 'put the Image (or tFilename') into "userimage''' then it make some sense. But it won't work. It's like 'Run dog eat tomato and Morning Cat'.....how do you probably make any sense out of this sentence? And why do you people use the small letter 't' or 'p' in front of the Filename (or others)? Why use capital letters like in 'acceptDrop' or maybe 'AcceptDrop'??

Sigh.....
Thanks very much, Klaus. You're a nice man.
And now I have to think about how to save the data in the standalone app

.