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

  1. /* REXX-Programm arsinh.CMD  */
  2.    Signal on syntax name arsinhMsg
  3.  
  4. /* Diese Variablen müssen für jede Prozedur definiert werden, damit die  */
  5. /* Prozedur die Variable bufND kennt und die Variable ND übernehmen kann.*/
  6.    Pfd=SysSearchPath("PATH", "kzr.cmd")
  7.    lp=LastPos("\", Pfd)
  8.    Pfd=DelStr(Pfd, 1+lp)
  9.    NDAarsinh=Pfd||"NDAarsinh.DAT"
  10.    bufND  =Pfd||"NDZahl.DAT"
  11.    bufMsg =Pfd||"Meldung.DAT"
  12.    ND = LineIn(bufND, 1)
  13.  
  14.    if ND > 400 then
  15.    do
  16.      ND=400
  17.      call charout(NDAarsinh) ; Call SysFileDelete NDAarsinh
  18.      ret=LineOut(NDAarsinh, 400)
  19.      Call Charout,"   Achtung, nur 400 Dezimalstellen bei der Berechnung von  arsinh(...)"
  20.      say
  21.      Beep(444, 200); Beep(628,300)  /* Hier kein EXIT ! */
  22.    end
  23.  
  24.    /* Wenn ND <= 400 ist, wird ND = ND  weitergegeben */
  25.    call charout(NDAarsinh) ; Call SysFileDelete NDAarsinh
  26.    ret=LineOut(NDAarsinh, ND)
  27.  
  28.    arg x,y  /* y soll "illegale" Komma's im Funktions-Argument aufspüren */
  29.    p0p=x*x  /* Diese Anweisung prvoziert eine Syntax-Fehlermeldung       */
  30.  
  31.    if length(y) > 0 then
  32.    do
  33.      call charout(NDAarsinh); Call SysFileDelete NDAarsinh
  34.      ret=LineOut(bufMsg, "Im Argument von  arsinh(...)  ist mindestens  1  nicht zulässiges Komma !")
  35.      /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  36.      /*  damit in den diesbezüglichen temporären Dateien                      */
  37.      /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  38.      EXIT
  39.    end
  40.  
  41.    Numeric Digits ND+7
  42.  
  43.    if abs(x) >  0.35 then Signal B
  44.  
  45. A: m=2; g=1; v=1; t=x*x
  46.    do forever
  47.      g=-g*t*(m-1)*(m-1)/(m*(m+1))
  48.      v=v+g
  49.      if abs(g/v) < 10**(-ND-4) then leave
  50.      m=m+2
  51.    end
  52.    y=x*v
  53.    Signal W
  54.  
  55. B: y=ln(x+sqrt(x*x+1))
  56.  
  57.    /* Ausgabe */
  58. W: numeric digits ND
  59.    return(Format(y))
  60.  
  61. arsinhMsg:
  62.    sf=ErrorText(RC)
  63.    if  Pos("Bad arithmetic conversion", sf) > 0 then
  64.    do
  65.      call charout(NDAarsinh); Call SysFileDelete NDAarsinh
  66.      ret=LineOut(bufMsg, "Sie haben in  arsinh(...)  kein gültiges Argument eingegeben !")
  67.   /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  68.   /*  damit in den diesbezüglichen temporären Dateien                      */
  69.   /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  70.      EXIT
  71.    end
  72.  
  73.