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 ... 6 7 [8] 9 10 ... 12
106
Round Table / ScriptBasic - New Build Process
« on: April 25, 2010, 04:31:52 PM »
The 2.1 release will be the last version using the original build scripts done by Peter Verhas. As of version 2.2, the Windows version will be built and offered as a Visual Studio 2008 project. The Linux/Unix version will be redone as a configure and make standard build process. Since I don't have a Mac, I'm counting on others to test the build process on that platform.

If you have built VS2008 projects or configure/make scripts and would like to help with the effort, please reply to this post.


107
Round Table / SB & C
« on: April 15, 2010, 02:21:26 AM »
I have been playing around with the CINT C interpreter and thought I would give it a try within ScriptBasic.

Code: Text
  1. PRINT "Hello "
  2. x = EXECUTE("cint world.c",-1,p)
  3.  

Code: Text
  1. #include <stdio.h>
  2. main() {
  3.   printf("World");
  4.   }
  5.  

Output:

C:\scriptbasic\test>hello
Hello World
C:\scriptbasic\test>

Q. Can you pass variables to your C program and get the results of the C program returned back to the ScriptBasic program in a string?

A.
If the number of variables you want to pass are many, build the C program dynamically in SB and write it to a file with the embedded SB variable values as C constants. (the SB constants could be an #include file as well) If you only need to pass a couple values, then add them to the EXECUTE(cint pgm arg) and extract them from the C program's command line argument when it runs.

To return results back to SB, you need to redirect the output to a file and open it in SB after the C program runs and GET the results. If your going to use redirection or piping, you need to include the CMD processor in your EXECUTE statement.

Code: [Select]
x = EXECUTE("cmd /C \"cint your_pgm.c > results.out\"", -1, pval)

108
Tutorials / Compiling ScriptBasic for Windows
« on: April 14, 2010, 08:34:45 PM »
This tutorial will be a step-by-step guide to creating a ScriptBasic Windows binary set of executables and DLLs from source. ScriptBasic has only one set of source files for all platforms and some of the extension modules are based on cross platform open source libraries. The C compiler used in this tutorial will be the Microsoft free Visual C++ Toolkit. (VC7) This was the compiler Peter Verhas used to create the 2.1 beta and what Armando used for the final 2.1 ScriptBasic Windows release.

You can download the Visual C++ Toolkit from HERE (ScriptBasic site) or one of the many other sites on the web. This first post will show the C compiler being installed. The next post will be installing the development versions of the open source libraries used with the extension modules. The final post will show you how to compile ScriptBasic source to build the binaries.

















109
Round Table / History of *nix
« on: February 13, 2010, 01:12:04 PM »

110
Round Table / Windows download virus false positive
« on: October 09, 2009, 10:54:10 AM »
I recieved a report from Roberto lo Storto (SB user and wiki contributor) that the NT.DLL is showing warnings/virus alerts in a couple of the anti-virus packages being used. The NT.DLL extension module allows you to work with the registry and shutdown the system from your ScriptBasic program as an example. If your anti-virus software detects the NT.DLL is unsafe, it might be if your not careful using the extension module correctly. Roberto sent me an online scan report in a PDF that shows which anti-virus packages detected a problem.

NT.DLL virus check report



111
Tutorials / ScriptBasic OOP
« on: October 08, 2009, 09:23:36 PM »
Here is an example how you can use OOP (Object-oriented Programming) with ScriptBasic. I plan to show other aspects of OOP style programming as time permits.

Comments and suggestions welcome !

Code: [Select]
' ScriptBasic OOP Example

MODULE Customer

instance = 0

' Default property settings
_name[0] = ""
_addr1[0] = ""
_addr2[0] = ""

property{"name"} = _name[0]
property{"addr1"} = _addr1[0]
property{"addr2"} = _addr2[0]

FUNCTION GetName(object)
  GetName = property{"name"}[object]
END FUNCTION

FUNCTION SetName(object,value)
  property{"name"}[object] = value
END FUNCTION

FUNCTION GetAddr1(object)
  GetAddr1 = property{"addr1"}[object]
END FUNCTION

FUNCTION SetAddr1(object,value)
  property{"addr1"}[object] = value
END FUNCTION

FUNCTION GetAddr2(object)
  GetAddr2 = property{"addr2"}[object]
END FUNCTION

FUNCTION SetAddr2(object,value)
  property{"addr2"}[object] = value
END FUNCTION

FUNCTION New
  instance += 1
  _name[instance] = _name[0]
  _addr1[instance] = _addr1[0]
  _addr2[instance] = _addr2[0]
  new = instance
END FUNCTION

FUNCTION Destroy(object)
  _name[object] = undef
  _addr1[object] = undef
  _addr2[object] = undef
END FUNCTION

END MODULE

'
' MAIN
'
mycust = customer::New()

customer::SetName(mycust,"John Doe")
customer::SetAddr1(mycust,"123 Main St.")
customer::SetAddr2(mycust,"Anytown, USA")

PRINT customer::GetName(mycust),"\n"
PRINT customer::GetAddr1(mycust),"\n"
PRINT customer::GetAddr2(mycust),"\n"

customer::Destroy(mycust)

C:\scriptbasic\test>custobj
John Doe
123 Main St.
Anytown, USA

C:\scriptbasic\test>

112
Tutorials / CGI Programming II
« on: October 08, 2009, 03:11:23 PM »
This thread is an attempt to introduce CGI programming using Basic as your server side CGI scripting language. The goal is to show how using Basic as your server side scripting language and interacting with the browser client via CGI and JavaScript can provide feature rich applications with desktop like  functionality. This tutorial will be Linux / Apache based.

113
Tutorials / ScriptBasic namespace support
« on: October 08, 2009, 10:53:56 AM »
SB supports namespaces using the MODULE / END MODULE statements. All variables, function and subs are localized to the module and the :: syntax must be use to access the modules resources from your main:: program (or other modules) namespace.

Code: [Select]
bar = 1

MODULE foo

PRINT bar,"\n"

bar = 2

FUNCTION modfunc
  LOCAL bar
  bar = 3
  modfunc = bar
END FUNCTION

END MODULE

PRINT bar, "\n"

PRINT foo::bar, "\n"

PRINT foo::modfunc(), "\n"

C:\scriptbasic\test>module
undef
1
2
3

C:\scriptbasic\test>

114
Tutorials / Calling functions and subs implicity
« on: October 08, 2009, 10:51:58 AM »
SB allows you to pass addresses of functions/subs to other functions and call them implicitly within the function with ICALL.

Code: [Select]
FUNCTION addone(x)
  addone = x + 1
END FUNCTION

FUNCTION x10(y)
  x10 = y * 10
END FUNCTION

FUNCTION printit(v,a)
  LOCAL r
  r = ICALL(a,v)
  PRINT r,"\n"
END FUNCTION

f1 = ADDRESS(addone())
f2 = ADDRESS(x10())

printit(1,f1)
printit(1,f2)

C:\scriptbasic\test>icall
2
10

C:\scriptbasic\test>

115
Tutorials / Arrays in ScriptBasic
« on: October 08, 2009, 10:50:15 AM »
Here is an example of using a mix of associative and standard arrays. I see this as a way to build/emulate TYPE/UNION structures in SB.

Code: [Select]
a[1]="John Doe"
a[2]="123 St."
a[3]="Anytown,USA"
a[4,1]="800-THE-SHOP"
a[4,2]="900-OUR-CELL"

cust{"addr_blk"} = a

PRINT cust{"addr_blk"}[1],"\n"
PRINT cust{"addr_blk"}[2],"\n"
PRINT cust{"addr_blk"}[3],"\n"
PRINT cust{"addr_blk"}[4,1],"\n"
PRINT cust{"addr_blk"}[4,2],"\n"

C:\scriptbasic\test>aaa
John Doe
123 St.
Anytown,USA
800-THE-SHOP
900-OUR-CELL
C:\scriptbasic\test>


This example uses three associative arrays to provide a customer address block structure.

Code: [Select]
IMPORT t.bas

p{"shop"} = "800-THE-SHOP"
p{"cell"} = "900-OUR-CELL"

a{"name"} = "John Doe"
a{"addr1"} = "123 St."
a{"addr2"} = "Anytown,USA"
a{"phone"} = p

cust{"addr_blk"} = a

PRINT cust{"addr_blk"}{"name"},"\n"
PRINT cust{"addr_blk"}{"addr1"},"\n"
PRINT cust{"addr_blk"}{"addr2"},"\n"
PRINT cust{"addr_blk"}{"phone"}{"shop"},"\n"
PRINT cust{"addr_blk"}{"phone"}{"cell"},"\n"

xmlstr = t::ArrayToXML(cust)

PRINT xmlstr,"\n"

Code: [Select]
C:\scriptbasic\test>aaaa
John Doe
123 St.
Anytown,USA
800-THE-SHOP
900-OUR-CELL
<?xml version="1.0" encoding="UTF-8"?><V><A l="0" h="1"><S>addr_blk</S><A l="0" h="7"><S>name</S><S>John Doe</S><S>addr1</S><S>123 St.</S><S>addr2</S><S>Anytown,USA</S><S>phone</S><A l="0" h="3"><S>shop</S><S>800-THE-SHOP</S><S>cell</S><S>900-OUR-CELL</S></A></A></A></V>
C:\scriptbasic\test>



Another variation for fun.

Code: [Select]
IMPORT t.bas

n[1] = "name"
n[2] = "addr1"
n[3] = "addr2"
n[4] = "phone"
n[4,1] = "shop"
n[4,2] = "cell"

p{n[4,1]} = "800-THE-SHOP"
p{n[4,2]} = "900-OUR-CELL"

a{n[1]} = "John Doe"
a{n[2]} = "123 St."
a{n[3]} = "Anytown,USA"
a{n[4]} = p

cust{"addr_blk"} = a

PRINT cust{"addr_blk"}{"name"},"\n"
PRINT cust{"addr_blk"}{"addr1"},"\n"
PRINT cust{"addr_blk"}{"addr2"},"\n"
PRINT cust{"addr_blk"}{"phone"}{"shop"},"\n"
PRINT cust{"addr_blk"}{"phone"}{"cell"},"\n"

xmlstr = t::ArrayToXML(cust)

PRINT xmlstr,"\n"


116
Tutorials / Recursive functions and variable scope
« on: October 08, 2009, 10:42:03 AM »
This example shows calling a function recursively and how to define how variables are created in functions by default. (GLOBAL or LOCAL)

Code: [Select]
FUNCTION PlusMinusOne(arg)
  IF limit < 5 THEN
    limit += 1
    arg += 1
    PRINT arg,"\n"
    PlusMinusOne(arg)
  ELSE IF arg <> 0 THEN
    arg -= 1
    PRINT arg,"\n"
    PlusMinusOne(arg)
  END IF 
  PlusMinusOne = "Done"
END FUNCTION

limit = 0

x = PlusMinusOne(0)

PRINT x,"\n"
PRINTNL
PRINT arg,"\n"
PRINT limit,"\n"

END

C:\scriptbasic\test>recurfunc
1
2
3
4
5
4
3
2
1
0
Done

undef
5

C:\scriptbasic\test>

In this example I define and assign a GLOBAL variable within the function and reference it in main. By default, variables are global unless explicitly declared as LOCAL in SUBs and FUNCTIONs. SB allows switching this functionality so variables are LOCAL by default in functions/subs and you must explicitly declare variables GLOBAL.

Quote from: SB Docs
declare option DefaultLocal

This will mean that all variables inside a function or subroutine following this line will be local unless explicitly declared to be global.

Code: [Select]
FUNCTION PlusMinusOne(arg)
  IF limit < 5 THEN
    limit += 1
    arg += 1
    PRINT arg,"\n"
    PlusMinusOne(arg)
  ELSE IF arg <> 0 THEN
    arg -= 1
    PRINT arg,"\n"
    PlusMinusOne(arg)
  END IF
  funcvar = "Defined/assigned in the function" 
  PlusMinusOne = "Done"
END FUNCTION

limit = 0

x = PlusMinusOne(0)

PRINT x,"\n"
PRINTNL
PRINT arg,"\n"
PRINT funcvar,"\n"
PRINT limit,"\n"

END

C:\scriptbasic\test>recurfunc
1
2
3
4
5
4
3
2
1
0
Done

undef
Defined/assigned in the function
5

Look what happens when we add DECLARE OPTION DefaultLocal as to the top of the above program. Since limit isn't GLOBAL it's no longer STATIC and breaks the function.

C:\scriptbasic\test>rflocal
Done

undef
undef
0

C:\scriptbasic\test>

Okay, lets fix the program by declaring limit GLOBAL.

Code: [Select]
DECLARE OPTION DefaultLocal

FUNCTION PlusMinusOne(arg)
  GLOBAL limit
  IF limit < 5 THEN
    limit += 1
    arg += 1
    PRINT arg,"\n"
    PlusMinusOne(arg)
  ELSE IF arg <> 0 THEN
    arg -= 1
    PRINT arg,"\n"
    PlusMinusOne(arg)
  END IF
  funcvar = "Defined/assigned in the function" 
  PlusMinusOne = "Done"
END FUNCTION

limit = 0

x = PlusMinusOne(0)

PRINT x,"\n"
PRINTNL
PRINT arg,"\n"
PRINT funcvar,"\n"
PRINT limit,"\n"

END

C:\scriptbasic\test>rflocal
1
2
3
4
5
4
3
2
1
0
Done

undef
undef
5

C:\scriptbasic\test>

117
Download / ScriptBasic 2.1 Linux
« on: September 12, 2009, 11:25:31 PM »
I'm pleased to announce that the first release candidate for ScriptBasic 2.1 Linux is available.

The ODBC interface has changed from unixODBC to iODBC to align with the OS X version.

Download

  • download the compressed tar file to your /usr/src directory
  • In your Linux console, cd to /usr/scr and type bunzip2 SB_2.1_RC1_Linux.tbz
  • this creates a SB_2.1_RC1_Linux.tar file.
  • extract the tar file with tar -xvf SB_2.1_RC1_Linux.tar
  • this creates a scriptbasic directory with everything needed to install ScriptBasic
  • cd into the scriptbasic directory and type ./install.sh


You are now able to use ScriptBasic

118
Download / ScriptBasic 2.1 OS X (Intel)
« on: September 06, 2009, 07:28:26 PM »
ScriptBasic OS X RC2 has been released. The following extension modules are included in this release.

ScriptBasic OS X RC2 Download - (source, documentation and pre-built binaries)

cgi.dylib - CGI Helper
curl.dylib - cURL Interface
hash.dylib - Hash (key/value pair)
mt.dylib - Web scripting session manager
mysql.dylib - MySQL direct C API interface
re.dylib - Regular Expression module
sdbg.dylib - ScriptBasic socket based debugger preprocessor
t.dylib - Tools (advanced array support)
trial.dylib - Well documented example extension module
ux.dylib - Unix fork and chmod functions
xml.dylib - Gnome Libxml2 interface
zlib.dylib - ZLIB (un)compress string / files


119
Download / ScriptBasic 2.1 Windows
« on: September 06, 2009, 07:26:45 PM »
ScriptBasic Windows 2.1 RC1 has been released.

Release Notes - Armando Rivera

  • Full release includes pre-built binaries, source and documentation
  • All modules except the hash module seem to be working.
  • Berkeley DB is original pre-compiled extension module that Peter Verhas released.

** Scriptbasic Updated 3rd Party Module Support **

-- 2009-09-06 AIR --
The following Modules have been updated to use newer versions
of 3rd party libararies:

 ----------------------------------------
| MODULE      LIBRARY VERSION       |
 ----------------------------------------
   GD      2.0.35
   CURL      7.19.5
   MYSQL   6.0.2(CONNECTOR)
   XML      2.7.3
   PSQL      8.4.0-1
   ZLIB      1.2.3
   
Import Libraries and Includes for the above are located
in the Module_Support folder.

The entire package has been rebuilt using VC++9.  Version 7 is the minimum
required version for compiling from source.

Please read the license.txt file for general licencing terms.

The 3rd party libraries may be governed by different licencing.  Please read
their licencing terms when you download each library from the provider.

AIR.


120
What's New / ScriptBasic News
« on: September 05, 2009, 06:00:47 PM »


The ScriptBasic LGPL open source project would like to announce a few new features as variations of the language API.

Home Page
Forum
Wiki



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