Sign in to follow this  
Followers 0
pekster

Strings And Underscores

12 posts in this topic

#1 ·  Posted (edited)

I have spent close to an hour trying to figure this one out, and I am at a loss.

I have some code that wraps a huge string (that is valid AutoIt code itself) over some lines to make it eaisier to read and edit when I wish to make changes. The problem occurs on line 4, and in the resulting file that is written to, it actually prints an underscore. I do not want it to do this, but want the line to be continued. However, you'll notice I used the exact same syntax on line 1, and it does not produce an underscore in the resulting file.

One thing I did try was changing the end of line 4 to read LF('\n_ to make it conform to what I did on line 1, but I still have the same problem.

Although I know I could join the string differently to solve my issue, I would really like to use my current format so that I can make sense of this code next week, or whenever I re-visit it.

Two small notes so that you can understand this code segment:

  • LF() is simply a function that replaces any \n chars with a LineFeed char (newline)
  • $timestamp is true for my tests, so you may replace it by 1, or define it yourself
Edit: FYI, I'm using the Aug 5th build of 3.0.103.

FileWrite($out, LF('\n_
Func Debugger($n, $s) \n_
  Local $err_status = @error \n_'))
If $timestamp Then FileWrite($out, LF('_
  FileWrite($Debugger_out,"["&@HOUR&":"&@MIN&":"&@SEC&"]") \n'))
FileWrite($out, LF('_
  If StringInStr($s, "echo") Then \n_
    FileWriteLine($Debugger_out, $n & ": " & StringTrimLeft($s, 4)) \n_
  ElseIf $s <> 0 Then \n_
    FileWriteLine($Debugger_out, "Skipping next " & $s & " lines") \n_
    SetError($err_status) \n_
    return \n_
  Else \n_
    If $n = -1 Then $n = "End Of Script" \n_
    If $n = 0 Then $n = "Script Started" \n_
    If IsNumber($n) Then FileWrite($Debugger_out, "Executed ") \n_
    FileWriteLine($Debugger_out, $n) \n_
  EndIf \n_
  SetError($err_status) \n_
EndFunc \n'))
Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Have you tried this:

LF(' _

or

LF('\n _

note the space...

also, does it do it on line 6?

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

Have you tried this:

LF(' _

note the space...

<{POST_SNAPBACK}>

Yup. Still no dice. In addition, the space appears after the underscore (so the first character on the line is the underscore, and the 2nd is the space.) I think that's pretty wierd.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I changed the post... this forum is becoming like IM///

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

I changed the post... this forum is becoming like IM///

<{POST_SNAPBACK}>

Yea, I tried that too, and it still failed. I got an underscore on a line all by itself, and the next line started with a space. Again, very wierd.

I suppose I should have posted all of what I tried before, but oh well.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

EDIT: I FOUND THE ERROR:

Local $err_status = @error \n_'))

remove the _ in this line since there is no line break.

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

EDIT: I FOUND THE ERROR:

remove the _ in this line since there is no line break.

<{POST_SNAPBACK}>

Heh, it's always the stupid mistakes. Thanks. And there I was trying to play with the underscore position, extra newlines, CRLF instead of LF chars... bah!

Thanks again.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

No problem, all I ask is that you send me your code as-is an let me be a beta tester.


Who else would I be?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

No problem, all I ask is that you send me your code as-is an let me be a beta tester.

<{POST_SNAPBACK}>

I have no clue if this even works or not, but feel free to play with it. I should have a fully working pre 2.0 release (IE: a tested and working 1.9 release) by tomorrow afternoon. We'll see how close my estimate is. Feel free to play with what I have now. But do realise that I'm still changing stuff around, so you may get bad output, buttons that don't work, or an option that fails compleatly. Download the upload that I made here (version 1.9 is released, so use that or any higher release since then.) Also know that I probably won't update it, so in about 10 mins you'll be looking at an obsolete working release. Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

where is lf.au3?


Who else would I be?

Share this post


Link to post
Share on other sites

where is lf.au3?

<{POST_SNAPBACK}>

Heh, just my funciton I talked about above that turns \n chars into newlines. I don't paste the code in until my final release. Either define it manually, or put that in your #include path :ph34r:. If you'd like, replace that line with:

Func LF($s)
  return StringReplace($s, "\n", @LF)
EndFunc

It's just eaisier for me when I design to use crap that's already in my library of code and either include it with my final release, or paste it in when I'm finished. If I need to add or remove functions, it's eaisier to remove the #include line than to hunt to find the chunk of code that I wish to add/remove/change.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Thx. I figured that was all it did.


Who else would I be?

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  
Followers 0