Jump to content
Sign in to follow this  
bobheart

I'm Learning :) Can This Be Done ?

Recommended Posts

bobheart

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 .

Share this post


Link to post
Share on other sites
herworth

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]

Share this post


Link to post
Share on other sites
emmanuel

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)

Share this post


Link to post
Share on other sites
Valik

emmanuel... Best. Avatar. Ever.

Share this post


Link to post
Share on other sites
bobheart

Well sure looks good .. now I have figure out where to put it all . lol

Share this post


Link to post
Share on other sites
emmanuel

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)

Share this post


Link to post
Share on other sites
Valik

Looking at the help file is the first step to looking in the help file, though.

Share this post


Link to post
Share on other sites
emmanuel

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)

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.