# WimpWorks Information File
# WimpWorks  Jaffa Software 1997. All rights reserved.

DEF TASKdetails
	Name		Maths
	Purpose		Produce statistics
	Author		 Jaffa Software 1997
	Licence		
	Version		1.01 (18-Nov-1997)
	Compress	False
	Memory		0K
	IconbarSide	Right
	IconbarPriority	&00000000
	IconbarSprite	!maths
	IconbarText	
ENDTASK

DEF WEMinclude
ENDWEM

DEF MENUiconMenu%
	Maths
	Info
		S(infoWindow%)
		
	Quit
		
		CLOSEDOWN
ENDMENU

DEF SUBR_PROCfile_dragged
	Event	4
	Every	-1
DEF PROCfile_dragged(window%, icon%, file$, type%)
  LOCAL file%,line$,line, mean,tolerance,stdev,sigx,sigxsq,num%

  ' Check the file *is* a file...
  IF type%>&FFF THEN WARNING(TOKEN("Unable"),"Message from Maths"):ENDPROC

  HOURON:file%=OPENIN(file$)
  WHILE NOT EOF#file%
    ' Get line as string and a number
    line$=TRIM(GET$#file%):line=VAL(line$)
    IF LEFT$(line$,1)<>"0" AND line=0 THEN
      ' This line is obviously invalid, so ignore it
    ELSE
      ' Add line's value to totals
      sigx+=line:sigxsq+=line^2:num%+=1
    ENDIF
  ENDWHILE
  CLOSE#file%:HOUROFF

  mean     = sigx/num%
  tolerance= (sigxsq/num%)-(mean^2)
  stdev    = SQR(tolerance)

  ' Copy results into window and open it
  SETICON(results,results_total,STR$(sigx))
  SETICON(results,results_number,STR$(num%))
  SETICON(results,results_mean,STR$(mean))
  SETICON(results,results_tolerance,STR$(tolerance))
  SETICON(results,results_stdev,STR$(stdev))
  OPENWINDOW(results)
ENDPROC
ENDSUBR

