home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxedit03.zip / RxEdit.CMD
OS/2 REXX Batch file  |  1998-05-24  |  25KB  |  673 lines

  1. /****************************** RxEdit.CMD *********************************/
  2. /*                                                                         */
  3. /* The four functions                                                      */
  4. /*                                                                         */
  5. /*      EditChar(), EditCharC(), EditStr(), EditStrC()                     */
  6. /*                                                                         */
  7. /* allow to edit uncolored and colored characters and strings.             */
  8. /*                                                                         */
  9. /*  1.                                                                     */
  10. /*  ch=EditChar()                                                          */
  11. /*  stores a single character in  ch                                       */
  12. /*  without any attributes used by EditChar().                             */
  13. /*  EditChar() shows the edited character on the screen                    */
  14. /*  with the colors white on black while editing and                       */
  15. /*  with the colors bright white on black after editing.                   */
  16. /*                                                                         */
  17. /*  2.                                                                     */
  18. /*  ch=EditCharC(fcw, bcw, fca, bca)                                       */
  19. /*  stores a single character in  ch                                       */
  20. /*  without any attributes used by EditCharC().                            */
  21. /*  EditCharC() shows the edited character on the screen                   */
  22. /*  with  fcw  on  bcw  while editing and                                  */
  23. /*  with  fca  on  bca  after You hit the Enter key.                       */
  24. /*  Allowed colors for  fcw, bcw, fca, bca                                 */
  25. /*  are: black, red, green, yellow, blue, magenta, cyan and white.         */
  26. /*  Note that foreground colors  fcw  and  fca                             */
  27. /*  are the highlighted version of the selected color.                     */
  28. /*                                                                         */
  29. /*  3.                                                                     */
  30. /*  st=EditStr()                                                           */
  31. /*  stores a string which length is 12 characters and stores it            */
  32. /*  in the variable  st  without any attributes used by EditStr().         */
  33. /*  EditStr() shows the edited string on the screen                        */
  34. /*  with the colors white on black while editing and                       */
  35. /*  with the colors bright white on black after editing.                   */
  36. /*                                                                         */
  37. /*  4.                                                                     */
  38. /*  st=EditStrC(fcw, bcw, fca, bca)                                        */
  39. /*  stores a string which length is 16 characters and stores it            */
  40. /*  in the variable  st  without any attributes used by EditStrC().        */
  41. /*  EditStrC() shows the edited string on the screen                       */
  42. /*  with  fcw  on  bcw  while editing and                                  */
  43. /*  with  fca  on  bca  after You hit the Enter key.                       */
  44. /*  Allowed colors for  fcw, bcw, fca, bca                                 */
  45. /*  are: black, red, green, yellow, blue, magenta, cyan and white.         */
  46. /*  Note that foreground colors  fcw  and  fca                             */
  47. /*  are the highlighted version of the selected color.                     */
  48. /*                                                                         */
  49. /*                                                                         */
  50. /*  The following special keys are available                               */
  51. /*  EditChar() and EditCharC():                                            */
  52. /*                                                                         */
  53. /*  Backspace, Enter, Esc                                                  */
  54. /*                                                                         */
  55. /*                                                                         */
  56. /*  The following special keys are available                               */
  57. /*  in EditStr() and EditStrC():                                           */
  58. /*                                                                         */
  59. /*  Backspace, Enter, Esc, left Arrow, right Arrow, Home, End, Entf        */
  60. /*  (These key names are the english key names of a german keyboard.)      */
  61. /*                                                                         */
  62. /***************************************************************************/
  63. /*                                                                         */
  64. /*  If these functions are useful for You,                                 */
  65. /*  please use them without any obligation (Freeware)                      */
  66. /*                                                                         */
  67. /*  The author of the ANSI-Procedures is Jamie Hoglund                     */
  68. /*  jhoglund@cncns.com                                                     */
  69. /*                                                                         */
  70. /*                                                                         */
  71. /*  Hermann Mahr                                                           */
  72. /*  Hermann.Mahr@t-online.de                                               */
  73. /*  24.05.1998                                                             */
  74. /*                                                                         */
  75. /***************************************************************************/
  76.    Call RxFuncAdd 'SysLoadFuncs', RexxUtil, 'SysLoadFuncs'
  77.    Call SysLoadFuncs
  78.    call SysCls
  79.   
  80.    /* Bei Betätigung der Tasten-Kombination  Strg+C  wird RxEdit.CMD beendet.  */
  81.    signal on halt name ende
  82.    
  83.    call Locate 02,15
  84.    call CsrAttrib "High";  call Color "white"   
  85.    call Charout,"Please try the following four functions for editing:"
  86.    call Locate 03,12
  87.    call CsrAttrib "Normal"
  88.    call Charout,"(If necessary, please read the comment in this RxEdit.CMD)"
  89.  
  90.  
  91.    call Locate 05,06
  92.    call Charout,"Edit a single uncolored character  ch:"
  93.    call Locate 06,06
  94.    call Charout,"ch  =  "; ch=EditChar()
  95.    call Locate 07,06
  96.    call Charout,"The single uncolored character  ch  is stored as:"
  97.    call Locate 08,06
  98.    call Charout,"ch  =  "ch
  99.    
  100.                                      
  101.    call Locate 10,06
  102.    call Charout,"Edit a single colored character  ch:"
  103.    call Locate 11,06
  104.    call Charout,"ch  =  "; ch=EditCharC("cyan","cyan","yellow","green")
  105.    call Locate 12,06
  106.    call Charout,"The single colored character  ch  is stored as:"
  107.    call Locate 13,06
  108.    call Charout,"ch  =  "ch
  109.    
  110.    call Locate 15,06
  111.    call Charout,"Edit a uncolored string  str:"
  112.    call Locate 16,06
  113.    call Charout,"str =  "; str=EditStr(12)
  114.    call Locate 17,06
  115.    call Charout,"The uncolored string  str is stored as:"
  116.    call Locate 18,06
  117.    call Charout,"str =  "str
  118.    
  119.    call Locate 20,06
  120.    call Charout,"Edit a colored string  str:"
  121.    call Locate 21,06
  122.    call Charout,"str =  "; str=EditStrC(16,"cyan","cyan","green","yellow")
  123.    call Locate 22,06
  124.    call Charout,"The colored string  str  is stored as:"
  125.    call Locate 23,06
  126.    call Charout,"str =  "str
  127.    say
  128.                 
  129. ende:           
  130. EXIT
  131.  
  132.  
  133. EditStr:
  134.   Procedure
  135.   /* ImGegensatz zur ANSI-Prozedur "call Locate y,x", deren Variable */
  136.   /* y für Zeile und x für Spalte mit 1 beginnen, beginnen die       */
  137.   /* Variablen für Zeile und Spalte der Funktion                     */
  138.   /* "parse value SysCurPos with Zeile Spalte" mit dem Wert 0  !!!!  */
  139.   "@ echo off"
  140.   /* Ausgangs-Koordinaten PosY und PosX ermitteln */
  141.   anf="47"; bckspc="08"; ende="4F";   enter="0D"; entf="53" 
  142.   esc="1B"; links="4B";  rechts="4D"; tab="09"
  143.   parse value SysCurPos() with PosY PosX
  144.  
  145.   parse arg l
  146.  
  147. AnfEditStr:
  148.   call SysCurPos PosY, PosX
  149.   if l>=0 then call Charout,copies(" ",l)
  150.   call SysCurPos PosY, PosX
  151.   done=0; k=1; i=1; si=""
  152.   k0=0
  153.   do while done<>1
  154.     
  155.     /* Einlese-Befehl */
  156.     ch=SysGetKey("noecho")
  157.  
  158.     /* Eingabetaste schließt die Eingabe ab. */
  159.     if c2x(ch)==enter then done=1
  160.  
  161.     /* Escapetaste leert das Eingabefeld. */
  162.     if c2x(ch)==esc & l>0 then Signal AnfEditStr
  163.  
  164.     /* Sondertasten, deren Tastencode zwei Symbole zurückliefert. */
  165.     if c2x(ch)=="00" | c2x(ch)=="E0" then
  166.     do
  167.       /* andere Variable hc unbedingt erforderlich ! */
  168.       hc=SysGetKey("noecho") 
  169.       /* 1. Cursor nach links */
  170.       if c2x(hc)==links & k>1 then
  171.       do
  172.         call SysCurPos PosY, PosX+k-2
  173.         hc=""; ch=""
  174.         k=k-1
  175.       end
  176.       /* 2. Cursor nach rechts */
  177.       if c2x(hc)==rechts & k<l then
  178.       do
  179.         call SysCurPos PosY, PosX+k
  180.         hc=""; ch=""
  181.         k=k+1
  182.       end
  183.       /* 3. Cursor an den Anfang */
  184.       if c2x(hc)==anf & k<=l+1 then
  185.       do
  186.         call SysCurPos PosY, PosX
  187.         hc=""; ch=""
  188.         k=1
  189.       end
  190.       /* 4. Cursor an das Ende */
  191.       if c2x(hc)==ende & k<=l then
  192.       do
  193.         call SysCurPos PosY, PosX+l
  194.         hc=""; ch=""
  195.         k=l+1
  196.       end
  197.       /* 5. Entf-Taste einrichten */
  198.       if c2x(hc)==entf & k<=l+1 then
  199.       do
  200.         call SysCurPos PosY, PosX
  201.         call Charout,copies(" ",l)
  202.         call SysCurPos PosY, PosX
  203.         sa=DelStr(si, k)
  204.         se=SubStr(si, k+1)
  205.         call Charout,sa||se
  206.         call SysCurPos PosY, PosX+k-1
  207.       end
  208.       /* 6. Fast alle Sondertasten werden ignoriert.     */
  209.       k=k-1
  210.       ch=""; hc="" 
  211.     end /* Sondertasten, deren Tastencode zwei Symbole zurückliefert. */
  212.  
  213.     /* Tabtaste wird ignoriert */
  214.     if c2x(ch)==tab then
  215.     do
  216.       ch=""
  217.       k=k-1
  218.     end
  219.  
  220.     /* Backspace-Taste einrichten. */
  221.     if c2x(ch)==bckspc & k>1 then
  222.     do
  223.       lsi=Length(strip(si))
  224.       lsik=lsi-k                     
  225.         call SysCurPos PosY, PosX
  226.         call Charout,copies(" ",l)
  227.         call SysCurPos PosY, PosX    
  228.         sil=Left(strip(si),k-2)
  229.         sir=Right(strip(si),lsi-k+1)
  230.         si=strip(sil||sir) 
  231.         call Charout,si
  232.         call SysCurPos PosY, PosX+k-2 
  233.         k=k-1
  234.     end
  235.  
  236.     /* Es werden nur erlaubte Zeichen eingelesen. */
  237.     if k<=l & c2x(ch)<>bckspc then
  238.     do
  239.       call Charout,ch
  240.       si=si||ch
  241.       /* String vom Bildschirm einlesen und in der Variablen si speichern. */
  242.       si=SysTextScreenRead(posY,PosX,l)
  243.       if c2x(ch)==enter then leave
  244.       k=k+1
  245.     end
  246.  
  247.   end /* do while */
  248.  
  249.   /* Ausgabe-Vorbereitung */
  250.   call SysCurPos PosY, PosX
  251.   call CsrAttrib "High"
  252.   if l>=0 then call Charout,copies(" ",l)
  253.   call SysCurPos PosY, PosX
  254.   call Charout,si
  255.   call CsrAttrib "Normal"
  256.   /* Die folgenden zwei Zeilen sind unbedingt erforderlich, weil in        */
  257.   /* dieser Funktion "EditStr" beim Abschluß der Eingabe mit "Enter" das   */
  258.   /* hexadezimale Zeichen 0D (dezimal: 13) angehängt wird.                 */
  259.   /* (Eine Ausnahme liegt dann vor, wenn genau soviele Zeichen eingegeben  */
  260.   /* werden, wie es die zulässige Länge des Eingabestrings erlaubt.)       */
  261.   /* Da dieses Zeichen zu den ASCII-Steuerzeichen gehört und somit von     */
  262.   /* einem Editor nicht in einen Quelltext eingefügt werden kann, muß für  */
  263.   /* REXX-Funktion "Pos" das Zeichen 0D mit Hilfe der REXX-Funktion x2c()  */
  264.   /* dargestellt werden, also mit  x2c(0D).                                */
  265.   q0D=Pos(x2c(0D), si)
  266.   if q0D>0 then si=DelStr(si,q0D)
  267.   return(si) /* EditStr */
  268.  
  269.  
  270. EditStrC:
  271.   Procedure
  272.   /* Farbige Ausgabe des Eingabestrings                              */
  273.   /* ImGegensatz zur ANSI-Prozedur "call Locate y,x", deren Variable */
  274.   /* y für Zeile und x für Spalte mit 1 beginnen, beginnen die       */
  275.   /* Variablen für Zeile und Spalte der Funktion                     */
  276.   /* "parse value SysCurPos with Zeile Spalte" mit dem Wert 0  !!!!  */
  277.   "@ echo off"
  278.   anf="47"; bckspc="08"; ende="4F";   enter="0D"; entf="53" 
  279.   esc="1B"; links="4B";  rechts="4D"; tab="09"
  280.   /* Ausgangs-Koordinaten PosY und PosX ermitteln */
  281.   parse value SysCurPos() with PosY PosX
  282.  
  283.   parse arg l,fve,fhe,fvb,fhb
  284.  
  285.   if l>0 then
  286.   do
  287.     z1=1
  288.     z2=2 
  289.   end
  290.   if l==0 | l=="" then
  291.   do
  292.     z1=0
  293.     z2=0 
  294.   end
  295.                       
  296. AnfEditStrC:
  297.   call SysCurPos PosY, PosX-z1
  298.   call CsrAttrib "High";  call Color fve,fhe
  299.   if l>=0 then call Charout,copies(" ",l+z2)
  300.   call SysCurPos PosY, PosX
  301.   done=0; k=1; si=""
  302.   
  303.   do while done<>1
  304.     
  305.     /* Einlese-Befehl */
  306.     ch=SysGetKey("noecho")
  307.  
  308.     /* Eingabetaste schließt die Eingabe ab. */
  309.     if c2x(ch)==enter then done=1
  310.  
  311.     /* Escapetaste leert das Eingabefeld. */
  312.     if c2x(ch)==esc & l>0 then Signal AnfEditStrC
  313.  
  314.     /* Sondertasten, deren Tastencode zwei Symbole zurückliefert. */
  315.     if c2x(ch)=="00" | c2x(ch)=="E0" then
  316.     do
  317.       /* andere Variable hc unbedingt erforderlich ! */
  318.       hc=SysGetKey("noecho") 
  319.       /* 1. Cursor nach links */
  320.       if c2x(hc)==links & k>1 then
  321.       do
  322.         call SysCurPos PosY, PosX+k-2
  323.         hc=""; ch=""
  324.         k=k-1
  325.       end
  326.       /* 2. Cursor nach rechts */
  327.       if c2x(hc)==rechts & k<l then
  328.       do
  329.         call SysCurPos PosY, PosX+k
  330.         hc=""; ch=""
  331.         k=k+1
  332.       end
  333.       /* 3. Cursor an den Anfang */
  334.       if c2x(hc)==anf & k<=l+1 then
  335.       do
  336.         call SysCurPos PosY, PosX
  337.         hc=""; ch=""
  338.         k=1
  339.       end
  340.       /* 4. Cursor an das Ende */
  341.       if c2x(hc)==ende & k<=l then
  342.       do
  343.         call SysCurPos PosY, PosX+l
  344.         hc=""; ch=""
  345.         k=l+1
  346.       end
  347.       /* 5. Entf-Taste einrichten */
  348.       if c2x(hc)==entf & k<=l+1 then
  349.       do
  350.         call SysCurPos PosY, PosX
  351.         call Charout,copies(" ",l)
  352.         call SysCurPos PosY, PosX
  353.         sa=DelStr(si, k)
  354.         se=SubStr(si, k+1)
  355.         call Charout,sa||se
  356.         call SysCurPos PosY, PosX+k-1
  357.       end
  358.       /* 6. Fast alle Sondertasten werden ignoriert.     */
  359.       k=k-1
  360.       ch=""; hc="" 
  361.     end /* Sondertasten, deren Tastencode zwei Symbole zurückliefert. */
  362.  
  363.     /* Tabtaste wird ignoriert */
  364.     if c2x(ch)==tab then
  365.     do
  366.       ch=""
  367.       k=k-1
  368.     end
  369.  
  370.     /* Backspace-Taste einrichten. */
  371.     if c2x(ch)==bckspc & k>1 then
  372.     do
  373.       lsi=Length(strip(si))
  374.       lsik=lsi-k                     
  375.         call SysCurPos PosY, PosX
  376.         call Charout,copies(" ",l)
  377.         call SysCurPos PosY, PosX    
  378.         sil=Left(strip(si),k-2)
  379.         sir=Right(strip(si),lsi-k+1)
  380.         si=strip(sil||sir) 
  381.         call Charout,si
  382.         call SysCurPos PosY, PosX+k-2 
  383.         k=k-1
  384.     end
  385.  
  386.     /* Es werden nur erlaubte Zeichen eingelesen. */
  387.     if k<=l & c2x(ch)<>bckspc then
  388.     do
  389.       call Charout,ch
  390.       si=si||ch
  391.       /* String vom Bildschirm einlesen und in der Variablen si speichern. */
  392.       si=SysTextScreenRead(posY,PosX,l)
  393.       if c2x(ch)==enter then leave
  394.       k=k+1
  395.     end
  396.  
  397.   end /* do while */
  398.  
  399.   /* Ausgabe-Vorbereitung */
  400.   call SysCurPos PosY, PosX-z1
  401.   call CsrAttrib "HIGH";  call Color fvb,fhb
  402.   if l>=0 then call Charout,copies(" ",l+z2)
  403.   call SysCurPos PosY, PosX
  404.   call Charout,si
  405.   call CsrAttrib "Normal" 
  406.   /* Die folgenden zwei Zeilen sind unbedingt erforderlich, weil in        */
  407.   /* dieser Funktion "EditStrC" beim Abschluß der Eingabe mit "Enter" das  */
  408.   /* hexadezimale Zeichen 0D (dezimal: 13) angehängt wird.                 */
  409.   /* (Eine Ausnahme liegt dann vor, wenn genau soviele Zeichen eingegeben  */
  410.   /* werden, wie es die zulässige Länge des Eingabestrings erlaubt.)       */
  411.   /* Da dieses Zeichen zu den ASCII-Steuerzeichen gehört und somit von     */
  412.   /* einem Editor nicht in einen Quelltext eingefügt werden kann, muß für  */
  413.   /* REXX-Funktion "Pos" das Zeichen 0D mit Hilfe der REXX-Funktion x2c()  */
  414.   /* dargestellt werden, also mit  x2c(0D).                                */
  415.   q0D=Pos(x2c(0D), si)
  416.   if q0D>0 then si=DelStr(si,q0D)
  417.   return(si) /* EditStrC */
  418.  
  419.  
  420.  
  421.   
  422. EditChar:
  423.   Procedure
  424.   /* ImGegensatz zur ANSI-Prozedur "call Locate y,x", deren Variable */
  425.   /* y für Zeile und x für Spalte mit 1 beginnen, beginnen die       */
  426.   /* Variablen für Zeile und Spalte der Funktion                     */
  427.   /* "parse value SysCurPos with Zeile Spalte" mit dem Wert 0  !!!!  */
  428.   "@ echo off"                                            
  429.   /* Ausgangs-Koordinaten PosY und PosX ermitteln */
  430.   parse value SysCurPos() with PosY PosX 
  431.   enter="0D"; bckspc="08"; esc="1B"
  432.  
  433. AnfEditChar:  
  434.   call SysCurPos PosY, PosX  
  435.   call Charout," "
  436.   call SysCurPos PosY, PosX  
  437.   done=0; k=1;si=""  
  438.   
  439.   do while done<>1
  440.     
  441.     /* Einlese-Befehl */
  442.     ch=SysGetKey("noecho")
  443.     
  444.     /* Eingabetaste schließt die Eingabe ab. */                                
  445.     if c2x(ch)==enter then done=1
  446.  
  447.     /* Escapetaste leert Eingabefeld. */                            
  448.     if c2x(ch)==esc then Signal AnfEditChar
  449.  
  450.     /* Sondertasten, deren Tastencode zwei Symbole zurückliefert. */
  451.     if c2x(ch)=="00" | c2x(ch)=="E0" then
  452.     do
  453.       /* andere Variable hc unbedingt erforderlich ! */
  454.       hc=SysGetKey("noecho") 
  455.       ch=""; hc=""  
  456.       k=k-1 
  457.     end    
  458.     
  459.     /* Tabtaste und Leertaste werden ignoriert */
  460.     if c2x(ch)=="09" | c2x(ch)=="20" then 
  461.     do
  462.       ch=""
  463.       k=k-1 
  464.     end 
  465.  
  466.     /* Backspace-Taste für EditChar einrichten. */
  467.     if c2x(ch)==bckspc then Signal AnfEditChar
  468.  
  469.     /* Es werden nur erlaubte Zeichen eingelesen. */
  470.     if k<=1 & c2x(ch)<>bckspc then
  471.     do
  472.       call Charout,ch
  473.       si=si||ch
  474.       if c2x(ch)==enter then leave
  475.       k=k+1 
  476.     end
  477.  
  478.   end /* do while */  
  479.   
  480.   /* Ausgabe-Vorbereitung */
  481.   call SysCurPos PosY, PosX
  482.   call CsrAttrib "High";  call Color "white"
  483.   call Charout," "  
  484.   call SysCurPos PosY, PosX
  485.   call Charout,si 
  486.   call CsrAttrib "Normal"
  487.   /* Die folgenden zwei Zeilen sind unbedingt erforderlich, weil in        */
  488.   /* dieser Funktion "EditChar" beim Abschluß der Eingabe mit "Enter" das  */
  489.   /* hexadezimale Zeichen 0D (dezimal: 13) angehängt wird.                 */
  490.   /* (Eine Ausnahme liegt dann vor, wenn genau soviele Zeichen eingegeben  */
  491.   /* werden, wie es die zulässige Länge des Eingabestrings erlaubt.)       */
  492.   /* Da dieses Zeichen zu den ASCII-Steuerzeichen gehört und somit von     */
  493.   /* einem Editor nicht in einen Quelltext eingefügt werden kann, muß für  */
  494.   /* REXX-Funktion "Pos" das Zeichen 0D mit Hilfe der REXX-Funktion x2c()  */
  495.   /* dargestellt werden, also mit  x2c(0D).                                */
  496.   q0D=Pos(x2c(0D), si) 
  497.   if q0D>0 then si=DelStr(si,q0D) 
  498.   return(si) /* EditChar */       
  499.          
  500. EditCharC:
  501.   Procedure
  502.   /* Farbige Ausgabe des Eingabestrings                              */
  503.   /* ImGegensatz zur ANSI-Prozedur "call Locate y,x", deren Variable */
  504.   /* y für Zeile und x für Spalte mit 1 beginnen, beginnen die       */
  505.   /* Variablen für Zeile und Spalte der Funktion                     */
  506.   /* "parse value SysCurPos with Zeile Spalte" mit dem Wert 0  !!!!  */
  507.   "@ echo off"                                            
  508.   /* Ausgangs-Koordinaten PosY und PosX ermitteln */
  509.   parse value SysCurPos() with PosY PosX 
  510.   enter="0D"; bckspc="08"; esc="1B" 
  511.  
  512.   parse arg fcw,bcw,fca,bca
  513.   
  514. AnfEditCharC:  
  515.   call SysCurPos PosY, PosX  
  516.   call CsrAttrib "High";   call Color fcw,bcw 
  517.   call Charout," "
  518.   call SysCurPos PosY, PosX  
  519.   done=0; k=1; si="" 
  520.    
  521.   do while done<>1
  522.     
  523.     /* Einlese-Befehl */
  524.     ch=SysGetKey("noecho")
  525.     
  526.     /* Eingabetaste schließt die Eingabe ab. */                                
  527.     if c2x(ch)==enter then done=1
  528.  
  529.     /* Escapetaste leert das Eingabefeld. */
  530.     if c2x(ch)==esc then Signal AnfEditCharC
  531.  
  532.     /* Sonderttasten, deren Tastencode zwei Symbole zurückliefert. */                                
  533.     if c2x(ch)=="00" | c2x(ch)=="E0" then
  534.     do
  535.       /* andere Variable hc unbedingt erforderlich ! */
  536.       hc=SysGetKey("noecho")
  537.       ch=""; hc=""  
  538.       k=k-1 
  539.     end                                 
  540.     
  541.     /* Tabtaste und Leertaste werden ignoriert */
  542.     if c2x(ch)=="09" | c2x(ch)=="20" then 
  543.     do
  544.       ch=""
  545.       k=k-1 
  546.     end
  547.     
  548.     /* Backspace-Taste einrichten. */
  549.     if c2x(ch)==bckspc then Signal AnfEditCharC
  550.  
  551.     /* Es werden nur erlaubte Zeichen eingelesen. */
  552.     if k<=1 & c2x(ch)<>bckspc then
  553.     do  
  554.       call Charout,ch
  555.       si=si||ch
  556.       if c2x(ch)==enter then leave
  557.       k=k+1 
  558.     end
  559.  
  560.   end /* do while */  
  561.   
  562.   /* Ausgabe-Vorbereitung */
  563.   call SysCurPos PosY, PosX
  564.   call CsrAttrib "HIGH";  call Color fca,bca  
  565.   call Charout," "  
  566.   call SysCurPos PosY, PosX
  567.   call Charout,si 
  568.   call CsrAttrib "Normal"
  569.   /* Die folgenden zwei Zeilen sind unbedingt erforderlich, weil in        */
  570.   /* dieser Funktion "EditCharC" beim Abschluß der Eingabe mit "Enter" das */
  571.   /* hexadezimale Zeichen 0D (dezimal: 13) angehängt wird.                 */
  572.   /* (Eine Ausnahme liegt dann vor, wenn genau soviele Zeichen eingegeben  */
  573.   /* werden, wie es die zulässige Länge des Eingabestrings erlaubt.)       */
  574.   /* Da dieses Zeichen zu den ASCII-Steuerzeichen gehört und somit von     */
  575.   /* einem Editor nicht in einen Quelltext eingefügt werden kann, muß für  */
  576.   /* REXX-Funktion "Pos" das Zeichen 0D mit Hilfe der REXX-Funktion x2c()  */
  577.   /* dargestellt werden, also mit  x2c(0D).                                */
  578.   q0D=Pos(x2c(0D), si) 
  579.   if q0D>0 then si=DelStr(si,q0D) 
  580.   return(si) /* EditCharC */       
  581.         
  582.  
  583.                
  584. /*------------------------------- ANSI-Prozeduren-Anfang -------------------------------*/
  585. /* Ansi Procedures for moving the cursor */
  586. Locate: Procedure   /*  Call Locate Row,Col */
  587. Row = arg(1)
  588. Col = Arg(2)
  589. Rc = Charout(,D2C(27)"["Row";"col"H")
  590. return ""
  591.  
  592. CsrUp: Procedure  /* CsrUp(Rows) */
  593. Arg u
  594. Rc = Charout(,D2C(27)"["u"A")
  595. return ""
  596.  
  597. CsrDown: Procedure /* CsrDn(Rows) */
  598. Arg d
  599. Rc = Charout(,D2C(27)"["d"B")
  600. return ""
  601.  
  602. CsrRight: Procedure  /* CsrRight(Cols) */
  603. arg r
  604. Rc = Charout(,D2C(27)"["r"C")
  605. Return ""
  606.  
  607. CsrLeft: procedure  /* CsrLeft(Cols) */
  608. arg l
  609. Rc = Charout(,D2C(27)"["l"D")
  610. Return ""
  611.  
  612.  
  613. /*
  614. A------------------------------------------------------------:*
  615. SaveCsr and PutCsr are meant to be used together for saving  :*
  616. and restoring the cursor location. Do not confuse            :*
  617. with Locate, CsrRow, CsrCol, these are different routines.   :*
  618. SaveCsr Returns a string that PutCsr can use.                :*
  619. A:*/
  620. SaveCsr: procedure  /* cursor_location = SaveCsr() (for PutCsr(x))*/
  621. Rc = Charout(,D2C(27)"[6n")
  622. Pull Q
  623. Call CsrUp
  624. return Q
  625.  
  626. PutCsr: procedure  /* Call PutCsr <Previous_Location>  (From SaveCsr() ) */
  627. Where = arg(1)
  628. Rc = Charout(,substr(Where,1,7)"H")
  629. return ""
  630. /*
  631. A:*/
  632. /* clear screen :*/
  633. Cls: Procedure      /* cls() Call Cls */
  634. Rc = CharOut(,D2C(27)"[2J")
  635. return ""
  636.  
  637.     /* get cursors Line */
  638. CsrRow: Procedure      /* Row = CsrRow()*/
  639. Rc = Charout(,D2C(27)"[6n")
  640. Pull Q
  641. Return substr(Q,3,2)
  642.  
  643.    /* get cursors column */
  644. CsrCol: Procedure          /*  Col = CsrCol()  */
  645. Rc = Charout(,D2C(27)"[6n")
  646. Pull Q
  647. return Substr(Q,6,2)
  648.  
  649. /* procedure to color screen
  650. A:--------------------------------------------------------------*
  651. accepts colors: BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE  *
  652. */
  653. Color: Procedure /* Call Color <ForeGround>,<BackGround> */
  654. arg F,B
  655. Colors = "BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE"
  656. return CHAROUT(,D2C(27)"["WORDPOS(F,COLORS)+29";"WORDPOS(B,COLORS)+39";m")
  657.  
  658. /*  change screen attributes
  659. A:---------------------------------------------------------------*
  660. attributes: NORMAL HIGH LOW ITALIC UNDERLINE BLINK RAPID REVERSE *
  661. */
  662. CsrAttrib: Procedure  /* call CsrAttrib <Attrib> */
  663. Arg A
  664. attr = "NORMAL HIGH LOW ITALIC UNDERLINE BLINK RAPID REVERSE"
  665. return CHAROUT(,D2C(27)"["WORDPOS(A,ATTR) - 1";m")
  666.  
  667. EndAll:
  668. Call Color "White","Black"
  669. CALL CsrAttrib "Normal"
  670.  
  671. /*-------------------------------- ANSI-Prozeduren-Ende --------------------------------*/
  672.                   
  673.