home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0926.lha
/
JcGraph
/
Rexx
/
Graph_Advantage.rex
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-10-07
|
8KB
|
246 lines
/********************************************************************/
/* Graph_Advantage.rex */
/* ------------------- */
/* This script create a hot-link between JcGraph and Advantage */
/* so you can enter your data and use Advantage functions and ease */
/* of use and still have wonderfull JcGraph charts as output!!! */
/* You just have to execute it from Advantage after having selected */
/* the range of data you want to have a chart from... */
/* (ARexx -> Execute) */
/* PS You can change the Y ratio in varying the following variable. */
/* (100 to 1000) */
/********************************************************************/
UserCtrl=250
NbCotations=10
options results
address 'Advantage'
say '--------'
'DrawMessage'
"Working. Please wait..."
'Current' /* Determine current selected range. */
range = result
'GetValue'
value=result
colon_posn = pos(":",range) /* Look for colon delimiter in range. */
if colon_posn = 0 then /* If no colon, this is not a range. */
do /* Set the start and end cells to */
start_cell = range /* the selected cell. */
end_cell = range
end
else /* Otherwise, it is a range. */
/* Extract the start/end cells from the specified range. */
do
start_cell = left(range,colon_posn - 1)
end_cell = substr(range,colon_posn + 1)
end
start_column = GetColumn(start_cell) /* Determine range of columns */
end_column = GetColumn(end_cell) /* to be filled. */
start_row = GetRow(start_cell) /* Determine range of rows */
end_row = GetRow(end_cell) /* to be filled. */
st_etiq1=value(start_row)-1
st_etiq2=d2c(c2d(start_column)-1)
if open('tempo','T:Link','W') then do
writeln('tempo','1002,')
writeln('tempo',(c2d(end_column)-c2d(start_column)+1) || ',' || (end_row-start_row+1) || ',')
'GetValue'
highest=result
'DrawMessage'
"First pass. Please wait..."
/* First pass. Find the highest values... */
/* -------------------------------------- */
do rownum = start_row to end_row
column = start_column /* Reset column pointer. */
do until c2d(column) > c2d(end_column)
/* Build complete cell name from row and column. */
next_cell = column || rownum
/* Select the cell to be modified. */
'SelectCell'
value(next_cell)
'GetValue'
tempo=result
if value(abs(tempo)) > value(abs(highest)) then do
highest=tempo
end
/* Advance to the next column. */
column = NextColumn(column)
end
end rownum
rationalfactor=highest
multiplieurdonnees=UserCtrl/rationalfactor
writeln('tempo',abs(UserCtrl/NbCotations) || ',' || (1 / multiplieurdonnees) || ',' )
'DrawMessage'
"Second pass. Please wait..."
/* Second pass. */
/* ------------ */
do rownum = start_row to end_row
column = start_column /* Reset column pointer. */
do until c2d(column) > c2d(end_column)
/* Build complete cell name from row and column. */
next_cell = column || rownum
/* Select the cell to be modified. */
'SelectCell'
value(next_cell)
'GetValue'
tempo=result
/* Write to the temporary file. */
writeln('tempo',trunc(tempo * multiplieurdonnees + 0.5) || ',')
/* Advance to the next column. */
column = NextColumn(column)
end
end rownum
/* Third pass. Label names */
/* ----------------------- */
/* Columns */
/* ------- */
column = start_column /* Reset column pointer. */
do until c2d(column) > c2d(end_column)
/* Build complete cell name from row and column. */
next_cell = column || st_etiq1
/* Select the cell to be modified. */
'SelectCell'
value(next_cell)
'GetLabel'
tempo=result
/* Write to the temporary file. */
writeln('tempo',tempo || ',')
/* Advance to the next column */
column = NextColumn(column)
end
/* Rows */
/* ---- */
do rownum = start_row to end_row
/* Build complete cell name from row and column. */
next_cell = st_etiq2 || rownum
/* Select the cell to be modified. */
'SelectCell'
value(next_cell)
'GetLabel'
tempo=result
/* Write to the temporary file. */
writeln('tempo',tempo || ',')
end rownum
close('tempo')
/* Reselect the original range of cells. */
'SelectRange'
value(start_cell)
value(end_cell)
'DrawMessage'
"Sending to JcGraph. Please wait..."
address 'JCGRAPH'
'Open Filename=T:Link'
'ScreenToFront'
'requestnotify Your data has been transfered to JcGraph. You can do wathever you want with it now.'
end
exit /* That's all folks! */
/* ----------------------------------------------------------------- */
/* Internal Functions (subroutines) */
/* ----------------------------------------------------------------- */
/* == GetRow: Extract the row number from a cell name. == */
GetRow: procedure
arg CellName /* Function expects to be passed a cell name. */
/* Find the first numeric digit in the cell name. */
start_number = verify(CellName,"0123456789","Match")
/* Extract all characters starting at the first digit and continuing */
/* to the end of the cell name. */
rownum = substr(CellName,start_number)
return rownum
/* == GetColumn: Extract the column label from a cell name. == */
GetColumn: procedure
arg CellName /* Function expects to be passed a cell name. */
/* Find the first numeric digit in the cell name. */
start_number = verify(CellName,"0123456789","Match")
/* Extract all characters in the cell name up to the first numeric */
/* character (start of row number). */
column = left(CellName,start_number-1)
return column
/* == NextColumn: Given the current column label, determine the label == */
/* == for the next sequential column. NOTE: This is a == */
/* == recursive function. == */
NextColumn: procedure
arg ThisColumn /* Function expects to be passed a column label. */
/* If the column label is empty (null string), then we must be */
/* starting a new group of column labels (for example, going */
/* from column ZZ to column AAA. Return an "A". */
if length(ThisColumn) = 0 then
new_column = "A"
/* Otherwise, we must advance the last character in the column */
/* name to the next sequential alphabetic character. */
else
do
col_number = , /* Convert last character */
c2d( right(ThisColumn,1) ) /* to decimal value. */
col_number = col_number + 1 /* Increment to next character. */
new_char = d2c(col_number) /* Convert back to a character. */
/* If we've gone past 'Z', find the next column for the column */
/* label minus the last character and then append an "A" to */
/* this label (start of a new label set). */
if new_char > "Z" then
do
temp_column = left( ThisColumn, length(ThisColumn)-1 )
new_column = NextColumn(temp_column) || "A"
end
/* Otherwise, replace the last character of the column label */
/* with the next sequential character. */
else
new_column = overlay(new_char,ThisColumn,length(ThisColumn))
end
return new_column