gottygolly

get total instances for _stringbetween()

5 posts in this topic

I've been working on a project and I ran into a little error. I need to make a for loop and have it stop at the total amount for the _stringbetween()

I know some functions have it setup where $function[0][0] will give you the number but _stringbetween doesn't seem to have this option built into it.

Could someone point me towards the answer or help me with it. (I saw that the _arraydisplay tells you but couldn't figure out where in the array.au3 file.)

Thanks in advance. If you need me to post some code to better explain myself please let me know!

Share this post


Link to post
Share on other sites



Yes, posting your code or a reproducer of your issue is always a good idea.

But if you just mean to stop the loop when your search reaches a certain identifier then you could add a;

If $_stringbetween() = 123

Then ExitLoop

Share this post


Link to post
Share on other sites

Thanks for the reply, here is the code to help explain what I meant.

#include<string.au3>
#include<guiconstants.au3>
$gui = GUICreate("",310,180)
Opt("GUIOnEventMode",1)
GUISetOnEvent(-3,"_Exit")
$string = "| e5g6 | e456ybv | y8m9o | 2qser | y78m | q3dx4r | gnm | exrgv |"
GUICtrlCreateLabel($string,5,5,300,Default,$ss_center)
$ss = _StringBetween($string,"|","|")
$data = ""
For $i = 0 To 7 ;instead of 7 I want to be able to put in a variable.
    $data = $data & $ss[$i] & @CRLF
Next
GUICtrlCreateLabel($data,5,55,300,180,$ss_center)
GUISetState()

While 1
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc

 

Share this post


Link to post
Share on other sites

gottygolly,

Use UBound to find the size of the array:

For $i = 0 To UBound($ss) - 1
    $data &= $ss[$i] & @CRLF
Next

And you can see that using the &= operator makes the code a bit shorter too.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks for the help Melba, I tried that before but I messed it up a bit.

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