@Excessus:
Well....I tried this but it did not work, too.
@All
I have written a bit more code so that you can see what I want to do exactly
and I have added comments for most of the functions.
I think I am doing the same fault as above but I could not think of something else.
If you know a solution you just correct the fault.
I can send you the .c-file, too.
Here's the code:
"
///////////////////////////////////////////////////////////////// Begin
// I want to write a script with functions that allow you to
// create ListBoxes (like in Microsoft VB) dynamically.
// I include the headers for Lite-C
#include <acknex.h>
#include <default.c>
// I define some variables
var Debug_1 = 0; // Debugging
var ListBoxID = 0; // Storing the ID of the created ListBox
var ListBoxCount = 0; // The amount of ListBoxes
// I define some function prototypes
function TestLoop();
// That's the struct "LISTBOX" with all important properties
// (I defined only the var "Active" for testing)
typedef struct {
var Active;
} LISTBOX;
// That's the pointer array for storing the pointers of
// created ListBoxes
LISTBOX* ListBoxArray[100];
// This is the most important function, I think.....
function NewListBox()
{
// Increase the amount of ListBoxes
ListBoxCount += 1;
// I create a new object with the type "ListBox"
// I do this just as in the manual (-> structs)
// < SPOT myspot; // creates an uninitalized SPOT struct named "myspot" >
LISTBOX Test; // (the same as TWO did)
// I suppose I could define the struct "Test" global...but there would be other problemes then
// This ListBox is not filled with any content, so I fill it
Test.Active = 50;
// ---> The ListBoxArray[100] is an array of 100 "ListBox"-pointers.
// ---> I convert the "ListBox"-struct "Test" into a "ListBox"-pointer
// ---> and let an element of the array point to it.
// This way I will (hopefully) be able to access this "ListBox"-struct later throught the array!
ListBoxArray[ListBoxCount] = &Test;
// Return the ID of the new ListBox
return(ListBoxCount);
}
// The main function in which I load the level and call the "NewListBox" function
function main()
{
// Load level
level_load("");
wait(3);
// Create new ListBox
ListBoxID = NewListBox();
// Change properties
(ListBoxArray[ListBoxID]).Active = 100;
// Call "TestLoop()"
TestLoop(ListBoxID);
}
// Is the ListBox created and do I have access to it?
// -> Then Debug_1 should be "100" (as set in main)
function TestLoop(var TestListBoxID)
{
while(1)
{
Debug_1 = (ListBoxArray[TestListBoxID]).Active;
wait(1);
}
}
// Debugging Panel
PANEL* Debug_Pan =
{
flags = VISIBLE;
digits = 100,100,8.4,*,1,Debug_1;
}
///////////////////////////////////////////////////////////////// End
"