I'm horrible with tables, so here goes nothing....
I need to popultae a tree object at runtime with the section names [my section] in an ini file. I'm stumped on this one.....
Mike
Professional Software Development Tools
I'm horrible with tables, so here goes nothing....
I need to popultae a tree object at runtime with the section names [my section] in an ini file. I'm stumped on this one.....
Mike
You can try this and adjust it to your needs. What I am doing is obtaining a list of the value names (which builds a table) and then for each item in the returned table you build the tblNodeData (another table) that will create your node on the tree, then insert that object into the tree. This only builds one level and if you want more than one level you would have to adjust it accordingly.
Code:tbvnames = INIFile.GetValueNames(sFilename, "my section"); if tbvnames then for i,v in tbvnames do -- Initialize node data table tblNodeData = {}; tblNodeData.Text = INIFile.GetValue(sFilename, "my section", v); tblNodeData.Data = ""; tblNodeData.Expanded = true; tblNodeData.NodeIndex = i..""; --tblNodeData.ImageIndex = 1; --tblNodeData.SelectedImageIndex = 2; -- Insert the node Tree.InsertNode("Tree1", i.."",tblNodeData); end end
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
Thanks tigg ..... what am I doing wrong?
Told you I suck at tables!Code:SAVED_CARDS = INIFile.GetSectionNames(_ProgramFilesFolder.."\\CCkeeper\\SAVED\\cards.ini"); tbvnames = INIFile.GetValueNames(sFilename, SAVED_CARDS); if tbvnames then for i,v in tbvnames do -- Initialize node data table tblNodeData = {}; tblNodeData.Text = INIFile.GetValue(sFilename, SAVED_CARDS, v); tblNodeData.Data = ""; tblNodeData.Expanded = true; tblNodeData.NodeIndex = i..""; --tblNodeData.ImageIndex = 1; --tblNodeData.SelectedImageIndex = 2; -- Insert the node Tree.InsertNode("Tree1", i.."",tblNodeData); end end
from what it looks like is you are trying to use a table where a string should go. If you want to step through a table you need to use a for loop. Does your ini file have multiple sections and then within each section there are multiple entries? You then need to figure out how you want it to then populate into the tree. Here is another example that might work.
Code:sFilename = "AutoPlay\\Docs\\test.ini" SAVED_CARDS = INIFile.GetSectionNames(sFilename); if SAVED_CARDS then --verifies that the table is good --clear the tree contents Tree.RemoveNode("Tree1", "0"); for ii,vv in SAVED_CARDS do --steps through each entry -- Initialize node data table tblNodeData = {}; tblNodeData.Text = vv; tblNodeData.Data = vv; tblNodeData.Expanded = true; tblNodeData.NodeIndex = ii..""; --tblNodeData.ImageIndex = 1; --tblNodeData.SelectedImageIndex = 2; -- Insert the node Tree.InsertNode("Tree1", ii.."",tblNodeData); tbvnames = INIFile.GetValueNames(sFilename, vv); --vv will be replaced by each entry everytime it steps through if tbvnames then --verifies that the table is good --starting here we will add all the entries below the section name for i,v in tbvnames do -- Initialize node data table tblNodeData = {}; tblNodeData.Text = INIFile.GetValue(sFilename, vv, v); tblNodeData.Data = v; tblNodeData.Expanded = true; --this sets the node number to be under the ii value assigned above tblNodeData.NodeIndex = ii.."."..i; --tblNodeData.ImageIndex = 1; --tblNodeData.SelectedImageIndex = 2; -- Insert the node Tree.InsertNode("Tree1", ii.."."..i,tblNodeData); end end end end
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
ok, I'll try it. Maybe I need to change my approach? Maybe an sql database? What I'm trying to do is store multiple sections, with several values under it. The sections are populted in the tree, when the node is selected, it should display all the values in the section - via paragraph, input, etc..
ok, tried it .... good coding tigg! Where can I find good beginner info RE: tables?
It's half the battle, it displays the section, and all the values under it.... hmm, I think I'll give the database a try. I need to be able to pull the values & use them.
I started with the ini because I could put all the data in one file & encrypt it, but I can do that with a database too, right?
hmmmm........
but I can do that with a database too, right?
yup, i would head over to tiggs site and view his video tuts if i were you, the first set of tuts focus on a small encrypted database app, thats what got me started with the sqlite plugin/encrypted database,
theres even a sample project( Again, Good Work Tigg
)
Open your eyes to Narcissism, Don't let her destroy your life!!
I started on TiggTV 11 which deals with tables but I have not had a chance to record the show.
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
GRRAAAATE! Tigg.... I've always had so many questions about tables, looking forward to episode 11.
Rizula, I've watched episode 1, now I just need to watch it about 12 more times & I might get it! LOL
thanks for all the help guys
ok - another table question.
I'm using the dialog file browse, which returns the selected file name in a table, right? How do I get the filename/path out of the tabel?
Code:OPEN = Dialog.FileBrowse(true, "Locate File", _ProgramFilesFolder.."\\COMMS\\MESSAGES\\RECIEVED\\", "All Files (*.enc)|*.enc|", "", "enc", false, true);
code to browse for file and split the path into parts and output them to paragraph object
Code:--Get File Location And Store In Table "tbOpen" tbOpen = Dialog.FileBrowse(true, "Locate File", _ProgramFilesFolder.."\\COMMS\\MESSAGES\\RECIEVED\\", "All Files (*.enc)|*.enc|", "", "enc", false, true); --We Should Only Have One Entry In The Table AS Mutilple Choice Was Disabled --Take The First Item In tbOpen and Split The Path Into Its Relative Parts And Store In A New Table "tbSplit" tbSplit = String.SplitPath(tbOpen[1]); --Here Are All The Variables In The tbSplit Table Stored In Variables --Drive sDrive = tbSplit.Drive; --Folder sFolder = tbSplit.Folder; --FileName (no extension) sFilename = tbSplit.Filename; --Extension sExtension = tbSplit.Extension; --Output The Variables In Mutiple Lines In A Paragraph Object Paragraph.SetText("Paragraph1", "Drive = " .. sDrive .. "\nFolder = " .. sFolder .. "\nFileName = " .. sFilename .. "\nExtension = " .. sExtension);
thanks desrat, good code, it works, only I'm trying to open the selected file. The file will be encrypted, i.e. somehting.enc ..... when the user selects it, it will decrypt & then display the contents of the file.