Register | Login
Forum Index > Samples > Open Array
Author Message
Pages: 1
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1339] Open Array - posted: 2013-02-18 04:21:29
Version 1.2.1.8 now has better support for arrays and initialized data, so let us take a look at creating an open array in ziron.

Code:
program WIN32CUI 'sample';

#include 'ch.zir';

//declare a small block so we can have short strings in our array
block ShortString {
  char text[32];
}


now we can declare our array several different ways

Code:
// here we can see the array can hold upto 6 different strings, but we only use 4 of them
ShortString value[6] = ['ziron', ' is my ', 'fav ', 'language!!!'];


or

Code:
// here we let ziron count the array items at compile time. 
ShortString value[] = ['ziron', ' is my ', 'fav ', 'language!!!'];
// you may also disregard the [] after value.


and finally we will print our array, so we will end our sample with:

Code:
print(@value[0], @value[1], @value[2], @value[3], '\r\n');


wait_key();
ExitProcess(0);



Some other things to note, i have tried to make ziron to be as lenient as possible so it is possible to assign different values in different ways to global variales. I will write a few examples using the same variable name for reference:

Code:
Int32 arr[4]; //all array items are null

Int32 arr[4] = 512; //first array entry is 512

Int32 arr[4] = [512, 1024, 2048]; //1-3 array items filled in last is null

Int32 arr[] = [512]; //array length 1, size 4 bytes

Int32 arr = [512, 1024]; //array length 2, size 8


I hope this helps, if you need more help just let me know smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 11 user(s) online. 0 member(s) and 11 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd