home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / ronheb.zip / RONMEMO.PRG < prev   
Text File  |  1988-03-22  |  14KB  |  511 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. * --  ÜîüéàÄ ,ìëïæÄ 'æÄ ëÉö îÆ (ÜàïàÿÇ ÜàÇÿÖÿÖ) àÄÄ-ëÉÜÖÄ ÜïëÿÆ ÜëûùÉàö
  7. * --     ÜÇ ìëÿêÄÿöï ÜîüùÄ .äéûä/äïëÿÆî Åàîç ÜçÜàö .ÜàÿàÖ 66-î ÜëÜàÿëÿÖ
  8. * --    ÜâÆàëÄ .äïëÿÆ-Üëéàî äëûùëâÉëÇ,Åàîçä ìàùëÄ,äéûä/äïëÿÆî äÉÜÖÄä ìÖ
  9. * --   äÿàûü ùåçàÄ äÉÜÖÄä .ìëïàÿÇ ìëëÿüÆ ÜàâÖ ÿàüÆ MEMOEDIT() ÜÇ ôëîçäî
  10. * --                                                          .INVERTED
  11. * -- edit_var=hebedit('edit_var',ltrow,ltcol,rtrow,rtcol,update) äÇëÿùä
  12.  
  13. function hebedit
  14.  
  15. parameters txtname,ltrow,ltcol,rtrow,rtcol,updt
  16.  
  17. txt=&txtname
  18.  
  19. width=rtcol-ltcol-4
  20. rows=rtrow-ltrow-1
  21. if (width<1).or.(width>75).or.(rows<1).or.(rows>66)
  22.    return(txt)
  23. endif
  24. rhcolor=setcolor()
  25. rhcolour()
  26.  
  27. declare edbak[rows]
  28.  
  29. if updt
  30.    @ 24,0 say " äÇëûë<-ESC │ ìàëæ<-^END │ äÿàÖ îêü/ôæàä<═╝/BS│ ÿàçÇî èæÄ<-PgUp│ äÄëâù èæÄ<-PgDn"
  31. else
  32.    @ 24,0 say " äÇëûë<-ESC                               ÿàçÇî èæÄ<-PgUp       äÄëâù èæÄ<-PgDn "
  33. endif 
  34.  
  35. setcolor(rhcolor)
  36. @ ltrow,ltcol clear to rtrow,rtcol
  37. @ ltrow,ltcol to rtrow,rtcol
  38.  
  39. rhmemoact=0
  40. rhstrt=0
  41. rowstrt=1
  42. rhpgsize=66
  43. do while .t.
  44.    subtxt=rhhmed(substr(txt,rhstrt*width+1,rows*width))
  45.  
  46.    do case
  47.  
  48.       case rhmemoact=3
  49.          if updt
  50.             txt=left(txt,rhstrt*width)+subtxt+;
  51.             substr(txt,(rhstrt+rows)*width+1,max(len(txt)-(rhstrt+rows)*width,0))
  52.          endif
  53.          rhstrt=iif((rhstrt+rows)*width<len(txt),rhstrt+rows,len(txt)/width)
  54.          rowstrt=1
  55.  
  56.       case rhmemoact=18
  57.          if updt
  58.             txt=left(txt,rhstrt*width)+subtxt+;
  59.             substr(txt,(rhstrt+rows)*width+1,max(len(txt)-(rhstrt+rows)*width,0))
  60.          endif
  61.          rhstrt=iif(rhstrt>=rows,rhstrt-rows,0)
  62.          rowstrt=1
  63.  
  64.       case rhmemoact=23
  65.          if updt
  66.             txt=left(txt,rhstrt*width)+subtxt+;
  67.             substr(txt,(rhstrt+rows)*width+1,max(len(txt)-(rhstrt+rows)*width,0))
  68.          endif
  69.          return(txt)
  70.          rowstrt=1
  71.  
  72.       case rhmemoact=27
  73.          txt=&txtname
  74.          return(txt)
  75.  
  76.       otherwise
  77.          if updt
  78.             txt=left(txt,rhstrt*width)+subtxt+;
  79.             substr(txt,(rhstrt+rows)*width+1,max(len(txt)-(rhstrt+rows)*width,0))
  80.          endif
  81.  
  82.    endcase
  83.  
  84. enddo
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. function rhhmed
  94. parameters rhremain
  95. private i,y,z,rhsubst,carrystr
  96. y=0
  97. * fill arrays and take care of word-wrapping
  98. for i=1 to rows
  99.    rhsubst=substr(rhremain,1,width)
  100.    z=len(rhsubst)
  101.    y=y+z
  102.    rhremain=substr(rhremain,z+1,len(rhremain)-z)
  103.    edbak[i]=space(width-z)+inv(rhsubst)
  104. next
  105. carrystr=""
  106.  
  107. do while .t.
  108.    @ ltrow+1,ltcol+1 clear to rtrow-1,rtcol-1
  109.    for i=1 to rows
  110.       rhcolour()
  111.       @ ltrow+i,ltcol+4 say edbak[i]
  112.       setcolor(rhcolor)
  113.       @ ltrow+i,ltcol+1 say str(iif((rhstrt+i)!=rhpgsize,;
  114.       (rhstrt+i)%rhpgsize,rhpgsize),2)+"<" 
  115.    next
  116.    if updt
  117.       rhcolour()
  118.       h=1
  119.       v=rowstrt
  120.       @ ltrow+v,rtcol-1 say ""
  121.       ins=.f.
  122.       rhact=.f.
  123.       tmp=edbak[v]
  124.       carrystr=""
  125.       do while .t.
  126.          if rhact
  127.             for i=1 to rows
  128.                @ ltrow+i,ltcol+4 say edbak[i]
  129.             next
  130.             @ ltrow+v,rtcol-h say ""
  131.             rhact=.f.
  132.          endif
  133.  
  134.          inkey(0)
  135.          l=lastkey()
  136.          do case 
  137.             case l>31
  138.                if h>width
  139.                   if v<rows
  140.                      edbak[v]=tmp
  141.                      * check word-wrapping
  142.                      atspace=at(" ",tmp)
  143.                      if (substr(tmp,1,1)>" ").and.(atspace>0)
  144.                         carrystr=" "+htrans(l)+substr(tmp,1,atspace-1)
  145.                         h=atspace+1
  146.                         i=v
  147.                         do while !empty(carrystr)
  148.                            edbak[i]=stuff(edbak[i],1,atspace-1,space(atspace-1))
  149.                            i=i+1
  150.                            if i<=rows
  151.                               edbak[i]=edbak[i]+carrystr
  152.                               carrystr=""
  153.                               atspace=at(" ",edbak[i])
  154.                               if atspace>0
  155.                                  carrystr=" "+substr(edbak[i],1,atspace-1)
  156.                               endif
  157.                               edbak[i]=substr(edbak[i],len(edbak[i])-width+1,width)
  158.                            else
  159.                               rhremain=inv(carrystr)+rhremain
  160.                               carrystr=""
  161.                               exit
  162.                            endif
  163.                         enddo
  164.                         v=v+1
  165.                         tmp=edbak[v]
  166.                         rhact=.t.
  167.                         loop
  168.                      else
  169.                         v=v+1
  170.                         tmp=edbak[v]
  171.                         ins=.f.
  172.                         h=1
  173.                      endif
  174.                   else
  175.                      h=width
  176.                      ?? chr(7)
  177.                      loop
  178.                   endif
  179.                endif
  180.    
  181.                tmprvar=htrans(l)
  182.                if .not.ins
  183.                   tmp=substr(tmp,1,width-h)+tmprvar+substr(tmp,width-h+2,h-1)
  184.    
  185.                   * htrans will transform an inkey() value into
  186.                   * corresponding hebrew set charecter by substr a charecter-list string.
  187.    
  188.                   * if .not. ins then say tmp[i] and cursor only. else say by arraysay 
  189.                   * after ains with pos=i+1
  190.    
  191.                   @ ltrow+v,rtcol-h say tmprvar
  192.                   h=h+1
  193.                   @ ltrow+v,rtcol-h say ""
  194.                   loop
  195.                else
  196.                   * check word-wrapping
  197.                   atspace=at(" ",tmp)
  198.                   if (substr(tmp,1,1)>" ").and.(atspace>0)
  199.                      carrystr=" "+substr(tmp,1,atspace-1)
  200.                      edbak[v]=tmp
  201.                      i=v
  202.                      do while !empty(carrystr)
  203.                         edbak[i]=stuff(edbak[i],1,atspace-1,space(atspace-1))
  204.                         i=i+1
  205.                         if i<=rows
  206.                            edbak[i]=edbak[i]+carrystr
  207.                            carrystr=""
  208.                            atspace=at(" ",edbak[i])
  209.                            if atspace>0
  210.                               carrystr=" "+substr(edbak[i],1,atspace-1)
  211.                            endif
  212.                            edbak[i]=substr(edbak[i],len(edbak[i])-width+1,width)
  213.                         else
  214.                            rhremain=inv(carrystr)+rhremain
  215.                            carrystr=""
  216.                            exit
  217.                         endif
  218.                      enddo
  219.                      rhact=.t.
  220.                      tmp=edbak[v]
  221.                      tmp=substr(tmp,2,width-h)+tmprvar+substr(tmp,width-h+2,h-1)
  222.                      h=h+1
  223.                      loop
  224.                   else
  225.                      tmp=substr(tmp,2,width-h)+tmprvar+substr(tmp,width-h+2,h-1)
  226.                      @ ltrow+v,rtcol-width say substr(tmp,1,width-h+1)
  227.                      h=h+1
  228.                      @ ltrow+v,rtcol-h say ""
  229.                      loop
  230.                   endif
  231.                endif
  232.  
  233.             case (h=1).and.(l=8)
  234.                adel(edbak,v)
  235.                rowstrt=v
  236.                rhmemoact=8
  237.                result=""
  238.                for i=1 to rows-1
  239.                   result=result+inv(edbak[i])
  240.                next
  241.                result=result+rhremain
  242.                setcolor(rhcolor)
  243.                return(result)
  244.  
  245.             case (ins).and.(l=13)
  246.  
  247.                rhremain=inv(edbak[rows])+rhremain
  248.                ains(edbak,v)
  249.                edbak[v]=space(width)
  250.                tmp=space(width)
  251.                rhact=.t.
  252.                loop
  253.       
  254.             case l=4  && rt arrow
  255.                if h>1
  256.                   h=h-1
  257.                else
  258.                   if v>1
  259.                      edbak[v]=tmp
  260.                      v=v-1
  261.                      tmp=edbak[v]
  262.                      ins=.f.
  263.                      h=width
  264.                   else
  265.                      ?? chr(7)
  266.                      h=1
  267.                   endif
  268.                endif
  269.                * say cursor only
  270.                @ ltrow+v,rtcol-h say ""
  271.                loop
  272.    
  273.             case l=19 && lt arrow
  274.                if h<width
  275.                   h=h+1
  276.                else
  277.                   if v<rows
  278.                      edbak[v]=tmp
  279.                      v=v+1
  280.                      tmp=edbak[v]
  281.                      ins=.f.
  282.                      h=1
  283.                   else
  284.                      h=width
  285.                      ?? chr(7)
  286.                   endif
  287.                endif
  288.                * say cursor only
  289.                @ ltrow+v,rtcol-h say ""
  290.                loop
  291.  
  292.             case l=13
  293.                if v<rows
  294.                   edbak[v]=tmp
  295.                   v=v+1
  296.                   tmp=edbak[v]
  297.                   ins=.f.
  298.                endif
  299.                h=1
  300.                @ ltrow+v,rtcol-h say ""
  301.                loop
  302.                
  303.             case l=22 && insert
  304.                ins=iif(ins,.f.,.t.)
  305.                loop
  306.    
  307.             case l=7  && del
  308.                tmp=" "+substr(tmp,1,width-h)+substr(tmp,width-h+2,h-1)
  309.                @ ltrow+v,rtcol-width say tmp
  310.                @ ltrow+v,rtcol-h say ""
  311.                loop
  312.            
  313.             case l=5  && up arrow
  314.                if v>1
  315.                   edbak[v]=tmp
  316.                   v=v-1
  317.                   @ ltrow+v,rtcol-h say ""
  318.                   tmp=edbak[v]
  319.                   ins=.f.
  320.                endif
  321.                loop 
  322.  
  323.             case l=24 && down arrow
  324.                if v<rows
  325.                   edbak[v]=tmp
  326.                   v=v+1
  327.                   tmp=edbak[v]
  328.                   @ ltrow+v,rtcol-h say ""
  329.                   ins=.f.
  330.                endif
  331.                loop
  332.  
  333.             case l=8  && backspace
  334.                h=h-1
  335.                tmp=substr(tmp,1,width-h)+" "+substr(tmp,width-h+2,h-1)
  336.                @ ltrow+v,rtcol-width say tmp
  337.                @ ltrow+v,rtcol-h say ""
  338.                loop
  339.            
  340.             case l=1
  341.                h=1
  342.                @ ltrow+v,rtcol-h say ""
  343.                loop
  344.  
  345.             case l=2
  346.                loop
  347.             case l=26
  348.                loop
  349.             case l=29
  350.                loop
  351.             case l=30
  352.                loop
  353.             case l=31
  354.                loop
  355.    
  356.             case l=27
  357.                rhmemoact=27
  358.                setcolor(rhcolor)
  359.                return(" ")
  360.    
  361.             case l=3  && pgdn
  362.                edbak[v]=tmp
  363.                rhmemoact=3
  364.                return(rhedrslt())
  365.  
  366.             case l=18 && pgup
  367.                edbak[v]=tmp
  368.                rhmemoact=18
  369.                return(rhedrslt())
  370.  
  371.             case l=23
  372.                edbak[v]=tmp
  373.                rhmemoact=23
  374.                return(rhedrslt())
  375.    
  376.             otherwise
  377.                * check for pre-defined hot-keys
  378.                if !(rhsk[l+40]=="")
  379.                   dorhsk=rhsk[l+40]
  380.                   setcolor(rhcolor)
  381.                   do &dorhsk with prg,0,txtname
  382.                   rhcolor=setcolor()
  383.                   rhcolour()
  384.                   @ ltrow+v,rtcol-h say ""
  385.                   ins=.f.
  386.                   loop
  387.                endif
  388.          endcase
  389.       enddo
  390.  
  391.    else
  392.  
  393.       inkey(0)
  394.       do case
  395.          case lastkey()=3
  396.             rhmemoact=3
  397.             return(" ")
  398.          case lastkey()=18
  399.             rhmemoact=18
  400.             return(" ")
  401.          case lastkey()=27
  402.             rhmemoact=27
  403.             return(" ")
  404.       endcase
  405.  
  406.    endif
  407. enddo
  408.  
  409.  
  410.  
  411.  
  412. function rhedrslt
  413. private i,y
  414. i=rows
  415. if empty(rhremain)
  416.    do while i>0 
  417.       if !empty(edbak[i])
  418.          exit
  419.       endif
  420.       i=i-1
  421.    enddo
  422. endif
  423. for y=i to 1 step -1
  424.    rhremain=inv(edbak[y])+rhremain
  425. next
  426. setcolor(rhcolor)
  427. return(rhremain)
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435. *  -- (âàÄÆ îâàé) ÜàÿàÖ 66-î ÜëÜàÿëÿÖ ÜîüéàÄ .ìëïàÿÇ ìëëÿüÆ ÜàâÖî äæöâä ÜëûùÉàö
  436. *  --          hebprn(äæöâäî äâÖä ìÖ,ìëëîÇÄÖ ìëëîàÖ,ìëëÉÄë ìëëîàÖ) :äÇëÿùä Üÿàû
  437.  
  438. function hebprn
  439.  
  440. parameters txt,ltmargin,rtmargin
  441. declare edarray[67]
  442. width=80-rtmargin-ltmargin
  443. if width>75
  444.    return(.f.)
  445. endif
  446. rows=iif((len(txt)/width)>int(len(txt)/width),int(len(txt)/width)+1,;
  447. len(txt)/width)
  448. afill(edarray,space(width))
  449. y=1
  450. for i=1 to rows
  451.    edarray[i]=edarray[i]+inv(substr(txt,y,width))
  452.    edarray[i]=substr(edarray[i],len(edarray[i])-width+1,width)
  453.    y=y+width
  454. next
  455. for i=1 to rows
  456.    @ prow(),ltmargin say edarray[i]
  457.    @ prow()+1,0 say ""
  458. next
  459. eject
  460. return(.t.)
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467. function hebmac
  468. *  --    ëÿüÆ àÄÄ äâÖî àÿùÄ .ìëëÿüÆ àÄÄ ÜàâÖü 'àÿùÄ ÜçëÜöî ÜÇå äëûùÉàö
  469. *  --  ìëÄëÇÜÄ ìëçààÿ ÿÇÖàäÖ äçëÉÄ äçëÜöä .îëéÿ Åààïü { } Åëü îÆ ÅëàûÄ
  470. *  --                                                          .ÜàÿàÖü
  471. parameters txt
  472. z=1
  473. i=0
  474. y=0
  475. head=""
  476. tail=txt
  477. do while len(tail)>0
  478.    i=at("}",tail)
  479.    y=at("{",tail)
  480.    if (i=0).or.(y=0)
  481.       head=head+tail
  482.       tail=""
  483.       exit
  484.    endif
  485.    if y<i
  486.       head=head+substr(tail,1,i)
  487.       tail=substr(tail,i+1,len(tail)-i)
  488.       loop
  489.    endif
  490.    mac=inv(substr(tail,i+1,2))
  491.    xpand=y-i+1
  492.    spand=space(xpand)
  493.    do case
  494.       case type('&mac')='C'
  495.          xval=inv(right(ltrim(trim(&mac)),min(xpand,len(ltrim(trim(&mac))))))
  496.       case type('&mac')='N'
  497.          xval=inv(left(ltrim(str(&mac)),xpand))
  498.       case type('&mac')='D'
  499.          xval=inv(left(dtoc(&mac),xpand))
  500.    endcase
  501.    tail=stuff(tail,i,xpand,stuff(spand,1,len(xval),xval))
  502.    head=head+substr(tail,1,i+xpand-1)
  503.    tail=substr(tail,i+xpand,len(tail)-i-xpand+1)
  504. enddo
  505. txt=head
  506. return(txt)
  507.  
  508.  
  509.  
  510.  
  511.