 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
[deXter]
Joined: 28 Nov 2004 Posts: 35
|
Posted: Fri Dec 08, 2006 11:08 am Post subject: Chr(0) or A_Null |
|
|
Can they be implemented in any future releases? Or is there any workaround?
What I want to do is create null embedded strings. In one particular case, I need to use a null terminated string in the lParam of a SendMessage.
I've refered to Microsofts' KB articles and code samples; the KB article asks to send a null terminated string and one of the code samples shows the strings being terminated by a Chr(0).
However, there's no such facility in AutoHotkey. Chr(0) only returns an empty string, so if I use a %lParam%Chr(0), will it be the same as a null terminated string? Or do all the lParams sent by AHK null terminated by default? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5812
|
Posted: Fri Dec 08, 2006 11:28 am Post subject: Re: Chr(0) or A_Null |
|
|
| [deXter] wrote: | | Can they be implemented in any future releases? |
AutoHotkey variables are already Null-terminated strings!
See this topic: How to manipulate Binary data with Pointers ?
 _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1028 Location: switzerland
|
Posted: Fri Dec 08, 2006 11:31 am Post subject: |
|
|
want ask you also, I don't see ascii codes below 33
Example,LF is SPACE =CHR$(32)
but I get nothing (Case1) or zero (Case2)
| Code: | ;Case1=
Transform,D2,ASC,%LF% ;D2 is nothing
;Case2=
D2:=ASC(LF) ;D2 is 0
|
|
|
| Back to top |
|
 |
[deXter]
Joined: 28 Nov 2004 Posts: 35
|
Posted: Fri Dec 08, 2006 11:32 am Post subject: |
|
|
Thanks a lot, thats a very useful thread.  |
|
| Back to top |
|
 |
[deXter]
Joined: 28 Nov 2004 Posts: 35
|
Posted: Fri Dec 08, 2006 11:36 am Post subject: |
|
|
@garry, I don't think you can use LF.
and:
LF = Line Feed = Chr$(10)
SPC = Space = Chr$(32) |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Fri Dec 08, 2006 11:43 am Post subject: |
|
|
| garry wrote: | | I don't see ascii codes below 33 | These are control chars (except 32), and except under MS-Dos, you cannot "see" them (but see their effect with CR, LF, TAB, and some others). _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1028 Location: switzerland
|
Posted: Fri Dec 08, 2006 11:45 am Post subject: |
|
|
thanks deXter, PhiLho
LF here is a variable from script
was thinking D2 woul'd show me the ASCII code
| Code: | F1="http://www.Atest.de" 123
A=http://
IfInString,F1,%A%
{
{
StringGetPos,P1,F1,%A%
P1:=P1+1
}
stringlen,L2,F1
stringmid,A6,F1,P1,L2-P1
I=0
Loop,parse,A6
{
I++
LF=%A_LOOPFIELD%
;Asc, String: Retrieves the ASCII code (a number between 1 and 255) for the first character in String.
;If String is empty, OutputVar will also be made empty.
;For example: Transform, OutputVar, Asc, %VarContainingString%. Corresponding function: Asc(String).
Transform,D2,ASC,%LF% ;nothing
;Asc(String): Returns the ASCII code (a number between 1 and 255) for the first character in String.
;If String is empty, 0 is returned.
;D2:=ASC(LF) ;0
;msgbox,%D2%
if D2= ;for SPACE nothing=>Transform,D2,ASC,%LF% or 0=>D2:=ASC(LF)
GOTO,GG2
if D2=34 ;"
GOTO,GG2
if D2=60 ;<
GOTO,GG2
if D2=62 ;>
GOTO,GG2
}
GG2:
StringMid,url,A6,1,I-1
msgbox,%I% %URL%
}
exitapp |
|
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Fri Dec 08, 2006 12:20 pm Post subject: |
|
|
Uuh, what are you trying to do? Get the URL? There are simpler ways...
You can do something like that if you want the traditional parsing:
| Code: | F1="http://www.Atest.de" 123
A=http://
IfInString,F1,%A%
{
P1 := InStr(F1, A)
stringmid,A6,F1,P1
end := 0
Loop Parse, A6
{
If A_LoopField in ", ,<,>
{
end := A_Index - 1
Break
}
}
if end > 0
stringleft,A6,A6,end
}
MsgBox %a6%
|
or much simpler, use regular expressions:
| Code: | F1="http://www.Atest.de" 123
A=http://
A6 := RegExReplace(F1, "^.*?(" . A . "[^"" <>]+).*$", "$1")
MsgBox %A6%
|
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1028 Location: switzerland
|
Posted: Fri Dec 08, 2006 12:29 pm Post subject: |
|
|
thanx PhiLho, I save your script, work with the old gwbasic...
very short script, works fine, should read and .... understand
http://phi.lho.free.fr/programming/RETutorial.en.html
Last edited by garry on Fri Dec 08, 2006 3:31 pm; edited 1 time in total |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5812
|
Posted: Fri Dec 08, 2006 1:16 pm Post subject: |
|
|
| garry wrote: | | I don't see ascii codes below 33 |
Most of the ASCII characters ( Except Null, Tab, Linefeed, Carriage return etc ) can be displayed in a AHK GUI by using ASCII.TTF.
Drop ASCII.TTF in the fonts folder & use GUI, Font, , ASCII
| Code: | Loop 31
Str := Str . Chr(A_Index)
Gui, Font, s24 Bold, ASCII
Gui, Add , Text,, %Str%
Gui, Show, ,ASCII Chrs < 32
Return
GuiEscape:
GuiClose:
ExitApp
Return |
Regards,  _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1028 Location: switzerland
|
Posted: Fri Dec 08, 2006 3:23 pm Post subject: |
|
|
thank you for the fonts ascii.ttf
here example for DOS =
40 FOR i% = 1 TO 255
50 PRINT "Code"; i%; "= "; CHR$(i%)
60 IF (i% MOD 23 = 0) THEN INPUT "Press Enter for more...", dummy$
70 NEXT i%
I was meaning I see the ascii code for space like 32
......
LF=%A_loopfield%
Transform,D2,ASC,%LF% ;result for space is nothing, example for "A" I get 65
if D2=32 then goto ........
or other asked:
-can I get the ascii code for digits smaller as ascii 33 |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5812
|
Posted: Fri Dec 08, 2006 3:49 pm Post subject: |
|
|
Transform does not retrieve the ASCII values for hTAB & SPACE, which are 9 & 32 respectively ( without AutoTrim, OFF )
Code to reproduce the said effect:
| Code: | ; AutoTrim, OFF
Loop 32
Str := Str . Chr(A_Index)
Loop, Parse, Str
{
LF = %A_loopfield%
Transform, D2, ASC, %LF%
MsgBox, %D2%
} |
 _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
[deXter]
Joined: 28 Nov 2004 Posts: 35
|
Posted: Fri Dec 08, 2006 3:57 pm Post subject: |
|
|
Hey, I was going to post the autotrim code.. No fair, you edited it before I posted  |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5812
|
Posted: Fri Dec 08, 2006 3:58 pm Post subject: |
|
|
I was fast enough to correct myself!  _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1028 Location: switzerland
|
Posted: Fri Dec 08, 2006 4:10 pm Post subject: |
|
|
autotrim,off ...arghh... I knew once worked
thank you all very much ..  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|