string

Propose new features and changes
bourdin07
Posts: 15
Joined: 23 Jun 2019, 12:57

string

14 Aug 2019, 08:55

By default string in Autohotkey is verbatim behavior like in C# :

Code: Select all

@"\\backslash is easy to type" ; output : \\backslash is easy to type
or

Code: Select all

@"""Hello world""" ; output : "Hello world"
I think it's a better practice to define like this:

Code: Select all

mystr := "\\\\need escape backslash" ; output : \\need escape backslash
or

Code: Select all

mystr := "\"Hello world\"" ; output : "Hello world"
Wish
I'd like to define explicitly if I want to use verbatim behavior or normal in Autohotkey

Code: Select all

mystr := @"""verbatim""" ; "verbatim"

; but I also want normal
mystr := "\"normal\""
or like this

Code: Select all

; currently in Autohotkey
mystr := """verbatim""" 

; new feature
mystr := @"\"normal\""
; or
mystr := @"`"normal`""
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: string

24 Aug 2019, 09:08

I haven't particularly liked many of the verbatim text options in other programming languages.
I've collected the various AHK approaches currently available. And added two notes where I think the functionality could be extended slightly.

Code: Select all

;chars 33-127 in different forms:

;VERBATIM

;chars 32-127: verbatim 1 line
 !"#$%&'()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~

;chars 32-127: verbatim 3 lines
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~

;ASSIGNMENT

;[NOTE: an AHK v1/v2: var `= value%var%, could be good]
;[... with `s made available for such lines in AHK v1(/v2)]
;[... it would not be affected by AutoTrim]
;[... and %A_Pct% could be useful instead of/alongside `%]

;chars 32-127: AHK v1 = [escaped: %A_Space% `% ``]
AutoTrim, Off
Clipboard = %A_Space%!"#$`%&'()*+,-./0123456789:;<=>[email protected][\]^_``abcdefghijklmnopqrstuvwxyz{|}~

;chars 32-127: AHK v1 := [escaped: "" ``]
Clipboard := " !""#$%&'()*+,-./0123456789:;<=>?"
. "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"
. "``abcdefghijklmnopqrstuvwxyz{|}~"

;chars 32-127: AHK v2 := [escaped: `" ``]
Clipboard := " !`"#$%&'()*+,-./0123456789:;<=>?"
. "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"
. "``abcdefghijklmnopqrstuvwxyz{|}~"

;chars 32-127: AHK v2 := (using apostrophes) [escaped: `' ``]
Clipboard := ' !"#$%&`'()*+,-./0123456789:;<=>?'
. '@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_'
. '``abcdefghijklmnopqrstuvwxyz{|}~'

;CONTINUATION SECTION

;chars 32-127: AHK v1 = continuation section
AutoTrim, Off
dummy := ""
Clipboard = %dummy%
(% ` Join
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
)

;chars 32-127: AHK v1 := continuation section [escaped: ""]
Clipboard := "
(` Join
 !""#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
)"

;[NOTE: an AHK v1/v2 two-way compatible: var := continuation section, would be good]
;[... i.e. that handles " without having to escape it]
;[... perhaps some option letter could be added]

;chars 32-127: AHK v2 := continuation section
Clipboard := "
(LTrim0 ` Join
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
)"
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 10 guests