CONTROL Statement

bjdobs

New Member
I'm wondering if there is a startup switch that tells Progress to treat (##) as a character with ## as a decimal value (with the CONTROL Statement)?

If so can this parameter be turned on and off from an active program?

I am attempting to use an existing printer control codes table to dynamically bold parts of an existing report.

Maintaining a character base DB in Progress 8x ... the printer setup strings have all been stored in a table using decimal values for control characters ie (27) is being used as an ESC.

These strings are being used by a background print process written in 4GL and are used in the following way:

PUT CONTROL tablename.fieldname.

where the field name is type character and contains (27)(40)s3B
as an example.

If I take either the example string or the data from the print string table and attempt to use this command in the RRE there is no conversion done, however the background process appears to work if there is a CONTROL statement as the first output to the stream .... however the following code also does not work in the background process.

PUT STREAM streamname UNFORMATTED "foo".
PUT STREAM streamname CONTROL "(27)(40)s3B".
PUT STREAM streamname UNFORMATTED "Bold Foo".
PUT STREAM streamname CONTROL "(27)(40)s0B".

I did use the octal ~033 example and CONTROL appears to convert this properly all the time. Problem is the entire 4000 plus print string table would need to be converted from the (##) format to octal ... which isn't an option.
 

bjdobs

New Member
Extreme egg on face ... great way for starting a new forum

(##) does NOT convert with CONTROL ... a background process converted this string and stored to another field in raw format

Sorry to clutter the forum
 
I know it's just a work around, but here is a function that converts your "(D)" format to "~0O". You can run it over your database fields or use:

PUT STREAM streamname CONTROL FixFmt(Tablename.Fieldname).


Code:
function DecToOct returns char (ipi_value as int):
  def var lc_result as char.
  def var li_remainder as int.

  do while ipi_value >= 1:
    li_remainder = ipi_value mod 8.
    lc_result = string(li_remainder) + lc_result.
    ipi_value = ipi_value / 8.
  end.

  return lc_result.
End Function.

function FixFmt returns char (ipc_string as char):
    def var li_cnt as int no-undo.
    def var lc_word as char no-undo.
    def var li_decval as int no-undo.
    def var lc_result as char no-undo.

    if num-entries(ipc_string, "(") = 1 then
        return ipc_string.

    do li_cnt = 1 to num-entries(ipc_string, "("):
        lc_word = entry(li_cnt, ipc_string, "(").
        if num-entries(lc_word, ")") > 1 then
        do:
            li_decval = int(entry(1, lc_word, ")")) no-error.
            if error-status:error then do:
                lc_result = lc_result + "(" + lc_word.
                next.
            end.
            lc_result = lc_result + "~~0" + DecToOct(li_decval) +
                entry(2, lc_word, ")").

        end.
        else lc_result = lc_result + "(" + lc_word.

    end.
    return substring(lc_result, 2).
end Function.
 
Top