Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declare array of strings

I was trying to declare an array of strings like so:

str ar1[2] = ['One','Two'];

Getting a syntax error. How can I initialize and assign an array like above?

like image 699
Mohammad Yusuf Avatar asked Mar 07 '26 14:03

Mohammad Yusuf


2 Answers

['One', 'Two'] is a container in the axapta. axapta has no syntax for initialize an array. use:

str ar1[2];

ar1[1] = 'One';
ar1[2] = 'Two';
like image 192
mazzy Avatar answered Mar 10 '26 12:03

mazzy


In AX, you'r trying to assign a container collection to an array collection. Which is incorrect, Therefore you can try to follow one of the approach listed below:

Using an array:

str number[2];

// Array starts at one in AX; hence number[0] will clear every value in the array
number[1] = 'One';
number[2] = 'Two';

The other way, would be to use a container:

container con;

con += 'One';  // Equivalent to 'con = conIns(con, conLen(con)+1, 'One');
con += 'Two';  // Equivalent to 'con = conIns(con, conLen(con)+1, 'Two');

or a shortcut would be to use:

container con = ['One', 'Two'];
like image 43
Danyal Imran Avatar answered Mar 10 '26 13:03

Danyal Imran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!