alien13 Posted September 14, 2007 Share Posted September 14, 2007 Hi, I'll try explain this best as possible. I have a program that has many input boxes and the user, when filled in the fields needed, can save it all to a text file. How would I go about getting it to only write to the text file, the input boxes that are filled in? FileWrite($NFO & ".nfo", _ " File Name....................: " & GUICtrlRead($FNInput) & @CRLF & _ " File Size....................: " & GUICtrlRead($FSInput) & @CRLF That is part of what it writes. So it has the 2 input boxes (FS and FN), but say if the user only put in the information for File Name, but not the File Size, how would I get the script to filewrite only the section: " File Name....................: " & GUICtrlRead($FNInput) & @CRLF & _ Let me know if this is too confusing. Thanks, alien13 Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 14, 2007 Share Posted September 14, 2007 Something like this: If GuiCtrlRead($FNInput) <> "" Then FileWriteLine($NFO & ".nfo", "File..." & GuiCtrlRead($FNInput)) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
alien13 Posted September 14, 2007 Author Share Posted September 14, 2007 (edited) Something like this: If GuiCtrlRead($FNInput) <> "" Then FileWriteLine($NFO & ".nfo", "File..." & GuiCtrlRead($FNInput)) Hey, Thanks for your reply. How would I go about doing this for 22 of these input boxes? I'm not sure about how I would go with doing it... Would I just repeat the statement for each field? Would it be easier for me to just add a selection screen with checkboxes and labels and let the user select the required fields and then have it read from there? Thanks for your help. Here is the whole script BTW for anyone to have a look at. alien13NFOMaker_source.au3 Edited September 14, 2007 by alien13 Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 14, 2007 Share Posted September 14, 2007 Thanks for your reply. How would I go about doing this for 22 of these input boxes? I'm not sure about how I would go with doing it... Would I just repeat the statement for each field? I would assemble an array of the controls to check and just loop through it. If you need to know what kind of value goes with each, then you could make it a 2D array like $avControls[22][2], where $avControls[n][0] = Control ID, and [n][1] = label i.e. "File name". If you are not comfortable with multi-dim arrays, then use two 1D arrays, like $avControls[22] and $avLabels[22] and reference them both with the same For/Next loop variable: For $n = 0 To Ubound($avControls) - 1 If GuiCtrlRead($avControls[$n]) <> "" Then FileWriteLine($NFO & ".nfo", $avLabels[$n] & "... " & GuiCtrlRead($avControls[$n])) Next Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
alien13 Posted September 14, 2007 Author Share Posted September 14, 2007 I would assemble an array of the controls to check and just loop through it. If you need to know what kind of value goes with each, then you could make it a 2D array like $avControls[22][2], where $avControls[n][0] = Control ID, and [n][1] = label i.e. "File name". If you are not comfortable with multi-dim arrays, then use two 1D arrays, like $avControls[22] and $avLabels[22] and reference them both with the same For/Next loop variable: For $n = 0 To Ubound($avControls) - 1 If GuiCtrlRead($avControls[$n]) <> "" Then FileWriteLine($NFO & ".nfo", $avLabels[$n] & "... " & GuiCtrlRead($avControls[$n])) Next Thanks for the reply. It's kind of confusing at first, but I'm going to look into that as I sort of understand what you mean. Thanks for the help, alien13 Link to comment Share on other sites More sharing options...
weaponx Posted September 14, 2007 Share Posted September 14, 2007 Heres a quick and dirty way of doing it without resorting to multi-dimensional arrays: NFOMaker_source2.au3 Also I changed it so when you chose a file or folder the file size would update automagically. Link to comment Share on other sites More sharing options...
alien13 Posted September 14, 2007 Author Share Posted September 14, 2007 Heres a quick and dirty way of doing it without resorting to multi-dimensional arrays: NFOMaker_source2.au3 Also I changed it so when you chose a file or folder the file size would update automagically. Cool, thanks for those. They worked excellently Thanks for both of your help, alien13 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