/* Send a file out VLT 4.824 with delay-per-char, delay-per-line, and
   empty lines padded with spaces.  Currently all adjustment settings are
   compiled in.  Change the next few lines to adjust them. */

bunch = 6
linedelay = 15

/* it turns out that calling Delay between individual characters is
   ridiculous -- rexx is so farkin slow that just sending the characters
   one at a time with no delay is slower than we probably want!  So the
   number bunch above is: how many characters do we send in one batch
   with no internal delays? */

parse arg filename .

if ~show('P', 'VLT') then do
    exit 30
end

if ~open(foo, filename, 'Read') then do
    exit 20
end

if ~show('l','rexxsupport.library') then
    if ~addlib('rexxsupport.library',0,-30) then do
        exit 40
    end

if show('Ports', 'Cap2Uedit-signal') then
    address 'Cap2Uedit-signal' foo

address VLT 'activate vt100'

do while ~eof(foo)
    line = readln(foo)
    l = length(line)
    if l = 0 then address VLT send raw '" "'
    else do i = 0 to (l - 1) / bunch
        if l < bunch then address VLT send '"'right(line, l)'"'
        else address VLT send '"'substr(line, i * bunch + 1, bunch)'"'
        l = l - bunch
    end

    address VLT send '"*r*n"'
    if ~(linedelay == 0) then call Delay(linedelay)
end

call close(foo)
