(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
program edit(input,output);

const
   COLLAPSE = 2;
   TRIM = 8 + 128;
   COMPRESS = 16;
   UPCASE = 32;
   QUOTE = 256;

type
   varstr = varying[255] of char;

[external]
function dbasic$edit(%DESCR newstr : varstr;
                     %DESCR oldstr : varstr;
                     %IMMED editlist : integer) :  integer; external;

procedure test(s : varstr; editlist : integer);

var
   res : varstr;

begin
   dbasic$edit(res, s, editlist);
   writeln('|' + s + '| -> |' + res + '|');
end;

begin
   test('Test', UPCASE);
   test(' X ', TRIM);
   test('X   X', COMPRESS);
   test('X X X', COLLAPSE);
   test(' x  x  x ', COMPRESS + TRIM + UPCASE);
   test('x x " x x " x x', COLLAPSE + UPCASE);
   test('x x " x x " x x', COLLAPSE + UPCASE + QUOTE);
end.
