Jump to content

Datatype from DLLStruct


Recommended Posts

Hello,

is it possible to get the datatype inside a structure giving the same result as the function VarGetType?

If you take a look at his example:

Dim $sStruct = "struct;boolean Test_Bool;uint Test_UInt;char Test_Char[1];endstruct"
Dim $tStruct = DllStructCreate($sStruct)
Dim $vBool = False

ConsoleWrite("Bool by Dim:    " & VarGetType($vBool) & @CRLF)

DllStructSetData($tStruct, 1, False)
ConsoleWrite("IsStruct?:      " & VarGetType($tStruct.Test_Bool) & @CRLF)

$vBool = DllStructGetData($tStruct, 1)
ConsoleWrite("Bool by struct: " & VarGetType($tStruct.Test_Bool) & @CRLF)

$vBool = True
ConsoleWrite("Bool by assign: " & VarGetType($vBool) & @CRLF)

If the variable is directly assigned the correct datatype is shown (Bool by Dim: Bool).

If the value is set using DllStructSetData the returned datatype is Int32 - which I guess is the internal AutoIt representation.

Is there away to receive the datatype that is actually held within the elements of the structure?

Edited by HurleyShanabarger
Update script
Link to comment
Share on other sites

Here's a way to get byte fundamental datatypes:

Local $t = DllStructCreate("byte;char;wchar;short;ushort;int;uint;int64;float;double;ptr;boolean;bool")
DllStructSetData($t, 1, 0x3C)
DllStructSetData($t, 2, 't')
DllStructSetData($t, 3, 'µ')
DllStructSetData($t, 4, -12345)
DllStructSetData($t, 5, 23456)
DllStructSetData($t, 6, -3456789)
DllStructSetData($t, 7, 4567890)
DllStructSetData($t, 8, 123456789123456)
DllStructSetData($t, 9, 123.456789)
DllStructSetData($t, 10, 123.4567891234567)
DllStructSetData($t, 11, DllStructGetPtr($t))
DllStructSetData($t, 12, True)
DllStructSetData($t, 13, True)
ConsoleWrite(_VarDump($t) & @LF)

It has also been posted another way, using a Windows API but I don't remember which. Use search feature.

Yet you can't differentiate a Boolean or a Bool from their byte or int internal representation in the structure.

Dump.au3

Edited by jchd

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 here
RegExp tutorial: enough to get started
PCRE 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)

Link to comment
Share on other sites

Link to comment
Share on other sites

Yes but this requires to supply the struct tag string to get back types. It's easier to grab struct element types by regex!

Or, is the tag supplied is an empty string, then you get a useless list of bytes.

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 here
RegExp tutorial: enough to get started
PCRE 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)

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

  • Recently Browsing   0 members

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