Jump to content

I'm Learning :) Can This Be Done ?


Recommended Posts

I have this code I found in the readme .

$file = FileOpen("willthiswork.doc", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWriteLine($file, "Line1")
FileWriteLine($file, "Line2" & @CRLF)
FileWriteLine($file, "Line3")
FileClose($file)

So it will make a doc for me but how would you make it everytime you say click a button the make the doc it adds a new number on the end of it ?

So it would be willthiswork1.doc ,willthiswork2.doc etc ..

And I guess it would need to keep some info in the reg so if you restart it and would start from the last number .

Link to comment
Share on other sites

You would need to set the filename using a loop something like this:

$x = 1
While 1
$file = "C:\path\willthiswork" & $x & ".doc"
if fileexists("C:\path\willthiswork" & $x & ".doc") then
$x = $x + 1
continueloop
else
exitloop
wend
rest of script using $file where appropriate

This assumes that all the *.docs are in the same folder.

[u][font="Arial"]Pete[/font][/u]
Link to comment
Share on other sites

You would need to set the filename using a loop something like this:

$x = 1
While 1
$file = "C:\path\willthiswork" & $x & ".doc"
if fileexists("C:\path\willthiswork" & $x & ".doc") then
$x = $x + 1
continueloop
else
exitloop
wend
rest of script using $file where appropriate

This assumes that all the *.docs are in the same folder.

I was trying to think of how to tell him how to do that... thanks!

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

emmanuel... Best. Avatar. Ever.

thanks Valik, and funny enough, it's a play on words... 'cause looking at the helpfile does nothing for you (unless you're conducting some sort of survey of uses of the question mark in modern society, or maybe have a thing for slightly suggestivly shapped yellow things) it's looking in the helpfile, or reading and comprehending the helpfile that's really needed. (and that can be tough, I know.)

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Well anything was better than the previous one !!!  :huh2:  :)

:D you're welcome, very glad to remove the pain of my visage. :):lol: Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...