Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Support

Pages: 1 ... 7 8 [9] 10 11 12
121
Round Table / Using open source software
« on: August 01, 2009, 12:24:03 PM »
It couldn't be a better time to start using open source software. A client is more willing to expand the scope of a project and not be so price conscious when the software they will be using is free. The budget for the project is used to pay for your services and on going support. You remove the risk and give the feeling that life can go on if you or your company doesn't. It's much harder to get a client to take on new projects these days not knowing what the ROI may be. With open source software you can provide solutions that are already available which you can use as is or integrate into your custom solutions. You can be more competitive against larger commercial solutions because you have the open source community behind you covering your back. Linux and the many php based offerings are proof the concept works.

It's all about using shared resources and creating a community of users/VARS that take ownership into the software they use. Open  source software in general is more secure, better written and supported. The more eyes your have looking at the code the more stable it will be. Contribute your time to projects you plan to use to solve your clients needs.


122
Round Table / ScriptBasic Task List - Ver. 2.1
« on: July 25, 2009, 09:03:00 PM »
I thought I would post the ScriptBasic task list if anyone wants to jump on board and take on one of the projects.

  • Refresh the 2.1 Windows (setup) installation process with a recompile to update the extension modules with current library levels.
  • Clean up the source directory to separate what is needed for a build and move examples and documentation to a separate download
  • Create a current RPM, DEB and TAR installs for Linux
  • Create examples to show how unique features of ScriptBasic are used
  • Update SourceForge and enable/maintain SVN  of current source
  • Promote the embeddable aspect of ScriptBasic

If you have feature requests that you would like to see in a future release of ScriptBasic, please reply to this thread.



123
Round Table / ScriptBasic developers needed
« on: October 11, 2008, 09:38:28 PM »
The ScriptBasic project needs ANSI C programmers to help maintain the Basic. The author is busy with other projects and has moved on for the most part. If you would like to help keep the ScriptBasic open source project moving forward, your contributions would be appreciated by the many ScriptBasic users that count on the language for their daily tasks.The Basic is solid but the extension modules need to be refreshed with current libraries and new binary distributions for the primary platforms generated.

Please respond here or send me a e-mail to support at this URL if you can help out.

Thanks !

John Spikowski
ScriptBasic Project Manger

124
Tutorials / Runtime error handling
« on: September 24, 2008, 05:53:11 PM »
Q. How does ScriptBasic handle runtime errors?

A. ScriptBasic uses exception handling like most Basic languages. See specifics bellow.

Code: [Select]
ON ERROR GOTO ErrorTrap

ERROR 1

PRINT "This won't print\n"

ErrorTrap:

PRINT "This is the error message.\n"

END

To turn off error handling use the the following directive.

Code: [Select]
ON ERROR GOTO NULL
The RESUME directive will retry the same statement that cause the error.

The RESUME NEXT will execute the next statement after the one that caused the error.

The RESUME label will resume execution of the next statement following the provided label.

ERROR 0  clears the last error value but doesn't turn off error handling or change the resume point.

The ON ERROR RESUME label will resume execution following the provided label.

The ON ERROR RESUME NEXT will try to execute the statement after the one that caused the error.

Error Codes
Code: [Select]
0 = No error
1 = Memory error
2 = Function can not return a whole array
3 = Division by zero or other calculation error
4 = Argument to operator is undefined
5 = The command or sub was called the wrong way
6 = There are not enough arguments for the module function.
7 = The argument passed to a module function is not the correct type.
8 = The argument passed to a module function is out of acceptable range.
9 = The module experiences difficulties reading the file
10 = The module experiences difficulties writing the file.
11 = The module experiences difficulties handling the file.
12 = There is a circular reference in memory.
13 = The module can not be unloaded, because it was not loaded.
14 = Some modules were active and could not be unloaded.
15 = The module can not be unloaded, because it is currently active.
16 = The requested module can not be loaded.
17 = The requested function does not exist in the module.
18 = The module did not initialize correctly
19 = The module was developed for a different version of ScriptBasic.
20 = File number is out of range, it should be between 1 and 512
21 = The file number is already used.
22 = The file can not be opened.
23 = The file is not opened.
24 = The lock type is invalid.
25 = The print command failed. The file may be locked by another process.
26 = Directory can not be created.
27 = The directory or file could not be deleted.
28 = Command is not implemented and no currently loaded extension module defined behaviour for it
29 = The character can not be a joker or wild card character.
30 = The code tried to execute a resume while not being in error correction code.
31 = The directory name in open directory is invalid.
32 = Invalid option for directory open.
33 = The directory can not be opened.
34 = The record length is invalid in the open statement (undefined, zero or negative)
35 = The current directory can not be retrieved for some reason.
36 = The directory name in chdir can not be undef.
37 = Cannot change the current working directory to the desired directory.
38 = The command RETURN can not be executed, because there is no where to return.
39 = The argument for the function address is invalid.
40 = The attribute value or symbol is invalid in the set file command.
41 = The user does not exist.
42 = The chown command is not supported on Win95 and Win98
43 = Can not change owner.
44 = The file name is invalid.
45 = Setting the create time of the file has failed.
46 = Setting the modify time of the file has failed.
47 = Setting the access time of the file has failed
48 = The specified time format is invalid
49 = The time is not valid, cannot be earlier than January 1, 1970. 00:00
50 = Extension specific error: (ext. error code)
51 = The operation can be done on files only and not on sockets.
52 = The embedding application tried to start the code at an invalid location
53 = Mandatory argument is missing
54 = Subprocess did not finish within time limits
55 = The module can not be unloaded
56 = The preprocessor said to abort program compilation or execution.

User Guide - Error Handling

125
Tutorials / Working with files
« on: September 24, 2008, 05:51:58 PM »
Q. What types of files does ScriptBasic support?

A. ScriptBasic supports text and binary files native and a verity of database options with extension modules.

A file is just a byte stream to ScriptBasic. You can open a file for reading, writing, or both of these operations without closing and reopening the file.

Code: [Select]
OPEN file_name FOR access_mode AS [#]file_number [LEN=record_length]

Access Modes:

INPUT
OUTPUT
APPEND
RANDOM
BINARY

You can switch modes for a file while it's open with the following directives.

Code: [Select]
BINMODE [#]file_number

TEXTMODE [#]file_number

To change ScriptBasic's standard IN/OUT modes, these directives can be used.

Code: [Select]
BINMODE INPUT
BINMODE OUTPUT

TEXTMODE INPUT
TEXTMODE OUTPUT

The FREEFILE function returns an available file number.

Code: [Select]
file_number = FREEFILE

The ISDEFINED(file_numeber) or ON ERROR GOTO can be used to determine if a file handle was return by FREEFILE().

When a file is opened in RANDOM or BINARY modes, the SEEK directive may be used to position the file pointer for the next read or write operation.

Code: [Select]
SEEK [#]file_number, position
To return to the beginning of the file, use the SEEK or REWIND directives.

Code: [Select]
SEEK [#]file_number, 0
REWIND [#]file_number

If the file is opened using the optional LEN=record_length option, then the LOF function returns the total number of records for the file otherwise the LOF function returns the total number of bytes for the file.

Code: [Select]
number_of_records = LOF(file_number)
The POS function returns the current record position if the LEN=record_lenght is used otherwise the current byte position is returned.

Code: [Select]
record_position = POS(file_number)
To write to a file, the PRINT directive is used.

Code: [Select]
PRINT #file_number,expression_list
If the file is opened in text mode and a new line character is required at the end of the line, the following syntax can be used.

Code: [Select]
PRINT #file_numebr,"some test to write\n"
PRINTNL #file_numebr,"some test to write"

To read lines from a opened text file, the LINE INPUT directive is used.

Code: [Select]
LINE INPUT #file_number,variable
To read from a binary file use the INPUT function. The function will return the number of bytes specified or the remaining data.

Code: [Select]
variable = INPUT(number_of_bytes,file_number)
The current working directory can be determined with the CURDIR system variable and changed with the CHDIR directive.

Code: [Select]
PRINT CURDIR

CHDIR "directory_path"

ScriptBasic supports advisory locking of files.

Code: [Select]
LOCK #file_number,option
Options:

WRITE
READ
RELEASE

A range of bytes within a file may be locked as well.

Code: [Select]
LOCK RANGE #file_number FROM start_pos TO end_pos FOR option
Options are the same as the LOCK directive.

An open binary file my be truncated with the TRUNCATE directive.

Code: [Select]
TRUNCATE #file_number,new_file_size
A file or empty directory can be removed with the DELETE directive.

Code: [Select]
DELETE "file_name"
DELETE "directory_name"

To remove a directory and everything below it, the DELTREE directive can be used. Be careful with this command as ALL files/directories below the given directory name will be permanently deleted. (no recycle bin use)

To create a directory or a new path made up of multiple sub-directories use the MKDIR directive.

Code: [Select]
MKDIR "dir_name"
MKDIR "dir_name/sub_dir_name"

Returns true if the named file exists.

Code: [Select]
status = FILEEXISTS(file_name)

The FILELEN function returns the length in bytes of an unopened file given it's filename as the argument.

Code: [Select]
file_size = FILELEN("file_name")

File parameters can be set using the SET FILE directive.

Code: [Select]
SET FILE file_name parameter=value
Parameters:

Owner
CreateTime
ModifyTime
AccessTime


Get the time the file was modified last time.

Code: [Select]
fct = FILECREATETIME(file_name)

Get the time the file was accessed last time.

Code: [Select]
fat = FILEACCESSTIME(file_name)

Get the time the file was modified last time.

Code: [Select]
fmt = FILEMODIFYTIME(file_name)

If the destination file already exists then the command overwrites the file. If the destination file is to be created in a directory that does not exist yet then the directory is created automatically.

Code: [Select]
FILECOPY file_name_from, file_name_to

126
Tutorials / Retriving a web page
« on: September 24, 2008, 05:50:34 PM »
Q. How would I go about getting the html from a web page on the net?

A. You have two options. You can use the built in socket support in ScriptBasic or use the cURL extension module.

ScriptBasic Native
Code: [Select]
ON ERROR GOTO SiteError
OPEN "allbasic.info:80" FOR SOCKET AS #1
PRINT #1,"GET http://localhost/ HTTP/1.0\n\n"

WHILE NOT EOF(1)
  LINE INPUT #1, page_line
  PRINT page_line
WEND
CLOSE #1
END

SiteError:
PRINT "The web server allbasic.info on port 80 is not available\n"

cURL Extension Module

Example on All Basic


127
Tutorials / Reading a directory
« on: September 24, 2008, 05:49:31 PM »
Q. How do I get a list of file names in a given directory.

A. Check out the ScriptBasic wiki for directory open & close and the nextfile command to get to get a list of file names. (optionally based on a pattern)

Directory Read Information

Code: [Select]
OPEN DIRECTORY dir_name PATTERN pattern_value OPTION option_value AS dir_number

file_name = NEXTFILE

x = EOD(dir_number)

RESET DIRECTORY #dir_number

CLOSE DIRECTORY #dir_number

OPTIONS
  • SbCollectDirectories Collect the directory names as well as file names into the file list.
  • SbCollectDots Collect the virtual . and .. directory names into the list.
  • SbCollectRecursively Collect the files from the directory and from all the directories below.
  • SbCollectFullPath The list will contain the full path to the file names. This means that the file names returned by the function NextFile will contain the directory path specified in the open directory statement and therefore can be used as argument to file handling commands and functions.
  • SbCollectFiles Collect the files. This is the default behavior.
  • SbSortBySize The files will be sorted by file size.
  • SbSortByCreateTime The files will be sorted by creation time.
  • SbSortByAccessTime The files will be sorted by access time.
  • SbSortByModifyTime The files will be sorted by modify time.
  • SbSortByName The files will be sorted by name. The name used for sorting will be the bare file name without any path even if the option bit SbCollectPath is specified.
  • SbSortByPath The files will be sorted by name including the path. The path is the relative to the directory, which is currently opened. This sorting option is different from the value sbSortByName only when the value sbCollectRecursively is also used.
  • SbSortAscending Sort the file names in ascending order. This is the default behavior.
  • SbSortDescending Sort the file names in descending order.
  • SbSortByNone Do not sort. Specify this value if you do not need sorting. In this case directory opening can be much faster especially for large directories.

Note: Use AND if more then one option is needed with the OPEN DIRECTORY directive.

Here is a bit of code I snagged from my MLS utility that removes old photos of properties that have gone off market. My directory structure is made up of 1000 sub-directories numbered from 000 to 999. The last three digits of the MLS # determines which sub-directory the photo(s) resides in. The following code would read all 1000 directories selecting only .jpg files and print the file names.

Code: [Select]
fn = FREEFILE

FOR d = 0 TO 999
  DName = FORMAT("%~000~",d)
  OPEN DIRECTORY DName PATTERN "*.jpg" OPTION sbCollectFiles AS #fn
  RESET DIRECTORY #fn
  GOSUB READ_DIR
  CLOSE DIRECTORY #fn
NEXT d

END

READ_DIR:

FName = NEXTFILE(fn)
IF FName = undef THEN RETURN
PRINT FName & "\n"
GOTO READ_DIR

128
Documentation / ScriptBasic Reserved Word List
« on: April 25, 2008, 05:35:45 PM »
ABS
ACOS
ACOSECANT
ACTAN
ADDDAY
ADDHOUR
ADDMINUTE
ADDMONTH
ADDRESS
ADDSECOND
ADDWEEK
ADDYEAR
ALIAS
AND
AS
ASC
ASECANT
ASIN
ATAN
ATN
BIN
BINMODE
BY
BYVAL
CALL
CHDIR
CHOMP
CHR
CHR$
CINT
CLOSE
CLOSEALL
COMMAND
CONF
CONST
COS
COSECANT
COTAN
COTAN2
CRYPT
CURDIR
CVD
CVI
CVL
CVS
DAY
DECLARE
DELETE
DELTREE
DIRECTORY
DO
ELIF
ELSE
ELSEIF
ELSIF
END
ENDIF
ENVIRON
ENVIRON$
EOD
EOF
ERROR
ERROR$
EVEN
EXECUTE
EXIT
EXP
FALSE
FILE
FILEACCESSTIME
FILECOPY
FILECREATETIME
FILEEXISTS
FILELEN
FILEMODIFYTIME
FILEOWNER
FIX
FOR
FORK
FORMAT
FORMATDATE
FORMATTIME
FRAC
FREEFILE
FROM
FUNCTION
GCD
GLOBAL
GMTIME
GMTIMETOLOCALTIME
GO
GOSUB
GOTO
HCOS
HCOSECANT
HCTAN
HEX
HEX$
HOSTNAME
HOUR
HSECANT
HSIN
HTAN
ICALL
IF
IMAX
IMIN
INPUT
INSTR
INSTRREV
INT
ISARRAY
ISDEFINED
ISDIRECTORY
ISEMPTY
ISFILE
ISINTEGER
ISNUMERIC
ISREAL
ISSTRING
ISUNDEF
JOIN
JOKER
KILL
LBOUND
LCASE
LCASE$
LCM
LEFT
LEFT$
LEN
LET
LIB
LIKE
LINE
LOC
LOCAL
LOCALTIMETOGMTIME
LOCK
LOF
LOG
LOG10
LOOP
LOWER
LOWER$
LTRIM
LTRIM$
MAX
MAXINT
MID
MID$
MIN
MININT
MINUTE
MKD
MKD$
MKDIR
MKI
MKI$
MKL
MKL$
MKS
MKS$
MODULE
MONTH
NAME
NEXT
NEXTFILE
NO
NOT
NOW
NULL
OCT
OCT$
ODD
ON
OPEN
OPTION
OR
OUTPUT
PACK
PATTERN
PAUSE
PI
POP
POW
PRINT
PRINTNL
QUOTE
RANDOMIZE
REF
REGION
REPEAT
REPLACE
RESET
RESUME
RETURN
REWIND
RIGHT
RIGHT$
RND
ROUND
RTRIM
RTRIM$
SEC
SECANT
SEEK
SET
SGN
SIN
SLEEP
SPACE
SPACE$
SPLIT
SPLITA
SPLITAQ
SQR
STEP
STOP
STR
STR$
STRING
STRING$
STRREVERSE
STRREVERSE$
SUB
SWAP
SYSTEM
TAN
TAN2
TEXTMODE
THEN
TIME
TIMEVALUE
TO
TRIM
TRIM$
TRUE
TRUNCATE
TYPE
UBOUND
UCASE
UCASE$
UNDEF
UNPACK
UNTIL
UPPER
UPPER$
VAL
VAR
WAITPID
WEEKDAY
WEND
WHILE
WILD
XOR
YEAR
YEARDAY

Not Implemented
  • BIN - This is a planned function to convert the argument number to binary format. (aka. format as a binary number containing only 0 and 1 characters and return this string)
  • GCD - Mathematical function has become a reserved word, but are not implemented.
  • LCM - Mathematical function has become a reserved word, but are not implemented.
  • ATN - This is a planned function to calculate the arcus tangent of the argument.
  • ATAN - This is a planned function to calculate the arcus tangent of the argument.
  • TAN - This is a planned function to calculate the tangent of the argument.
  • TAN2 - This is a planned function to calculate the tangent of the ratio of the two arguments.
  • COTAN - This is a planned function to calculate the cotangent of the argument.
  • COTAN2 - This is a planned function to calculate the cotangent of the ratio of the two arguments.
  • ACTAN - This is a planned function to calculate the arcus cotangent of the argument.
  • SECANT - This is a planned function to calculate the secant of the argument.
  • COSECANT - This is a planned function to calculate the cosecant of the argument.
  • ASECANT - This is a planned function to calculate the arcus secant of the argument.
  • ACOSECANT - This is a planned function to calculate the arcus cosecant of the argument.
  • HSIN - This is a planned function to calculate the sinus hyperbolicus of the argument.
  • HCOS - This is a planned function to calculate the cosinus hyperbolicus of the argument.
  • HTAN - This is a planned function to calculate the tangent hyperbolicus of the argument.
  • HCTAN - This is a planned function to calculate the cotangent hyperbolicus of the argument.
  • HSECANT - This is a planned function to calculate the secant hyperbolicus of the argument.
  • HCOSECANT - This is a planned function to calculate the cosecant hyperbolicus of the argument.
  • MAX - This is a planned function to select and return the maximum of the arguments.
  • MIN - This is a planned function to select and return the minimum of the arguments.
  • IMAX - This is a planned function to select and return the index of the maximum of the arguments.
  • IMIN - This is a planned function to select and return the index of the minimum of the arguments.
  • CVD - This is a planned function to convert the argument string into a real number. (8 byte)
  • CVI - This is a planned function to convert the argument string into an integer. (2 bytes)
  • CVL - This is a planned function to convert the argument string into an long integer. (4 bytes)
  • CVS - This is a planned function to convert the argument string into an integer. (4 byte)
  • MKD - This is a planned function to convert the argument real number to an 8 byte string. (8 byte)
  • MKI - This is a planned function to convert the argument integer number to a string. (2 byte)
  • MKS - This is a planned function to converts a single-precision number "n" into a  string so it can later be retrieved from a random-access file as a numeric value. (4 byte)
  • MKL - This is a planned function converts a long-integer number "n" into a string so it can later be retrieved from a random-access file as a numeric value. (4-byte)

129
This zip file contains the Windows 2.1 setup built by Peter Verhas. The 2.1 version of ScriptBasic was never officially released by Peter. There have been a couple changes since the setup.exe and cab file were built. I have included an updates directory that contains the application server (sbhttpd.exe) and MySQL extension module. (mysql.dll)  Replace the installed version with these updated copies.

ScriptBasic 2.1.1 for Windows  

Note: The setup dialog will indicate that the version being installed is 2.0 which is incorrect. (scriba -v will show 2.1 for the interpreter)

Extension Module Summary
  • BDB - Berkeley DB
  • CGI - CGI helper functions
  • CIO - Console mnemonics
  • cURL - libcurl is a free and easy-to-use client-side URL transfer library, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos4), file transfer resume, http proxy tunneling and more!
  • DBG - ScrptBasic debugger (console and CGI interactive) A Windows GUI version is currently being tested.
  • DYC - This extension allow ScriptBasic to access DLL's without having to created an extension module.
  • GD - GD is an open source code library for the dynamic creation of images by programmers.
  • HASH - A hash is a set of key value pairs. Each value appearing in a hash is assigned to a key when entered into the hash and can be retrieved knowing the key.
  • MT - This module provides session support and interprocess global variables. It is used with the ScriptBasic HTTP application server.
  • MYSQL - C API interface to the MySQL database engine.
  • NT - This module implements some Win32 system calls that are not implemented in the core of ScriptBasic but can be helpful for those who want to write system maintenance scripts using ScriptBasic.
  • ODBC - Open standard database access interface. (Windows / unixODBC)
  • PSQL - PostgreSQL interface module
  • RE - Regular expression handling functions
  • T - Misc functions that didn't fit in the core language and ended up in the (T)oolbox
  • TRIAL - Example extension module to show you how to build your own.
  • XML - Functions that allow you to read/write/create XML data.
  • ZLIB - A free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operating system.
These modules require external libraries that may need to be installed for the extension module to work. All other modules have static linked the libraries as part of the extension module.


Building multi-platform GUI applications with GTK and ScriptBasic



What is GTK+?

GTK+ is a highly usable, feature rich toolkit for creating graphical user interfaces which boasts cross platform compatibility and an easy to use API. GTK+ it is written in C, but has bindings to many other popular programming languages such as C++, Python and C# among others. GTK+ is licensed under the GNU LGPL 2.1 allowing development of both free and proprietary software with GTK+ without any license fees or royalties.

Stability

GTK+ has been developed for over a decade to be able to deliver the enticing features and superb performance that it brings to your application development. GTK+ is supported by a large community of developers and has core maintainers from companies such as Red Hat, Novell, Imendio and Opened Hand.

Cross Platform

Originally GTK+ was developed for X Windows but it has grown over the years to include backend support for other well known windowing systems. Today you can use GTK+ on:
  • GNU/Linux and Unix
  • Windows
  • Mac OS X
I have assembled into one zip (8 MB) everything you need for GTK development with ScriptBasic.
  • GTK runtime for Windows
  • GTK-server for Windows
  • Glade-3 GUI designer
  • libglade - Load Glade XML project files with a few lines of code.
Download GTK for Windows

130
DYC / DYC - Documentation
« on: February 28, 2008, 12:30:02 PM »
The normal way to access external resources are via a ScriptBasic extension module. This requires creating an interface module in C. With the DYC extension the ScriptBasic programmer can make calls to system DLL's or custom one that you might create in another language.
Code: [Select]
include dyc.bas
 
a$ = "message text" & chr$(0)
print dyc::dyc("ms,i,USER32.DLL,MessageBox,PZZL",0,a$,"title",3)


Prints to the console the following values:
 
Titlebar Exit = 2
Yes = 6
No = 7
Cancel = 2

DYC("format", arguments)  - by Peter Verhas

This function calls an arbitrary function from an arbitrary dll. The first argument to the function has to be a format string and the rest of the arguments are the arguments for the function to be called. The format string has to specify the calling convention of the function, the return value, the name of the DLL and the function to call and the argument types. These have to be specified one after the other separated by commas. The format string should not contain space.

The format string has the following format:

"Xc,Xr,DllName,FunctionName,Xargs"

where


Xc specifies the calling convention
Xr specifies the return value
DllName is the name of the DLL
FunctionName is the name of the function
Xargs specifies the arguments

When the function is called the arguments are converted from their BASIC value and the function is called according to the format specification. However note that a misformed format string can cause access violation in the program and thus stopping the process. Therefore it is recommended that you fully debug your code and the way you use this function. It may be a wise idea not to install this module on a server where different programmers can develop their programs and run in shared process n multiple threads. For example a hosted web server running the Eszter SB Application Engine can be stopped by a BASIC program using this external module.

In the following I describe the format string specifiers.

Xc CALLING CONVENTION

The calling convention can be one, two or at most three characters. The character m or M means that the code was compiled using Microsoft compiler. This is the default behavour, thus there is no need to specify this. The opposite is b or B meaning that the code was compiled using Borland compiler. The difference between these two compilers is how the return value is passed back to the caller. You should not use both b and m at a time. Actually m will be ignored.

The calling convention can also be s or S meaning standard callign convention or c or C meaning language C calling convention. Only one of them is to be used in a function call. If you are callign some function from a Windows system DLL then it is certainly s. If you do not know which to use write a small test program and experiment.

The difference between standard and C calling convention is the order of the arguments placed on the stack and also who the responsible is to clean the arguments from the stack (the called function or the calling code).

Finally you can specify 4 or 8 to specify that the function is returning a four or eight-byte floating point number. Although this is a kind of return value specification, it is stated here, because this affects the calling convention. These values are returned not in a memory place from the function but rather in the co-processor register and function dyc has to know to fetch them from there rather than expection the function to return a four or eight-byte memory chunk.

Xr RETURN VALUE

The return value should be specified using a single character. This can be:

i or I int, l or L long, p or P pointer, f or F float, d or D for double or v or V for __int64.

The int and long types are converted to a BASIC integer number, which is stored as a long in ScriptBasic. float and double values are returned as real number, which is stored as double in ScriptBasic. A pointer value is converted to long and is returned in an integer value. An __int64 value is returned as an 8 byte string copiing the bytes of the original __int64 value to the bytes of the BASIC string.

DllName

This parameter has to specify the name of the DLL. This name will be used to load the DLL calling the system function LoadLibrary. This means that the name can but also may not include the full path to the file. In the latter case the system function will search the path for the DLL as specified int he Microsoft provided documentation for the function LoadLibrary.

When a function from a certain DLL is called first the module loads the DLL and when the BASIC program finishes and the module is unloaded it unloads all DLLs it loaded. Any DLL by the module will only be loaded once. Whent he module is used in a multi-thread environment the interpreter threads load and unload the DLLs independently. If you do not understand what it means then just ignore this explanation: nothing to worry about.

FunctionName

The name of the function to be called from the certain DLL. If the function is not present in the DLL then the program tries to use the function with the original name with an 'A' appended to it. Many system functions happen to have this format in the Windows librares.


Xargs argument types

This parameter should specify the arguments. It has to have as many character as many arguments there are. Each character should specify exactly one argument and will control how the actual BASIC arguments are converted to their native format. For each argument one of the following characters can be used:

1,2,4,8 specifies that the argument is an arbitrary 1-, 2-, 4- or 8-byte argument. The BASIC argument should be string value and should have at least as many characters as needed (1, 2, 4 or 8 as specified).
It is possible to use undefined, integer or real value for 1-, 2- or 4-byte values. In this case the value will be converted to integer and the bytes of the value will be used as argument. In case of 8-byte argument the BASIC argument is converted to string.

c specifies that the argument is a single character. If the BASIC argument is a string then the first character of the string is used. If the argument is a real number or an integer number then the value will be used as ASCII code. If the argument is undef or if the string has no characters in it then the value will be zero.

s specifies that the argument is a short(2-byte) value. The BASIC argument is converted to an integervalue if needed and truncated to two bytes if needed.

f specifies that the argument is a float value. The BASIC argument is converted to a real value and its precision is decreased from double to float.

h,p,l specifies that the argument is a handle, pointer or long. In these cases the BASIC argument is converted to an integer value if needed.

z specifies that the argument is a pointer that should point to a zero terminated string. The BASIC argument is converted to string and a pointer to the start of the string is passed as actual argument. Note that BASIC strings are not zero terminated and the function dyc does not append the terminating zero character to the string. Thus you have to append a zero character to the BASIC string before you pass it as zero terminated string.

On the other hand you can safely use string constants as argument like in the example above "title" because string constants in ScriptBasic contain an extra zero character following their normal characters.

d specifies that the argument is a double value. The BASIC argument is converted to a real value if needed, which is stored in BASIC internally as double and is passed to the function.

Note: that this is a wise idea to write a wrapper function in BASIC that gets the arguments performs some checks if needed and calls the module dyc instead of putting the dyc call into the main BASIC code.

131
General Discussions / Application Server Users
« on: February 04, 2008, 02:52:47 AM »
Forum Members,

I'm trying to get a head count of the ScriptBasic application server (sbhttpd) users. If you have an application server running, please reply and share your experience using it.

If your using scriba (command line interpreter) for your CGI scripts, let us know as well.

Thanks !

John

P.S.

Was the CGI programming tutorial or the explanation of how to setup the application server of help to anyone?

132
What's New / ScriptBasic Developer Services Available
« on: January 09, 2008, 05:01:18 PM »
Is it time to convert that custom legacy application to a desktop GUI or a browser based solution? ScriptBasic is the fastest and most cost effect way to retain your business logic and get more out of your application. The project manager for ScriptBasic is a software developer with 30 years of experience and is available to convert your application or assist you with the task. Contact support@scriptbasic.org  for more information about this service.
  • DOS character based application conversions
  • Data migration to SQL
  • Interfaces (web services, data capture devices and shipping systems)
  • Custom programming, design and project management

John Spikowski
ScriptBasic Project Manager
www.scriptbasic.org

133
Tutorials / ScriptBasic CGI Programming Tutorial
« on: January 04, 2008, 01:10:49 AM »
Part 1 - Hello World

This thread will be an on-going tutorial on how to use ScriptBasic for your CGI scripting needs. I will start this first post with the standard "Hello World" with the minimal amount of code needed for ScriptBasic (scriba) to generate a dynamic page. It is assumed that you have ScriptBasic installed and configured correctly. (another tutorial at a later date)

Code: [Select]
#! /usr/bin/scriba -c

INCLUDE cgi.bas

OPTION cgi$Method cgi::Get

cgi::Header(200, "text/html")
cgi::FinishHeader()

a = "Hello World !"

PRINT """
<html>
<header>
<title>ScriptBasic CGI</title>
</header>
<body>
<center>
"""

PRINT "<h1>" & a & "</h1>\n"

PRINT """
</center>
</body>
</html>
"""

END

#! /usr/bin/scriba -c
The first line of your program starts the ScriptBasic interpreter and the -c option tells scriba that this is a CGI program.

INCLUDE cgi.bas
The cgi.bas include file contains both ScriptBasic code and declares to C functions in the cgi.dll (.so) shared library. Access to cgi.bas functions and variables within it's name space is accomplished by using the cgi:: reference.
(similar to Perl)

OPTION cgi$Method cgi::Get
The OPTION statement is used to define what CGI methods are valid for the page. In our example, only GET request will be allowed. The following constants are available as an a argument for the OPTION statement. You may combine values using the OR operator.
Code: [Select]
' constants for setting option cgi$Method
const None   = &H00000000
const Get    = &H00000001
const Post   = &H00000002
const Upload = &H00000006
const Put    = &H00000008
const Del    = &H00000010
const Copy   = &H00000020
const Move   = &H00000040
const Head   = &H00000080

Header() & FinishHeader() functions
These two functions build the the basic page header that all HTML pages require.

a = "Hello World !"
Here we assign a variable with a string value. Variables do not have to have their type declared or dimensioned using a DIM statement.

PRINT """   """
The PRINT statement outputs to the browser whatever is between the triple quotes verbatim as it is in your program keeping what formating you have used.

PRINT "<h1>" & a & "</h1>\n"
The & character is used to concatenate the quoted text and the string variable holding our "Hello World !" stored value. The \n causes ScriptBasic to print a new line character. (more on using the \ character later)

END
The terminates the ScriptBasic program, ending it's connection with the web server. (optional end of program keyword)

134
GTK-Server / GTK Glade - Hello World
« on: December 02, 2007, 11:42:42 PM »
This example is using the GTK Glade designer to create a fixed size window, apply a fixed position grid and putting a label in the center of the screen. The ScriptBasic event handler is looking for the close window system button event to exit the REPEAT loop.



hello.bas
Code: [Select]

' Glade Hello World

' GTK Interface
include gtk.bas

' GTK Interface Function
FUNCTION GUI(g0, g1, g2, g3, g4, g5, g6, g7, g8, g9)
LOCAL gtk_cmd
gtk_cmd = STR(g0) & " " & STR(g1) & " " & STR(g2) & " " & STR(g3) & " " & STR(g4) & " " & STR(g5) & " " & STR(g6) & " " & STR(g7) & " " & STR(g8) & " " & STR(g9)
GUI = GTK::gtk(gtk_cmd)
END FUNCTION

' GTK Function DEF's
GUI("/etc/gtk-server.cfg")

' Initialize GTK & Glade
GUI("gtk_init")
GUI("glade_init")

' Load and show Glade defined window
xml = GUI("glade_xml_new", "hello.glade")
GUI("glade_xml_signal_autoconnect", xml)

' Get window ID and define window close event
win = GUI("glade_xml_get_widget", xml, "window1")
GUI("gtk_server_connect", win, "delete-event", "window")

' Event Handler
REPEAT
this_event = GUI("gtk_server_callback", "WAIT")
UNTIL this_event = "window"

END


hello.glade - Glade project XML file
Code: [Select]

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class="GtkWindow" id="window1">
  <property name="visible">True</property>
  <property name="title" translatable="yes">Hello</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="default_width">400</property>
  <property name="default_height">350</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <property name="decorated">True</property>
  <property name="skip_taskbar_hint">False</property>
  <property name="skip_pager_hint">False</property>
  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
  <property name="focus_on_map">True</property>
  <property name="urgency_hint">False</property>

  <child>
    <widget class="GtkFixed" id="fixed1">
      <property name="visible">True</property>

      <child>
<widget class="GtkLabel" id="label1">
 <property name="width_request">122</property>
 <property name="height_request">17</property>
 <property name="visible">True</property>
 <property name="label" translatable="yes">Hello World !</property>
 <property name="use_underline">False</property>
 <property name="use_markup">False</property>
 <property name="justify">GTK_JUSTIFY_LEFT</property>
 <property name="wrap">False</property>
 <property name="selectable">False</property>
 <property name="xalign">0.5</property>
 <property name="yalign">0.5</property>
 <property name="xpad">0</property>
 <property name="ypad">0</property>
 <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
 <property name="width_chars">-1</property>
 <property name="single_line_mode">False</property>
 <property name="angle">0</property>
</widget>
<packing>
 <property name="x">128</property>
 <property name="y">128</property>
</packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>


To get an idea of the types of widgets you can use in your screen design, check out the following link.

GNOME 2.20 Release Notes

GTK+ Reference Manual

135
Round Table / Roll Call
« on: December 01, 2007, 02:53:42 AM »
ScriptBasic Users,

If your currently using ScriptBasic for any of your applications, utilities or hobby projects, please reply to this post. I really need to get an idea of the user base ScriptBasic currently has.

Based on this number of posts made by the forum members, I'm starting to wonder if I'm the only developer using the language.

This is important and please take the time to respond if you want to see ScriptBasic continue to evolve.

This means joining the forum if you haven't done so already.

Projects I'm willing to share what I've learned if there is interest in the language:

ScriptBasic Application Server - setup and application programming

GUI programming with ScriptBasic using the GTK-server extension module


John

Pages: 1 ... 7 8 [9] 10 11 12