nightwatcher Posted April 23, 2018 Posted April 23, 2018 Local $str = "int var1;byte var2;uint var3;char var4[128]" Local $a = DllStructCreate($str) we usually use the following way DllStructSetData($a, "var1", -1)DllStructSetData($a, "var2", 255)DllStructSetData($a, "var3", -1)DllStructSetData($a, "var4", "Hello")DllStructSetData($a, "var4", Asc("h"), 1) but I see someone use something like this to set struct data $a.var1 = -1; $a.var2 = 255; $a.var3 = -1; $a.var4 = 'Hello'; ;~ $a.var4[0] = 'h'; this was a wrong way…… Is there any problem for this kind of usage? And I am wondering how to set data of an array in this way. Like mentioned before , change 'H' to 'h'. change an item of an array ,but keep others unchanged.
AspirinJunkie Posted April 23, 2018 Posted April 23, 2018 Local $str = "int var1;byte var2;uint var3;char var4[128]" Local $a = DllStructCreate($str) $a.var4(1) = "H" $a.var4(2) = "e" $a.var4(3) = "l" $a.var4(4) = "l" $a.var4(5) = "o" ConsoleWrite($a.var4 & @CRLF) ConsoleWrite($a.var4(3) & @CRLF)
nightwatcher Posted April 23, 2018 Author Posted April 23, 2018 (edited) 18 minutes ago, AspirinJunkie said: Local $str = "int var1;byte var2;uint var3;char var4[128]" Local $a = DllStructCreate($str) $a.var4(1) = "H" $a.var4(2) = "e" $a.var4(3) = "l" $a.var4(4) = "l" $a.var4(5) = "o" ConsoleWrite($a.var4 & @CRLF) ConsoleWrite($a.var4(3) & @CRLF) wow,tks for guiding! I got an other question , how to print char greater than 0x80 I use this to test the output. For $i = 0x00 To 0xff $a=Chr($i) ConsoleWrite($a&@CRLF) ConsoleWrite(Asc($a)&@CRLF) Next but when greater than 127 ,the outputs are all the same '?'. and the ascii code is 63……weird. Edited April 23, 2018 by Jos
Developers Jos Posted April 23, 2018 Developers Posted April 23, 2018 4 minutes ago, nightwatcher said: but when greater than 127 ,the outputs are all the same '?' Must be something with your codepage as things work fine here running it from ScITE. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
nightwatcher Posted April 23, 2018 Author Posted April 23, 2018 3 minutes ago, Jos said: Must be something with your codepage as things work fine here running it from ScITE. Jos what does ' codepage ' mean? I can't understand you…… Is there a way to work this out
AndyG Posted April 23, 2018 Posted April 23, 2018 1 hour ago, nightwatcher said: what does ' codepage ' mean? http://lmgtfy.com/?q=codepage
jchd Posted April 23, 2018 Posted April 23, 2018 The codepage in effect is the charset currently selected by system/user for ANSI strings. Note that AutoIt, just like Windows, uses Unicode for native strings. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
nightwatcher Posted April 23, 2018 Author Posted April 23, 2018 3 minutes ago, jchd said: The codepage in effect is the charset currently selected by system/user for ANSI strings. Note that AutoIt, just like Windows, uses Unicode for native strings. according to you statement , normally, that couldn't happed. because those characters are included in Unicode . what upset me is that when I use asc(), try to resum it from chr,all the acsii code is 63,this doesn't make sense…… if the key of the problem is code page , the asc() function should return the rigth ascii code?
nightwatcher Posted April 23, 2018 Author Posted April 23, 2018 (edited) 9 hours ago, AspirinJunkie said: Local $str = "int var1;byte var2;uint var3;char var4[128]" Local $a = DllStructCreate($str) $a.var4(1) = "H" $a.var4(2) = "e" $a.var4(3) = "l" $a.var4(4) = "l" $a.var4(5) = "o" ConsoleWrite($a.var4 & @CRLF) ConsoleWrite($a.var4(3) & @CRLF) $te=DllStructCreate('byte b[3]') $te.b(1)=1 $te.b(2)=2 $te.b(3)=3 For $a=1 To DllStructGetSize($te) ConsoleWrite($te.b($a)) Next I want to enum all the data,but this seem not work when using a variable like $a. I use eval to work this out $te=DllStructCreate('byte b[3]') $te.b(1)=1 $te.b(2)=2 $te.b(3)=3 For $a=1 To DllStructGetSize($te) ConsoleWrite( $te.b(Eval('a'))&@CRLF) Next Edited April 24, 2018 by nightwatcher add a solution
jchd Posted April 23, 2018 Posted April 23, 2018 1 hour ago, nightwatcher said: according to you statement , normally, that couldn't happed. because those characters are included in Unicode . what upset me is that when I use asc(), try to resum it from chr,all the acsii code is 63,this doesn't make sense…… if the key of the problem is code page , the asc() function should return the rigth ascii code? Of course, every character is part of Unicode, but its codepoint in Unicode is fixed and trivially unique, albeit it may or not be part of a given codepage. Every Unicode character (wchar type in DllStruct) which is not within the current ANSI codepage is replaced by a question mark when converted to a char type. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
nightwatcher Posted April 24, 2018 Author Posted April 24, 2018 5 hours ago, jchd said: Of course, every character is part of Unicode, but its codepoint in Unicode is fixed and trivially unique, albeit it may or not be part of a given codepage. Every Unicode character (wchar type in DllStruct) which is not within the current ANSI codepage is replaced by a question mark when converted to a char type. OKay, that is a little difficult for me to understand……but I get you…… I naturally think 0x00 to 0xff will be surpported And I ignore the truth that the basic ascii code is only up to 127. using chrw() can resolve this porblem. thinks for all of you.
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