Insert an element into the middle of an Array

Hello,

I am trying to insert a number into the middle of an already defined array and have the arrays total size grow by 1 rather than overwrite the value at that particular index.

I have searched through the array libraries and have come up short. Any insight?

Thanks,

Maybe not the smartest way and there might be a special library, however: loop over the array and write the values into another one and while doing so, insert your additional value at the dedicated position

Just curious, what’s the use case here?

Along the lines of max’s solution which might not be the slickest way… but I have built a sequence where you can store your value as the positionID of the SeqAdd and SeqInsertAt functions. Build and insert values into your sequence as desired, and then loop back through your sequence using GetPositionID to extract the value and set to your new correctly ordered/sized array

There is a library named HSLExtentions, I presume it is being shared in the public libraries, otherwise I can send it to you.

Depending on your needs, you can use the Extention " Array" and use this to work your request.

You can use this to look for values in an array (Contains) and you can also use this to Find a value (It outputs an array with all the positions your value has been found.)

For what I read here you have an array with a size of X and you wish to put a value at a specific index, for example index 13, but you don’t want to overwrite the array.

Easiest method
Create a SMT
Obtain the size of this array
Loop this number, loopcounter = Index-Array
Make an If/Else statement that if the loopcounter = position you wish to place insert number
Continue looping

If you wish to put a value just at a specified index, you can use the set/at command and select your index as the position you wish to put the values.

I do hope I understood you question here, feel free to ping me otherwise.

Just confirming that the HSL Extensions library is indeed in the repository we shared - see this link.

1 Like

It’s a normalization method where I have a volume array created from a user generated csv. The method will select three different tip types based on the volumes by building an array of 1’s and zero’s from the volume array and concatenating them together into a string to input into a tip pick up command. The problem occurs when switching plates and not needing all 8 channels. So I was trying to insert zero’s into the tip selector array dynamically based off the source plates. I left out a big chunk of details because it was getting convoluted but this is the basic gist. I can clarify more if this is still confusing haha.

It sounds like this library is what I need but I’m a little stuck as a work computer won’t let me run the setup.exe from that particular library. I’ll see what I can do about that in the meantime.

Hi @Nerve

Oh, why didn’t you say that directly!

You need the HSLExtentions to be available to you. I would use both array and string here. Make an SMT with :
Input : volume to create CP for
Index : current index in the volume array (Use this to count in the array)
Output : ChannelPattern

Create an array with X number of channels size and use Initialize to set all via the array lib to “0” X stands for the number of available channels. Make sure you

Now loop X times over your volume array and set an if/else which will set the value to “1” on the current loopcounter like below image

image

When your loop ends, you’ll have set for all volume that are within this range a “1” and for those outside the value remains “0”

Use the string library here to JOIN your array into a string

image

This way your 8 index array will look like a string of 8 chars.

Put the output from this to be your output.

This setup can be repeated for all volumes and tip types you use.

In general I generate it for both 50 and 300 and then execute a tip pickup. As an addition to this I made a SMT that will also scan the volumes and then add the liquidclass I need to use. That way I get a liquidclass string that I use in pipetting. This way my 8 channels do a pickup and then aspirate at the same time using different liquidclasses for each asp.

Venus is cool! Love it!

1 Like

Thanks @Pascal

I used your suggestion and it works great!

1 Like