Jump to content
Sign in to follow this  
alien13

Writing question

Recommended Posts

alien13

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


Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
alien13

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.

alien13

NFOMaker_source.au3

Edited by alien13

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
alien13

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


Share this post


Link to post
Share on other sites
weaponx

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.

Share this post


Link to post
Share on other sites
alien13

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


Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.