Jump to content

Recommended Posts

Posted

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?

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.
Posted

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

Posted

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.

Posted

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.
Posted

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.

  • 3 weeks later...
Posted

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

>.<

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...