AutoHotkey Community

It is currently May 24th, 2012, 10:03 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: April 10th, 2007, 12:05 am 
Offline

Joined: September 2nd, 2006, 6:39 am
Posts: 279
Location: Scotland
This does as I expect
Code:
FileAppend, % File%CurrentFile%, C:\FileList.txt


This doesnt
Code:
FileAppend, `n% File%CurrentFile%, C:\FileList.txt


I get the error
Quote:
---------------------------
New AutoHotkey Script (2).ahk
---------------------------
Error at line 46.

The following variable name contains an illegal character:
" File"

The program will exit.
---------------------------
OK
---------------------------


How do I add a linefeed before the contents of the variable?

I almost feel embarrassed to have to ask this


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 12:23 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8646
Location: Salem, MA
Code:
FileAppend, % `nFile%CurrentFile%, C:\FileList.txt

?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 12:37 am 
Offline

Joined: September 2nd, 2006, 6:39 am
Posts: 279
Location: Scotland
it seems to read that as me trying to use a linefeed as part of a variable name.Although rather than 'the program will exit' i now get the 'current thread will exit'.
Quote:
Error: The following variable name contains an illegal character:
"
File1"

The current thread will exit.


It hasnt stopped me working on my script as I've just given the linefeed a FileAppend of its own but I'd still like to know how to do it on one line.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 10th, 2007, 1:52 am 
Offline

Joined: October 28th, 2005, 1:26 am
Posts: 113
Hey jps
Quote:
FileAppend, `n% File%CurrentFile%, C:\FileList.txt

My normal practice is to place the line feed at the end of the entry. The first entry always has to be on the first line anyway right? This way, the next entry will always go into the next line.

Code:
FileAppend, % File%CurrentFile% `n, C:\FileList.txt


Hope that helps

Gary


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 2:15 am 
Offline

Joined: September 2nd, 2006, 6:39 am
Posts: 279
Location: Scotland
Hmm,I had tried that already without success so to be sure it wasnt some other fault in my script causing it I tried this bit of code on its own to check

Code:
File1 = text
CurrentFile := 1
FileAppend, % File%CurrentFile% `n, C:\FileList.txt


but i get

Quote:
---------------------------
New AutoHotkey Script (3).ahk
---------------------------
Error at line 15.

The following variable name contains an illegal character:
"
"

The program will exit.


Thanks for the help guys.Maybe theres just something funky with my copy of ahk.I'll try reinstalling


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 2:18 am 
This code should work
Code:
FileAppend, % "`n" . File%CurrentFile%, C:\FileList.txt


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 3:17 am 
Offline

Joined: September 2nd, 2006, 6:39 am
Posts: 279
Location: Scotland
Ah,gotta make it a literal string if its inside of an expression.

I knew I'd feel stupid once I was told the answer.

Infact now that you've told me,I can see the line in the help file is glaringly obvious.
Sometimes I just cant see the wood for the trees.

Quote:
Consequently, literal strings must be enclosed in double quotes to distinguish them from variables


Thanks mate.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 5:39 am 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
jps wrote:
...
Quote:
Consequently, literal strings must be enclosed in double quotes to distinguish them from variables

...


Whoa, that would be ""`n""....something fishy.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 3:25 pm 
Offline

Joined: April 6th, 2007, 5:16 pm
Posts: 12
@ahklerner:

This is a double quote.
Quote:
"


And this is a single quote.
Quote:
'



And just for fun:

This is a back-tick or a back-quote.
Quote:
`



So to enclose something in double quotes, you do this:

Quote:
"Hello World"


not this:

Quote:
""Hello World""

_________________
~ Eric D. Burdo


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2007, 9:34 pm 
Offline

Joined: September 2nd, 2006, 6:39 am
Posts: 279
Location: Scotland
@ edburdo:

This is a quotation mark
Quote:
"


And this is an apostrophe
Quote:
'


And just for fun:

This is a grave accent
Quote:
`


:P Just playin with ya


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Cephei1, Google [Bot], Google Feedfetcher, toddintr and 71 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group