Sign in to follow this  
Followers 0
KABUKISTAR

_StringBetween not working

3 posts in this topic

I cannot, for the life of me, get _stringbetween to work properly. I've looked at examples using it, and tried to duplicate the syntax exactly, but it still doesn't seem to work.

I tried running a simply script that would just test out _stringbetween:

#include <String.au3>
#include <File.au3>

dim $filetest = "File Writing is working"
dim $ostring = "abcStringBetween is Workingxyz"
dim $betweenstring = _stringbetween($ostring, "abc", "xyz")
dim $betweenstring2 = _stringbetween("abcStringBetween is Workingxyz", "abc", "xyz")
$file = fileopen("test.txt", 1)

filewriteline($file, $filetest)
filewriteline($file, $betweenstring)
filewriteLine($file, $betweenstring2)

The resulting test.txt file contains the line "File Writing is Working", followed by two blank lines. Can anyone tell me what I'm doing wrong?

Share this post


Link to post
Share on other sites



I guess you haven't looked in the help file (or you have but missed this part)

Return Value

Success: A 0 based $array[0] contains the first found string.

Failure: 0

@Error - 1 = No inbetween string found.

so, in order for your script to work you need to write an array element.

#include <String.au3>
#include <File.au3>

dim $filetest = "File Writing is working"
dim $ostring = "abcStringBetween is Workingxyz"
$betweenstring = _stringbetween($ostring, "abc", "xyz")

$file = fileopen("test.txt", 1)

filewriteline($file, $filetest)
filewriteline($file, $betweenstring[0])

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Ah, thank you very much. I can get it to work now.

Share this post


Link to post
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
Sign in to follow this  
Followers 0