Jump to content

Struct within struct?


VeryGary
 Share

Recommended Posts

I'm playing around with creating a UI for engines built using the Checkerboard API, but I'm having difficulty creating the struct required for calls to the .dll. The API documentation defines the C++ struct:

struct CBmove
{
int jumps; // number of jumps in this move
int newpiece; // moving piece after jump
int oldpiece; // moving piece before jump
struct coor from,to; // from,to squares of moving piece
struct coor path[12]; // intermediate squares to jump to
struct coor del[12]; // squares where men are removed
int delpiece[12]; // piece type which is removed
}

How do i go about creating a substruct within my DllStructCreate( "Struct" )? Do I somehow use Arrays in their place?

Edited by VeryGary
Link to comment
Share on other sites

You can just break the struct into its components and add then in sequence in the 'parent struct' in th ecorrect position. So if you have a struct like this

struct str1

{int a1, a2;

char dummy[80];

}

and you had it in a struct like this

Struct2

{int bb;

struct str1;

int figs[20];

}

then this is equivalent to

Struct2

{int BB;

int a1;

int a2;

char dummy[80];

int figs[20];

}

I think that transexx has a udf in example scripts for structs in structs. Definitely worth looking for.

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

You can also download the beta which introduces support for nested structs.

It seems stable enough now but of course it's still a beta.

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

The coord struct was just a "int; int". I ended up doing the following:

$a = "int; "
Const $JUMPS = 1; number of jumps in this move
$a &= "int; "
Const $NEWPIECE = 2; moving piece after jump
$a &= "int; "
Const $OLDPIECE = 3; moving piece before jump
$a &= "int; int; int; int; "
Dim Const $FROM[2] = [4,5] ; from,to squares of moving piece
Dim Const $TO[2] = [6,7]
For $t = 1 to 24
$a &= "int; "
Next
Dim Const $PATH[12][2] = [  [8,9],[10,11],[12,13],[14,15],[16,17],[18,19], _
[20,21],[22,23],[24,25],[26,27],[28,29],[30,31] ] ; intermediate squares to jump to
For $t = 1 to 24
$a &= "int; "
Next
Dim Const $DEL[12][2] = [ [32,33],[34,35],[36,37],[38,39],[40,41],[42,43], _
[44,45],[46,47],[48,49],[50,51],[52,53],[54,55] ] ; squares where men are removed
For $t = 1 to 12
$a &= "int"
If $t < 12 Then
$a &= "; "
EndIf
Next
Dim Const $DELPIECE[12] = [56,57,58,59,60,61,62,63,64,65,66,67]

Using the Const's for index values within the struct instead of the parameter name.

Edited by VeryGary
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...