Jump to content

Recommended Posts

Posted

$log = FileOpen($destination & "Ian's Documents\_Backup.txt", 1) ' Open for Append

When I try to run my script, I get an error message: String missing closing quotes, on the above line. What am I doing wrong?

Thanks for your help,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Posted

$log = FileOpen($destination & "Ian's Documents\_Backup.txt", 1) ' Open for Append

When I try to run my script, I get an error message: String missing closing quotes, on the above line. What am I doing wrong?

Thanks for your help,

Ian

you're using the wrong comment character. VB coder? change your ' to a ;
Posted

I still suck at this part, but wouldn't you need to use two ' in the folder name? Using two of them should result in only one, at least that's how it works with other things like $$.

Posted

I still suck at this part, but wouldn't you need to use two ' in the folder name? Using two of them should result in only one, at least that's how it works with other things like $$.

it's not the folder name where the unterminated string is occuring, it's the comment after the function call. with autoit you're able to include a single quote within a literal string surrounded by double quotes (and vice versa) without needing an escape character.
Posted (edited)

it's not the folder name where the unterminated string is occuring, it's the comment after the function call. with autoit you're able to include a single quote within a literal string surrounded by double quotes (and vice versa) without needing an escape character.

Thanks cameronsdad, I passed right over that one.

Ian

The 10 points are yours.

Edited by ioliver

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Posted

Another 10 points on the board:

How about this:

$today = @YEAR & @MON & @MDAY
$now = @HOUR & ":" & @MIN & ":" & @SEC

FileWriteLine($log, $today & " " & $now)

I get an error message, stating FileWriteLine to many paramaters. Any Idea?

Thanks again,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Posted

Another 10 points on the board:

How about this:

$today = @YEAR & @MON & @MDAY
$now = @HOUR & ":" & @MIN & ":" & @SEC

FileWriteLine($log, $today & " " & $now)

I get an error message, stating FileWriteLine to many paramaters. Any Idea?

Thanks again,

Ian

is that your only filewritelilne? there's nothing wrong with that one
  • Moderators
Posted

I used to get this error a long time ago, I can't remember why... Your not using Beta are you?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

is that your only filewritelilne? there's nothing wrong with that one

There are these FileWriteLine's:

$today = @YEAR & @MON & @MDAY
$now = @HOUR & ":" & @MIN & ":" & @SEC

If FileExists($destination & "\Ian''s Documents\_Backup.txt") Then
    $log = FileOpen($destination & "Ian's Documents\_Backup.txt", 1); Open for Append
    FileWriteLine($log, "")
    FileWriteLine($log, $today & " " & $now)
    FileWriteLine($log, "Note: ")

Thanks again,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Posted

There are these FileWriteLine's:

$today = @YEAR & @MON & @MDAY
$now = @HOUR & ":" & @MIN & ":" & @SEC

If FileExists($destination & "\Ian''s Documents\_Backup.txt") Then
    $log = FileOpen($destination & "Ian's Documents\_Backup.txt", 1); Open for Append
    FileWriteLine($log, "")
    FileWriteLine($log, $today & " " & $now)
    FileWriteLine($log, "Note: ")

Thanks again,

Ian

those look good, could you include a full listing of your code? also you may want to look at _FileWriteLog() to save yourself some typing
Posted

Here's the script:

; This script will create a backup copy of the folder Ian's Documents

$source = InputBox("Source", "Drive where the Ian's Documents folder is located:")
$destination = InputBox("Destination", "Drive where the backup copy of Ian's Documents should be created:")

RunWait(@ComSpec & ' /c xcopy "' & $source & '\Ian''s Documents" "' & $destination & '\Ian''s Documents" /E /I /H /-Y')

$today = @YEAR & @MON & @MDAY
$now = @HOUR & ":" & @MIN & ":" & @SEC

If FileExists($destination & "\Ian''s Documents\_Backup.txt") Then
    $log = FileOpen($destination & "Ian's Documents\_Backup.txt", 1); Open for Append
    FileWriteLine($log, "")
    FileWriteLine($log, $today & " " & $now)
    FileWriteLine($log, "Note: ")
Else
    $log = FileOpen($destination & "Ian's Documents\_Backup.txt", 2); Open for Write
    FileWriteLine($log, "The files in this directory are a backup.")
    FileWriteLine($log, "Do not make changes to the files in this directory.")
    FileWriteLine($log, "If a file needs to be modified, the original should be modified.")
    FileWriteLine($log, ""
    FileWriteLine($log, $today & " " & $now)
    FileWriteLine($log, "Note: ")
EndIf

FileClose($log)

It's a lot of Copy & Paste, but I'll check in to _FileWriteLog(), I didn't know that existed.

Thanks,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Posted

I looked at _FileWriteLog()

_FileWriteLog( $sLogPath, $sLogMsg )

Maybe I don't understand, but how is that different from FileWriteLine() ?

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Posted

Here's the script:

; This script will create a backup copy of the folder Ian's Documents

$source = InputBox("Source", "Drive where the Ian's Documents folder is located:")
$destination = InputBox("Destination", "Drive where the backup copy of Ian's Documents should be created:")

RunWait(@ComSpec & ' /c xcopy "' & $source & '\Ian''s Documents" "' & $destination & '\Ian''s Documents" /E /I /H /-Y')

$today = @YEAR & @MON & @MDAY
$now = @HOUR & ":" & @MIN & ":" & @SEC

If FileExists($destination & "\Ian''s Documents\_Backup.txt") Then
    $log = FileOpen($destination & "Ian's Documents\_Backup.txt", 1); Open for Append
    FileWriteLine($log, "")
    FileWriteLine($log, $today & " " & $now)
    FileWriteLine($log, "Note: ")
Else
    $log = FileOpen($destination & "Ian's Documents\_Backup.txt", 2); Open for Write
    FileWriteLine($log, "The files in this directory are a backup.")
    FileWriteLine($log, "Do not make changes to the files in this directory.")
    FileWriteLine($log, "If a file needs to be modified, the original should be modified.")
    FileWriteLine($log, ""
    FileWriteLine($log, $today & " " & $now)
    FileWriteLine($log, "Note: ")
EndIf

FileClose($log)

It's a lot of Copy & Paste, but I'll check in to _FileWriteLog(), I didn't know that existed.

Thanks,

Ian

FileWriteLine may not like receiving your empty string. try changing it to " "
Posted

I looked at _FileWriteLog()

Maybe I don't understand, but how is that different from FileWriteLine() ?

few ways

1) don't need to use fileopen() or fileclose()

2) it generates it's own timestamp instead of having to put one in manually

Posted

FileWriteLine($log, "If a file needs to be modified, the original should be modified.")

FileWriteLine($log, "")

FileWriteLine($log, $today & " " & $now)

good eye, i didn't see that and didn't tidy it either...
  • Developers
Posted

good eye, i didn't see that and didn't tidy it either...

nah... AU3Check:

>Running AU3Check (1.54.1.1)  params:  from:C:\Program Files\AutoIt3\Beta
C:\Development\winutil\AutoIt3\programs\test\test.au3(21,27) : ERROR: syntax error
    FileWriteLine($log, ""
~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Development\winutil\AutoIt3\programs\test\test.au3(22,44) : ERROR: FileWriteLine() [built-in] called with wrong number of args.
    FileWriteLine($log, $today & " " & $now)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

good eye, i didn't see that and didn't tidy it either...

Thanks JdeB and cameronsdad, for the tips and explanations. That should take care of it.

Thanks again,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

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
  • Recently Browsing   0 members

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