cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an array feature in IML? Also struggling with macro syntax.

SOLVED
TimSharp
Regular Member

Is there an array feature in IML? Also struggling with macro syntax.

I'm doing a macro that writes values to a text file and it's not working properly. Intention is to give me an estimate of the time saved using each macro.

The last bit of the line below doesn't work - (macro_1_count * 5)

fwrite write_file_name macro_1_name + ',' + macro_1_count + ',time-saved-' + (macro_1_count * 5)

If the line is

fwrite write_file_name macro_1_name + ',' + macro_1_count + ',time-saved-' + macro_1_count

It works fine, but as soon as I try to put the calculation in it, it doesn't work.

macro_1_count is defined as a float, so is does IML not allow calculations within some commands? If so I'll have to add an extra line in my macro to create a variable for the write string.

For a macro like this, where there are several variables for each macro, it would be better if the values were stored in some sort of array or table - is there something like this in IML? I'm currently evaluating 38 macros, so there are a lot of variables to create.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Is there an array feature in IML? Also struggling with macro syntax.

My rule of thumb is to not perform mathematical calculations in messages, fwrites, or other functions. My suggestion is to add a variable (global might simplify for your 38 macros) and do the calculation prior to your fwrite command and just insert it like you have for the other.

In regards to arrays, no, there is no function. Depending on your need, you might be able to get fancy with a parsing of a string variable (comma delimit or similar), but the effort is often not worth the trouble.

View solution in original post

3 REPLIES 3

Re: Is there an array feature in IML? Also struggling with macro syntax.

My rule of thumb is to not perform mathematical calculations in messages, fwrites, or other functions. My suggestion is to add a variable (global might simplify for your 38 macros) and do the calculation prior to your fwrite command and just insert it like you have for the other.

In regards to arrays, no, there is no function. Depending on your need, you might be able to get fancy with a parsing of a string variable (comma delimit or similar), but the effort is often not worth the trouble.

View solution in original post

Re: Is there an array feature in IML? Also struggling with macro syntax.

I suspected that there was no array function, but hoped they might have added one in a later version. I also guess that it doesn't cope with calculations in some functions and that I'll have to work out the variable first, no problem, it's just not the way I'm used to doing it. Thanks Trevor

Re: Is there an array feature in IML? Also struggling with macro syntax.

Arrays would be nice. There have been a number of times I'm staring at a macro problem thinking how handy an array would be. If I stare at it long enough, I usually find a way to get around the array problem.

In regards to limitations of calculations in functions, here is my favorite frustration. Say you want to transfer all the contents from one file to another. So what I tried to do was loop through the layers appending the layer names to a string with a comma separation. Then I tried both an export layers command as well as an import layers command. Failed. I tried variations on this for two days with no luck.

You can do this if you manually specify the layers in the command, but the use of a variable for the same purpose seemed to kill the function. Seems basic, but for some reason it didn't work.

Again, I did make it work but it opens and closes the source file for each layer. Not efficient, but effective.

Announcements