Asc: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
|||
(6 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
== Description == | == Description == | ||
Returns an Integer representing the character code corresponding to the first letter in a string. | |||
== Syntax == | == Syntax == | ||
Line 13: | Line 13: | ||
== Usage == | == Usage == | ||
<highlight-nsis> | <highlight-nsis> | ||
${Asc} "a" | ${Asc} "a" $0 ; returns 97 in $0 | ||
${Asc} "AA" $0 ; returns 65 in $0 | |||
${Asc} " | |||
</highlight-nsis> | </highlight-nsis> | ||
== The Function == | == The Function == | ||
<highlight-nsis> | <highlight-nsis> | ||
!macro Asc _STRING _RETURN | |||
Push ${_STRING} | |||
Call Asc | |||
Pop ${_RETURN} | |||
!macroend | |||
!define Asc "!insertmacro Asc" | |||
Function Asc | Function Asc | ||
; Returns an Integer representing the character code corresponding to the first letter in a string. | ; Returns an Integer representing the character code corresponding to the first letter in a string. | ||
; | ; | ||
; Syntax: | ; Syntax: | ||
; ${Asc} "String" | ; ${Asc} "String" "Return" | ||
; | ; | ||
; "String" ; string argument | ; "String" ; string argument | ||
; | ; "Return" ; Variable where the ASCII code is returned. | ||
; | |||
; | ; | ||
; e.g. | ; e.g. | ||
; ${Asc} "a" | ; ${Asc} "a" $0 ; returns 97 in $0 | ||
; ${Asc} "AA" $0 ; returns 65 in $0 | |||
; ${Asc} " | |||
; | ; | ||
; get parameter | ; get parameter | ||
Exch $0 ; CHAR | |||
Push $1 | |||
System::Call "*(&t1 r0)i.r1" | |||
System::Call "*$1(&i1 .r0)" | |||
System::Free $1 | |||
Pop $1 | |||
Exch $0 | |||
FunctionEnd | FunctionEnd | ||
</highlight-nsis> | </highlight-nsis> | ||
[[Category:String Functions]] | [[Category:String Functions]] |
Latest revision as of 07:39, 3 August 2007
Author: nechai (talk, contrib) |
Description
Returns an Integer representing the character code corresponding to the first letter in a string.
Syntax
${Asc} "String" "String" ; string argument Stack 1 ; Ascii code
Usage
${Asc} "a" $0 ; returns 97 in $0 ${Asc} "AA" $0 ; returns 65 in $0
The Function
!macro Asc _STRING _RETURN Push ${_STRING} Call Asc Pop ${_RETURN} !macroend !define Asc "!insertmacro Asc" Function Asc ; Returns an Integer representing the character code corresponding to the first letter in a string. ; ; Syntax: ; ${Asc} "String" "Return" ; ; "String" ; string argument ; "Return" ; Variable where the ASCII code is returned. ; ; e.g. ; ${Asc} "a" $0 ; returns 97 in $0 ; ${Asc} "AA" $0 ; returns 65 in $0 ; ; get parameter Exch $0 ; CHAR Push $1 System::Call "*(&t1 r0)i.r1" System::Call "*$1(&i1 .r0)" System::Free $1 Pop $1 Exch $0 FunctionEnd