DataGrid getting data from user input

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ecflyer
Posts: 24
Joined: Tue Oct 20, 2009 12:04 am

DataGrid getting data from user input

Post by ecflyer » Sun Nov 29, 2009 6:15 am

I have a main stack with a data grid table. The data that will populate the table needs to come from a substack with fields that a user will fill in and then hit a save button. I've read everything I could about DG's, but only found information on populating with either the contents of the PI or by putting the data itself in the script of the DG. Is there a way to use an on MouseUp handler to tell the program where to put the data?

i.e.
on mouseUp
put fld "date" into tDate
put tDate into --the next available row in the date column of the dg group on the mainstack--
put empty into fld "date"
end mouseUp

Do I even need the variable? Once the data is entered into the DG, the substack the user will use to enter data will be cleared and ready for the next set of data.
?
E

chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Re: DataGrid getting data from user input

Post by chris9610 » Mon Nov 30, 2009 4:44 am

Look at the AddLine in the Revolution_Data_Grid.pdf documentation pg 169. I believe this is what you are looking for.
Developing with Windows XP & Revolution 4.5

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: DataGrid getting data from user input

Post by trevordevore » Tue Dec 01, 2009 3:52 pm

Here is the lesson from the manual that shows how:

How Do I Add A Row Of Data To An Existing Data Grid?
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

ecflyer
Posts: 24
Joined: Tue Oct 20, 2009 12:04 am

Re: DataGrid getting data from user input

Post by ecflyer » Wed Dec 02, 2009 6:15 am

Thanks,

I read the dg lesson from Bluemango. I am currently using the 30 day trial of revStudio and the program will not allow me to declare any variables. This seems to be a big part of the problem with using the dg commands.
I type this into a button script:
on mouseUp
put "1" into tEricVariable
put tEricVariable into fld "field"
end mouseUp
and get the error message:
button "Button": compilation error at line 2 (Chunk: can't create a variable with that name (explicitVariables?)) near "tEricVariable", char 12
I can get it to work just fine in revMedia.
Is there something I did to cause the variables to be treated this way in Studio? Do I have a bad install? Is the problem because I have the free 30 day trial version (I don't think so because it works in the 30 day trial for Enterprise).
I'll be re-installing studio tomorrow when I have time, but any input would be great. Still trying to learn and not being able to get the script to work like in the examples is frustrating.

Thanks for the past posts,
E

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: DataGrid getting data from user input

Post by SparkOut » Wed Dec 02, 2009 10:22 am

Hi Eric,

The trial is fully functional, whatever version, it seems that your problem is that you have "Strict Compilation Mode" enabled in the preferences, rather than any bad installation issue. If you use the Edit menu and choose Preferences, then pick the "Script Editor" option, you can remove the tick from the "Strict Compilation Mode" box.
Then your script will compile.
Alternatively (as my personal feeling is that the Strict Compilation Mode helps quite a bit in development and especially while learning) you can leave it enabled but get used to explicitly declaring a variable at the appropriate place.
For a global variable (which is literally globally accessible to *any* open stack) you would use

Code: Select all

global gMyGlobalVarName
at the top of any script page that needs to access it, outside any handler.
Similarly for "Script Local" variables, which you can access from any handler on that page of script you can declare at the top of the page, outside any handler

Code: Select all

local sMyScriptLocalVarName
For local variables which are only accessible to the individual handler itself, and destroyed after the handler exits (ie doesn't keep unnecessary data in memory) then use the variable declaration inside the handler concerned, ie in your case

Code: Select all

on mouseUp
   local tEricVariable
   put "1" into tEricVariable
   put tEricVariable into fld "field"
end mouseUp
RunRev does a vary good job of interpreting the values passed to any function or handler without typing, so putting the literal string "1" into the variable is not generally necessary. There are some caveats and options regarding formatting of numbers for display, but mostly you should find that it is convenient to leave a numeric value as numeric.

HTH
SparkOut

ecflyer
Posts: 24
Joined: Tue Oct 20, 2009 12:04 am

Re: DataGrid getting data from user input

Post by ecflyer » Wed Dec 02, 2009 3:29 pm

Wow,

Thanks SparkOut.

That's exactly the answer I needed. I meant to ask a question about declaring variables, too, thanks for adding that. I have read a lot, but I'm sure from my questions it's obvious I'm just learning.

E

Post Reply