home *** CD-ROM | disk | FTP | other *** search
- /*
- SetsEntryRange.rexx
- */
- options results
- address PCALC
-
- 'current'
- range = result
-
- colon = pos(':', range)
-
- if colon = 0 then
- do
- 'DrawMessage' "Please select a range before executing this script"
- exit
- end
-
- 'GetString' "Proceed Horizontally or vertically? H/V"
- if upper(result) = V then
- direction = V
- else
- direction = H
-
- 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)
-
- if direction = H then
- do row = start_row to end_row
- do col = start_col to end_col
- 'position' makecell(row, col)
- 'GetString' "Entry Data and Press Return"
- data = result
-
- if data = 'RESULT' then exit
- if data ~= "" then
- 'PutCell' data
- end
- end
- else
- do col = start_col to col
- do row = start_row to end_row
- 'position' makecell(row, col)
- 'GetString' "Entry Data and Press Return"
- data = result
-
- if data = 'RESULT' then exit
- if data ~= "" then
- 'PutCell' data
- end
- end
-
- 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
-
-