Can get the DataGrid to work fine in the programming environment, but once compiled nada.. What gives?
Basically I'm reading a CSV file, creating the column headers, closing, then reading the CSV data into the DataGrid (cleanest way I've gotten to work so far).
This is the third DataGrid program that I've worked on that seems to be ending in frustration.
I'm using 4.5.2, I refuse to spend anymore money on LiveCode until I can get SOMETHING to work.
Code: Select all
on ReadDataFile
put "Please Wait ..." into Field "txtTeacherName"
put empty into field "text"
put empty into field "NumberOfStaff"
put empty into field "myCurrentPath"
set the dgText of grp "gdStaffData" to empty
set the dgColumns of grp "gdStaffData" to empty
set the dgProp["columns"] of group "gdStaffData" to empty
set the itemDelimiter to "/"
put the volumes into macdrives
put line 1 of macdrives into mydrive
put the effective filename of this stack into theFolder ## Finds the datapath
put item 1 to -2 of theFolder into theFolder # Strip off filename
if the platform is "MacOS" and theFolder contains ".app/Contents/MacOS" then
delete item -3 to -1 of theFolder
end if
if FileNotFound is "0" then
put theFolder&"/"&"StaffData.csv" into tFileName ## Reads the CSV file into tFileContents ## Add the file name
put tFileName into fld "myCurrentPath"
end if
put URL ("file:" & tFileName) into tFileContents
close file tFileName
Put tFileContents into field "text"
put line 1 of tFileContents into tColumnTitles ## Creates Columns from the contents of the CSV's first line
replace comma with return in tColumnTitles
set the dgProp["columns"] of group "gdStaffData" to tColumnTitles
set the dgData of group "gdStaffData" to theDataA
open file tFileName for read ## Populate the DataGrid using the CSV file
put 0 into NumberofTeacher
read from file tFileName until return ## Get the first line
put "No" into myExit
repeat
read from file tFileName until return
if the result is "eof" then
put "Yes" into myExit
End if
add 1 to NumberofTeachers ## Breaks each line down in to 5 different lines when
replace return with empty in it ## are inserted into a column of the DataGrid
replace comma with return in it
put line 1 of it into theDataA[NumberofTeachers]["LastName"]
put line 2 of it into theDataA[NumberofTeachers]["FirstName"]
put line 3 of it into theDataA[NumberofTeachers]["RoomNumber"]
put line 4 of it into theDataA[NumberofTeachers]["JobTitle"]
put line 5 of it into theDataA[NumberofTeachers]["SectionCode"]
if myExit ="Yes" then exit repeat
end repeat
set the dgData of group "gdStaffData" to theDataA ## Commits the DataGrid
put NumberofTeachers into field "NumberOfStaff"
close file tFilename
put "Completed ..." into Field txtTeacherName
end ReadDataFile