home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / kzr_0899.zip / kzr0.CMD < prev    next >
OS/2 REXX Batch file  |  1998-07-05  |  3KB  |  121 lines

  1. /* kzr0.CMD */
  2.    pi=3.141592653589793238462643383279502884197169399375105820975
  3.    ND=48
  4.    Numeric Digits ND
  5.    Call RxFuncAdd 'SysLoadFuncs', RexxUtil, 'SysLoadFuncs'
  6.    Call SysLoadFuncs
  7.    Pfd=SysSearchPath("PATH", "kzr0.cmd")
  8.    lp=LastPos("\", Pfd)
  9.    Pfd=DelStr(Pfd, 1+lp)
  10.    bufND =Pfd||"NDZahl.DAT"
  11.    ret=LineOut(bufND, ND)
  12.    signal on syntax name Fehlermeld
  13.  
  14.    parse upper arg str;   str=strip(str)
  15.  
  16.    if (length(str)= 0) then
  17.    do; "start /PM /MAX view.exe" Pfd||"KZR.INF"; EXIT; end
  18.  
  19.    st1=str
  20.    if Pos(":",       st1) > 0 then st2=Flt2(st1); else st2=st1
  21.    if Pos("DIVGANZ", st2) > 0 then st3=Flt3(st2); else st3=st2
  22.    if Pos("DIVREST", st3) > 0 then st4=Flt4(st3); else st4=st3
  23.    say
  24.                                                     
  25.    if Pos("D2X", st4)>0 | Pos("X2D", st4)>0 |,
  26.       Pos("B2X", st4)>0 | Pos("X2B", st4)>0 |,
  27.       Pos("D2B", st4)>0 | Pos("B2D", st4)>0 | Pos("PRIM", st4)>0 then Signal FalschRuf
  28.  
  29.    Numeric Digits ND+6
  30.    interpret "z="st4
  31.           
  32.    if DataType(z, N) <> 1 then Signal Fehlermeld
  33.    if DataType(z, N)  = 1 then
  34.    do
  35.      Numeric Digits ND
  36.      zz=Format(z)
  37.      st10=ErgFormat(zz)
  38.    end
  39.    else st10=z
  40.    say st4 "= "st10
  41.  
  42. PgmEnd:
  43.    Call charout(bufND);   Call SysFileDelete bufND
  44.    Dummy=MinNDA()
  45. EXIT
  46.   
  47. Flt2:
  48.   Procedure 
  49.   arg sti
  50.   n=Pos(":", sti); 
  51.   l=length(":")
  52.   sti=Overlay("/",sti, n, l)
  53.   Return(sti)
  54.  
  55. Flt3:
  56.   Procedure
  57.   parse arg str
  58.   i=1; st3.i=str
  59.   Anf3:
  60.   j=i+1
  61.   l3.i=Pos("DIVGANZ", st3.i); if l3.i > 0 then Signal w31
  62.   w31:
  63.   if l3.i=0 then Signal w3e
  64.   sub3.i=SubStr(st3.i, l3.i, 7)
  65.   st3.i =DelStr(st3.i, l3.i, 7)
  66.   if  sub3.i=="DIVGANZ" then neu3.i="%"
  67.   st3.j=Insert(neu3.i, st3.i, l3.i-1  ); st3=st3.j
  68.   i=i+1
  69.   signal Anf3
  70.   w3e:
  71.   Return(st3)
  72.                     
  73. Flt4:
  74.   Procedure
  75.   parse arg str
  76.   i=1; st4.i=str
  77.   Anf4:
  78.   j=i+1
  79.   l4.i=Pos("DIVREST", st4.i); if l4.i > 0 then Signal w41
  80.   w41:
  81.   if l4.i=0 then Signal w4e
  82.   sub4.i=SubStr(st4.i, l4.i, 7)
  83.   st4.i =DelStr(st4.i, l4.i, 7)
  84.   if  sub4.i=="DIVREST" then  neu4.i="//"
  85.   st4.j=Insert(neu4.i, st4.i, l4.i-1  ); st4=st4.j
  86.   i=i+1
  87.   signal Anf4
  88.   w4e:
  89.   Return(st4)
  90.  
  91. ErgFormat:
  92.   Procedure
  93.   arg u
  94.   if Pos(".", u)>0 & Pos("E", u)=0 then
  95.   do
  96.     do forever
  97.       lu=length(u)
  98.       if Pos("0", u, lu) > 0 then u=DelStr(u, lu); else leave
  99.     end
  100.     lu=length(u)
  101.     if Pos(".", u) = lu then u=DelStr(u, lu)
  102.   end
  103.   Return(u)
  104.    
  105. Fehlermeld:   
  106.   Beep(444, 200); Beep(628,300)
  107.   Call Charout,"Fehlerhafte Eingabe oder Funktion nicht verfügbar ! "; say
  108.   signal PgmEnd
  109.                                                                                 
  110. FalschRuf:
  111.   say
  112.   Call Charout,"Die Umwandlungsfunktionen"; say; say
  113.   Call Charout,"D2X, X2D, B2X, X2B, D2B  und  B2D"; say; say
  114.   call Charout,"sowie die Funktion  Prim.CMD  zur Primfaktor-Zerlegung"; say
  115.   call Charout,"dürfen nur von der Kommandozeile direkt und ohne den"; say
  116.   call Charout,"vorangesetzten Teilstring  'kzr xy,'  eingegeben werden."; say; say
  117.   call Charout,"(Näheres dazu in der kzr.INF)"
  118.   say
  119.   Beep(444, 200); Beep(628,300)
  120.   Signal PgmEnd
  121.