Sign in to follow this  
Followers 0
Xand3r

help with structures

3 posts in this topic

is there a way to create in autoit c style structure lists?

struct node{int information;node *next;};
node *start,*end;

node *add=new node;
add->information=smthing;
add->next=NULL;
..... and so on

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I started working on a linked list UDF...didn't get far yet.

Local $string = "char firstname[128];char lastname[128];ptr next"

Local $head = DllStructCreate ($string)
Local $headPtr = DllStructGetPtr ( $head)

DllStructSetData($head,1,"First Name 1")
DllStructSetData($head,2,"Last Name 1")
DllStructSetData($head,3,0)

Local $firstElement = DllStructCreate ($string)

DllStructSetData($head, 3, DllStructGetPtr($firstElement))

DllStructSetData($firstElement,1,"First Name 2")
DllStructSetData($firstElement,2,"Last Name 2")
DllStructSetData($firstElement,3,0)

Local $pNext = $headPtr
While $pNext <> 0
    Local $current = DllStructCreate($string, $pNext)
    ConsoleWrite(DllStructGetData($current, 1) & @CRLF)
    ConsoleWrite(DllStructGetData($current, 2) & @CRLF)
    $pNext = DllStructGetData($current, 3)
WEnd

EDIT: Some credit to Valik for fixing my code

Edited by weaponx

Share this post


Link to post
Share on other sites

tnx dude ... now... any ideea why this is not working??

Local $string = "int;int;ptr next"
Local $head = DllStructCreate ($string)
Local $headPtr = DllStructGetPtr ( $head)
$curptr=$headPtr
For $i=1 To 100
    $new=DllStructCreate($string)
    $newptr=DllStructGetPtr($new)
    DllStructSetData($new,1,$i)
    DllStructSetData($new,2,$i)
    DllStructSetData($new,3,0)
    $lol=DllStructCreate($string,$curptr)
    DllStructSetData($lol,3,$newptr)
    $curptr=$newptr
    ToolTip($i,0,0)
Next
Local $pNext = $headPtr
While $pNext <> 0
    Local $current = DllStructCreate($string, $pNext)
    ConsoleWrite(DllStructGetData($current, 1) & @CRLF)
    ConsoleWrite(DllStructGetData($current, 2) & @CRLF)
    $pNext = DllStructGetData($current, 3)
WEnd

it should create a list of 100 nodes but instead when it prints it only shows 3 nodes the first has 0 for the first 2 values , the last has 100 and the middle one... well...


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
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
Sign in to follow this  
Followers 0