Jump to content
Sign in to follow this  

String Woes

Recommended Posts

ok I have a variable, $command, that i need to break up into pieces for a paramater like function.

So at the input i wanted to type in

ping wpc 45

(wpc stands for workstation pc, spc stands for server)

I got all the code done except for the parameter part. currently i have that command in the input and is $command, duh! I just need to know what to do after making the variable into a string. please help!

Share this post

Link to post
Share on other sites

Not exactly sure what you want...

Look at the following in the help file: StringInStr, StringSplit, StringMid, (and also StringRight, StringTrimRight, StringLeft, StringTrimLeft)

If you want to break up "ping wpc 45" into three variables, you could do this:

$vars = StringSplit("pinc wpc 45", " ");split at spaces
If @error Then
  MsgBox(4096,"error","problem with parameters.... quitting")
; When you get to this point
;  $vars[1] should contain "ping"
; $vars[2] should contain "wpc"
;  and $vars[3] should contain "45"
; Special note:  $vars[0] contains the number of parameters

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post

Link to post
Share on other sites

:D nice! that will help a lot! I have never programmed in my life and i got a lot of this thing down in about 4 hours. I'm lovin it!

hmmm. the reason i wanted the vars was so that i could change the computer number or computer type wiuth the ping command. The whole thing would be done in dos and in the backround. well that part would. the idea is to have a command line that takes care of all the dos stuff, accouting, hours and sales. BTW i work at a cyber lounge... I also will be incorportating a WOL and wake all wpc type stuff.

Share this post

Link to post
Share on other sites

Yea, you can do a lot of stuff with dos, in a window, or send them to text files and read them later. ex:

tooltip("Pinging computers",200,0)
for $i=1 to 100
run(@comspec & " /c ping wpc " & $i & " >c:\wpc" & $i & "log.txt"); make individual ping text files

wrote it on the fly, and should just be an example, I don't know how many you have or the numbering you use.

AutoIt3, the MACGYVER Pocket Knife for computers.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...