Page 1 of 1 1
Topic Options
#22269 - 2002-05-28 03:53 PM Hello, help with this search script.
^REL^ Offline
Fresh Scripter

Registered: 2001-06-11
Posts: 30
Loc: Netherlands
Hello,

Iam busy personalizing a bit of code that I grabbed from this board. After lots of debugging.
I can't get it to work. This is for a kind of quota.

code:
  

$Path = "H:\"
$TempFile = "C:\00003.tmp"

$Lokaal = GETFILEVERSION("%WINDIR%\Explorer.exe", "Language")
? $Locale
IF $Lokaal = "0413Dutch"
$String = "bestand(en)"
ELSE
$String = "File(s)"
ENDIF

;=== 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'

$ = OPEN(1, $TempFile)
$Line = READLINE(1)
WHILE $Line <> ""
$PrevLine = $Line
$Line = READLINE(1)
LOOP
$ = CLOSE(1)
DEL $TempFile

$Files = VAL(LTRIM(SUBSTR($PrevLine, 1, INSTR($PrevLine, "f") - 2)))
$Bytes = LTRIM(SUBSTR($PrevLine, INSTR($PrevLine, ")") + 1, LEN($PrevLine) - INSTR($PrevLine, ")") - (LEN($PrevLine) - INSTR($PrevLine, "b") + 2)))
WHILE INSTR($Bytes, " ") <> 0
$Bytes = SUBSTR($Bytes, 1, INSTR($bytes, " ") -1) + SUBSTR($Bytes, INSTR($Bytes, " ") + 1, LEN($Bytes) - INSTR($Bytes, " ") + 1)
LOOP

;=== Converteer het resultaat naar een integer variable.
$Bytes = VAL($Bytes)
? $Bytes
$HomeDir_KBytes=$bytes+512)/1024
? $HomeDir_KBytes

The problem is that var $Byte returns 0, while there is a long list off output. And also how to convert $Bytes to Mb's (rounded).
Here is a bit off the $TempFile:

[LIST]

11 bestand(en) 21614165 bytes
8 bestand(en) 5802031 bytes
21 bestand(en) 174794 bytes
12 bestand(en) 20258 bytes
6 bestand(en) 550450 bytes
1 bestand(en) 141712 bytes
37 bestand(en) 9471557 bytes
2 bestand(en) 230275 bytes
5 bestand(en) 380928 bytes
2 bestand(en) 122880 bytes
6 bestand(en) 360009 bytes
19 bestand(en) 6200890 bytes
13 bestand(en) 13861188 bytes
12 bestand(en) 13936784 bytes
3 bestand(en) 93184 bytes
2 bestand(en) 53517 bytes
10 bestand(en) 4822 bytes
10 bestand(en) 4822 bytes
1 bestand(en) 1155801 bytes
1 bestand(en) 500 bytes
10 bestand(en) 25121 bytes
8 bestand(en) 14484 bytes
94 bestand(en) 3837701 bytes
44 bestand(en) 61698 bytes
82 bestand(en) 63496 bytes
5 bestand(en) 22852 bytes
22 bestand(en) 99250 bytes
2 bestand(en) 3436 bytes
6 bestand(en) 786463 bytes
1 bestand(en) 299008 bytes
15 bestand(en) 11599954 bytes
1 bestand(en) 16896 bytes
1 bestand(en) 308304 bytes
1 bestand(en) 9975 bytes
7610 bestand(en) 518343550 bytes

[/LIST]
_________________________
This is Unix Country. On a quiet night you can hear NT reboot.

Top
#22270 - 2002-05-28 03:58 PM Re: Hello, help with this search script.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
A way to simplify your code would be to take the strings and use the SPLIT command on them. You will then get an array.
code:
$line='11 bestand(en) 21614165 bytes'
$array=split($line,' ')
$files=$array[0]
$bytes=val($array[3])
$megabytes=$bytes/1048576

_________________________
There are two types of vessels, submarines and targets.

Top
#22271 - 2002-05-28 04:13 PM Re: Hello, help with this search script.
^REL^ Offline
Fresh Scripter

Registered: 2001-06-11
Posts: 30
Loc: Netherlands
Hello Jens,
This bb ROX, and thanks for your fast reply [Smile]

I understand your array idea, I should have 4 arrays, everyone containing a row of data, where row 3 contains only the bytes. I hope Iam close because Iam very bad in programming :|

I studied it and tryed to implement this in the peace off code. Here's my try:

code:
  

$Path = "H:\"
$TempFile = "C:\00003.tmp"

$Lokaal = GETFILEVERSION("%WINDIR%\Explorer.exe", "Language")
? $Locale
IF $Lokaal = "0413Dutch"
$String = "bestand(en)"
ELSE
$String = "File(s)"
ENDIF

;=== 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'

$ = OPEN(1, $TempFile)
$Line = READLINE(1)
WHILE $Line <> ""
$PrevLine = $Line
$Line = READLINE(1)
LOOP
$ = CLOSE(1)
DEL $TempFile

$array=split($line,' ')

LOOP

$bytes=val($array[3])
$megabytes=$bytes/1048576

Is this oke?

-rel
_________________________
This is Unix Country. On a quiet night you can hear NT reboot.

Top
#22272 - 2002-05-28 05:28 PM Re: Hello, help with this search script.
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
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

Top
#22273 - 2002-05-28 05:33 PM Re: Hello, help with this search script.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I have corrected your code extensively, corrected spellings, and so on, please read it carefully.
code:
$Path = 'H:\'
$TempFile = '%TEMP%\00003.tmp'

$Lokaal = GETFILEVERSION('%WINDIR%\Explorer.exe', 'Language')
? $Lokaal
IF $Lokaal = "0413Dutch"
$String = "bestand(en)"
ELSE
$String = "File(s)"
ENDIF

;=== 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)
$Line = READLINE(1)
WHILE $Line<>'' AND @ERROR=0
$PrevLine=$Line
$Line = READLINE(1)
LOOP
$retcode = CLOSE(1)
DEL $TempFile

$array=split($line,' ')
$files=$array[0]
$bytes=val($array[3])
$megabytes=$bytes/1048576
ENDIF

_________________________
There are two types of vessels, submarines and targets.

Top
#22274 - 2002-05-30 12:01 AM Re: Hello, help with this search script.
^REL^ Offline
Fresh Scripter

Registered: 2001-06-11
Posts: 30
Loc: Netherlands
Hello Jens,

I've read the code carefully. And I do not understand the way kix read files. The rewrite of your code is not working. [Frown]

As I studied this:
code:
  

SHELL '%COMSPEC% /C dir '+$Path+' /s /a-d /-c | find "'+$String+'" >'+$TempFile

OPEN(1, $TempFile)
$Line = READLINE(1)
WHILE $Line<>'' AND @ERROR=0
$PrevLine=$Line
$Line = READLINE(1)
LOOP
$retcode = CLOSE(1)
DEL $TempFile

As i tried to understand what this code does, here is my interpertation:

First line is appending "DIR /S" directory output to a tempfile.
Next line OPEN(1, $TempFile) Is opening the tempfile under handle# 1. $Line = READLINE(1) I guess the READLINE function will read the tempfile's first line and put this in VAR $line.
WHILE $Line<>'' AND @ERROR=0 As long as the $line VAR is not empty and no error occurs. $PrevLine=$Line Put VAR $line in $prefline.

My question is: Why to use the first READLINE before the loop, and Why using a second variable $PrefLine?

Oke, after the loop has finisched, I guess not the $Line variable but the $PrefLine variable would contain the same output as the TempFile did, right?

And then your array code, here is where the script errors. I don't know why maybe the $Line variable is empty or teh syntax is wrong.

code:
  
$array=split($Line,' ')
$files=$array[0]
$bytes=val($array[3])
$megabytes=$bytes/1048576

? $files
? $bytes
? $megabytes

Tell me if iam wrong, just and please help me with this.

-rel
_________________________
This is Unix Country. On a quiet night you can hear NT reboot.

Top
#22275 - 2002-05-30 12:13 AM Re: Hello, help with this search script.
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

About first remark: indeed $prevline will contain actual information read. $line doesn't
have any data anymore.

About seond one: first read our second description of problems in your own script. It has
to deal with the usage of SPACE instead of "," character in SPLIT/InStr function.
Please change code of sealeopard to:
code:
$array=split($line,",")
$files=$array[0]
$bytes=Val($array[3])
$megabytes=$bytes/1048576
? " files "+$files
? " bytes "+$bytes
? " MBytes "+$megabytes

greetings.
_________________________
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

Top
#22276 - 2002-05-30 12:40 AM Re: Hello, help with this search script.
^REL^ Offline
Fresh Scripter

Registered: 2001-06-11
Posts: 30
Loc: Netherlands
hello dear MCA,

I tried your latest version too, it reported only the amount off bytes. Only thing is that I found the code making me dizzy.
I like the array code better, only it wouldn't work right. firts in debug mode I placed this in the loop.

code:
 
OPEN(1, $TempFile)
$Line = READLINE(1)
WHILE $line<>'' AND @ERROR=0
$prefline=$line
$line = READLINE(1)
? "line : "+$line
? "prefline : "+$prefline
LOOP

So I can see what $line & $prefline contain at runtime. This is not a list but everytime just one line, So my first question is: How the hell should one off these variables contain a list at the end of the loop, each variable is getting overwritten in the loop, ending with the last line in the tempfile. Second question is that this syntax is wrong -> $bytes=Val($array[3]). And why can't I catch the error message kix is generating.. Iam having a heartattack here..!!

P.S. Thanks for the help..
-rel
_________________________
This is Unix Country. On a quiet night you can hear NT reboot.

Top
#22277 - 2002-05-29 02:54 PM Re: Hello, help with this search script.
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

It is correct that you trying to catch only the last line of your $tempfile.
This last line is the sum of previous lines.
First we think the same way, but later only we see that you are trying to get
the total amount of files and bytes in specified directory.
We have update our version a little bit.
New version:
code:
 $null=RedirectOutput("c:\kixdebug.txt")
$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)
$prevline=$line
WHILE ($line <> "") AND (@error = 0)
IF (InStr($line,"$string") <> 0)
$prevline=$line
ENDIF
$line=ReadLine(1)
? " line "+$line
? " prevline "+$prevline
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_Mbytes=Val($bytes)/1048576
? " MBytes "+$homedir_Mbytes

btw: didn't you get 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

Current version will show
code:
language 0409English -> search for File(s) in directory h:\
line 214 file(s) 34,605,720 bytes
prevline 19 file(s) 3,591,977,164 bytes
line 1 file(s) 27,648 bytes
prevline 214 file(s) 34,605,720 bytes
line 3 file(s) 281,795 bytes
prevline 1 file(s) 27,648 bytes
line 3 file(s) 1,046 bytes
prevline 3 file(s) 281,795 bytes
line 240 file(s) 3,626,893,373 bytes
prevline 3 file(s) 1,046 bytes
line
prevline 240 file(s) 3,626,893,373 bytes
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 -668073923
MBytes -637

btw: later we will react on SPLIT function call.

please return the output of file c:\kixdebug.txt on the board.
greetings.

[ 29 May 2002, 15:23: Message edited by: MCA ]
_________________________
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

Top
#22278 - 2002-05-29 03:08 PM Re: Hello, help with this search script.
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Which windows version running? We want to see "how FIND command is running".
Same command with a different way of calling can result in different results,
which can influence your script in a negative way.

find "file(s)" >output.txt
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

find "file(s)" input.txt >output.txt
code:
---------- input.txt
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

greetings.
_________________________
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

Top
#22279 - 2002-05-29 03:51 PM Re: Hello, help with this search script.
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

The result of SPLIT doesn't do the same thing as your first code
An example:
code:
 $prevline=LTRIM(RTRIM("     240 file(s)  3,626,893,373 bytes"))
$array=split($prevline," ")
$files=""+$array[0]
$bytes=""+$array[3]
? "files "+$files
? "bytes "+$bytes

The output will be
code:
 files  240
bytes 3,626,893,373

An additional SPLIT function is necessary to remove "," symbols.
We suggest to use original code.
Also we suggest as work-around for too great integer. New version
of our code is:
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)
$prevline=$line
WHILE ($line <> "") AND (@error = 0)
IF (InStr($line,"$string") <> 0)
$prevline=$line
ENDIF
$line=ReadLine(1)
? " line "+$line
? " prevline "+$prevline
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 (string) "+$bytes
? " bytes (integer) "+Val($bytes)
IF (Len($bytes) < 4)
$Kbytes="0"
ELSE
$KBytes=Substr($bytes,1,Len($bytes)-3)
ENDIF
$homedir_Mbytes=Val($Kbytes)/1024
? " MBytes "+$homedir_Mbytes

Example of latest version:
code:
language 0409English -> search for File(s) in directory h:\
line 214 file(s) 34,605,720 bytes
prevline 19 file(s) 3,591,977,164 bytes
line 1 file(s) 27,648 bytes
prevline 214 file(s) 34,605,720 bytes
line 3 file(s) 281,795 bytes
prevline 1 file(s) 27,648 bytes
line 3 file(s) 1,046 bytes
prevline 3 file(s) 281,795 bytes
line 240 file(s) 3,626,893,373 bytes
prevline 3 file(s) 1,046 bytes
line
prevline 240 file(s) 3,626,893,373 bytes
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 (string) 3626893373
bytes (integer) -668073923
MBytes 3541

greetings.
_________________________
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

Top
#22280 - 2002-05-29 06:02 PM Re: Hello, help with this search script.
^REL^ Offline
Fresh Scripter

Registered: 2001-06-11
Posts: 30
Loc: Netherlands
Hello MCA,

I tried the latest version u posted, this one is erroring too, and I can't find a kixdebug.txt file
on C:\ either.
I am using W2K SP2 as test, but our clients are NT4, W9x and W2k. Kix version is 2001 4.00 RC1.

I appreciate your explanations alot, I have learnd. And yes, I realized that I needed the last line in the TempFile before you told in your post. Just a funny way to grab the last line. Maybe there is a unix tool "tail" available for Windows. I will search for that. Would make the loop unnessary.

And believe me, Al the code you and Jens posted didnt run well. Erroring or the output is not what I was looking for. But on the other hand, I am not a programmer, so I can be doing things wrong here.

I have searched the BB again for usefull code and came along this peace:

code:
  
Function FolderSize($folder)
DIM $fso,$fold
$folderSize = -3
if exist($folder) = 1
$FSO = createobject("scripting.filesystemobject")
$fold = $fso.getfolder($folder)
$FolderSize = $fold.size
exit(0)
else
exit(3)
endif
endfunction

$catch=(FolderSize("h:\"))
$mbytes=$catch/1048576

This works like a dream, It uses objects as I could see. Now I don't know anything about objects
and I havnt tested it with other Os's. Will do that tommorow.

And I wanted also to make this work with a progress indicator. Only thing, I can't solve that. I used this function for it.

code:
  

Function ShowSpinner($Row,$Column)

; Progressie animatie.
If Not VarType($_Spin)
Global $_Spin
EndIf

AT($Row,$Column)
Select
Case $_Spin = 2
'/'
$_Spin = 3
Case $_Spin = 3
'-'
$_Spin = 4
Case $_Spin = 4
'\'
$_Spin = 1
Case 1
'|'
$_Spin = 2
EndSelect
EndFunction

Personally I think this leaks memory and fooks the CPU 100%.

But I tryed this indicator as follows.
code:
  
Function FolderSize($folder)
DIM $fso,$fold
$folderSize = -3
if exist($folder) = 1
$FSO = createobject("scripting.filesystemobject")
$fold = $fso.getfolder($folder)
$FolderSize = $fold.size
exit(0)
else
exit(3)
endif
endfunction

shell $catch=(FolderSize("h:\"))
do
sleep 0.5

ShowSpinner(10,33)

until $catch > 0

$mbytes=$catch/1048576

? $mbytes

sleep 10
exit

But this doesnt work. :|

Anyway, Iam off to hooome, been a long day.

p.s. Love the BB [Smile]

Cheers,
rel.
_________________________
This is Unix Country. On a quiet night you can hear NT reboot.

Top
#22281 - 2002-05-29 06:22 PM Re: Hello, help with this search script.
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
All this code seems a bit complex. It appears to me that you are only trying to find the total bytes used in a particular home directory. Although this particular code takes (a few seconds) longer, why not use something like this:

code:
$path = "h:\"
$totalsize = 0
$tempfile = "%temp%\00000000.tmp"
shell ("%comspec% /c dir " + $path + " /b /a-d /s > " + $tempfile)
If OPEN(1,$tempfile)=0
While @error = 0
$size = GETFILESIZE(READLINE(1))
$totalsize = $totalsize + $size
Loop
IF Close(1)= 0
DEl $tempfile
Endif
Endif
"Total bytes = " + $totalsize
?
"Total Kbytes = " + ($totalsize/1024)
?
"Total Mbytes = " + ($totalsize/1048576)

I'm sure someone else will shoot down this idea, but essentially, I'm running a bare (/b) dir command and outputting the file names to a temporary file. Then, I am reading each file name from the file and getting the filesize. These sizes are added to find the total space used by files in that particular directory tree.

Brian

Top
#22282 - 2002-05-29 06:39 PM Re: Hello, help with this search script.
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Indeed the problem is very simple and why above scripts doesn't work in a proper way isn't very
clear.
A question about your script: how are you handling LONG filesizes (> MAX INTEGER size).
greetings.
_________________________
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

Top
#22283 - 2002-05-29 08:29 PM Re: Hello, help with this search script.
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
The code posted above should work without modification for sizes up to 2147483647 bytes. As for larger sizes, it would be very simple to check for the size > 1000000000 bytes, add 1 to a flag called $GB, then subtract 1000000000 from the total. Let me see. I could also store the numbers in an array like and operate on them that way:

Total bytes = 53234356644
$Arraybytes = 4,4,6,6,5,3,4,3,2,3,5

Hmm. I suppose I could write functions to add numbers as an array (probably subtract, multiply, and divide as well). Would anyone be interested in this?

Brian

Top
#22284 - 2002-05-29 08:39 PM Re: Hello, help with this search script.
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

DrillSergeant have write scripts which can handle long values. We doesn't find related topics at this moment on the forums.
Required? Let me know.
greetings.
_________________________
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

Top
#22285 - 2002-06-03 11:04 AM Re: Hello, help with this search script.
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Hi,

I think MCA was refering to this post?:

http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=002997

btw, the latest version of KiXtart (4.10) can handle bigger numbers as long as you define them as a floating point integer.
code:
$val1=21474836470000.
$val2=3.


$test=$val1/$val2


? $test

$test=7158278823333.33
_________________________
The Code is out there

Top
#22286 - 2002-06-05 05:10 PM Re: Hello, help with this search script.
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
solved?
_________________________
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

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.232 seconds in which 0.125 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org