Home > database >  The Internet Transfer control error problem
The Internet Transfer control error problem

Time:10-01

The integer I
String fpath, fname
For I=1 to lb_1. TotalItems ()//lb_1 need to upload the full path to the file are shown in
Fpath=lb_1. Text (I)//fpath=full path to the file
Fname=right (fpath, len (fpath) - LastPos (fpath, ""))//fname=filename

Ole_1. Object. The execute (" ", "put" + + "" + fpath fname)
Do until ole_1. Object. StillExecuting=False
Loop

Next
//want to realize the function of the lb file shown in circulation call the Internet Transfer control to the execute method put batch upload file
Results the infinite loop who to see?
There is a problem how to get the execute method returns the value of the size?

CodePudding user response:

Tracking once know!


http://www.newasp.net/tech/net/12011.html

CodePudding user response:

 - when using PB development often need to use the FTP function, the most typical application is to generate TXT file of data in the data window, and then send the data file to use FTP to the remote server, due to the function of PB itself does not provide any FTP, so want to in PB for FTP transmission, can only be used outside of PB resources, the following is the author summed up several kinds of methods in the PB development, 

- 1. Use an external command

- this method is to run Windows in the program of pb, built-in FTP commands in the particular way is in the program to generate a. Bat file that will run FTP commands to the file, then run the batch file, assuming that the FTP server IP for 202.114.67.2, user named user, password, 12345, now will the local c: \ temp \ t00001 under the TXT files uploaded to the server \ txtdata \ directory, the pb code is as follows:

Integer li_bat//name of the file pointer
Li_bat=FileOpen (path_ftp + 'get_file. Bat',
LineMode! The Write! , LockWrite! The Replace!

FileWrite (li_bat, 'CD c: \ temp \')
FileWrite (li_bat, 'FTP 202.114.67.2')
FileWrite (li_bat, 'the user)
FileWrite (li_bat, '12345')
FileWrite (li_bat, 'put t00001. TXT
\ txtdata \ t00001 TXT ')
FileWrite (li_bat, 'bye')
FileWrite (li_bat, 'exit')
FileClose (li_bat)
The Run (path_ftp + get_file. BAT, Minimized!)
Messagebox (" message ", "data report")

- the advantage of this method is simple and feasible, both don't call API function, also do not need to join OLE, one disadvantage is to run the external command, will open a DOS window, lack of harmony; Two is impossible to judge success for data transmission, bad control during programming,

- 2. Using the Internet Transfer control

- the Internet control Transfer is a very commonly used in network programming, it supports two agreements at present the most widely used on the Internet, namely Http and Ftp, it is the system comes in windows98, detailed information please see the related books about this control, here we only use it to Ftp functions, add a with this control in PB OLE, named ole_1, and according to the following data set properties of this control (note not ole_1 attribute), not listed in the table of attributes, please use the default value:

Attribute values that
Protocol 2 specified use Ftp Protocol
Remotehost 202.114.67.2
The Username User1
The Password 12345

- the Internet Transfer control supports two types of data transmission, namely synchronous transmission mode and asynchronous Transfer mode, synchronous transmission mode in data transmission, they block program, this feature is implemented by calling the control method of OpenUrl; And asynchronous mode is not blocked procedure, the Execute method to achieve it by calling the control that synchronously although easy to control, but it can only download files, can't upload files, making it in an actual application is restricted, to implement the data upload download, can only use this control asynchronous transfer mode, to complete the example, the function, add the following statement in PB program can be:

Ole_1. Object. Execute (" ", "put c:
\ temp \ t00001 TXT \ txtdata \ t00001 TXT ")

- in the same way, if you want to download the file on the server to the local, under the procedure to add the line:

Ole_1. Object. The execute (" ", "get \ txtdata \ t00001 TXT c: \ temp \ t00001 TXT")

- Internet Transfer control function is powerful, it is enough to make a comparative complete FTP tool, and it's own operating system, there is no need to register the new controls in programming, but according to the author's experience, this control has two can't ignore the disadvantages, first, it is asynchronous transmission of data upload download, when only run one FTP command at a time, if a run multiple FTP commands will go wrong, for example, we want to enter the server \ file directory, upload the data again, this program should be as follows:

Ole_1. Object. The execute (" ", "CD \ file ")
Ole_1. Object. Execute (" ", "put
C: \ temp \ t00001 TXT \ txtdata \ t00001 TXT ")
- due to the execute method is executed asynchronously, order it is not a complete statement began to implement the second statement, this might server could transfer the current directory to \ under the file data has been uploaded, causing errors,

, secondly, the author also found a puzzling problem, that is using this control to upload when it will be uploaded to the server of the file on the file name to uppercase, as above case, the local t00001. TXT uploaded to the server, after the name will become t00001. TXT, this nature just as well in the NT, but on a Unix machine may bring errors,

- 3. Using Mabry Internet FTP/X Control

Is by Mabry Software company - this control provides a for the Ftp controls, the reader can be downloaded to the www.mabry.com this control (MFTPX. Ocx), by comparison, the author thinks in terms of Ftp transmission, using this control programming is the most convenient, it can complete most of the Ftp function, and can easily control program in the programming operation, such as to complete the function, we register the control first, then join one of the control in the program of PB Ole, named Ole_1; A single editor Sle_1, used to show the related information; Cb_1 a button, click it to Ftp operation, setting up a Boolean type Instance Variables, named is_con, and set to false, it is used to indicate whether or not the network has been connected, for the control of attributes in the following Settings:

Attribute values that
The Host 202.114.67.2
Logonname User
Logonpassword 12345
A Timeout of 10 according to the actual situation, set up

- add the following code in Cb_1 clicked event:

Sle_1. Text="is connect... "
Setpointer (hourglass!
Ole_1. Object. The connect ()

If is_con then
Sle_1. Text="began to transport... "
Ole_1. Object. Putfile
(" c: \ temp \ t00001. TXT ", "/txtdata t00001. TXT")
Sle_1. Text="up!"
End the if

Setpointer (arrow!
Is_con=false
In Ole_1 is added in the event of the corresponding code:
Connected events:
If fconnected then
Sle_1. Text="connection success!"
Is_con=true
The else
Sle_1. Text="connection failed!"
Is_con=false
End the if
Externalexception events:
Sle_1. Text="external error, may network impassability"

Action=ExceptionIgnore!
Progress:
Sle_1. Text="transferred"
+ string (bytestransfered) + "bytes... "



- this control other functions and attributes in PB, please see the Browser's sketchpad, no longer give details here,
- the programs in the system under test through:
- Digital Unix server
- development tools Pwin98 + Powerbuilder6.5

CodePudding user response:

What you said is tracking the debug? In the condition of debugging to run the program in all normal, infinite loop execution condition, very strange

CodePudding user response:

Problem a:
Ole_1. Object. The execute (" ", "put" + + "" + fpath fname)
Do until ole_1. Object. StillExecuting=False
Loop

Should not judge is FALSE, is equal to complete the FALSE means, should be:
Ole_1. Object. The execute (" ", "put" + + "" + fpath fname)
Do until ole_1. Object. StillExecuting=true
nullnullnullnullnullnull
  • Related