RAMMRODD Posted April 13, 2009 Share Posted April 13, 2009 Im starting to play with the array command and Im having an issue with stringbetween and reading a file. I've messed with stringbetween so Im a little familiar with it, but importing text from a document is completely foreign. Plz help #include <String.au3> #include <array.au3> $file = FileOpen("test.txt", 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop Wend $aArray1 = _StringBetween($line, 'Before', 'After'); MsgBox(0, "Text Between Before and After:", $aArray1) test.txt has Before Before Goal After Link to comment Share on other sites More sharing options...
CodyBarrett Posted April 13, 2009 Share Posted April 13, 2009 MsgBox(0, "Text Between Before and After:", $aArray1[0]) [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
RAMMRODD Posted April 14, 2009 Author Share Posted April 14, 2009 ==> Subscript used with non-Array variable.: Right at the [0] Im new to array's so plz point me towards anything I missed, wrong format wrong command anything....plz and thank you Link to comment Share on other sites More sharing options...
zorphnog Posted April 14, 2009 Share Posted April 14, 2009 (edited) Learn error handling. You always need to check the result of a function that returns an array. #include <String.au3> #include <array.au3> $sFile = FileRead("test.txt") If Not @error Then $aBetween = _StringBetween($sFile, 'Before', 'After') If Not @error And IsArray($aBetween) Then _ArrayDisplay($aBetween) Else MsgBox(16, "Text Between Before and After:", "Not found") EndIf Else MsgBox(16, "Error", "File not read") EndIf Edited April 14, 2009 by zorphnog Link to comment Share on other sites More sharing options...
RAMMRODD Posted April 19, 2009 Author Share Posted April 19, 2009 Wow that worked great. So does that mean the $aBetween can then be used in another if statement? Im pretty sure it can but just double checking. IF $aBetween > 50 then do something? I'd really like to figure some stuff out on my own, so if I could get a yes or no on this that'd be great... thanks again Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now