/* Export data to Diagramprogram V0.8 020694 */ options results If ~show('p','PCALC') Then do address 'DPort.1' Message "You must run first ProCalc!" exit end If ~show('p','DPort.1') Then do DrawMessage "You must run Diagramprogram first!" exit end SAY "This program fetch the current block from PROCALC." address PCALC 'current' range = result colon = pos(':', range) if colon = 0 then do address 'DPort.1' Message "Please select a range before executing this script" exit end 'current' range = result start_cell = substr(range, 1, colon - 1 ) end_cell = substr(range, colon + 1 ) start_row = cellrow(start_cell) end_row = cellrow(end_cell) start_col = cellcol(start_cell) end_col = cellcol(end_cell) dnr=1; /* Find startchar */ sch=65+32; RC=0; ADDRESS 'DPort.1' do while(RC=0) SetDS d2c(sch)||1 sch=sch+1 end sch=sch-1 ADDRESS 'PCALC' do col = start_col to end_col ADDRESS 'DPort.1' 'createset' d2c(sch)||dnr say 'Coloum : '||col||' Name : '||d2c(sch)||dnr dnr=dnr+1 do row = start_row to end_row 'position' makecell(row, col) 'IsValue' if result then do 'GetValue' px = result ADDRESS 'DPort.1' "adddata "||px end else do 'GetLabel' px = result ADDRESS 'DPort.1' "adddata "||px end end end SelectRange range ADDRESS 'DPort.1' DToFront; Refresh; ADDRESS COMMAND "c:wait 1" exit cellrow: procedure do parse arg cell do charpos = 2 to length(cell) if datatype( substr(cell, charpos, 1), n ) then return substr(cell, charpos) end return 0 end cellcol: procedure do parse arg cell labels = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" cell = upper(cell) len = length(cell) val = 0 do charpos = 1 to len if datatype( substr(cell, charpos, 1), n ) then do cell = reverse(substr(cell, 1, charpos - 1)) do x = 1 to length(cell) val = (26 ** (x - 1)) * pos(substr(cell, x, 1), labels) + val end return val end end return 0 end makecell: procedure do parse arg row, col label = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* no extensive mathematical functions built into arexx, so lets just * calculate the column in a loop */ column = "" do while col > 0 mod = col // 26 col = col % 26 column = column || substr(label, mod, 1) end return reverse(column) || row end