Jump to content

Extract string


pase
 Share

Recommended Posts

Hello,

I'm trying to write a script which uses the command line tool "wget" to download files.

The script should work as follows:

- copy the URL to the clipboard

- run the script -> it determines the filename and uses "wget"

Dim $file_temp = "", $clipboard = ClipGet(), $char = "", $count = 0, $file = ""

If StringLower(StringLeft($clipboard,3)) <> "htt" AND StringLower(StringLeft($clipboard,3)) <> "ftp" then Exit        ;no URL -> Exit

While StringLeft($char,1) <> "/"             ;determine filename
    $char = StringRight($clipboard,$count)
    $count = $count + 1
    $file_temp = $file_temp + $char
WEnd

$file = StringRight($file_temp,$count)      ;filename without "/"
msgbox(0,"Debug",$file)
[...]

My problem: the last msgbox doesn't print the filename on the screen; It just prints "0"!

I can't find the bug. I hope that somebody can help me :idiot:

Thanks in advance

pase :D

Link to comment
Share on other sites

$clipboard = ClipGet()
Msgbox(0, "", $clipboard)

$clipboard = value?

Before, you verified this variable?

Which is the value?

<{POST_SNAPBACK}>

I verified the variable with

If StringLower(StringLeft($clipboard,3)) <> "htt" AND StringLower(StringLeft($clipboard,3)) <> "ftp" then Exit

It contains the complete URL (e.g. http://fakeurl.org/files/afile.exe or ftp://lullaby.com/file.exe) and the file which is intended to be downloaded.

As I wrote before, the complete URL must be copied to clipboard, before the script starts. Then the clipboard will be read with "ClipGet()": its content will be saved in $clipboard.

I hope you could understand me.

Sorry for my bad English :idiot::D

greets

pase

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