View Full Version : zip filename from string?
4090987414711
06-21-2007, 05:51 PM
hi! is it at all possible to save a zip file using a stored string?
An explaination:
I got an app with a dialog.input asking for a name, it stores this name as itemname
What I want is for my app to add files to a zip file, but with the name from itemname, I have tried to use ".."to combine things, but it aint going right, the code I have at the moment is:
itemname = Dialog.Input("Enter Data", "Enter Name:", "", MB_ICONQUESTION);
Label.SetText("Atitle", itemname);
FileTable = {_SourceFolder.."\\AutoPlay\\TempFolder\\text.txt" ;_SourceFolder.."\\AutoPlay\\TempFolder\\Intro.txt" ;_SourceFolder.."\\AutoPlay\\TempFolder\\ending.txt" };
Zip.Add(_SourceFolder.. "\\AutoPlay\\Docs\\Inform\\"..itemname", FileTable, false, "passworded", 0, nil, false);
this informs me that a ')' was expected at the end of the password part, what am I doing wrong?
4090987414711
06-22-2007, 08:42 AM
... or even any sort of filename from a user unput for that matter would be a big help for various other projects I have running. :D
Desrat
06-22-2007, 10:51 AM
Zip.Add(_SourceFolder.. "\\AutoPlay\\Docs\\Inform\\"..itemname", FileTable, false, "passworded", 0, nil, false);
one too many quotes, remove the one on line 4 after itenname like so
Zip.Add(_SourceFolder.. "\\AutoPlay\\Docs\\Inform\\"..itemname, FileTable, false, "passworded", 0, nil, false);
4090987414711
06-22-2007, 05:34 PM
Thank you Desrat, that worked a treat!
Now I hope someone can solve the next part...
if you run the attatched project, and load the "demo file" I need the combo box to store in the name of the report and to automatically load the completed combo box on the next run, ie, to 'save' the contents of the combo and load it next time it is run, and also, Id like to code the combo box so when someone clicks a title in the combo, id like it to extract the file that has the same name and have it displayed in the main program window!
If this sounds confusing, just dload the exported app, preview or build it and have a play round as most of the time I know what I need to say, but cant find the right words without going all round the houses lol!!
Thanks again!
4090987414711
06-23-2007, 10:25 AM
Would it be at all possible cos if not, then I will have to think of a work-around for this part.
4090987414711
06-24-2007, 05:03 PM
well I take it nobody wants to help me, well thanks people, so much for a "forum"...
RizlaUK
06-24-2007, 05:31 PM
so much for a "forum"...
lol, this is properly the best dev help forum on the net, and its hard to help someone that dosent really know what it is they want to do, also taking that attitude is not the best way to go about getting help, this post slipped by me but as im here now i'll offer my advice.
to save the contents of the combo there are several ways to go about it, ini, text, sql, xml
when your app exits make it retrieve a table from the combo and save it and load the table when the app loads
heres some sample code that saves the combo contents to a ini file
put this in page "on close" (this will save the combo contents to ini file)
cCount = ComboBox.GetCount("ComboBox1");
if cCount ~= 0 then
for i=1, cCount do
cText = ComboBox.GetItemText("ComboBox1", i);
cData = ComboBox.GetItemData("ComboBox1", i);
INIFile.SetValue(_SourceFolder.."\\AutoPlay\\Docs\\ComboContents.ini", i, "Text", cText);
INIFile.SetValue(_SourceFolder.."\\AutoPlay\\Docs\\ComboContents.ini", i, "Data", cData);
end
end
put this in page "on show" (this will load the contents of the ini file to the combo
tbTable = INIFile.GetSectionNames(_SourceFolder.."\\AutoPlay\\Docs\\ComboContents.ini");
if tbTable then
for i,k in tbTable do
stText = INIFile.GetValue(_SourceFolder.."\\AutoPlay\\Docs\\ComboContents.ini", k, "Text");
stData = INIFile.GetValue(_SourceFolder.."\\AutoPlay\\Docs\\ComboContents.ini", k, "Data");
ComboBox.AddItem("ComboBox1", stText, stData);
end
end
and heres a example apz
4090987414711
06-24-2007, 06:03 PM
thanks and sorry for my outburst, as the saying goes, Im underpaid & overworked!
Im trying to take on as much as I can to make ends meat for me, my partner & our 3 yr old daughter, I know I shouldnt take on more than I can handle, but I really do need the money, and its experience that I need so I can put it on my CV to get the job I want, I have 2 part time jobs too, I hardly sleep n I dunno what Im doin most of the time, I know these maybe excuses, but Im just trying to install a bit of understanding for my outburst.
Thanks again Rizla, as always, the code is spot on!
How easy is it to get AMS to run/open docs & apps after a click of the right file in the combo box?
Is it as simple as a file.open command?
RizlaUK
06-24-2007, 06:19 PM
hey no problem, i would have posted you some code sooner but as i say, this post slipped by me, i don't have as much time for this stuff as i used to, its mainly weekends i get stuck into the forum, in the week im just to dam tired form working 12 hours a day on a building site.
i know all about trying to make ends meet, i too have a 3yo daughter and one on the way also, i have been trying to break into the programing world so i can work from home again but the building trade seems to have a firm grasp of me and i cant see that changing for a while now.......but thats a long story
to get a file to run from the combo its as simple as 2 lines of code
put this in your combo "on select" event
FilePath = ComboBox.GetItemData("ComboBox1", e_Selection);
result = File.Run(FilePath, "", "", SW_SHOWNORMAL, false);
good luck with your project and cv, and GET SOME SLEEP, lol
4090987414711
06-24-2007, 06:21 PM
lol thanks! I think I will hit the sack soon, just gonna paste the code in, save it n thats that for another day, need to be up at 6 in the morning lol!
Take it easy! :D
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.