Dear,

We take a look at your script.
We found some problems:
  • the amount of brackets in line 35 isn't correct.
  • you try in last WHILE/LOOP structure to remove "," symbols, but you
    are removing SPACE character.
  • you are using INTEGER which has a restrictive max/min value.
    As input we are using:
    code:
            19 file(s)  3,591,977,164 bytes
    214 file(s) 34,605,720 bytes
    1 file(s) 27,648 bytes
    3 file(s) 281,795 bytes
    3 file(s) 1,046 bytes
    240 file(s) 3,626,893,373 bytes

    the output becomes something like
    code:
     input          240 file(s)  3,626,893,373 bytes
    files 240
    bytes 3,626,893,373
    convert 3626,893,373
    convert 3626893,373
    convert 3626893373
    bytes -652415

    the latest value of "-652415" will be use for calculation number of KBytes.
Our version:
code:
 $path="h:\"
$tempfile="c:\00003.tmp"

$lokaal=GetFileVersion("%WINDIR%\Explorer.exe", "Language")
IF ($lokaal = "0413Dutch")
$string="bestand(en)"
ELSE
$string="File(s)"
ENDIF
? "language "+$lokaal+" -> search for "+$string+" in directory "+$path
;
;=== Vang de DIR info op, filter alle regels weg behalve de regels met $String (directory output)
;
SHELL '%comspec% /c dir "$path" /s /a-d /-c | find "$string" >$tempfile'
;
IF (Open(1, $tempfile, 2) = 0)
$line=ReadLine(1)
WHILE ($line <> "")
$prevline=$line
$line=ReadLine(1)
LOOP
$=Close(1)
ENDIF
DEL $tempfile
;
? " input "+$prevline
$files=Val(Ltrim(Substr($prevline, 1, InStr($prevline, "f") - 2)))
? " files "+$files
$bytes=Ltrim(Substr($prevline,InStr($prevline,")")+1,Len($prevline)-InStr($prevline,")")-(Len($prevline)-InStr($prevline,"b")+2)))
? " bytes "+$bytes
WHILE (InStr($bytes,",") <> 0)
$bytes=Substr($bytes,1,InStr($bytes,",")-1)+Substr($bytes,InStr($bytes,",")+1,Len($bytes)-InStr($bytes,", ")+1)
? " convert "+$bytes
LOOP
;
;=== Converteer het resultaat naar een integer variable.
;
? " bytes"+Val($bytes)
$homedir_kbytes=(Val($bytes)+512)/1024
? " KBytes "+$homedir_kbytes

greetings.
btw: verified on kixtart 3.63, 4.02 and 4.10
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA