data grid code
Josep
jmyepes at mac.com
Thu Apr 9 03:47:34 EDT 2009
Thanks for the piece of code... very nice :)
Salut,
Josep
mfstuart wrote:
>
> Hi Sadhu,
>
> 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:
>
> on mouseUp
> --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
> end if
> end mouseUp
>
> HTH U,
> Mark Stuart
>
>
> 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
>> says
>>
>> 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:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>>
>
>
--
View this message in context: http://www.nabble.com/data-grid-code-tp22935971p22966042.html
Sent from the Revolution - User mailing list archive at Nabble.com.
More information about the use-livecode
mailing list