SkinnyWhiteGuy Posted November 28, 2009 Share Posted November 28, 2009 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 More sharing options...
martin Posted November 28, 2009 Share Posted November 28, 2009 (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 November 28, 2009 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 More sharing options...
Zedna Posted November 28, 2009 Share Posted November 28, 2009 An underscore character is in Autoit treated as "continue line". So maybe this limitation is because of that. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
trancexx Posted November 28, 2009 Share Posted November 28, 2009 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 More sharing options...
SkinnyWhiteGuy Posted November 28, 2009 Author Share Posted November 28, 2009 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 More sharing options...
Zedna Posted November 28, 2009 Share Posted November 28, 2009 (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 November 28, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
martin Posted November 28, 2009 Share Posted November 28, 2009 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 More sharing options...
SkinnyWhiteGuy Posted November 28, 2009 Author Share Posted November 28, 2009 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 More sharing options...
Zedna Posted November 28, 2009 Share Posted November 28, 2009 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. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
mavor Posted December 20, 2009 Share Posted December 20, 2009 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 >.< Link to comment Share on other sites More sharing options...
Zedna Posted December 20, 2009 Share Posted December 20, 2009 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. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now