data grid code
mfstuart at cox.net
Tue Apr 7 16:18:21 EDT 2009
I've modified your mouseUp script a little to not only save you some typing,
but also to show another way to put a text file directly into a memory
variable: gTheData. Also, the script checks if the user actually selected a
file. The result of selecting a file returns the file path and name into
"it". If the Cancel button was clicked on the File dialog, then empty is in
the variable "it".
Here it is:
--Retrieve the Excel CSV (quote and comma delimited) file
answer file "The spread sheet file name?"
if it is not empty then --if file selected
put it into theExcelFile
put URL ("file:" & theExcelFile) into gTheData --this loads the file
directly into gTheData
-- Convert the CSV data to tab delimited
put quote & comma & quote into csvPattern
replace csvPattern with tab in gTheData
replace quote with empty in gTheData
-- Leave out the column headers since they are part of the data grid
delete line 1 of gTheData
set the dgText of group "Data Grid 1" to gTheData
Sadhunathan Nadesan wrote:
> Ok! Well you probably aren't that interested but I'm making progress.
> Here is the code for a button that loads the data, so the first part of
> the construction is accomplished. Any suggestions on improvement of
> course welcome. by the way, I noticed a typo in the docs, page 40, it
> If you set the uText dgText of a data grid table then the data is
> treated as tab delimited text.
> the "uText" should be removed.
> on mouseUp
> --Retreive the Excel CSV (quote and comma delimited) file
> answer file "The spread sheet file name?"
> put it into theExcelFile
> open file theExcelFile for read
> read from file theExcelFile until EOF
> put it into gTheData
> close file theExcelFile
> -- Convert the CSV data to tab delimited
> put quote & comma & quote into csvPattern
> replace csvPattern with tab in gTheData
> replace quote with empty in gTheData
> -- Leave out the column headers since they are part of the data grid
> delete line 1 of gTheData
> set the dgText of group "Data Grid 1" to gTheData
> end mouseUp
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
View this message in context: http://www.nabble.com/data-grid-code-tp22935971p22937414.html
Sent from the Revolution - User mailing list archive at Nabble.com.
More information about the Use-livecode