Jump to content

files to another program


Guest Ov6rMinD
 Share

Recommended Posts

Guest Ov6rMinD

Hello,

I am French but I need help:

I have this code :

$message = "Appuyez sur Shift ou Ctrl pour choisir plusieurs fichiers."

$var = FileOpenDialog($message, "My Documents", "Son et vidéos (*.m3u;*.avi;*.mp3;*.mpeg;*.wav;*.jpg)", 1 + 2 + 4 )

If @error Then
    MsgBox(4096,"","Acun fichier(s) choisi")
Else
    $var = StringReplace($var, "|", @CRLF)
    MsgBox(4096,"","You chose " & $var)

And I get $var to another program in oder to add files in the list.

This method is good for one file, but not for more files.

Help!

Thanks!

JMD

Link to comment
Share on other sites

And I get $var to another program in oder to add files in the list.

This method is good for one file, but not for more files.

from help file: FileOpenDialog

Returns the full path of the file(s) chosen. Results for multiple selections are "Directory|file1|file2|..."

Use StringSplit to get the selected files in an array.

$files = StringSplit($var, "|")

$directory = $files[1] 
$file1 = $files[2] 
$file2 = $files[3] 
$file3 = $files[4] 
etc.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Guest Ov6rMinD

$files = StringSplit($var, "|")

$directory = $files[1] 
$file1 = $files[2] 
$file2 = $files[3] 
$file3 = $files[4] 
etc.
Thanks, but the problem is that the number of files is never the same!
Link to comment
Share on other sites

$message = "Appuyez sur Shift ou Ctrl pour choisir plusieurs fichiers."

$var = FileOpenDialog($message, "My Documents", "Son et vidéos (*.m3u;*.avi;*.mp3;*.mpeg;*.wav;*.jpg)", 1 + 2 + 4 )

If @error Then
    MsgBox(4096,"","Aucun fichier choisi")
Else
    $files = Stringsplit($var, "|", @CRLF)
    For $i =1 to UBOUND($files)-1
    MsgBox(4096, $files[0]),"Vous avez choisi " & $files[$i])
    next
endif
:) Edited by jpm
Link to comment
Share on other sites

This array number-count requires some serious bookkeeping in this script. How about this small tweak?:

For $i =2 to UBOUND($files) -1
Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

This array number-count requires some serious bookkeeping in this script. How about this small tweak?:

For $i =2 to UBOUND($files) -1

<{POST_SNAPBACK}>

You right I didn't remember the [0] was the count so UBOUND is not really needed
$message = "Appuyez sur Shift ou Ctrl pour choisir plusieurs fichiers."

$var = FileOpenDialog($message, "My Documents", "Son et vidéos (*.m3u;*.avi;*.mp3;*.mpeg;*.wav;*.jpg)", 1 + 2 + 4 )

If @error Then
    MsgBox(4096,"","Aucun fichier choisi")
Else
    $files = Stringsplit($var, "|", @CRLF)
    For $i =2 to $files[0]
    MsgBox(4096, $files[1]),"Vous avez choisi " & $files[$i])
    next
endif
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...