Page 1 of 1 1
Topic Options
#35083 - 2003-01-09 10:53 PM Readline
colmain Offline
Lurker

Registered: 2003-01-09
Posts: 2
Loc: Canada
Hi guys,
I'm trying to gather some hardware information. I can get Kix to get everything other than system memory. I saw that there is another script that contains a memory.exe for this but would prefer to use tools installed by default on 2k/xp systems. I thought that maybe I could run the msinfo32 and print it into a file but am having some problems getting the information out of the file. I'm not a programmer by any means and am relativley new to kix. Here is the code I have so far...

,-------start
break on

;-------Operating System

? @producttype

;-------CPU Speed and type

$cpu = readvalue ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","processornamestring")

? $cpu

;-------Report the free Disk space if the drive exists

$drivec = getdiskspace( "c:\")
$drived = getdiskspace( "d:\")
$drivee = getdiskspace( "e:\")
$drivef = getdiskspace( "f:\")

If $drivec>0
? $drivec
endif
If $drived>0
? $drived
endif
If $drivee>0
? $drivee
endif
If $drivef>0
? $drivef
endif

;-------IP Address

? @IPADDRESS0

;-------System Memory

shell "C:\Program Files\Common Files\Microsoft shared\MSInfo\msinfo32.exe /report c:\test\msinfo.txt /categories applications"

If Open(1,"c:\test\msinfo.txt") = 0
WHILE @ERROR = 0
$x = ReadLine(1)
IF LEFT($x,21)= "Total physical memory"
left($mem,10)
? $mem

close (1)

ENDIF

If you guys could help I would appreciate it.

Tnx

Top
#35084 - 2003-01-09 10:58 PM Re: Readline
colmain Offline
Lurker

Registered: 2003-01-09
Posts: 2
Loc: Canada
If it helps here is the msinfo file.

System Information report written at: 01/09/03 14:49:56
System Name: xxxxxx
[System Summary]

Item Value
OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 1 Build 2600
OS Manufacturer Microsoft Corporation
System Name xxxxxx
System Manufacturer Dell Computer Corporation
System Model OptiPlex GX260
System Type X86-based PC
Processor x86 Family 15 Model 1 Stepping 2 GenuineIntel ~1800 Mhz
BIOS Version/Date Dell Computer Corporation A00, 5/10/2002
SMBIOS Version 2.3
Windows Directory C:\WINDOWS
System Directory C:\WINDOWS\System32
Boot Device \Device\HarddiskVolume1
Locale United States
Hardware Abstraction Layer Version = "5.1.2600.1106 (xpsp1.020828-1920)"
User Name xxxxxxxxxxxxxxxxxxxx
Time Zone Mountain Standard Time
Total Physical Memory 512.00 MB
Available Physical Memory 220.95 MB
Total Virtual Memory 1.16 GB
Available Virtual Memory 655.88 MB
Page File Space 673.08 MB
Page File C:\pagefile.sys

Top
#35085 - 2003-01-09 11:12 PM Re: Readline
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The second LEFT should be SUBSTR($x,22) as you want to read the stuff after the first 21 characters.

BTW, a more convenient way to gather hardware info is to utilize WMI. Just search the KiXtart BBS for 'hardware inventory' or look up Inquisitor.
_________________________
There are two types of vessels, submarines and targets.

Top
#35086 - 2003-01-10 08:22 AM Re: Readline
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I would follow Jens Suggestion to utilize WMI for that kind of tasks,

Anyway, to set the string manipulation right :



if open(1,"c:\test\msinfo.txt") = 0
   while @error = 0
       $x = readline(1)
       if instr($x,"Total physical memory")
           $mem = substr($x,22,12)
           ? $mem
       endif
   loop
   $ = close(1)
endif




[Wink]
_________________________



Top
#35087 - 2003-01-10 03:55 PM Re: Readline
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The third (length) parameter in SUBSTR($x,22,12) is optional:
quote:
Length

Optional numeric value representing the length of the substring. If omitted or if there are fewer than Length characters in the text (including the character at start), all characters from the start position to the end of the string are returned.

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

Top
#35088 - 2003-01-10 03:57 PM Re: Readline
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Jens,

that is something I overread since today ... Nice feature !!!
_________________________



Top
#35089 - 2003-01-10 04:05 PM Re: Readline
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You need to play KiXGolf since careful reading of the Manual is required to find all the (il)legal ways of saving keystrokes [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#35090 - 2003-01-10 04:15 PM Re: Readline
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
If you're doing WMI, try this...
code:
? "Total Physical Memory "+Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration",$machine))/1024+" MB"  



[ 10. January 2003, 17:42: Message edited by: Waltz ]
_________________________
We all live in a Yellow Subroutine...

Top
#35091 - 2003-01-10 04:17 PM Re: Readline
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Waltz:

You should use '+' signs when concacenating string fragments, better programming syntax!
code:
; not good
? 'aaa' $var 'bbb' $var
;good
? 'aaa'+$var+'bbb'+$var
$var='aaa'+$var+'bbb'+$var

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

Top
#35092 - 2003-01-10 04:26 PM Re: Readline
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
I knew that...
I was just testing you... [Wink]
Actually, the 'code' was cut and pasted from an old dev script, where neatness didn't count...
BTW, what is
quote:
concacenating
?
Is is similar to concatenating?... [Razz]

[ 10. January 2003, 16:28: Message edited by: Waltz ]
_________________________
We all live in a Yellow Subroutine...

Top
#35093 - 2003-01-10 04:34 PM Re: Readline
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Waltz is not (con)catenating string fragments - he is sending them to the console and the way he is doing it is perfectly correct.

Waltz's code outputs each string fragment to the console. Using '+' between the fragments will pop and push the fragments onto the stack as it constructs a temporary string to output, which is redundant and a waste of memory/CPU cycles.

Where you require a catenated string as in your assignment example the "+" signs are mandatory, not optional.

Don't forget that this is a free format language,
so
code:
? "Display" " a " "string"

is the same as
code:
?
"Display"
" a "
"string"

Sometimes it is easy to forget this and look at a script as containing "lines" of code.

Top
#35094 - 2003-01-10 04:49 PM Re: Readline
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Waltz: typo

Richard: I'm aware of the free-format aspect of KiXtart.

However, the advantage of the second example is that I can easily switch between assigning the string to a variable and outputting it to the console by just swithcing between '?' and '$var='

Also, being German, I prefer neatness [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#35095 - 2003-01-10 05:05 PM Re: Readline
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Jens,
I agree absolutely. If it was a KiX golf script however... [Wink]

I wanted to correct the implication that there was some sort of catenating going on. For instance
code:
$sVar="some variable"
$=MessageBox("sVar=" $sVar, "Debug")

Will not work.

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 1045 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.068 seconds in which 0.028 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