Link to home
Start Free TrialLog in
Avatar of Mateen
Mateen

asked on

To download a file from within pb7 script.

I want to run this link by the script of Powerbuilder 7.
I have Internet Explorer.

http://www.moosani.com/pricelst/May2006/12052006.csv

Is it possible to by pass every intermediaries.

I mean, internally, the script would connect to the above link. Save the file into directory D:\download without asking from the user. Etc.
ASKER CERTIFIED SOLUTION
Avatar of diasroshan
diasroshan
Flag of Kuwait image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

in ur case just change the below line
 li_FileNum = FileOpen("C:\"+ls_filename, LineMode!, Write!, LockWrite!, Append!)

To ,

 li_FileNum = FileOpen("D:\Download\"+ls_filename, LineMode!, Write!, LockWrite!, Append!)

Cheers,
Rosh
Hi,

missed something important... u need to create a user object

export the following file... copy the below content and save it as n_cst_internet.sru
and export it...

//From here
$PBExportHeader$n_cst_internet.sru
forward
global type n_cst_internet from internetresult
end type
end forward

global type n_cst_internet from internetresult
end type
global n_cst_internet n_cst_internet

type variables
String is_data
end variables
forward prototypes
public function integer internetdata (blob data)
end prototypes

public function integer internetdata (blob data);is_data = string(data)
RETURN 1

end function

on n_cst_internet.create
call super::create
TriggerEvent( this, "constructor" )
end on

on n_cst_internet.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on
//till here


Cheers,
Rosh
Avatar of Mateen
Mateen

ASKER

Hi dia,

U r genius.

I have one more wish.

I want to save the file "15052006.csv" ( todays' file) as "15052006.txt", I want to rename the extention of the file
from .csv to .txt

Many many thanks

Hi,

To save as .txt
change this line
ls_filename = Mid(ls_url,Len(ls_url) - 12) //grabbing file name from URl assuming it to b of same length

To,
ls_filename = Mid(ls_url,Len(ls_url) - 12,9) //grabbing file name from URL assuming it to b of same length

And,
li_FileNum = FileOpen("D:\Download\"+ls_filename, LineMode!, Write!, LockWrite!, Append!)

To,
li_FileNum = FileOpen("D:\Download\"+ls_filename + '.txt', LineMode!, Write!, LockWrite!, Append!)

Thanks for the compliment... feels gr8...
but buddy... im just refering to PB help... nothing else... ;)

Cheers,
Rosh
Avatar of Mateen

ASKER

Hi dia Roshan,

Sorry , I could not make it clear to where to change the file name. You had to work a lot.

Your code is working great and the downloaded file is being saved into
D:\download\15052006.csv
Once this file name is saved then after that I want to rename the file
D:\download\15052006.csv
as
D:\download\15052006.txt

I did a lot of search in EE Powerbuilder area about this, but, couldnt find any already asked question in this regard






Hi,


i have explained it in the above post...

in the code make changes in 2 lines...

To save as .txt
change this line
ls_filename = Mid(ls_url,Len(ls_url) - 12)
To,
ls_filename = Mid(ls_url,Len(ls_url) - 12,9)

And change the following line,
li_FileNum = FileOpen("D:\Download\"+ls_filename, LineMode!, Write!, LockWrite!, Append!)

To,
li_FileNum = FileOpen("D:\Download\"+ls_filename + '.txt', LineMode!, Write!, LockWrite!, Append!)


Hope im clear...

Cheers,
Rosh
Avatar of Mateen

ASKER

Yes, u r right.
Its ok
Thanks.