Conversion from string to media

Is it possible to put a string directly (using some function) in a media-field instead of first generating a temporary textfile and then read it binary?

_my_string = "bladiebla"
tempFile = plugins.file.createTempFile('memo','.tmp');	
success = plugins.file.writeTXTFile(tempFile, _my_string, 'ISO8859_1')
foundset.memo_field = plugins.file.readFile(tempFile.getPath())

We want this for conversion because our foxpro database-driver treats the memo-fields as a string.

why MEDIA?
you can also create TEXT columns instead of varchar.
just create a TEXT column in Servoy (with very large number) it will automaticly create a TEXT column for you in the DB (in case of Sybase)

Because in the foxpro table this field can also contain binary data (like an image or a word document), the foxpro driver presents this as a string to me. But in servoy and the sybase database I want store this data in a media-field.

There are major complications when storing text in binary, to be able to store as binary you have to use character encodings … you don’t want to get into character encoding problems.
Do keep text as text and leave char encoding to Java/database diriver and make sure database is running in UTF (as Servoy by default does)

Not that I want it, but I cannot tell the databasedriver (HXTT) to see the foxpro MEMO-field as a servoy MEDIA-field, instead of that it is treated as a TEXT(0) field. So in order to do my conversion from foxpro to sybase I have to do conversion from string to media…
In the samplecode the conversion is done correctly, but for performance reasons I don’t want to do this using a temporary file.

Michel,

try this: var doc = new java.lang.String(documents_to_templates.template)

in this case template is MEDIA field, which I get an RTF document. (TEXT)

Hope this helps

Both last posts (temp file and java String workarrounds) assume the binary format of the string being encoded in default (OS specific) charset…this is very likly NOT the case, leading to character conversion problems!!