Skip to Content
avatar image
Former Member

How to process a file with control characters?

Hello I have a problem with reading and processing files. Maybe somebody knows a solution. My task is to load a .prn file and replace a special string with a calculated value. (Search for '<<FS_REPLACE>>') And then write the finished file away. In the file to be read many ascii-control character are included. Which cause problems in LineMode! or TextMode!. What has worked was the reading the whole file in BLOB. The conversion Blob -> String has unfortunately not worked. And in a blob you can replace (BlobEdit()) but you cannot search for a string. Has anyone an idea what I could try next? I hope I have made myself clear greetings Stefan Malkwitz

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 09, 2017 at 07:00 AM

    You could write a function in C and create a DLL to use in Powerbuilder. I think this would be the fastest method.

    If you prefer to do it with Powerbuilder: I think you could encode the blob with a method that creates a string. URL-Encode would be useable because each byte is encoded separately.

    Encode the BLOB, the string you want to find and the string you want to replace with. Then you can use the string functions for replace.

    Finally you have to URL-Decode the result to a blob.

    Look here for a string based function for URL-Encode. I think you can simply rewrite it for BLOB.

    http://pfc.codeplex.com/SourceControl/latest#12.5/pfcapsrv/pfc_n_cst_string.sru

    I don't have a function for URL-Decode but I think it is not difficult to write it.

    HTH,

    René

    Add comment
    10|10000 characters needed characters exceeded