Strings and Databases.

cwilms's picture

Hello Kineme community! My name is Chris and I am the Audio Visual Technology Analyst for Loyalist College. I have a question about a fairly complex composition for Live Graphics that I am developing... and struggling with. I am hoping some brilliant mind out there can help me find a solution. :)

Basically I am using a datamatrix code over video as an input to generate a string. This string is then broken down into sub-strings that I can use to create text graphics via several "Image With String" patches. With some help I have been able to get the datamatrix working and have been able to separate all the substrings. The problem is that one of the substrings is 4 character "code" (i.e. CNTP, GAGC, PREH etc...) and depending on what that 4 character code is it needs to be replaced with 1 of 100 different predefined text strings as well as trigger a corresponding graphic to be displayed. Also this list of character codes and what string needs to replace it needs to be easily updated as there are often last minute changes to this list that may occur.

My thoughts were that I would have this list in a database form that can be easily queried to pull the proper replacement string. Whatever the solution it needs to be, stable and reliable, 64bit compatible, and call from a local database.

I am running: OSX 10.7.3 QC 4.6 (64bit) MacBook Pro, 2.2GHz i7, 16GB RAM

lookitscook's picture
Re: Strings and Databases.

I probably wouldn't mess with full db access. XML file would likely be simpler. If you need the content management side: Drupal does a great job for data input.. and you can use a view to output dynamic XML. Then you can save that XML as a file and your app is no longer coupled to a db (if needed).

cwilms's picture
Re: Strings and Databases.

Thanks for the feedback! I did actually start looking into the XML Import patch which would be great if I can get a usable workflow out of it as my initial file is an excel spreadsheet which can easily be exported to XML. However in my experimenting with the XML Import Patch it returns the data based on an index input value, how can I convert about 100 known 4 digit codes into the appropriate index value to recall and display the proper information???

I'm graphically/artistically creative and technical, but not a programer so this stuff is stretching my brain a little. Please bear with me if I'm missing something obvious. :)

Alexander Mitchell's picture
Re: Strings and Databases.

Were you able to get something working? I notice that you posted re: Named Structure Maker?

What you are wanting to achieve can be achieved with a Javascript working like a lookup table:

Sudocode:

for(i=0; i<index.length; i++){ switch (string[i]){ case = "Value[i]": result = "changedText[i]"; break; default: "defaultText"; } }

Obviously this needs a bit of work,... however you will also have to feed in a table consisting of the values to be changed, and the new values.

cwilms's picture
Re: Strings and Databases.

No my last idea fell though... however after talking with a buddy at work yesterday he had the same suggestion you just gave, so now I'm waiting to see if one of the coding people here at work have the time to dabble in some Javascript for me.

Thanks for the suggestion, it was a good indicator that I'm on the right track now! :)

cwilms's picture
Re: Strings and Databases.

BTW Javascript was the right answer. It simplified things a great deal and just plain works. In fact once I had a friend write the script I realized I could use it in a different part of my composition as well and simplified things even further. Thanks for everyones feed back. Greatly appreciated. THis is such a helpful community.