'TRANSPOS - general program to transpose address lists etc from vertical format
'           to horizontal for reading into d'bases etc

external   messbox() progress() lpath fgi bgi fgp bgp wraptext() psa dpath
external   fentrybox()

public     ptstr topmat

global     S_S_Format() TransJobs() linecount #width
global     nextdatecell  thisdatecell thisline nextline x \
           newcell y1 y2 y3 y bsize z #bottom #fttrs #lines $sort \
           nextblock botmat

MAIN
single-step off
  screen clear box 1 1 25 80 0 0 no-border
  repaint off
  quiet on
  lpath = "C:\programs\lib\"
  load lpath|"displib.rf3" in-memory
  load lpath|"wraptext.rf3" in-memory
' enter width of columns
  #width = 40
' enter size of block
  bsize = 9
  load lpath|"uintlib.rf3" in-memory

  S_S_Format()

END MAIN


FUNCTION S_S_Format()                      ' set up format of s/s
  at r1c1
  layout cell-size width #width columns bsize
  sheet goto lower-edge                ' find Nr of rows in s/s
  #lines = row
  linecount = #lines/bsize             ' by repeat size
  TransJobs()
  at r1c1
END FUNCTION


FUNCTION TransJobs()
local    i botmat nextblock cc cr
  at r1c1
  for i = 1 to linecount
    topmat = i                         'message "topmat is:"&str(topmat)
    botmat = topmat + (bsize-1)        'message "botmat is:"&str(botmat)
    nextblock ="r"|str(topmat)|":"|str(botmat)|"c1"
    sheet matrix transpose nextblock   ' transpose Job Nr's

    newcell = "r"|str(topmat)|"c1"     'go back to prev. pos'n
    cursor down
    edit delete rows bsize-1
    sheet goto cell newcell
    cursor down
  end for
END FUNCTION ' TransJobs()
