Plugin's variable names and their values.

Interested in developing new plug-ins? Got one to share? Post here!
bokkie
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:

ABORTEDONERROR,FALSE,REPAIR,FALSE,EXEDIR,C:\Temp\111111111111111111111\Release\Uncompressed\,TARGETDIR,"C:\Program Files (x86)\111111111111111111111\",FREDSRESULT,-1,WIZARD,NEXT,MYAH_thFinished,FALSE,REMOVE,FALSE,COMPLETE,TRUE,EXEFILE,C:\Temp\111111111111111111111\Release\Uncompressed\111111111111111111111.exe,WINDOWHANDLE,0,CHARSET_OVERRIDE,,MAINTENANCE,FALSE,NEEDSUPGRADE,FALSE,GPOPATH,,ZULU999,"Hello there, I am Zulu Bambulu!",NATIVE_ROLLBACK,TRUE,MINIMUM,FALSE,MYAH_thMin,0,ABORTONERROR,TRUE,NATIVE_OVERWRITE_OLDER,FALSE,PROGRESS,0,NATIVE_OVERRIDE_PERMISSIONS,FALSE,NATIVE_PROGRESS,0,ALLUSERS,TRUE,PERSONALIZED,FALSE,SILENT,FALSE,FXGROUND,BACKGROUND,ABORT,FALSE,IISHOST,localhost,MSIFILE,C:\Users\Peter\AppData\Local\Temp\mia1\111111111111111111111.msi,SFXFILE,,NATIVE_OVERWRITE,PROMPT,MYAH_COMPRESS_INSTALLER_CACHE,FALSE,NEWINSTANCE,FALSE,RECOMMENDEDUPGRADE,FALSE,PRODUCTCODE,{67E0900B-5467-42B7-AEAE-E27B46D44FA1},REBOOTNOW,OK,SFXPATH,,FX,SLIDE,MODIFY,TRUE,USERCOMPANY,,COPYWEBLOCK,,UNINSTALLLINK,C:\ProgramData\{3997EFC8-5CFA-4192-922C-31DBE049DA30}\111111111111111111111.exe,MYAH_LastActiveTick,17198689,MYAH_LastDelegateTick,17198689,MYAHLOGO,,REBOOTCOMPUTER,FALSE,LASTERROR,,NATIVE_ERROR,PROMPT,MYAH_DISABLE_VISTA_RESTART_MANAGER,FALSE,DATADIR,C:\Temp\111111111111111111111\Release\Uncompressed\data\,GLASS,TRUE,DELAYUNTIL_APPLYCHANGES,FALSE,CUSTOM_TASKBAR_PROGRESS_ENABLED,FALSE,SELECTED,0,MYAH_TIMEOUT,10,MYAH_IsCancelled,FALSE,MYAH_thCancelled,FALSE,MYAH_thProgressText,,DATE,11/04/2016,ADVERTISE,FALSE,TITLE,111111111111111111111,CMDLINE,,LICENSE,FALSE,PROGRESSMODE,,OVERRIDECACHE,,NATIVE_ENGINE,FALSE,ENGINECACHE,C:\ProgramData\{3997EFC8-5CFA-4192-922C-31DBE049DA30}\,NATIVE_LOGGING,,SETUPPATH,$EXEDIR$,CUSTOM_TASKBAR_PROGRESS_MAX,100,NATIVE_HARDLINK,TRUE,MYAH_DISABLE_ROLLBACK,FALSE,VERSION,1,RUNAPP,TRUE,SAVEDATA,FALSE,SUPPORTDIR,C:\Users\Peter\AppData\Local\Temp\mia1\,TEMPDIR,C:\Users\Peter\AppData\Local\Temp\,ROOTDIR,C:\Temp\111111111111111111111\Release\Uncompressed\,NATIVE_OVERRIDE_NON_RESTORABLE_PERMISSIONS,FALSE,MYAH_thProgress,0,LOGGED,,CUSTOM_TASKBAR_PROGRESS_PERCENT,0,PROGRESSTEXT,,LANGUAGE,,TIME,21:29:50,NEWLINE,"",FXTIME,1000,USERNAME,Peter,REVISIONCODE,{3997EFC8-5CFA-4192-922C-31DBE049DA30},STARTMENU,111111111111111111111,NATIVE_OLDLOG,,X,01,MYAH_thMax,100,COMPANY,

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

Damien
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^^)

bokkie
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

Damien,

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 38 guests