Plugin's variable names and their values.

Interested in developing new plug-ins? Got one to share? Post here!
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Plugin's variable names and their values.

Postby bokkie » Mon Apr 11, 2016 4:27 pm

This isn't so much a bug rather a dilemma. Perhaps somebody has been through the same pain I've just discovered. Let me explain.

Let's say I have three variables A, B and C and I set their values to TOM, DICK, and HARRY respectively. When my plugin runs I can conveniently split, A,"TOM",B,"DICK",C,"HARRY" using the comma character. This gives me an array of strings like:

0 - A
1 - "TOM" This is the value for variable A.
2 - B
3 - "DICK" This is the value for variable B.
4 - C
5 - "HARRY" and this is the value for variable C.

In my plugin if I want to replace the value for C with "SPOT THE DOG", I can search the strings for C, which I find in index 4 and I know that what's in 5 is what I overwrite with "SPOT THE DOG", giving C a new value. I then concatenate all the elements joining them with a comma and that's what the plugin passes back to IA when it returns. I then presume that IA will do something like splitting them using the comma and can then get the values. None of this is difficult and it all works fine. Where I have a problem, is when I pass in text values to variables (Set Variable statement) which contain commas as part of the text. For example, lets say I put some commas as part of the text in variable B, like this: A,"TOM",B,"D,I,C,K",C,"HARRY". If I split the array using commas I get this:

0 - A
1 - "TOM"
2 - B
3 - "D
4 - I
5 - C
6 - K"
7 - C
8 - "HARRY"

In a "well-formed" list of variable names and values, the variable names are usually in index positions 0, 2, 4... and the values would be in 1, 3, 5... but in my previous example the commas which should remain part of "D,I,C,K" breaks the clean rule where I can find the variable names. It gets a little worse if I have a variable using double quotes and commas in the text because not even Excel can cleanly interpret where commas are part of text and where they are column breaks.

If I write the string containing the variables and their values as my plugin gets it from the bridge, everything looks quite okay but the moment I split using the comma character then all hell breaks loose. :)

Has anybody handled such an anomaly before when writing a plugin? Providing I don't use commas in a variable then everything is fine but it's quite legal to create a variable and put anything in for its value, comma included.

If the bridge could pass the variables and values to a plugin like this: A,3,"TOM",B,7,"D,I,C,K",C,5,"HARRY" a string parser could easily be written and find variable A and the next component, 3, tells it there are three characters, TOM. For variable B the next component, 7, lets you isolate D,I,C,K and so on. Sorry for the length of this post and I hope it's not too confusing what my problem is and I'd appreciate any coding suggestions that'll give me a robust mechanism to handle it. Just to put this into perspective, here is an actual string the bridge gives me:


Look at variable, ZULU999. It contains a comma in the text value and that's where things go the proverbial titsup. :D

EDIT: If it helps to take this "offline", so to speak, I'd be happy to discuss it further with the bridge's author, Pawel Piotrowski if he'd like to.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

Posts: 14
Joined: Wed Dec 02, 2015 10:36 am

Re: Plugin's variable names and their values.

Postby Damien » Fri May 27, 2016 5:08 am

Hi bokkie,
I presume you are talking about .net bridge plugin (you speak about "bridge").
I was also disappointed when i saw whatpain is it to deal with variables in this case.

To extend IA features, with .net code, I needed plugin wich can serialize commands, typically in Json format.
And, deal with variables (use values, and asign it with this commands). So I had many specials chars, which may break split process.

To get around this, I am doing many steps :
    Encoding variables values rounded by " (careful html encode dont replace ',', do it manually) and removing surrounding "
    split on ','
    iterate all values, add to dictionary even as key and odd as value with decoded value. (be careful, " is escaped by double " by IA or bridge, replace it.)

    Revert the process to send it back to IA.
Its a lot of job to get variables, but you must do it^^.

I am probably missing some step i am doing, but important steps are here.

I am now facing an other (but easy to solve" problem: some IA functions replace line-break with $NEWLINE$, you must be aware of it.

It work pretty well, I am able to use Web services with json or xml serialization, use results in IA and send parameters to my plugins.

(sorry about my English^^)

Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: Plugin's variable names and their values.

Postby bokkie » Fri May 27, 2016 4:48 pm


I was looking for a foolproof way of decoding the string but it seems there's nothing you can do except to try and filter quotes and commas and newlines and hope for the best (at this point, unpin the grenade and stick fingers in your ears, the idea being, if you can't hear it go bang then it can't really hurt :D ).

Anyway, I'll just have to keep in mind and assume and hope there won't be any snafu with the string's contents.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

Return to “Plug-In Development”

Who is online

Users browsing this forum: No registered users and 1 guest