Page 1 of 1 1
Topic Options
#34777 - 2003-01-06 10:23 AM Copy Section of a Line
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Hi Everyone

Hope you all had a Happy Christmas and a Merry New Year!!!.

I have created a script that pulls in all lines from a log file and sets them lines as a verible.

Now what I want to do is cut just the information I want from the line like the following.

code:
 
Backup Completed: Sucessfully

Now I just wanted to get the part after the Backup Completed bit, it could be sucessfull or failed.

and then want to set that part as a verible.

Can anyone help me.

Thanks

Richard Farthing

Top
#34778 - 2003-01-06 10:59 AM Re: Copy Section of a Line
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Use either SubStr() or Split().

A simple example:
code:
$sLine="Backup Completed:  Sucessfully"

If Left($sLine,17)="Backup Completed:"
$sBackupStatus=SubStr($sLine,20)
EndIf

Notes:
1) Is the status really mis-spelled?
2) You will need to change the length for the Left() (the "17") and the start position of the SubStr() (the "20") to fit depending on the actual data returned.

Top
#34779 - 2003-01-06 11:03 AM Re: Copy Section of a Line
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Thanks that should now get me on my way.

Richard

Top
#34780 - 2003-01-07 12:46 AM Re: Copy Section of a Line
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I'd, use $status=trim(Split($line,":")[1])

if all that would wourk in whatever version you are running...
_________________________
How to ask questions the smart way <-----------> Before you ask

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
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.173 seconds in which 0.14 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