About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Questions about Arrays in esenthel
Author Message
Aniketos Offline
Member

Post: #1
Questions about Arrays in esenthel
How can I get the lenght (size) of an array of string and how can I insert an element without knowning the position in the array.

Lets say:

Str arrayName[] = { "bla", "bla2", "bla3" };

for(int i = 0; i< arrayName.lenght(); i++)
{
Str blaat = arrayName[i];
}

While debugging .lenght() is not actually the size of the array which should be 3 but 8 (in the .h files it says something like string lenght so I think these options are for regular string not the array).

Ofcourse because lenght is not the size adding like this doesn't work either:

int lenght = arrayName.lenght();
arrayName[lenght] = "something new";

Any idea how this all works...
(This post was last modified: 07-08-2011 10:19 AM by Aniketos.)
07-08-2011 10:17 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Truelegend Offline
Member

Post: #2
RE: Questions about Arrays in esenthel
In Esenthel for object you can do smile

Code:
for( int i =0 ; i < Statics.elms(); i++) {
        Statics[i].actor....
}
07-08-2011 10:21 AM
Find all posts by this user Quote this message in a reply
Aniketos Offline
Member

Post: #3
RE: Questions about Arrays in esenthel
(07-08-2011 10:21 AM)Truelegend Wrote:  In Esenthel for object you can do smile

Code:
for( int i =0 ; i < Statics.elms(); i++) {
        Statics[i].actor....
}

Yeah I know about objects I have seen the examples I just can't figure it out for strings... I don't feel its neccesary to make these strings to objects to just to fix this.
07-08-2011 10:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #4
RE: Questions about Arrays in esenthel
I'm not sure if it's ok (for six elements works ok) but try this:

Code:
Str arrayName[] = {"bla","bla2","bla3","a","b","adenozynotrifosforan"};

Int size=SIZE(arrayName)/SIZE(arrayName[0]);

SIZE() in Esenthel == sizeof()

Also Int size=SIZE(arrayName)/SIZE(Str); works ok.
(This post was last modified: 07-08-2011 12:50 PM by Harry.)
07-08-2011 12:46 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Aniketos Offline
Member

Post: #5
RE: Questions about Arrays in esenthel
(07-08-2011 12:46 PM)Harry Wrote:  I'm not sure if it's ok (for six elements works ok) but try this:

Code:
Str arrayName[] = {"bla","bla2","bla3","a","b","adenozynotrifosforan"};

Int size=SIZE(arrayName)/SIZE(arrayName[0]);

SIZE() in Esenthel == sizeof()

Also Int size=SIZE(arrayName)/SIZE(Str); works ok.

Thanks it works although quite strange way of doing it.
07-08-2011 03:12 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #6
RE: Questions about Arrays in esenthel
Yeah it's strange way smile
07-08-2011 03:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Questions about Arrays in esenthel
07-08-2011 05:01 PM
Find all posts by this user Quote this message in a reply
Aniketos Offline
Member

Post: #8
RE: Questions about Arrays in esenthel
(07-08-2011 05:01 PM)Esenthel Wrote:  http://www.esenthel.com/wiki/index.php?t...ing_Macros

These are very usefull however do you also have a function with which I can do a foreach.

Example:

foreach(obj test in obj testArray)
{
test->setVariable() = "blablabla";
}
07-08-2011 05:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #9
RE: Questions about Arrays in esenthel
You can use the "ITERATION MACROS"

e.g
PHP Code:
#define    REP(   n)   for(Int i=(n); --i>= 0 ;    ) //         repeat                : n-1 .. 0
#define    REPD(i,n)   for(Int i=(n); --i>= 0 ;    ) //         repeat with definition: n-1 .. 0
#define   FREP(   n)   for(Int i= 0 ;   i< (n); i++) // forward repeat                :   0 .. n-1
#define   FREPD(i,n)   for(Int i= 0 ;   i< (n); i++) // forward repeat with definition:   0 .. n-1 

Look in defines.h

There is always evil somewhere, you just have to look for it properly.
07-08-2011 06:55 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply