Page 1 of 1
Strange characters in LUA strings
Posted: 21 Jan 2012 08:21
by TSG
This maybe a LUA bug rather than FH but if I do:
fhSetValueAsText(objFILE, 'C:UsersTestPicturesbag.jpg')
LUA sets the objFILE value to:
C:UsersTestPictures[?]ag.jpg
(where ? is a strange character rendered as a black box with a circle in it)
This can be seen in the debug variables window and is also the value put into the multimedia record in FH.
ID:5836
Strange characters in LUA strings
Posted: 21 Jan 2012 08:22
by TSG
PS: I have only noticed this since 5.0.0.5. I *believe* it was working OK before but cannot guarantee it.
Strange characters in LUA strings
Posted: 21 Jan 2012 10:13
by SimonOrde
This isn't a bug - it's a feature of Lua. Within Lua, the backslash character '' has a special role in strings (as it does in other programming languages like C and C++). For example, 'n' means the newline character and 't' means a tab character. If you want to put a backslash into a string, you have to double it up to remove its special meaning. i.e. the line you needed was this:
fhSetValueAsText(objFILE, 'C:\Users\Test\Pictures\bag.jpg')
If you use that, the correct value 'C:UsersTestPicturesbag.jpg' will be inserted.
In case anyone reading this doesn't know what a 'string' is, incidentally, it means text in quotes.
Strange characters in LUA strings
Posted: 21 Jan 2012 11:32
by Jane
Just to add to this, the escaping of the is only needed if you are entering the string directly in the source code, if you are prompting for a file name or obtaining it from iup.getfile or similar it can be entered as normal.
This is detailed on the Lua Quickstart page in the plugin help.