Thanks for reply.
So mychair1 and mychair2 are pointers to newly created elements of ONE list. Then, the TYPE command DOES create a list and the NEW command adds elements to that list.
I thought the TYPE command was more like STRUCT in C and that a list was created by NEW command.
It's a bit different from C or other Basic dialects. It can be a bit confusing if one knows how lists work in C. In PureBasic for example, it would be:
So mychair1 and mychair2 are pointers to newly created elements of ONE list. Then, the TYPE command DOES create a list and the NEW command adds elements to that list.
I thought the TYPE command was more like STRUCT in C and that a list was created by NEW command.
;IT CREATES A LIST CALLED chair Type chair Field colour$ Field Height% End Type ;IT ADDS TWO ELEMENTS TO LIST chair AND ASSIGNS POINTERS ;TO VARIABLES mychair1 AND mychair2 . mychair1.chair = New chair mychair2.chair = New chair mychair1\colour$="brown" cont=1 For mychair1.chair= Each chair Print "ELEMENT: "+cont+" - "+mychair1\colour$ e$=Input() cont=cont+1 Next End
It's a bit different from C or other Basic dialects. It can be a bit confusing if one knows how lists work in C. In PureBasic for example, it would be:
;IT DEFINES A NEW TYPE Structure chair colour$ height.l EndStructure OpenConsole() ;IT CREATES TWO LISTS OF chair TYPE NewList mychair1.chair() NewList mychair2.chair() ;IT ADDS ONE ELEMENT TO LIST mychair1 AddElement(mychair1()) ;IF I NEED A POINTER TO THAT ELEMENT: ;*p=AddElement(mychair1()) mychair1()\colour$="brown" cont=1 ResetList(mychair1()) While NextElement(mychair1()) PrintN("ELEMENT: "+Str(cont)+" - "+mychair1()\colour$) e$=Input() cont=cont+1 Wend End