Jump to content
Sign in to follow this  
ioliver

String Missing Closing Quotes

Recommended Posts

ioliver

$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

Share this post


Link to post
Share on other sites
seandisanti

$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 ;

Share this post


Link to post
Share on other sites
inthewayboy

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 $$.

Share this post


Link to post
Share on other sites
seandisanti

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.

Share this post


Link to post
Share on other sites
ioliver

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

Share this post


Link to post
Share on other sites
seandisanti

Thanks cameronsdad, I passed right over that one.

Ian

The 10 points are yours.

no problem, glad to help. 10 points eh? woohoo! :)

Share this post


Link to post
Share on other sites
ioliver

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

Share this post


Link to post
Share on other sites
seandisanti

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

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
Share on other sites
seandisanti

I can't remember why...

bad code? :) oh yeah sorry if my girl was bothering you yesterday smoke, she said she aim'd you from my laptop

Share this post


Link to post
Share on other sites
ioliver

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

Share this post


Link to post
Share on other sites
seandisanti

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

Share this post


Link to post
Share on other sites
ioliver

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

Share this post


Link to post
Share on other sites
ioliver

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

Share this post


Link to post
Share on other sites
seandisanti

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 " "

Share this post


Link to post
Share on other sites
Jos

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

FileWriteLine($log, "")

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


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

Share this post


Link to post
Share on other sites
seandisanti

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

Share this post


Link to post
Share on other sites
seandisanti

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...

Share this post


Link to post
Share on other sites
Jos

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
ioliver

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

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  

×