strate Posted October 27, 2004 Share Posted October 27, 2004 Has anybody found a way to create a menu from a notepad list or any list for that matter? INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station... Link to comment Share on other sites More sharing options...
strate Posted October 27, 2004 Author Share Posted October 27, 2004 Yea, I'm sorry......In a previous thread of mine I requested help with .INI files. Through the help received I finished that task and now want to create it so the user can remove a line of text. Sample of file[Path 1]key=Zebra 140XI III on LPT2[Path 2]key=Zebra 140XI II on LPT1[Path 3]key=Zebra 170XI III on LPT3[Path 4]key=Zebra 170XI III on LPT4IniDelete will delete the need path for me but the user needs to know what the path is either 1,2,3, or 4. The list is ever expanding (or decreasing) so hard code wouldn't work well. This is the code$File = "G:\Projects\AutoIt V3\Prod. Recording\printers.ini"$CP = 0$C = 0 $RL = 1While 1 $line = FileReadLine($file,$RL) msgbox(1,"",$Line) $RL = $RL + 1 If $Line = "" Then ExitloopWend$NumofPaths = InputBox("Label Creation","How many paths would you like to create:")Do $C = $C + 1 $PrinterPath = InputBox("Label Creations","Please input printer path you would like to eliminate:") ;;;;;;;;;; Need to know Path (section) number;;;;;;;;; IniDelete($file, $path,"key")Until $C = $NumofPathsI would like the menu to display with/inside the input box.A solution like this:$Path = InputBox("Label Creation"," Please choose from the following:"&@CR & @CR&"1. Zebra 140XI III on LPT2" & @CR&"2. Zebra 140XI II on LPT1"& @CR&"3. Zebra 170XI III on LPT3"& @CR&"4. Zebra 170XI III on LPT4"&@CR&@CR&"Enter Printer Path:","","",-1,260,-1,-1)wouldn't be feasible. INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station... Link to comment Share on other sites More sharing options...
scriptkitty Posted October 27, 2004 Share Posted October 27, 2004 You can hard code it in, but just do it with a loop.[Path 1]key=Zebra 140XI III on LPT2[Path 2]key=Zebra 140XI II on LPT1[Path 3]key=Zebra 170XI III on LPT3[Path 4]key=Zebra 170XI III on LPT4This would grab all the keys, if you had missing ones in between, you could make a better test.Dim $var[101] $printertext=@crlf for $i=1 to 100; you could do 1000 if you like, or read the amount of lines in the file. $var[$i] = IniRead("C:\Temp\myfile.ini", "Path "& $i, "key", "NotFound") if $var[$i]="NotFound" then continueloop $count=$i-1 $printertext=$printertext&$i&" - "& $var[$i]& @crlf next $PrinterPath = InputBox("Label Creations","Please input printer path you would like to eliminate:"& $printertext) IniDelete("C:\Temp\myfile.ini", "Path "& $PrinterPath,"key")Just an adaption of your code and help file.If you were only going to use this for printer lines, you could do the count, but try this out for removal. Think of diferent aproaches, one may really come in handy some day. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
scriptkitty Posted October 27, 2004 Share Posted October 27, 2004 (edited) Oh, talking about InI files, I would have organised it more like this:[PrinterPath]path1=Zebra 140XI III on LPT2path2=Zebra 140XI II on LPT1path3=Zebra 170XI III on LPT3path4=Zebra 170XI III on LPT4Sample code:$x="Zebra 140XI III on LPT2|Zebra 140XI II on LPT1|Zebra 170XI III on LPT3|Zebra 170XI III on LPT4" $xarray=Stringsplit($x,"|") for $i = 1 to $xarray[0] IniWrite("C:\Temp\myfile.ini", "PrinterPath", "Path"& $i, $xarray[$i]) nextIni files can be great tools, with easy to read files in notepad or any other editor, but organising them helps a lot.Ex file:[PrinterPath]path1=Zebra 140XI III on LPT2path2=Zebra 140XI II on LPT1path3=Zebra 170XI III on LPT3path4=Zebra 170XI III on LPT4[users]user1=bobuser2=freduser3=strateand changed code to show one way of retrival and elimination.$var="" $printertext=@crlf for $i=1 to 100; you could do 1000 if you like, or read the amount of lines in the file. $var= IniRead("C:\Temp\myfile.ini", "PrinterPath", "path"& $i, "NotFound") if $var="NotFound" then continueloop $count=$i-1 $printertext=$printertext&$i&" - "& $var& @crlf next $PrinterPath = InputBox("Label Creations","Please input printer path you would like to eliminate:"& $printertext) IniDelete("C:\Temp\myfile.ini","PrinterPath", "Path"& $PrinterPath) Edited October 27, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
condoman Posted October 27, 2004 Share Posted October 27, 2004 This is what I use for a menu system to reach my various hot files.http://www.autoitscript.com/fileman/users/public/Condoman/LicenseLinkNG.jpgThe code is here: http://www.autoitscript.com/fileman/users/public/Condoman/LicenseLinkNG.au3And yes I know some menu items are mispelled Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now