Sign in to follow this  
Followers 0
=sinister=

Determining Amount Of Strings Split

12 posts in this topic

Just like the title says, how would I determine the amount of strings split in the function StringSplit.

Example:

In

$days = StringSplit("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",")

How many commas are there.

Share this post


Link to post
Share on other sites



From the documentation:

Returns an array, the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) contain the delimited strings.

:P

[font="Tahoma"]Craig Rodway, IT Support, Bishop Barrington School.[/font]

Share this post


Link to post
Share on other sites

I feel dumb, read that part wrong.... was thinking that [0] was the first string, and so on... Thanks.

Share this post


Link to post
Share on other sites

I feel dumb, read that part wrong.... was thinking that [0] was the first string, and so on... Thanks.

Just be careful not to get StringSplit() and StringRegExp() confused.

StringSplit() returns an array where [0] holds the number of elements. If you used StringRegExp() then [0] would be the first element, so you would have to use UBound($array) - 1 to give you the total number of elements (Personally I just got in the habbit for using that with everything).


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

k thanks for the tip, I have another question.

How can you read a certain line in GUICtrlCreateEdit using GUICtrlRead?

Share this post


Link to post
Share on other sites

Not too sure, but the first thing that springs to mind is that you would probably have to read the whole text, and split it with @CR and/or @LF to get individual lines.


[font="Tahoma"]Craig Rodway, IT Support, Bishop Barrington School.[/font]

Share this post


Link to post
Share on other sites

k thanks for the tip, I have another question.

How can you read a certain line in GUICtrlCreateEdit using GUICtrlRead?

Have an example of what you are talking about? Could be as easy as StringSplit(StringStripCR(GUICtrlRead($varedit)), @LF)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

_GUICtrlEditGetLine

Share this post


Link to post
Share on other sites

Never thought of using @LF, I tested using a msgbox but nothing appears.

Share this post


Link to post
Share on other sites

Ok, 1 more question until I get off yalls nerve, how about getting the line count to a GUICtrlEdit?

I tried:

$Test = UBound(GUICtrlRead($TestEdit))
    MsgBox(0, "Test", $Test)

Share this post


Link to post
Share on other sites

*grin grin* I need to look into these GUI UDF's... Thanks a ton!

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