Jump to content

get total instances for _stringbetween()


Recommended Posts

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!

Link to comment
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

Link to comment
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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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...