Jump to content
Sign in to follow this  
pase

Extract string

Recommended Posts

pase

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

Share this post


Link to post
Share on other sites
pase

$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

Share this post


Link to post
Share on other sites
pase

change:

$file_temp = $file_temp + $char

to

$file_temp = $file_temp & $char

:D

<{POST_SNAPBACK}>

Woohoo it works! Thanks a lot! :idiot:

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.