Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 1,177 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
SED; help with arrays #255977
03/13/09 22:03
03/13/09 22:03
Joined: Mar 2009
Posts: 16
X
xxGOTARxx Offline OP
Newbie
xxGOTARxx  Offline OP
Newbie
X

Joined: Mar 2009
Posts: 16
In c++ I would make an array of strings as follows;

string goblygoo[] = {"line one","line two","line three"};

How would I impliment this in c-lite?

I have been taking shots at it for about 2 hours now and cant figuar it out or find help anyplace else.

Any ideas?

Re: SED; help with arrays [Re: xxGOTARxx] #255981
03/13/09 22:57
03/13/09 22:57
Joined: Mar 2009
Posts: 16
X
xxGOTARxx Offline OP
Newbie
xxGOTARxx  Offline OP
Newbie
X

Joined: Mar 2009
Posts: 16
This is what I came up with but it is still not working the way I expected, anyone have any ideas?

#include <acknex.h>
#include <default.c>



STRING* one = "0";
STRING* two = "1";
STRING* three = "2";

function msgbox(STRING* new)
{

STRING* clearText = " ";
STRING* holder_one = " ";
STRING* holder_two = " ";
STRING* holder_three = " ";

str_cpy(holder_one,one);
str_cpy(holder_two,two);
//str_cpy(holder_three,three);


str_cpy(one,clearText);
str_cpy(two,clearText);
str_cpy(three,clearText);


TEXT* lnONE =
{
pos_y = 100;
string (one);
flags = VISIBLE;
}

TEXT* lnTWO =
{
pos_y = 110;
string (two);
flags = VISIBLE;
}

TEXT* lnTHREE =
{
pos_y = 120;
string (three);
flags = VISIBLE;
}

str_cpy(one,new);
str_cpy(two,holder_one);
str_cpy(three,holder_two);

}


function main()
{
msgbox("100");
wait(1000);
msgbox("is this working");
wait(1000);
msgbox("i guess so");
return;
}

Re: SED; help with arrays [Re: xxGOTARxx] #255984
03/13/09 23:10
03/13/09 23:10
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

Is : STRING* clearText = " ";
inside a function?

Try it outside the function...it will become global and not local.

Ottawa smile

Last edited by Ottawa; 03/13/09 23:11.
Re: SED; help with arrays [Re: xxGOTARxx] #256000
03/14/09 02:02
03/14/09 02:02
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
Hi,

I found this and saved it when i was browsing the forum.
Havent used it yet but thought it could be usefull.

Code:
//ARRAY of STRINGS
STRING** tst;
tst = malloc((long) sizeof(STRING*) * number of elements);
//tst = malloc((int) sizeof(STRING*) * number of elements);
for(int i=0;i<number of elements;i++)
tst[i]=str_create("#number of characters");

//now you can access the string array like this:

str_cpy(tst[0],"hallo");



hope this is what you need?


A8.3x Commercial, AcknexWrapper and VS 2010 Express
&#9675;pararealist now.
Re: SED; help with arrays [Re: pararealist] #256002
03/14/09 02:15
03/14/09 02:15
Joined: Mar 2009
Posts: 16
X
xxGOTARxx Offline OP
Newbie
xxGOTARxx  Offline OP
Newbie
X

Joined: Mar 2009
Posts: 16
I found that post also I could not get it to work, I am going to play around with it some more. **now where did my old c programming book end up at** smirk

UPDATE!

I got it to work by changing that code a bit i used...

STRING** tst;
tst = malloc((long) sizeof(STRING*) * 10);
var i = 0; // declared a var
for(i=0;i<10;i++) // removed the int
tst[i]=str_create("#10");

next...
How would I use that with
TEXT* box =
{
layer = 15;
string(tst);
flags = VISIBLE;
}
did not work...

Last edited by xxGOTARxx; 03/14/09 02:32.
Re: SED; help with arrays [Re: xxGOTARxx] #256293
03/15/09 21:49
03/15/09 21:49
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
So,

STRING* sTextString1 = "Welcome\n";
STRING* sTextString2 = "This is";
STRING* sTextString3 = " a ";
STRING* sTextString4 = "Text";
STRING* sTextString5 = "\nand this another line!";

TEXT* tInfo =
{
layer = 25;
pos_x = 300;
pos_y = 300;
string (sTextString1,
sTextString2,
sTextString3,
sTextString4,
sTextString5); // create an array of 5 string pointers
flags = SHOW;
}

Now you can access the strings with
tInfo.pstring[0] // (0-4) e.g

str_cpy(tInfo.pstring[0],"your text");

Time we got proper arrays me thinks.

Last edited by pararealist; 03/15/09 21:50.

A8.3x Commercial, AcknexWrapper and VS 2010 Express
&#9675;pararealist now.
Re: SED; help with arrays [Re: pararealist] #256636
03/17/09 21:20
03/17/09 21:20
Joined: Mar 2009
Posts: 112
Germany
K
KDuke Offline
Member
KDuke  Offline
Member
K

Joined: Mar 2009
Posts: 112
Germany
Though if you want to have several text-objects you have to do it this way

Code:
#include <acknex.h>
#include <default.c>

TEXT** myTextArray;

function main()
{
   int numberOfNeededTextObjects;
   myTextArray = (TEXT**)malloc((int)sizeof(TEXT*)*numberOfNeededTextObjects);

   //Now you can acces the text objects in following manner
   (myTextArray.layer)[0] = 25;
   (myTextArray.pos_x)[0] = 100;
   and so on...
}



EDIT: Oh yeah I forgot to mention.
You should make an exit-function which frees the memory again if you use malloc. Like
Code:
#include <acknex.h>
#include <default.c>

on_esc = myExitFunction;

function myExitFunction()
{
    free(myTextArray);
}


greetings
KDuke

Last edited by KDuke; 03/17/09 21:23.

Using A7 Free
Click and join the 3dgs irc community!
Room: #3dgs

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1