Jump to content

How to read part of line?


Go to solution Solved by czardas,

Recommended Posts

K dude thanks! worked!

 

That's good to hear

For parsing lines of code, most String functions are generally useful. You may sometimes need to trim spaces from one, or both ends, of each line using StringStripWS() before doing anything else.

Using more advanced features like StringRegExp() will take a lot of study, but ffirst check out all the simpler String functions and learn what they all do. That will bring you forward in your project.

Good luck with this. :)

Edited by czardas
Link to comment
Share on other sites

Here's an example of how I might do it.

;

Local $sLineFromFile = "msg NOTIFICATION, Hello World"
Local $sTrimLine = StringStripWS($sLineFromFile, 1) ; Strip leading white spaces (just in case there are any)
Local $aText ; Array variable to hold split line sections

If StringLeft ($sTrimLine, 4) = "msg " Then
    $sTrimLine = StringTrimLeft($sTrimLine, 4) ; Get rid of 'msg '
    $aText = StringSplit($sTrimLine, ",") ; Split the line
    MsgBox(0, $aText[1], $aText[2])
EndIf

;

Oops, spotted two stupid mistakes. Fixed. Any questions about the code, just ask.

Edited by czardas
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...