Jump to content

StringFormat Help


Recommended Posts

Would it be possible to use stringformat to pull each .sql file out of this output and run them separately?

$sUser = username
$DataRestore = mydatabase
$sPass = 12345
$Restore = FileOpenDialog("Choose MySql File", @HomeDrive & "\WINDOWS\updates", "Data To Restore (*.sql)", 5)
$sFormatString1 = "%s /c mysql.exe -u %s -p%s %s < %s"
$sExtCmd1 = StringFormat($sFormatString1, @ComSpec, $sUser, $sPass, $DataRestore, $Restore)
$Restoring = Run($sExtCmd1, @ScriptDir, @SW_HIDE)

Here Is the output

C:\windows\system32\cmd.exe /c mysql.exe -u username -p12345 mydatabase < C:\|1.sql|2.sql|3.sql

Here is the end result I'm hoping for

C:\windows\system32\cmd.exe /c mysql.exe -u username -p12345 mydatabase < C:\1.sql

C:\windows\system32\cmd.exe /c mysql.exe -u username -p12345 mydatabase < C:\2.sql

C:\windows\system32\cmd.exe /c mysql.exe -u username -p12345 mydatabase < C:\3.sql

Cheers

Edited by JamesDover
Link to comment
Share on other sites

FileOpenDialog is returning a string with all the selected filenames separated by a pipe.

You need to separate these results into an array, using the StringSplit function, and then processing each item separately.

Like in this example:

$sz = "a|b|c|d"

$array = StringSplit ($sz, "|", 1)

For $i = 1 To $array[0]
    MsgBox (0, "DEBUG", $array[$i])
Next

[quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"][/font]

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...