Jump to content

DllStruct Element Name Limits


Recommended Posts

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?

Link to comment
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)

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.
Link to comment
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

Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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.
Link to comment
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.

Link to comment
Share on other sites

  • 3 weeks later...

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
 Share

  • Recently Browsing   0 members

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