home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / programming / wimpworks / Apps / !Maths / WWv2Data < prev   
Encoding:
Text File  |  1998-09-03  |  1.4 KB  |  67 lines

  1. # WimpWorks Information File
  2. # WimpWorks © Jaffa Software 1997. All rights reserved.
  3.  
  4. DEF TASKdetails
  5.     Name        Maths
  6.     Purpose        Produce statistics
  7.     Author        © Jaffa Software 1997
  8.     Licence        
  9.     Version        1.01 (18-Nov-1997)
  10.     Compress    False
  11.     Memory        0K
  12.     IconbarSide    Right
  13.     IconbarPriority    &00000000
  14.     IconbarSprite    !maths
  15.     IconbarText    
  16. ENDTASK
  17.  
  18. DEF WEMinclude
  19. ENDWEM
  20.  
  21. DEF MENUiconMenu%
  22.     Maths
  23.     Info
  24.         S(infoWindow%)
  25.         
  26.     Quit
  27.         
  28.         CLOSEDOWN
  29. ENDMENU
  30.  
  31. DEF SUBR_PROCfile_dragged
  32.     Event    4
  33.     Every    -1
  34. DEF PROCfile_dragged(window%, icon%, file$, type%)
  35.   LOCAL file%,line$,line, mean,tolerance,stdev,sigx,sigxsq,num%
  36.  
  37.   ' Check the file *is* a file...
  38.   IF type%>&FFF THEN WARNING(TOKEN("Unable"),"Message from Maths"):ENDPROC
  39.  
  40.   HOURON:file%=OPENIN(file$)
  41.   WHILE NOT EOF#file%
  42.     ' Get line as string and a number
  43.     line$=TRIM(GET$#file%):line=VAL(line$)
  44.     IF LEFT$(line$,1)<>"0" AND line=0 THEN
  45.       ' This line is obviously invalid, so ignore it
  46.     ELSE
  47.       ' Add line's value to totals
  48.       sigx+=line:sigxsq+=line^2:num%+=1
  49.     ENDIF
  50.   ENDWHILE
  51.   CLOSE#file%:HOUROFF
  52.  
  53.   mean     = sigx/num%
  54.   tolerance= (sigxsq/num%)-(mean^2)
  55.   stdev    = SQR(tolerance)
  56.  
  57.   ' Copy results into window and open it
  58.   SETICON(results,results_total,STR$(sigx))
  59.   SETICON(results,results_number,STR$(num%))
  60.   SETICON(results,results_mean,STR$(mean))
  61.   SETICON(results,results_tolerance,STR$(tolerance))
  62.   SETICON(results,results_stdev,STR$(stdev))
  63.   OPENWINDOW(results)
  64. ENDPROC
  65. ENDSUBR
  66.  
  67.