#578 closed Bug (No Bug)
#570 CLOSED? AutoIt problems handling filenames with two or more consecutive dollar signs
Reported by: | S-O | Owned by: | |
---|---|---|---|
Milestone: | Component: | AutoIt | |
Version: | Other | Severity: | None |
Keywords: | Cc: |
Description
#570 CLOSED? AutoIt problems handling filenames with two or more consecutive dollar signs
I didn't want to make "false assumptions" about AutoIt. I am sorry if i offended some person. Please explain more specific what is wrong in my report. This is not the way to communicate between civilised persons. If I am wrong I will fully accept that. Have you run the script? And again - I'm sorry if I was writing clumsy and offending! I didn't want it to be this way!
REGARDS
S-O
Attachments (1)
Change History (6)
Changed 16 years ago by S-O
comment:1 Changed 16 years ago by TicketCleanup
- Version 3.2.12.0 deleted
comment:2 follow-up: ↓ 3 Changed 16 years ago by Valik
- Resolution set to No Bug
- Status changed from new to closed
- Type changed from Feature Request to Bug
- Version set to Other
Straight from the documentation for "ExpandVarStrings":
when in this mode and you want to use a literal $ or @ then double it up: "This is a single dollar $$ sign".
It has absolutely nothing to do with file names. It has everything to do with the feature you chose to turn on working working exactly as it was designed and documented. The behavior you describe is not a bug.
As for the false assumptions, all your comments on "compile-time" versus "run-time" are a load of ignorant conjecture. AutoIt is not a true compiled language. Very little is done at compile-time because AutoIt does not have an optimizing compiler. The only things that are done at compile-time are things that can't be done at run-time.
Changing this to a bug and closing it, again.
comment:3 in reply to: ↑ 2 Changed 16 years ago by anonymous
Replying to Valik:
Straight from the documentation for "ExpandVarStrings":
when in this mode and you want to use a literal $ or @ then double it up: "This is a single dollar $$ sign".
It has absolutely nothing to do with file names. It has everything to do with the feature you chose to turn on working working exactly as it was designed and documented. The behavior you describe is not a bug.
As for the false assumptions, all your comments on "compile-time" versus "run-time" are a load of ignorant conjecture. AutoIt is not a true compiled language. Very little is done at compile-time because AutoIt does not have an optimizing compiler. The only things that are done at compile-time are things that can't be done at run-time.
Changing this to a bug and closing it, again.
It is unbelievable! You hav not understood a thing what i am talking about. Run the script an see what happens! Have ypu looked at the script! I am sorry but your social competence is too low for me!
BYe
comment:4 follow-up: ↓ 5 Changed 16 years ago by Valik
I just looked at your code and AutoIt's code and it appears to be working as written. Every time you pass the variable around expansion occurs again. In short, because of the way you wrote your code, you caused the $'s to be stripped out.
; This first block demonstrates that the string is stored as shown but is ; expanded when accessed. Local $sOriginal = "5cbep$$$$$$$$$$bnk.txt" On() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 5 Off() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 10 ; Now, turn expansion back on and copy the string over itself. With ; expansion on, the actual content will contain 5 $'s. On() $sOriginal = $sOriginal ; Now let's look at the contents again without and with expansion. Off() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 5 On() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 3 ; As you can see, the assignment on line 12 has shortened the original ; string from 10 $'s to 5. Let's repeat that step again to further reduce ; the string. On() $sOriginal = $sOriginal ; Now let's look at the contents again without and with expansion. Off() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 3 On() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 2 ; Now, one more time. On() $sOriginal = $sOriginal ; Now let's look at the contents again without and with expansion. Off() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 2 On() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 1 ; At this point the contents of $sOriginal contains 2 $'s but as long as ; the expansion flag is set you will only see one. We have stripped ; as many matching sets of $ out of the string each time we ; performed an assignment with the flag enabled. ; Helper functions Func On() Opt("ExpandVarStrings", True) EndFunc Func Off() Opt("ExpandVarStrings", False) EndFunc Func State() Local $bState = Opt("ExpandVarStrings") If $bState Then Return "Expand On: " Else Return "Expand Off: " EndIf EndFunc
It really does take as little as 3 expansion to go from 10 $'s to 1 $ if ExpandVarStrings is on. In your code, the first expansion is when you pass $Filename[$IX] to StringReplace(). The second expansion occurs when the return value of StringReplace() is assigned to $Filename[$IX]. The third and final expansion occurs when $Filename[$IX] is assigned to $origfilename.
This is working as designed. This is not a bug. If you do not like this behavior, do not use this feature. It is a poor feature and should have never been added to the language in the first place. It's full of all kinds of pitfalls and leads to some poorly written, sloppy, unmaintainable code that obviously won't always work as intended. But it is not broken in-so-much-as it's working as it was written to work.
comment:5 in reply to: ↑ 4 Changed 16 years ago by anonymous
Replying to Valik:
I just looked at your code and AutoIt's code and it appears to be working as written. Every time you pass the variable around expansion occurs again. In short, because of the way you wrote your code, you caused the $'s to be stripped out.
; This first block demonstrates that the string is stored as shown but is ; expanded when accessed. Local $sOriginal = "5cbep$$$$$$$$$$bnk.txt" On() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 5 Off() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 10 ; Now, turn expansion back on and copy the string over itself. With ; expansion on, the actual content will contain 5 $'s. On() $sOriginal = $sOriginal ; Now let's look at the contents again without and with expansion. Off() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 5 On() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 3 ; As you can see, the assignment on line 12 has shortened the original ; string from 10 $'s to 5. Let's repeat that step again to further reduce ; the string. On() $sOriginal = $sOriginal ; Now let's look at the contents again without and with expansion. Off() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 3 On() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 2 ; Now, one more time. On() $sOriginal = $sOriginal ; Now let's look at the contents again without and with expansion. Off() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 2 On() ConsoleWrite(State() & $sOriginal & @CRLF) ; Displays 1 ; At this point the contents of $sOriginal contains 2 $'s but as long as ; the expansion flag is set you will only see one. We have stripped ; as many matching sets of $ out of the string each time we ; performed an assignment with the flag enabled. ; Helper functions Func On() Opt("ExpandVarStrings", True) EndFunc Func Off() Opt("ExpandVarStrings", False) EndFunc Func State() Local $bState = Opt("ExpandVarStrings") If $bState Then Return "Expand On: " Else Return "Expand Off: " EndIf EndFuncIt really does take as little as 3 expansion to go from 10 $'s to 1 $ if ExpandVarStrings is on. In your code, the first expansion is when you pass $Filename[$IX] to StringReplace(). The second expansion occurs when the return value of StringReplace() is assigned to $Filename[$IX]. The third and final expansion occurs when $Filename[$IX] is assigned to $origfilename.
This is working as designed. This is not a bug. If you do not like this behavior, do not use this feature. It is a poor feature and should have never been added to the language in the first place. It's full of all kinds of pitfalls and leads to some poorly written, sloppy, unmaintainable code that obviously won't always work as intended. But it is not broken in-so-much-as it's working as it was written to work.
Hallo again!
Thank you for your extensive answer! The starting problem of this was when I was
using _FileListToArray to make a list of filenames in a directory and a file named
CBEP$$BNK lost one dollar sign if ExpandVarString was ON. I am now going back to the new way of specifying literals and variables and are skipping Opt(ExpandVarString..) function. Thank you once again and I didn't meen in the beginning to be ignorent or some "besserwisser". I hope we can consider this conversation as ended to the best!
My Regards again!
S-O
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Automatic ticket cleanup.