Changing a vector value outside of eval, u, fill.

This code does not work:

C:\Users\User\Pictures\gmic-qt-data\tgi>gmic rep_test_vector 5
[gmic]-0./ Start G'MIC interpreter.
[gmic] *** Error in ./rep_test_vector/ (file 'C:\Users\User\AppData\Roaming\user.gmic', line #3) *** Unknown command or filename 'vec[1]=5'; did you mean 'dec'?


Make a helper command. stdlib has lots of commands like that.

The only workaround other than modifying command entirely is to create a command command that takes in 1 global image, then swap the value from there. Not quite pretty, but a good solution though.

Just a reminder: outside the math evaluator, a G’MIC variable is always a string. There are not such things as typed variables there (value, array of values, …).
If you want to store a sequence of values in a single variable, then


is OK, but still, remember this is a single string.
If you want to assign another number to the second value of this string, then use the math evaluator:


But again, keep in mind you are actually generating an entire (modified) new string that will be assigned to vec.

In case you are still no sure about that:
Values of G’MIC variables are strings :slight_smile:

PS : Inside the math evaluator however, variables are typed, they can be either a scalar value, or a vector of size N, nothing else.


We should collect these things into tutorials and put them in the reference. I don’t see anything about this in the reference, not even in Input Data or Substitution Rules. I recently learned this little rule about how variables are treated the hard way when doing that CIECAM02 thing…

1 Like

Indeed, G’MIC documentation is incomplete.
I’d really like to get help on :

English is not my primary language, and I’m pretty sure there are a lot of typos and sentences that could be reformulated in a clearer and more concise manner.

1 Like

When I get less busy I should be able to help with that. We need a list of things that aren’t already described in detail, such as the relevant syntax for the plugin GUIs.

I had to add [] to avoid item substitution error. So, is that a bug? I was using variable={($vector)[n]}.

Could you elaborate ? Add [] to what ?
Instead of what ?