SkellySoul Posted June 30, 2012 Share Posted June 30, 2012 Hello I wasn't sure what a good topic name would be for this question, so please forgive me. What I am trying to do is create a GUI that will allow the user to write in "GUICtrlCreateInput"s and when they push "Save" it will save the information to a file whether it be iniwrite, filewrite or filewriteline, which ever works. This isnt the best example and my script is so messy and unstable that it isnt worth posting especially because I would have to upload all the required files for it and I am over my bandwidth cap. So the problem, I have found with this code is "whitespaces", "Array problems because of empty lines", and using "," for spacing/splitting isn't the smartest idea, if the end user wishs to use it. So basically what I am trying to do is something like this...and split the information into an array like "If StringTrimLeft($App_Split[1], 7) = "Name" Then Put data into a Text Box... Name = Notepad, Link = [url="http://www.google.com"]www.google.com[/url], Type = Free, Installed = False, Description = Description, Image = Image Name = Calculator, Link = [url="http://www.wherever.com"]www.wherever.com[/url], Type = Paid, Installed = False, Description = Description, Image = Image Name = Paint, Link = [url="http://www.fake.ca"]www.fake.ca[/url], Type = Free, Installed = False, Description = Description, Image = Image Name = Internet, Link = [url="http://www.hello.com"]www.hello.com[/url], Type = Paid, Installed = False, Description = Description, Image = Image Name = Messenger, Link = [url="http://www.I-like-Autoit.com"]www.I-like-Autoit.com[/url], Type = Free, Installed = True, Description = Description, Image = Image expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Width = 300 $Height = 200 GUICreate("Test", $Width, $Height) $Save_Name = GUICtrlCreateInput("Name", 0, 0, $Width , 20) $Save_Link = GUICtrlCreateInput("Link", 0, 25, $Width , 20) $Save_Type = GUICtrlCreateInput("Type", 0, 50, $Width , 20) $Save_Installed = GUICtrlCreateInput("Installed", 0, 75, $Width , 20) $Save_Description = GUICtrlCreateInput("Description", 0, 100, $Width , 20) $Save_Image = GUICtrlCreateInput("Image", 0, 125, $Width , 20) $Save = GUICtrlCreateButton("Save", 0, 150, $Width, 25) $Read = GUICtrlCreateButton("Read", 0, 175, $Width, 25) GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE FileClose(@ScriptDir & "\Test.txt") Exit Case $Save FileWrite(@ScriptDir & "\Test.txt", "Name = " & GUICtrlRead($Save_Name) & ", Link = " & GUICtrlRead($Save_Link) & ", Type = " & GUICtrlRead($Save_Type) & ", Installed = " & GUICtrlRead($Save_Installed) & ", Description = " & GUICtrlRead($Save_Description) & ", Image = " & GUICtrlRead($Save_Image) & @CRLF) Case $Read If FileExists(@ScriptDir & "\Test.txt") Then $App_Read = FileOpen(@ScriptDir & "\Test.txt", 0) If $App_Read = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $App_Line = FileReadLine($App_Read) If @Error = -1 Then ExitLoop Else $App_Split = StringSplit($App_Line, ",") If StringTrimLeft($App_Split[1], 7) = "Name" Then ; Name actually isn't static...but it is in this example, in the actual script it will be linked to a list box. ;(but I am only worried about actually reading everything correctly.) MsgBox(0 , "", StringTrimLeft($App_Split[1], 7)) Else MsgBox(16, "Error", @ScriptLineNumber) Exit EndIf EndIf EndSwitch WEnd Sorry, If I made no sense what so ever. I had absolutely no sleep last night and cannot wrap my head around this some what simple problem. Thank you. Link to comment Share on other sites More sharing options...
abberration Posted June 30, 2012 Share Posted June 30, 2012 (edited) If it were me, I would do it as an ini file. But the string trimming stuff is totally unnecessary. This is how I would structure the ini. I only used the first two of your programs. [Notepad] Link=http://www.google.com Type=Free Intalled=False Description=Description Image=Image [Calculator] Link=http://www.wherever.com Type=Paid Installed=False Description=Description Image=Image Edited June 30, 2012 by abberration Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
SkellySoul Posted July 1, 2012 Author Share Posted July 1, 2012 If it were me, I would do it as an ini file. But the string trimming stuff is totally unnecessary. This is how I would structure the ini. I only used the first two of your programs. [Notepad] Link=http://www.google.com Type=Free Intalled=False Description=Description Image=Image [Calculator] Link=http://www.wherever.com Type=Paid Installed=False Description=Description Image=Image Thanks very much, I didn't even think about using section names. 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