can't edit cell in stand alone app

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

pmc
Posts: 62
Joined: Thu Sep 23, 2010 3:14 am

can't edit cell in stand alone app

Post by pmc » Sun Feb 06, 2011 4:31 pm

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.
Attachments
Table field.GIF
Table field.GIF (67.63 KiB) Viewed 10511 times

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: can't edit cell in stand alone app

Post by doc » Mon Feb 07, 2011 2:18 pm

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-
Attachments
table_properties.jpg
table_properties.jpg (37.37 KiB) Viewed 10497 times

pmc
Posts: 62
Joined: Thu Sep 23, 2010 3:14 am

Re: can't edit cell in stand alone app

Post by pmc » Tue Feb 08, 2011 2:16 am

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. :oops: I am surprised at this :evil:. 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.

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: can't edit cell in stand alone app

Post by doc » Tue Feb 08, 2011 3:47 am

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-

pmc
Posts: 62
Joined: Thu Sep 23, 2010 3:14 am

Re: can't edit cell in stand alone app

Post by pmc » Wed Feb 09, 2011 5:55 am

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..?

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: can't edit cell in stand alone app

Post by doc » Wed Feb 09, 2011 6:57 am

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-
Attachments
SampleStack.zip
(1.7 KiB) Downloaded 288 times

pmc
Posts: 62
Joined: Thu Sep 23, 2010 3:14 am

Re: can't edit cell in stand alone app

Post by pmc » Wed Feb 09, 2011 11:16 am

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.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: can't edit cell in stand alone app

Post by BvG » Wed Feb 09, 2011 1:01 pm

it is not difficult at all. BUt you need to do code, because that's what you do in LiveCode. 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
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: can't edit cell in stand alone app

Post by doc » Wed Feb 09, 2011 1:43 pm

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-
Attachments
SampleSaveStack.zip
(1.98 KiB) Downloaded 294 times

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: can't edit cell in stand alone app

Post by Klaus » Wed Feb 09, 2011 2:10 pm

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

pmc
Posts: 62
Joined: Thu Sep 23, 2010 3:14 am

Re: can't edit cell in stand alone app

Post by pmc » Wed Feb 09, 2011 4:08 pm

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.
Attachments
Capture.GIF
Capture.GIF (37.48 KiB) Viewed 10428 times

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: can't edit cell in stand alone app

Post by BvG » Wed Feb 09, 2011 4:17 pm

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.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

pmc
Posts: 62
Joined: Thu Sep 23, 2010 3:14 am

Re: can't edit cell in stand alone app

Post by pmc » Thu Feb 10, 2011 12:45 pm

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

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: can't edit cell in stand alone app

Post by Klaus » Thu Feb 10, 2011 1:14 pm

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

pmc
Posts: 62
Joined: Thu Sep 23, 2010 3:14 am

Re: can't edit cell in stand alone app

Post by pmc » Fri Feb 11, 2011 4:23 am

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 :roll: .

Post Reply