Sign in to follow this  
Followers 0
SkinnyWhiteGuy

DllStruct Element Name Limits

11 posts in this topic

I was working with a few DllCalls the other day, and ran into a limit I can't find mentioned any where, and thought it might just be something I missed. DllStruct Element Names cannot contain the underscore character, but actual C/C++ structures can. Without experimenting and finding out the hard way, I was wondering what the actual limits to Element Names were. Would someone mind telling me what the limits for DllStruct Element Names are?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

ConsoleWrite("Allowed characters" & @CRLF)
$ok = 0
for $i = 1 to 255
    $n = chr($i)
$d = dllstructcreate("int " & $n)
dllstructsetdata($d,$n,$i)
if dllstructgetdata($d,$n) = $i Then
    ConsoleWrite(chr($i) & ", " )
    $ok += 1
EndIf

if $ok <> 0 and mod($ok,40) = 0 then ConsoleWrite(@CRLF)
Next
ConsoleWrite(@CRLF & @CRLF)
ConsoleWrite("illegal character codes" & @CRLF)
$ok = 0
for $i = 1 to 255
    $n = chr($i)
$d = dllstructcreate("int " & $n)
dllstructsetdata($d,$n,$i)
if dllstructgetdata($d,$n) <> $i Then
    ConsoleWrite($i & ", " )
    $ok += 1
EndIf

if $ok <> 0 and mod($ok,40) = 0 then ConsoleWrite(@CRLF)
Next
ConsoleWrite(@CRLF)

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

ConsoleWrite("Allowed characters" & @CRLF)
$ok = 0
for $i = 1 to 255
    $n = chr($i)
$d = dllstructcreate("int " & $n)
dllstructsetdata($d,$n,$i)
if dllstructgetdata($d,$n) = $i Then
    ConsoleWrite(chr($i) & ", " )
    $ok += 1
EndIf

if $ok <> 0 and mod($ok,40) = 0 then ConsoleWrite(@CRLF)
Next
ConsoleWrite(@CRLF & @CRLF)
ConsoleWrite("illegal character codes" & @CRLF)
$ok = 0
for $i = 1 to 255
    $n = chr($i)
$d = dllstructcreate("int " & $n)
dllstructsetdata($d,$n,$i)
if dllstructgetdata($d,$n) <> $i Then
    ConsoleWrite($i & ", " )
    $ok += 1
EndIf

if $ok <> 0 and mod($ok,40) = 0 then ConsoleWrite(@CRLF)
Next
ConsoleWrite(@CRLF)

Outstanding.

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Martin: That was the hard way I was trying to avoid, cause what if some chars are allowed only as non-first letters? Also, if the char is invalid, DllStructCreate returns @error of 2, claiming an invalid parameter (at least for an underscore). That would make for a quicker check.

Zedna: I thought that too, but AutoIt variables themselves allow underscores in the names, as do functions. Also, considering the struct format is passed into AutoIt as a string, it shouldn't affect it in there.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Zedna: I thought that too, but AutoIt variables themselves allow underscores in the names, as do functions. Also, considering the struct format is passed into AutoIt as a string, it shouldn't affect it in there.

Yes. Of course you are right.

It was just my quick (wrong) idea.

Edited by Zedna

Share this post


Link to post
Share on other sites

Martin: That was the hard way I was trying to avoid, cause what if some chars are allowed only as non-first letters? Also, if the char is invalid, DllStructCreate returns @error of 2, claiming an invalid parameter (at least for an underscore). That would make for a quicker check.

Yes that's all true, so

ConsoleWrite("Allowed characters" & @CRLF)
$ok = 0
for $i = 1 to 255
    $n = 'A' & chr($i) & 'B'
$d = dllstructcreate("int " & $n)

if not @error Then
    ConsoleWrite(chr($i) & ", " )
    $ok += 1
EndIf

if $ok <> 0 and mod($ok,40) = 0 then ConsoleWrite(@CRLF)
Next
ConsoleWrite(@CRLF & @CRLF)
ConsoleWrite("illegal character codes" & @CRLF)
$ok = 0
for $i = 1 to 255
    $n = 'A' & chr($i) & 'B'
$d = dllstructcreate("int " & $n)
if @error = 2 Then
    ConsoleWrite($i & ", " )
    $ok += 1
EndIf

if $ok <> 0 and mod($ok,40) = 0 then ConsoleWrite(@CRLF)
Next
ConsoleWrite(@CRLF)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Well, I ran what Martin provided, and it basically confirmed what I thought: Only allowed chars in element names are letters and numbers, A-Z a-z 0-9. Ok, next obvious question: Why? Is it just limited that way just because, or is there a reason for it? Also, information like this would be good to add to the help entry for DllStructCreate, after confirming which chars are legal and which aren't.

Share this post


Link to post
Share on other sites

Also, information like this would be good to add to the help entry for DllStructCreate, after confirming which chars are legal and which aren't.

I fully agree.

Make ticket for this on bugtrac or send PM to some of developers with access to Autoit sources to confirm such a limitation.

Share this post


Link to post
Share on other sites

Hey guys thanks a ton for this post. It saved me another two+ hours of debugging. You are right, it has a hissy fit if you use ANYTHING other then letters and numbers

>.<

Share this post


Link to post
Share on other sites

Hey guys thanks a ton for this post. It saved me another two+ hours of debugging. You are right, it has a hissy fit if you use ANYTHING other then letters and numbers

>.<

Use latest 3.3.2 version.

There is fix for this: Underscore is now possible.

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