IIC si_variable_write, array

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
chefpilot
Posts: 90
Joined: Wed Aug 02, 2017 12:51 pm

IIC si_variable_write, array

#1 Post by chefpilot »

I have a problem writing IIC variables to an array.
I tried this script:

Code: Select all

switch_id = si_variable_create("my_var", "INT4]", {1, 3, 5, 7})

si_variable_write(switch_id, {data}, 2)
Intention is to store data at the second position in the array, buth data is allways stored at the first position and not at the second, what I expected.
How can I solve the problem?
Marc

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: IIC si_variable_write, array

#2 Post by Ralph »

Maybe a type error, but it should be "INT[4]" not "INT4]".
Aside from this, I'm not sure if the offsets are even a feature with si_variable_write. Maybe Corjan knows, but he probably has to dig in the code :)

chefpilot
Posts: 90
Joined: Wed Aug 02, 2017 12:51 pm

Re: IIC si_variable_write, array

#3 Post by chefpilot »

Thanks Ralph,
but that is just a typo in this threat. I just checked it in the original script. The reference comes out of the wiki:
https://siminnovations.com/wiki/index.p ... ble_create

Marc

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: IIC si_variable_write, array

#4 Post by Ralph »

That might be a copy paste from X-Plane. We will have to check.

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: IIC si_variable_write, array

#5 Post by Ralph »

It's no feature at the moment, as you can see here:
https://siminnovations.com/wiki/index.p ... able_write

But it'll probably be added to 4.2.

User avatar
Corjan
Posts: 2936
Joined: Thu Nov 19, 2015 9:04 am

Re: IIC si_variable_write, array

#6 Post by Corjan »

Hi,


Offsets are not supported at the moment.
I have fixed the incorrect example in the 'si_variable_create' page.

Have added this to our TODO list, it will be part of AM 4.2 when it hits.


Corjan

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: IIC si_variable_write, array

#7 Post by Keith Baxter »

Corjan wrote: Fri Sep 30, 2022 2:48 pm Hi,


Offsets are not supported at the moment.
I have fixed the incorrect example in the 'si_variable_create' page.

Have added this to our TODO list, it will be part of AM 4.2 when it hits.


Corjan
Hi,

It is only the off set write that does not work.
That does not stop writing an array.

On a branch off to that...
I had asked some time ago for a null write to a array index.
Example.

my_array = {"red"',"red"',"red"',"red"'}

I do not want to write to a some indexes, keeping their values.
In other words I want to write

my_array = {null,null, “yellow”,null}

So only [2] is changed.

my_array = {"red"',"red"',"yellow"',"red"'}

Keith
Last edited by Keith Baxter on Fri Sep 30, 2022 4:29 pm, edited 1 time in total.
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: IIC si_variable_write, array

#8 Post by jph »

Keith Baxter wrote: Fri Sep 30, 2022 4:06 pm
Corjan wrote: Fri Sep 30, 2022 2:48 pm Hi,


Offsets are not supported at the moment.
I have fixed the incorrect example in the 'si_variable_create' page.

Have added this to our TODO list, it will be part of AM 4.2 when it hits.


Corjan
Hi,

It is only the off set write that does not work.
That does not stop writing an array.

On a branch of that...
I had asked some time ago for a null write to a array index.
Example.

my_array = {"red"',"red"',"red"',"red"'}

I do not want to write to a some indexes, keeping their values.
In other words I want to write

my_array = {null,null, “yellow”,null}

So only [2] is changed.

my_array = {"red"',"red"',"yellow"',"red"'}

Keith
you mean only [3] is changed (by convention) ....
Joe. CISSP, MSc.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: IIC si_variable_write, array

#9 Post by Keith Baxter »

jph wrote: Fri Sep 30, 2022 4:28 pm
Keith Baxter wrote: Fri Sep 30, 2022 4:06 pm
Corjan wrote: Fri Sep 30, 2022 2:48 pm Hi,


Offsets are not supported at the moment.
I have fixed the incorrect example in the 'si_variable_create' page.

Have added this to our TODO list, it will be part of AM 4.2 when it hits.


Corjan
Hi,

It is only the off set write that does not work.
That does not stop writing an array.

On a branch of that...
I had asked some time ago for a null write to a array index.
Example.

my_array = {"red"',"red"',"red"',"red"'}

I do not want to write to a some indexes, keeping their values.
In other words I want to write

my_array = {null,null, “yellow”,null}

So only [2] is changed.

my_array = {"red"',"red"',"yellow"',"red"'}

Keith
you mean only [3] is changed (by convention) ....
No 2 because arrays start at 0 in most coding except lua.

Keith
Last edited by Keith Baxter on Fri Sep 30, 2022 4:36 pm, edited 1 time in total.
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: IIC si_variable_write, array

#10 Post by jph »

The convention in Lua is starting at 1 but it is not enforced so you can start at 0 if you like - just to be different :D . (haha - notice the quick edit you did :lol: ) ;)
Joe. CISSP, MSc.

Post Reply