Jump to content
Sign in to follow this  
HeXetic

Help using StringFormat Function

Recommended Posts

HeXetic

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.

Share this post


Link to post
Share on other sites
colafrysen

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]

Share this post


Link to post
Share on other sites
Scriptonize

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]
Edited by Scriptonize

If you learn from It, it's not a mistake

Share this post


Link to post
Share on other sites
HeXetic

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.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.