Jump to content

Help using StringFormat Function


Recommended Posts

I'm trying to format a string using StringFormat but i'm not sure how to do it properly.

The string I'm formatting is this:

\\Servername\HP Laser Color 3500

What I want to end up with is the "Servername" as one string and "HP Laser Color 3500" as another string. Of course if there is a better way of doing this instead of using StringFormat let me know.

Link to comment
Share on other sites

Dirty method, but whatever...

$aSplits = StringSplit ( "\\Servername\HP Laser Color 3500", "\")
$Server = $aSplits[$aSplits[0]-1]
$Printer = $aSplits[$aSplits[0]-0]
ConsoleWrite($Server & @CRLF)
ConsoleWrite($Printer & @CRLF)
[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

Also possible:

#include<array.au3>

  $text = "\\Servername\HP Laser Color 3500"

  $text = StringReplace($text,"\\","\")

  $array = StringSplit($text,'\',2)

  _ArrayDisplay($array)
  ;So the values you are looking for are in $array[1] and $array[2]

This works great, thanks a lot man. It looks like StringSplit was the function I need, I don't know how I missed that.
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...