March 28, 2024, 08:48:27 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


ftp or tcp dll

Started by m4u, September 30, 2008, 08:47:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

m4u

Hi
Do yuo Know if there is a ftp or tcp dll to use width Creative Basic?

thank

pistol350

September 30, 2008, 09:37:21 AM #1 Last Edit: September 30, 2008, 09:48:41 AM by pistol350
Hi!
I know of winsock.dll, Wininet.dll and netlib.dll .
Sure there are plenty of others, but i can provide you samples code using each of these ones.

EDIT:

I've had that link among my bookmarks for quite a long time.
Maybe you can find it useful as well :

http://oregonstate.edu/~reeset/html/other/socket.html
Regards,

Peter B.

aurelCB

Hi m4u .... :)
I find old IBasicStd example by Bizzy.
I hope that would be useful for you.

' Bizzy FTP
' A Simple FTP Uploader
' Internet Explorer ver 4 or later needed on computer to use this prog.

SETID "INTERNET_SERVICE_FTP",1
SETID "INTERNET_PRECONFIG",0
SETID "INTERNET_DIRECT",1
SETID "INTERNET_PROXY",3
SETID "INTERNET_FLAG_RELOAD",0x80000000
SETID "FTP_TRANSFER_TYPE_BINARY",2

DECLARE "wininet",InternetOpenA(agent:string,access:int,proxyname:string,proxybypass:string,flags:int),int
DECLARE "wininet",InternetConnectA(session:int,server:string,port:word,username:string,pass:string,service:int,flags:int,context:int),int
DECLARE "wininet",FtpPutFileA(hfile:int,strin:string,strout:string,flags:int,context:int),int
DECLARE "wininet",InternetCloseHandle(handle:int),int

TYPE params
def host:string
def userid:string
def pword:string
def localfile:string
def hostfile:string
ENDTYPE

DEF d1:DIALOG
DEF d2:DIALOG
DEF settings:params
DEF answer:int
DEF hopen,hconnect,hhttp:int
DEF infile,outfile:STRING
DEF site,userid,pword,ref:STRING
DEF null:POINTER
DEF paramfile:BFILE

REM change the site$ to any site you want.

DIALOG d1,0,0,295,168,0x80C20080,0,"BizzyPak FTP",DiagOne
CONTROL d1,"B,UPLOAD,26,31,100,30,0x50018001,1"
CONTROL d1,"B,SETTINGS,170,31,100,30,0x50018000,2"
CONTROL d1,"B,EXIT,97,82,100,30,0x50018000,3"
CONTROL d1,"T,,3,145,289,16,0x50000100,4"

DIALOG d2,0,0,352,171,0x80C80080,0,"Internet Parameters",DiagTwo
CONTROL d2,"T,Host:,17,16,28,15,0x5000010B,1"
CONTROL d2,"T,User ID:,17,40,42,14,0x5000010B,2"
CONTROL d2,"T,Password:,17,64,51,16,0x5000010B,3"
CONTROL d2,"T,Local File:,17,88,50,13,0x5000010B,4"
CONTROL d2,"T,Host File:,18,112,45,14,0x5000010B,5"
CONTROL d2,"E,,70,12,266,20,0x50810080,6"
CONTROL d2,"E,,70,36,266,20,0x50810080,7"
CONTROL d2,"E,,69,60,266,20,0x508100A0,8"
CONTROL d2,"E,,70,84,220,20,0x50810080,9"
CONTROL d2,"B,Browse,293,86,43,18,0x50010000,10"
CONTROL d2,"E,,70,108,267,20,0x50810080,11"
CONTROL d2,"B,Save,71,138,70,20,0x50010000,12"
CONTROL d2,"B,Exit,266,138,70,20,0x50010000,13"
CONTROL d2,"B,B,11,134,32,20,0x40080001,14"

SHOWDIALOG d1
run = 1
waituntil run=0
closedialog d1
END

'the message handler subroutine for the dialog
sub DiagOne
select @CLASS
case @IDCONTROL
select @CONTROLID
case 1
UploadFile
case 2
DoSettings
BeginWithFile
case 3
run = 0
endselect
'all controls should be initialized in response to @IDINITDIALOG
case @IDINITDIALOG
CENTERWINDOW d1
SETCONTROLTEXT(d1,4," Ready                  ")
SETCONTROLCOLOR d1,4,RGB(255,0,0),RGB(255,255,0)
' opens file for internet parameter
BeginWithFile
endselect
return

'the message handler subroutine for the dialog
sub DiagTwo
select @CLASS
case @IDCONTROL
select @CONTROLID
case 10
' Browse
BrowseFolder
case 12
' Save
WriteParamFile
case 13
closedialog d2,@IDOK
endselect
'all controls should be initialized in response to @IDINITDIALOG
case @IDINITDIALOG
CENTERWINDOW d2
' read file and put data into Edits
ObtainParamFile
endselect
return

sub UploadFile
DEF ret:int

hopen = InternetOpenA(ref,@INTERNET_PRECONFIG,"","",0)
IF hopen
SETCONTROLTEXT d1,4, " Wininet initialized       "
hconnect = InternetConnectA(hopen,site,21,userid,pword,@INTERNET_SERVICE_FTP,0,0)
IF hconnect
' Connection established
SETCONTROLTEXT d1,4, " Transfer in Progress . . . Please Wait . . .  "
SETCURSOR (d1, @CSWAIT)
ret = FtpPutFileA(hconnect,infile,outfile,@FTP_TRANSFER_TYPE_BINARY,0)
IF ret
SETCONTROLTEXT d1,4, " Upload Complete                                  "
MESSAGEBOX d1,"Transfer Complete","Upload File",@IDOK
ENDIF
SETCURSOR (d1, @CSARROW)
InternetCloseHandle(hconnect)
ENDIF
InternetCloseHandle(hopen)
ENDIF
SETCONTROLTEXT d1,4, " Ready                "
return

sub DoSettings
' load the settings dialog
DOMODAL d2
return

sub BeginWithFile
IF(OPENFILE(paramfile,getstartpath +"PARAM.DAT","R") = 0)
GET paramfile,1,settings
CLOSEFILE paramfile
' Transfer to DiagTwo edit boxes and Variables used by FtpPutFile
site = settings.host
userid = settings.userid
pword = settings.pword
infile = settings.localfile
outfile = settings.hostfile
ref = "BizzyPak"
ENDIF
return

sub ObtainParamFile
IF(OPENFILE(paramfile,getstartpath +"PARAM.DAT","R") = 0)
GET paramfile,1,settings
CLOSEFILE paramfile
' Transfer to DiagTwo edit boxes and Variables used by FtpPutFile
site = settings.host
userid = settings.userid
pword = settings.pword
infile = settings.localfile
outfile = settings.hostfile
ref = "TechShop"
SETCONTROLTEXT d2,6,site
SETCONTROLTEXT d2,7,userid
SETCONTROLTEXT d2,8,pword
SETCONTROLTEXT d2,9,infile
SETCONTROLTEXT d2,11,outfile
ENDIF
return

sub WriteParamFile
' Write settings to Param File
SETCURSOR (d2, @CSWAIT)
settings.host = GETCONTROLTEXT(d2,6)
settings.userid = GETCONTROLTEXT(d2,7)
settings.pword = GETCONTROLTEXT(d2,8)
settings.localfile = GETCONTROLTEXT(d2,9)
settings.hostfile = GETCONTROLTEXT(d2,11)

IF(OPENFILE(paramfile,getstartpath +"PARAM.DAT","W") = 0)
PUT paramfile,1,settings
CLOSEFILE paramfile
ENDIF
SETCURSOR (d2, @CSARROW)
return

sub BrowseFolder
DEF filename,filter,fileonhost:string
DEF Fnd,pos,loc:int

' Filter can be set to Find only specific File Types - Optional
' Set Filter  - fix filter to MS Access database
filter = "Access Files (*.mdb)|*.mdb|All Files (*.*)|*.*||"
' obtain the Path to the folder and files
filename = filerequest("Select Upload File Folder",d2,1,filter,"*.*",0)
' get path Only
Fnd = 1:pos = 1
DO
IF (INSTR(pos, filename, "\") > 0) THEN loc = pos ELSE Fnd = 0
pos = pos + 1
until Fnd = 0
' get file name to put in Host file name
fileonhost = MID$(filename, loc+1)
' put filename in Host filename
SETCONTROLTEXT (d2, 11, fileonhost)
'Put Path and File in Edit Box where file to upload is
SETCONTROLTEXT (d2, 9, filename)
return


In attachment is complet program with data file and "readme" file.

pistol350

September 30, 2008, 03:53:36 PM #3 Last Edit: October 01, 2008, 02:07:49 PM by pistol350
Well done Aurel!

I was thinking of providing that same example.
Thought it was already somewhere on the forum.

EDIT : By the way, this utility is really very handy.
I've been using it alot today to have a small site set up.
It's very simple and easy to use.
Thank you again Allan for writing it.
Cheers!
Regards,

Peter B.

aurelCB

Thanks Peter...
This example is from old ibasic extras colection . ;)