Xand3r Posted March 4, 2008 Posted March 4, 2008 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
weaponx Posted March 4, 2008 Posted March 4, 2008 (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 March 4, 2008 by weaponx
Xand3r Posted March 4, 2008 Author Posted March 4, 2008 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
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