hBasic > hManual > FTP

hBasic Manual
FTP related commands

FTP



FTP flags ok flags added to FTP Client commands
FTPS

These commands control hBasic's built-in ftp server.

FTPS.SET
FTPS.START
FTPS.STOP
FTPS.LOOPBACK
FTPS Return Codes
Configures the server. (must restart server after)
Starts the server.
Stops the server
Set or clear a loopback address for the server IP.
List of FTPS command return codes


FTP Commands

FTP.<XXX> Return Flags


An optional return flag was inserted into these FTP client commands.

FTP.OPEN   {ok_nvar,} url_sexp, port_nexp, user_sexp, pw_sexp
FTP.PUT    {ok_nvar,} source_sexp, destination_sexp
FTP.GET    {ok_nvar,} source_sexp, destination_sexp
FTP.DIR    {ok_nvar,} list_nvar {,dirmark_sexp}
FTP.CD     {ok_nvar,} new_directory_sexp
FTP.RENAME {ok_nvar,} old_filename_sexp, new_filename_sexp
FTP.DELETE {ok_nvar,} filename_sexp
FTP.RMDIR  {ok_nvar,} directory_sexp
FTP.MKDIR  {ok_nvar,} directory_sexp
FTP.CLOSE  {ok_nvar}

If ok_nvar is not present, an error will stop with an error message (like legacy Basic).
If ok_nvar is present, the app will not stop with a run-time error.

if ok_nvar is 1 (true), the command was successful. There was no error.
if ok_nvar is 0, (false) there was an error. Further information may be contained in getERROR$().

Note that if you don't use this flag (omitted), then it's following comma (if any) is ignored.
FTPS Commands

These commands are able to control hBasic's built-in ftp server programmatically.


FTPS.SET return_code_nvar {, port_nexp} {, username_sexp} {, password_sexp} {, welcome_string_sexp}

Configures the server.
Do this before starting the server.
Do not use this command if the server is running, otherwise the outcome is unpredictable.

return_code_nvar

Setting
Description
Default
port_nexp the server's control port (1025 to 65535)

2345
username_sexp the login user name from client to server

hbasic
password_sexp the login password from client to server

hbasic
welcome_string_sexp The welcome string from server to client.
This must not contain newline characters.

"Welcome to the hBasic's FTP-Server"
Commas are need to separate parameters if they are used.
e.g
FTPS.SET rc,5555,"john", p$, "Welcome to myApp's Server"
FTPS.SET rc, ,"john", "mypass"
FTPS.SET rc, , ,newpassword$


Do not put any newlines ("\n") inside the welcome string.
Note that some ftp-clients do not allow to have empty usernames and/or passwords.

FTPS.START return_code_nvar {,IP_svar}

Starts the server.

return_code_nvar
IP_svar
The IP returned as the server's ip address plus the port number used as "d.d.d.d:port"
e.g    192.0.0.105:2345

e.g
FTPS.START rc, IP$
IF rc > 0 THEN PRINT "Error" ELSE PRINT "Server started on ";IP$

FTPS.STOP return_code_nvar

Stops the server.

return_code_nvar

e.g
FTPS.STOP rc
IF rc <> 0 THEN PRINT "Error" ELSE PRINT "Server stopped"

FTPS.LOOPBACK flag_nexp

If flag is true then a loopback address (127.0.0.1) is forced for the server IP.
If the flag is false then the server address is auto-detected (default).

This is only ever useful if your app is being tested in a emulator.
For most situations this flag should be false (the default if unused).
You might need this command if you had previously set the loopback in the Editor Preferences and need to reset it before a run.
Do not use this command if the server is running, otherwise the outcome is unpredictable.

e.g
FTPS.LOOPBACK    0                 % turn off the loopback

FTPS Return codes

Some commands return an exit code (not optional) which will be one of the following;

Code
Meaning
    0    
ok
1
could not start server
2
server already running
3
could not stop server
4
server already closed
5
bad port number (port number must be from 1025 to 65535)
6
no internet permission



-End