Hi,
I've made a KIX script that reads a txt-file and the txt-file is only 800KB. When I run the script on my server it has 100% CPU usage. Is there any way I can run the script with low CPU usages/set priority
Jan
PS The script look like this:
FUNCTION READFILE($_file,optional $_delim,optional $_amount) DIM $
$=$_file $_delim=""+$_delim $_amount=0+$_amount $_file=FREEFILEHANDLE() IF 0=$_file EXIT 1 ENDIF IF OPEN($_file,$) EXIT 2 ENDIF $="" DO $=$+READLINE($_file)+CHR(10) UNTIL @error $ReadFile=SPLIT(LEFT($,LEN($)-2),CHR(10)) $=CLOSE($_file) $=""
IF $_amount<0 FOR $_file=$_amount+UBOUND($ReadFile)+1 TO UBOUND($ReadFile) $=$+$ReadFile[$_file]+CHR(10) NEXT $ReadFile=SPLIT(LEFT($,LEN($)-1),CHR(10)) ENDIF
IF $_amount>0 FOR $_file=0 TO $_amount-1 $=$+$ReadFile[$_file]+CHR(10) NEXT $ReadFile=SPLIT(LEFT($,LEN($)-1),CHR(10)) ENDIF
IF $_delim $ReadFile=JOIN($ReadFile,$_delim) ENDIF EXIT 0
ENDFUNCTION
FUNCTION GET_AVG
DIM $x $z $y $line $lines $min
$min=403 $x = "Pooled Available:"
FOR EACH $line IN ReadFile($log,,) $array = $line+@CRLF IF INSTR($array,$x) <> 0 $y = RIGHT($array,5) $y = VAL($y) $sum = $sum + $y $lines = $lines + 1 IF $max < $y $max = $y ENDIF IF $min => $y $min = $y ENDIF
ENDIF NEXT $avg = $sum / $lines
ENDFUNCTION
FUNCTION ADD2LOG
SHELL '%comspec% /c clicense connections > $file'
FOR EACH $line IN ReadFile($file,,22) $array=$array+$line+@CRLF NEXT $InUse= SUBSTR($array,332,500) IF @error "error @error" ENDIF
ENDFUNCTION
;====== Main program
$file="\\dkbirfs01\q8logon$\Scripts\screendump.log" $log="\\dkbirfs01\q8logon$\Scripts\ctxcount.log" ;$log="h:\Scripts\ctxcount.log" ; just for testing
GET_AVG ADD2LOG
REDIRECTOUTPUT($log,0) "@CRLF***********************************@CRLF" "Started Date: @DATE Time: @TIME@CRLF"
"$InUse" "@CRLFAVG licenses available: $avg@CRLF" "MIN licenses available: $min@CRLF" "MAX licenses available: $max@CRLF"
|