Sign in to follow this  
Followers 0
stigma

How to extract a substring from a string?

3 posts in this topic

#1 ·  Posted (edited)

Hey all,

I am working on a script that communicated via autoits TCP functionality to another autoit script.

What I would like to acomplish is to send commands from one script to the other, that makes the recipient script run a desired function.

of course this coudl be easily done by means of:

if $message == "functionX" then FunctionX()

However, this is not very elegant since each spesific command would need to be anticipated in the recipient client. The problem is further compounded by the fact that many of the functions have parameters, when there are hundreds of possible parameters that can be used for each function, it is not a good idea to just make hundres of lines of "if" sentences to figure out which it is.

So, Here is the question:

I want to be able to send both the NAME of a function, and the PARAMETER(s) for it in a single string.

If the sent command was formated like this for example: "#functionname#paramter1#parameter2|"

then it should be possible for the program to easily extract the substrings by searching for the seperators (#) and the endofline (|)

After this it would be a piece of cake to run the comamnd with its correct parameters like so:

Call ($functionname,$parameter1,parameter2)

The problem is, I don't know how to extract a substringin autoit. As far as I can see there is not a substring function, or a character-by-character read, atleast not that I have found.

So, can someone please point me in the direcction of a suitable function to use for dividing up a string into substrings?

-Stigma

Edited by stigma

Share this post


Link to post
Share on other sites



We generally use arrays to cut down on the "possibles", along with loops can turn 100's of "If" statements into a 3 or 4 liner.

Having said that... Look at StringSplit in the help file.


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.

Share this post


Link to post
Share on other sites

We generally use arrays to cut down on the "possibles", along with loops can turn 100's of "If" statements into a 3 or 4 liner.

Having said that... Look at StringSplit in the help file.

thanks, im looking at it now.

-Stigma

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