whitts Posted November 6, 2007 Share Posted November 6, 2007 Hi i was wondering if anyone can help me. I have several gui input boxes, call them input A, input B and input C. Once these are filled in, you press the add button and these are added into memory, i wanted to be able to do this as many times as needed until you press the finsihde button, once the finish button is pressed i want all the text in memory to be written to a text file. eg. Input A; Testing Input B; Testing1 Input C; Testing2 Add Input A; somethingelse Input B; somethingelse1 Input C; somethingelse2 Add Each time add is pressed the text goes into memory. Then when i press finish all the text in memory is written to a text file.. I dont know how to do this without pre-defing the number of time the person inupt something.. Thanks Link to comment Share on other sites More sharing options...
Nahuel Posted November 6, 2007 Share Posted November 6, 2007 You want it so the prevoious text that was in Input A remains there? For example, you type "hello" in input A, press add and then type "bye" in the same input box. So, when you write to the file it will write: "Hello bye". If that's what you want, this seems to work alright. #include <GUIConstants.au3> #include <File.au3> Global $Saved[3] GUICreate("", 273, 192, 217, 152) $Input1 = GUICtrlCreateInput("Input1", 12, 14, 245, 21) $Input2 = GUICtrlCreateInput("Input2", 12, 47, 245, 21) $Input3 = GUICtrlCreateInput("Input3", 12, 80, 245, 21) $Save = GUICtrlCreateButton("Save to memory", 22, 130, 105, 45, $BS_DEFPUSHBUTTON) $Write = GUICtrlCreateButton("Write to file", 142, 130, 105, 45, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save $Saved[0]=$Saved[0] & " " &GUICtrlRead($Input1) $Saved[1]=$Saved[1] & " " &GUICtrlRead($Input2) $Saved[2]=$Saved[2] & " " &GUICtrlRead($Input3) GUICtrlSetData($Input1,"") GUICtrlSetData($Input2,"") GUICtrlSetData($Input3,"") Case $Write _FileWriteFromArray("MyFile.txt",$Saved) $Saved[0]="" $Saved[1]="" $Saved[2]="" EndSwitch WEnd Link to comment Share on other sites More sharing options...
whitts Posted November 6, 2007 Author Share Posted November 6, 2007 Something like that, i will describe what i wanted it to do. I basically anted the program to ask for the ip (inputA), share name (input and display name (input C). Then when the user hits add those go to memory. Then the user can repeat the same steps for different printer and so on until he hits finish. When finish is pressed i want all the printers in memory and their details to be written to a file. The file is formatted as follows:- ECHO.^<package^>>"yes.wsf" ECHO.>>"yes.wsf" ECHO.^<job id="vbs"^>>>"yes.wsf" ECHO.>>"yes.wsf" ECHO. ^<script language="VBScript"^>>>"yes.wsf" ECHO.set WshShell = WScript.CreateObject("WScript.Shell")>>"yes.wsf" ECHO.WScript.Sleep 3000>>"yes.wsf" ECHO.WshShell.SendKeys "Y">>"yes.wsf" ECHO.^</script^>>>"yes.wsf" ECHO.^</job^>>>"yes.wsf" ECHO.^</package^>>>"yes.wsf" ECHO.Windows Registry Editor Version 5.00>"printer.reg" ECHO.>>"printer.reg" ECHO.[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports]>>"printer.reg" ECHO."\\\\192.168.136.88(INPUT A)\\ICU (INPUT "="">"printer.reg">>"printer.reg" ECHO.[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports]>>"printer.reg" ECHO."\\\\192.168.136.89(INPUT A - ADDED AGAIN)\\ER ((INPUT b -ADDED AGAIN)"="">"printer.reg">>"printer.reg" regedit /S printer.reg net stop spooler net start spooler start wscript yes.wsf rundll32 /s printui.dll, PrintUIEntry /if /q /b "ICU" /f "c:\8220\Adduni.inf" /r "\\192.168.136.88\ICU" /m "Brother MFC-8220" w start wscript yes.wsf rundll32 /s printui.dll, PrintUIEntry /if /q /b "ER" /f "c:\8220\Adduni.inf" /r "\\192.168.136.90\ER" /m "Brother MFC-8220" w del yes.wsf del printer.reg tHANKS Link to comment Share on other sites More sharing options...
whitts Posted November 6, 2007 Author Share Posted November 6, 2007 I can now get it to go into the array but how to i get it out of the array in the format that i want? Link to comment Share on other sites More sharing options...
Nahuel Posted November 6, 2007 Share Posted November 6, 2007 It shouldn't be hard... just modify the script I gave you. I don't understand that, to be honest, so I wouldn't know where to put the values returned by the inputboxes. Link to comment Share on other sites More sharing options...
whitts Posted November 7, 2007 Author Share Posted November 7, 2007 Thanks Nahuel I think im nearly there now.... Link to comment Share on other sites More sharing options...
whitts Posted November 7, 2007 Author Share Posted November 7, 2007 #include <GUIConstants.au3> #include <File.au3> Global $Saved[3] GUICreate("", 273, 192, 217, 152) $Input1 = GUICtrlCreateInput("Input1", 12, 14, 245, 21) $Input2 = GUICtrlCreateInput("Input2", 12, 47, 245, 21) $Input3 = GUICtrlCreateInput("Input3", 12, 80, 245, 21) $Save = GUICtrlCreateButton("Save to memory", 22, 130, 105, 45, $BS_DEFPUSHBUTTON) $Write = GUICtrlCreateButton("Write to file", 142, 130, 105, 45, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save $Saved[0]=$Saved[0] & " " &GUICtrlRead($Input1) &GUICtrlRead($Input2) &GUICtrlRead($Input3) ;I want to display like this. GUICtrlSetData($Input1,"") GUICtrlSetData($Input2,"") GUICtrlSetData($Input3,"") Case $Write _FileWriteFromArray("MyFile.txt",$Saved) $Saved[0]="" $Saved[1]="" $Saved[2]="" EndSwitch WEnd But when i add the second lot of data i dont want it go on the end i want it to go to the next line. How do i make start a new line? Thanks Link to comment Share on other sites More sharing options...
Nahuel Posted November 7, 2007 Share Posted November 7, 2007 (edited) Mmm.. try this: #include <GUIConstants.au3> #include <Array.au3> #include <File.au3> Global $Saved[1];This will be an array of 2 elements, but _ArrayAdd will take care of ;making it bigger as you add data. GUICreate("", 273, 192, 217, 152) $Input1 = GUICtrlCreateInput("Input1", 12, 14, 245, 21) $Input2 = GUICtrlCreateInput("Input2", 12, 47, 245, 21) $Input3 = GUICtrlCreateInput("Input3", 12, 80, 245, 21) $Save = GUICtrlCreateButton("Save to memory", 22, 130, 105, 45, $BS_DEFPUSHBUTTON) $Write = GUICtrlCreateButton("Write to file", 142, 130, 105, 45, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save _ArrayAdd($Saved,GUICtrlRead($Input1) & "*" &GUICtrlRead($Input2)& "*" &GUICtrlRead($Input3)) GUICtrlSetData($Input1,"") GUICtrlSetData($Input2,"") GUICtrlSetData($Input3,"") Case $Write ;~ _ArrayDisplay($Saved) _FileWriteFromArray("MyFile.txt",$Saved) EndSwitch WEnd I added a * separator, so when you build your file, you can use StringSplit() and get the individual values of each line. Shouldn't be hard to do. Edited November 7, 2007 by Nahuel Link to comment Share on other sites More sharing options...
whitts Posted November 7, 2007 Author Share Posted November 7, 2007 Thankyou so much Thats exactly how i wanted it... Thanks again for your time an knowledge 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