Page 1 of 1 1
Topic Options
#108528 - 2003-11-20 03:33 PM Read File content
@lejo @rias Offline
Starting to like KiXtart

Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
Hi, I have a file like this

last.cfg

log_size=1024000
udp_interval=300
udp_attempts=6
login_interval=1800
lcs.machine_name=bmded15juarias0grlot
lcs.crypt_mode=196608
lcfd_alternate_port=9496


I need look in this file the line
lcs.machine_name=
And save in a variable the content of this line
for example:

lcs.machine_name=bmded15juarias0grlot
$lcsname="bmded15juarias0grlot"

how do this???
tks
PD: pls I canīt use functions but if is necesary....
_________________________
Look always 4 the best...

Top
#108529 - 2003-11-20 03:45 PM Re: Read File content
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sorry, you can't open a file without a function.

anyway, instead of giving you the whole thing on silver platter I give you pointers.
for getting the line from the file you need to study open() and readline() (both are functions ) from manual.
for getting the correct line, you need somekinda comparison where instr() is a good and simple choice.
_________________________
!

download KiXnet

Top
#108530 - 2003-11-20 03:49 PM Re: Read File content
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
If you decide to use UDFs, see ReadFile() and FilterArray()
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#108531 - 2003-11-20 04:55 PM Re: Read File content
@lejo @rias Offline
Starting to like KiXtart

Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
Iīm a starter and I make this script, but donīt work, Can u helpme pls?
Code:

Function FilterArray($array,$find, optional $inclusive)
Dim $lf, $t, $l, $sp
$lf=Chr(10) $sp=Chr(32)
If NOT VarType($Array) & 8192 Exit(1) EndIf
For Each $l In $array
If (InStr($l,$find) AND $inclusive AND Trim($l)> $sp)
OR (NOT InStr($l,$find) AND NOT $inclusive AND Trim($l)> $sp)
$t=$t+$lf+$l
EndIf
Next
$FilterArray=Split(SubStr($t,2),$lf)
EndFunction

Function ReadFile($file)
Dim $lf, $f, $_, $t
$lf=Chr(10)
$f=FreeFileHandle
$_=Open($f,$file)
If @error Exit @error EndIf
Do $t=$t+$lf+ReadLine($f) Until @error
$_=Close($f)
$ReadFile=Split(SubStr($t,2),$lf)
EndFunction

$tivfile=ReadFile(c:\temp\last.cfg)
$tivarray=FilterArray($tivfile,"lcs.machine_name")
?$tivarray


_________________________
Look always 4 the best...

Top
#108532 - 2003-11-20 05:01 PM Re: Read File content
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
$tivarray=FilterArray($tivfile,"lcs.machine_name")
for each $item in $tivarray
? $item
next
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#108533 - 2003-11-20 05:28 PM Re: Read File content
@lejo @rias Offline
Starting to like KiXtart

Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
The script work fine now, but donīt do that I need,
I need that look this line
lcs.machine_name=bmded15juarias0grlot
and save in a variable the text "bmded15juarias0grlot"
_________________________
Look always 4 the best...

Top
#108534 - 2003-11-20 05:44 PM Re: Read File content
@lejo @rias Offline
Starting to like KiXtart

Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
$tivarray=FilterArray($tivfile,"lcs.machine_name", 1 )

now works that I need... tks all
_________________________
Look always 4 the best...

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 1183 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.072 seconds in which 0.04 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