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.


Messages - Support

Pages: 1 ... 38 39 [40] 41 42 ... 59
586
ScriptBasic Examples w/source / Re: sbhttpd curl using open api
« on: July 29, 2011, 01:05:25 AM »
All the links you have posted point to my local network. (192.168...)

I would look at your Apache config host IP.

587
ScriptBasic Examples w/source / Re: sbhttpd curl using open api
« on: July 28, 2011, 11:13:07 PM »
I'm using cURL for a SOAP interface to a MLS web service for listing data and photos.

I have shown how you can use cURL as a way to initiate sbhttpd tasks from a scriba script.

588
mxml / Re: ScriptBasic Mini-XML Extension Module
« on: July 28, 2011, 11:05:13 PM »
Extension modules and their seamless integration with the language API is one of the most powerful aspects of the language. SB can morph into whatever your needs may be. The SB macro API interface makes interfacing with external libraries a breeze.


589
General Discussions / Re: Application Server Users
« on: July 26, 2011, 10:17:19 PM »
Ron,

Maybe this thread will help you get your sbhttpd server going as a proxy with Apache.

http://www.scriptbasic.org/forum/index.php/topic,112.0.html

Here is echo.bas running on sbhttpd as a proxy server.

http://www.northwestliving.info/home/echo.bas


John

590
General Discussions / Re: Application Server Users
« on: July 26, 2011, 08:50:11 PM »
It is still trying to connect to 192.168.0.101 as the IP. (pointing to my local intranet, not yours)

Are you running sbhttpd as a proxy or standalone?


591
General Discussions / Re: Application Server Users
« on: July 26, 2011, 04:32:49 PM »
Your URL's are still pointing to my 192.168.... local network.

I have a VPS server at a data center I host the ScriptBsic and a couple other open source Basic projects on. I have used NO-IP as a DNS service in the past when I was running on Windows and wanted to test sbhttpd.

Sorry about the use dbg line in echo.bas. I must have forgot to remove it when I was testing the remote debugger.

592
General Discussions / Re: Application Server Users
« on: July 26, 2011, 10:47:32 AM »
That's good to hear that you got your sbhttpd server running. Are you using it as a proxy server with Apache? The sbhttpd server doesn't serve up images (only Basic CGI scripts) so running as a proxy to handle this, security and load leveling is the best method. (what Apache does best)

Make sure you undef the session array returned after checking for expired sessions.

Keep us in the loop with your progress.

John

P.S.

The IP you posted is for a local intranet and isn't visible over the web.

593
GSL / Re: GNU Scientific Library (GSL)
« on: June 01, 2011, 10:56:23 PM »
This is a beta version of the GSL Mathematical Functions portion of the library. I have attached the 32 and 64 bit version for Linux if you would like to try it out. I plan to create a gsl.bas module include file when the library has been fully implemented in ScriptBasic.

Code: [Select]
/*
   GNU Scientific Library
   Based on GSL 1.15
   Interface By: John Spikowski
   Refinements By: Armando I. Rivera (AIR)
   Version 0.01
*/

#include <stdio.h>
#include "../../basext.h"
#include <gsl/gsl_math.h>
     
besVERSION_NEGOTIATE
    return (int)INTERFACE_VERSION;
besEND

besSUB_START

besEND

besSUB_FINISH

besEND

/* Elementary Functions */

besFUNCTION(_log1p)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_log1p(x));
besEND


besFUNCTION(_expm1)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_expm1(x));
besEND


besFUNCTION(_hypot)
  double x,y;

  besARGUMENTS("rr")
    &x,&y
  besARGEND 

  besRETURN_DOUBLE(gsl_hypot(x, y));
besEND


besFUNCTION(_hypot3)
  double x,y,z;
 
  besARGUMENTS("rrr")
    &x,&y,&z
  besARGEND 

  besRETURN_DOUBLE(gsl_hypot3(x, y, z));
besEND


besFUNCTION(_acosh)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_acosh(x));
besEND


besFUNCTION(_asinh)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_asinh(x));
besEND


besFUNCTION(_atanh)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_atanh(x));
besEND


besFUNCTION(_ldexp)
  double x;
  int y;

  besARGUMENTS("ri")
    &x,&y
  besARGEND 

  besRETURN_DOUBLE(gsl_ldexp(x, y));
besEND


besFUNCTION(_frexp)
  double f;
  LEFTVALUE e;

  besARGUMENTS("r")
    &f
  besARGEND
  besLEFTVALUE(besARGUMENT(2),e);
 
  besRETURN_DOUBLE(gsl_frexp(f, *e));
besEND


/* Small integer powers */


besFUNCTION(_pow_int)
  double x;
  int n;

  besARGUMENTS("ri")
    &x,&n
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_int(x, n));
besEND


besFUNCTION(_pow_uint)
  double x;
  unsigned int n;

  besARGUMENTS("ri")
    &x,&n
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_uint(x, n));
besEND


besFUNCTION(_pow_2)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_2(x));
besEND


besFUNCTION(_pow_3)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_3(x));
besEND


besFUNCTION(_pow_4)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_4(x));
besEND


besFUNCTION(_pow_5)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_5(x));
besEND


besFUNCTION(_pow_6)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_6(x));
besEND


besFUNCTION(_pow_7)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_7(x));
besEND


besFUNCTION(_pow_8)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_8(x));
besEND


besFUNCTION(_pow_9)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_9(x));
besEND


/* Testing the Sign of Numbers */


besFUNCTION(_SIGN)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_LONG(GSL_SIGN(x));
besEND


/* Testing for Odd and Even Numbers */


besFUNCTION(_IS_ODD)
  int x;

  besARGUMENTS("i")
    &x
  besARGEND 

  besRETURN_LONG(GSL_IS_ODD(x));
besEND


besFUNCTION(_IS_EVEN)
  int x;

  besARGUMENTS("i")
    &x
  besARGEND 

  besRETURN_LONG(GSL_IS_EVEN(x));
besEND


/* Maximum and Minimum functions */


besFUNCTION(_MIN)
  double a,b;

  besARGUMENTS("rr")
    &a,&b
  besARGEND 

  besRETURN_DOUBLE(GSL_MIN(a, b));
besEND


besFUNCTION(_MAX)
  double a,b;

  besARGUMENTS("rr")
    &a,&b
  besARGEND 

  besRETURN_DOUBLE(GSL_MAX(a, b));
besEND


besFUNCTION(_MIN_DBL)
  double a,b;

  besARGUMENTS("rr")
    &a,&b
  besARGEND 

  besRETURN_DOUBLE(GSL_MIN_DBL(a, b));
besEND


besFUNCTION(_MAX_DBL)
  double a,b;

  besARGUMENTS("rr")
    &a,&b
  besARGEND 

  besRETURN_DOUBLE(GSL_MAX_DBL(a, b));
besEND


besFUNCTION(_MIN_INT)
  long a,b;

  besARGUMENTS("ii")
    &a,&b
  besARGEND 
  besRETURN_LONG(GSL_MIN_INT(a,b));
besEND


besFUNCTION(_MAX_INT)
  long a,b;

  besARGUMENTS("ii")
    &a,&b
  besARGEND 

  besRETURN_LONG(GSL_MAX_INT(a, b));
besEND


besFUNCTION(_MIN_LDBL)
  double a,b;

  besARGUMENTS("rr")
    &a,&b
  besARGEND 

  besRETURN_DOUBLE(GSL_MIN_LDBL((long double)a, (long double)b));
besEND


besFUNCTION(_MAX_LDBL)
  double a,b;

  besARGUMENTS("rr")
    &a,&b
  besARGEND 

  besRETURN_DOUBLE(GSL_MAX_LDBL((long double)a, (long double)b));
besEND


/* Approximate Comparison of Floating Point Numbers */


besFUNCTION(_fcmp)
  double x,y,epsilon;
 
  besARGUMENTS("rrr")
    &x,&y,&epsilon
  besARGEND 

  besRETURN_LONG(gsl_fcmp(x, y, epsilon));
besEND



594
GSL / Re: GNU Scientific Library (GSL)
« on: May 30, 2011, 12:11:36 AM »
I added the Small Integer Powers to the ScriptBasic GSL extension module.

Code: [Select]
/* Small integer powers */


besFUNCTION(_pow_int)
  double x;
  int n;

  besARGUMENTS("ri")
    &x,&n
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_int(x, n));
besEND


besFUNCTION(_pow_uint)
  double x;
  unsigned int n;

  besARGUMENTS("ri")
    &x,&n
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_uint(x, n));
besEND


besFUNCTION(_pow_2)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_2(x));
besEND


besFUNCTION(_pow_3)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_3(x));
besEND


besFUNCTION(_pow_4)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_4(x));
besEND


besFUNCTION(_pow_5)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_5(x));
besEND


besFUNCTION(_pow_6)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_6(x));
besEND


besFUNCTION(_pow_7)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_7(x));
besEND


besFUNCTION(_pow_8)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_8(x));
besEND


besFUNCTION(_pow_9)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_pow_9(x));
besEND

Code: [Select]
DECLARE SUB pow_4 ALIAS "_pow_4" LIB "gsl"

PRINT FORMAT ("%.16g",pow_4(3.141)),"\n"

97.335607906161

595
GSL / GNU Scientific Library (GSL)
« on: May 29, 2011, 09:09:12 PM »
I have finished the Elementary Functions portion of the ScriptBasic extension module for the GSL library.

Code: [Select]
/*
   GNU Scientific Library
   Based on GSL 1.15
   Interface By: John Spikowski
   Refinements By: Armando I. Rivera (AIR)
   Version 0.01
*/

#include <stdio.h>
#include "../../basext.h"
#include <gsl/gsl_math.h>
     
besVERSION_NEGOTIATE
    return (int)INTERFACE_VERSION;
besEND

besSUB_START

besEND

besSUB_FINISH

besEND

/* Elementary Functions */

besFUNCTION(_log1p)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_log1p(x));
besEND


besFUNCTION(_expm1)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_expm1(x));
besEND


besFUNCTION(_hypot)
  double x,y;

  besARGUMENTS("rr")
    &x,&y
  besARGEND 

  besRETURN_DOUBLE(gsl_hypot(x, y));
besEND


besFUNCTION(_hypot3)
  double x,y,z;
 
  besARGUMENTS("rrr")
    &x,&y,&z
  besARGEND 

  besRETURN_DOUBLE(gsl_hypot3(x, y, z));
besEND


besFUNCTION(_acosh)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_acosh(x));
besEND


besFUNCTION(_asinh)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_asinh(x));
besEND


besFUNCTION(_atanh)
  double x;

  besARGUMENTS("r")
    &x
  besARGEND 

  besRETURN_DOUBLE(gsl_atanh(x));
besEND


besFUNCTION(_ldexp)
  double x;
  int y;

  besARGUMENTS("ri")
    &x,&y
  besARGEND 

  besRETURN_DOUBLE(gsl_ldexp(x, y));
besEND


besFUNCTION(_frexp)
  double f;
  LEFTVALUE e;

  besARGUMENTS("r")
    &f
  besARGEND
  besLEFTVALUE(besARGUMENT(2),e);
 
  besRETURN_DOUBLE(gsl_frexp(f, *e));
besEND

Calling GSL SB extension module functions:

log1p()

Code: [Select]
DECLARE SUB log1p ALIAS "_log1p" LIB "gsl"

PRINT FORMAT("%.32g", log1p(34.0)),"\n"

3.5553480614894135136694330867613

frexp()

Code: [Select]
DECLARE SUB frexp ALIAS "_frexp" LIB "gsl"

x = 16.4
e = 0
fraction = frexp(x, e)

PRINT FORMAT("%g",fraction),"\n"
PRINT e,"\n"

0.5125
5

596
General Discussions / Re: error &H3e:Include file is not found
« on: April 24, 2011, 10:57:32 PM »
Welcome to the ScriptBasic forum.

If you want to reference extensions modules from your scripts, (using IMPORT or INCLUDE)  you should have a configuration file defined that at least points to the module and include directories. Keep in mind that the configuration file needs to compiled with the scriba -k <text version of config file>. If no pre-existing config is found in the bin directory, ScriptBasic will generate it in the C:\WINDOWS directory. Using the scriba -d <your script> will show the loading process and success of extension modules you may be using in your scripts.

GTK-Server is a great way to add a GUI to your ScriptBasic scripts.

Let us know if you need any help getting up to speed with SB.


597
mxml / Re: ScriptBasic Mini-XML Extension Module
« on: April 13, 2011, 01:14:59 PM »
The Mini-XML API isn't fully implemented in the ScriptBasic mxml extension module. If you find this interface of value and would be willing to contribute by expanding it, please reply here and indicate your willingness to help the project out.


Mini-XML API
mxmlAdd
mxmlDelete
mxmlElementDeleteAttr
mxmlElementGetAttr
mxmlElementSetAttr
mxmlElementSetAttrf
mxmlEntityAddCallback
mxmlEntityGetName
mxmlEntityGetValue
mxmlEntityRemoveCallback
mxmlFindElement
mxmlIndexDelete
mxmlIndexEnum
mxmlIndexFind
mxmlIndexNew
mxmlIndexReset
mxmlLoadFd
mxmlLoadFile
mxmlLoadString
mxmlNewCDATA
mxmlNewCustom
mxmlNewElement
mxmlNewInteger
mxmlNewOpaque
mxmlNewReal
mxmlNewText
mxmlNewTextf
mxmlNewXML
mxmlRelease
mxmlRemove
mxmlRetain
mxmlSAXLoadFd
mxmlSAXLoadFile
mxmlSAXLoadString
mxmlSaveAllocString
mxmlSaveFd
mxmlSaveFile
mxmlSaveString
mxmlSetCDATA
mxmlSetCustom
mxmlSetCustomHandlers
mxmlSetElement
mxmlSetErrorCallback
mxmlSetInteger
mxmlSetOpaque
mxmlSetReal
mxmlSetText
mxmlSetTextf
mxmlSetWrapMargin
mxmlWalkNext
mxmlWalkPrev

ScriptBasic extension module interface
declare sub     ::LoadDoc      alias "LoadDoc"      lib "mxml"
declare sub     ::GetNext      alias "GetNext"      lib "mxml"
declare sub     ::GetChild     alias "GetChild"     lib "mxml"
declare sub     ::GetNodeValue alias "GetNodeValue" lib "mxml"
declare sub     ::GetProperty  alias "GetProperty"  lib "mxml"
declare sub     ::GetNode      alias "GetNode"      lib "mxml"
declare sub     ::SaveDoc      alias "SaveDoc"      lib "mxml"
declare sub     ::NewDoc       alias "NewDoc"       lib "mxml"
declare sub     ::FreeDoc      alias "FreeDoc"      lib "mxml"

Mini-XML functions used by ScriptBasic
mxmlLoadFile
mxmlElementGetAttr
mxmlFindElement
mxmlSaveFile
mxmlNewXML
mxmlDelete

mxml ScriptBasic interface.c
Code: [Select]
/*

Mini-XML Support code for Scriptbasic

Copyright 2010, Armando I. Rivera, Recursive Media Group.

Released under the terms of the Mini-Xml Licence.

The Mini-XML library and included programs are provided under the terms of the
GNU Library General Public License (LGPL) with the following exceptions:

  1. Static linking of applications to the Mini-XML library does not constitute
a derivative work and does not require the author to provide source code for
the application, use the shared Mini-XML libraries, or link their applications
against a user-supplied version of Mini-XML.

  If you link the application to a modified version of Mini-XML, then the
changes to Mini-XML must be provided under the terms of the LGPL in sections
1, 2, and 4.

  2. You do not have to provide a copy of the Mini-XML license with programs
that are linked to the Mini-XML library, nor do you have to identify the
Mini-XML license in your program or documentation as required by section 6
of the LGPL.

  FILE   : interface.c
  HEADER : interface.h
  BAS    : mxml.bas
  AUTHOR : *TODO*

  DATE:

  CONTENT:
  This is the interface.c file for the ScriptBasic module xml

UXLIBS: -lmxml
DWLIBS: -lmxml

 */

#include <mxml.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "../../basext.h"

typedef struct _ModuleObject {
  void *HandleArray;
}ModuleObject,*pModuleObject;

#define _MAX_PATH 4096

#define GET_ARGUMENT_POINTER(X,Y) \
  if( besARGNR < Y )return COMMAND_ERROR_ARGUMENT_RANGE;\
  Argument = besARGUMENT(Y);\
  besDEREFERENCE(Argument);\
  if( Argument == NULL )X=NULL; else { \
      if( Argument->vType != VTYPE_STRING ||\
          STRLEN(Argument) != sizeof(void *) ){\
    return COMMAND_ERROR_ARGUMENT_RANGE;\
    }\
  memcpy(&(X),STRINGVALUE(Argument),sizeof(void *));\
  }

#define RETURN_POINTER(X) \
  besALLOC_RETURN_STRING( sizeof( void *) );\
  memcpy(STRINGVALUE(besRETURNVALUE),&(X),sizeof(void *));



besVERSION_NEGOTIATE
  return (int)INTERFACE_VERSION;
besEND

besSUB_START
  pModuleObject p;

  besMODULEPOINTER = besALLOC(sizeof(ModuleObject));
  if( besMODULEPOINTER == NULL )return 0;

  p = (pModuleObject)besMODULEPOINTER;
  return 0;

besEND

besSUB_FINISH
  pModuleObject p;

  p = (pModuleObject)besMODULEPOINTER;
  if( p == NULL )return 0;
  return 0;
besEND

/**
=section LoadDoc
=H Load an XML file and read into memory

You should use this function to read the content of an XML file into memory.
The argument of the function is the name of the file to be read. The function
will return a handle to the structure created during the parsing of the file
content.

=verbatim
 DOC = mxml::LoadDoc("my_file.xml")
=noverbatim

*/
besFUNCTION(LoadDoc)
mxml_node_t *tree;
FILE *fp;
char *pszFileName;

besARGUMENTS("z")
    &pszFileName
  besARGEND

fp = fopen(pszFileName, "r");
  // check if file exists
  if(fp == NULL) {
      return NULL;
  }
   
  tree = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK);
fclose(fp);

  //besFREE(pszFileName);

  besRETURN_POINTER(tree);
besEND

/**
=section GetNext
=H Get the next node of a document node

This function should be used to get the handle to the  next node in a
document node

=verbatim
 node = mxml::GetNext(<node pointer>)
=noverbatim
*/
besFUNCTION(GetNext)
mxml_node_t *rootNode;

besARGUMENTS("p")
    &rootNode
  besARGEND

besRETURN_POINTER(rootNode->next);
besEND

/**
=section GetChild
=H Get the next Child node of a document node

This function should be used to get the handle to the next Childe node of a
document node

=verbatim
 node = mxml::GetChild(<node pointer>)
=noverbatim
*/
besFUNCTION(GetChild)
mxml_node_t *rootNode;

besARGUMENTS("p")
    &rootNode
  besARGEND

besRETURN_POINTER(rootNode->child);
besEND

/**
=section GetNodeValue
=H Get the value of a document node

This function should be used to get the value (text) of a node

=verbatim
 text = mxml::GetNodeValue(<node pointer>)
=noverbatim
*/
besFUNCTION(GetNodeValue)
mxml_node_t *rootNode;

besARGUMENTS("p")
    &rootNode
  besARGEND

besSET_RETURN_STRING(rootNode->child->value.opaque);
besEND

/**
=section GetProperty
=H Get the a property value of a document node

This function should be used to get the
value of a property of a document node

=verbatim
 text = mxml:: mxml::GetProperty(<node pointer>,<string identifier>)
=noverbatim
*/
besFUNCTION(GetProperty)
mxml_node_t* node;
const char* attr;
char* pszValue;

besARGUMENTS("pz")
    &node,&attr
  besARGEND

pszValue = mxmlElementGetAttr(node, attr);

besSET_RETURN_STRING(pszValue);
besEND

/**
=section GetNode
=H Get a handle to a specified node

This function should be used to get the handle of a specific node.
It uses XPATH syntax, which resembles a UNIX path.

Ex, node = mxml::GetNode(doc, "/stufflist/stuff_test3/painting/img")

=verbatim
 node = mxml::GetNode(<node pointer>,<path-like string>)
=noverbatim
*/
besFUNCTION(GetNode)
mxml_node_t *rootNode, *node;
char *pszValue;
char *token, tmpStr[_MAX_PATH];

besARGUMENTS("pz")
    &rootNode,&pszValue
  besARGEND

node = rootNode;

memset(tmpStr,0,sizeof(tmpStr));
strncpy(tmpStr, pszValue, strlen(pszValue));


token = strtok(tmpStr, "/");
  while ( token  ) {
node = mxmlFindElement(node,node,token,NULL,NULL,MXML_DESCEND);
    token = strtok( NULL, "/" );
  }

besRETURN_POINTER(node);
besEND

/**
=section SaveDoc
=H Save to an XML file

This function should be used to save the contents of an XML tree
to a disk file

=verbatim
 mxml::SaveDoc(<DOC (root) node pointer>,<string filename>)
=noverbatim
*/
besFUNCTION(SaveDoc)
mxml_node_t* node;
const char* fileName;
FILE *fp;
int retVal;

besARGUMENTS("pz")
    &node,&fileName
  besARGEND

fp = fopen(fileName, "w");
  if(fp == NULL) {
    besRETURN_LONG(-1);
  }

retVal = mxmlSaveFile(node, fp, MXML_NO_CALLBACK);
fclose(fp);
besRETURN_LONG(retVal);
besEND

/**
=section NewDoc
=H Create a new XML document in memory

This function should be used to create a new XML document in memory.

The second parameter (xml version) is optional.  If not provided,
it defaults to version="1.0"

It would create a header that looks like:
<?xml version="1.0">

=verbatim
 doc = mxml::NewDoc(<string version>)
=noverbatim
*/
besFUNCTION(NewDoc)
mxml_node_t* node;
char* pszVersion;


besARGUMENTS("[z]")
    &pszVersion
  besARGEND

node = mxmlNewXML(pszVersion);
besRETURN_POINTER(node);

besEND

/**
=section FreeDoc
=H Releases/Destroys an XML tree in memory

This function should be used to delete an new XML document in memory.

=verbatim
 mxml::FreeDoc(<doc pointer>)
=noverbatim
*/
besFUNCTION(FreeDoc)
mxml_node_t* node;

besARGUMENTS("p")
    &node
  besARGEND

if (node) mxmlDelete(node);
besEND


/*
Exported Function List
*/
SLFST XML_SLFST[] ={

{ "versmodu" , versmodu },
{ "bootmodu" , bootmodu },
{ "finimodu" , finimodu },
{ "LoadDoc" , LoadDoc },
{ "GetNext" , GetNext },
{ "GetChild" , GetChild },
{ "GetNodeValue", GetNodeValue },
{ "GetNode" , GetNode },
{ "SaveDoc" , SaveDoc },
{ "NewDoc" , NewDoc },
{ "FreeDoc" , FreeDoc },
{ "GetProperty", GetProperty },
{ NULL , NULL }
  };

I have attached the 64 bit Linux version of the mxml extension module. (binary, source, example and readme included)

598
mxml / ScriptBasic Mini-XML Extension Module
« on: April 10, 2011, 05:45:16 PM »
Mini-XML is a small XML library that you can use to read and write XML and XML-like data files in your application without requiring large non-standard libraries.

Armando created the mxml extension module as a replacement for the GNOME libxml2 extension module that was introduced with the 2.0 release by Peter Verhas but never fully tested or documented.

Code: [Select]
include mxml.bas

filename = "stuff.xml"
doc = mxml::LoadDoc(filename)

node =  mxml::GetNode(doc,"/stufflist/stuff_test")
if node then print "Test1: ", mxml::GetNodeValue(node),"\n"
node =  mxml::GetNode(doc,"/stufflist/stuff_test2")
if (node) then print "Test2: ", mxml::GetNodeValue(node),"\n\n"

node = mxml::GetNode(doc,"/stufflist/stuff_test3/painting/img")
if node then
print "Image: ", mxml::GetProperty(node,"src"), "\n"
print "Alt Image: ", mxml::GetProperty(node,"alt"), "\n\n"
endif

node = mxml::GetNode(doc,"/stufflist/books")
child = mxml::GetChild(node)

while child
node = mxml::GetNode(child,"id")
if node then print "ID = ", mxml::GetNodeValue(node),"\n"
node = mxml::GetNode(child,"name")
if node then print "Name = ", mxml::GetNodeValue(node),"\n"
child = mxml::GetNext(child)
wend

if doc then mxml::FreeDoc(doc)

Code: Text
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <stufflist>
  3.         <stuff_test>This is a test!</stuff_test>
  4.         <stuff_test2>And this is another test!</stuff_test2>
  5.         <stuff_test3>
  6.                 <painting>
  7.                         <img src="madonna.jpg" alt='Foligno Madonna, by Raphael'/>
  8.                         <caption>This is Raphael's "Foligno" Madonna, painted in
  9.                                 <date>1511</date>.
  10.                         </caption>
  11.                 </painting>
  12.         </stuff_test3>
  13.         <books>
  14.     <book>
  15.         <id>1</id>
  16.         <name>Hello, world!</name>
  17.     </book>
  18.     <book>
  19.         <id>2</id>
  20.         <name>Hello, China!</name>
  21.     </book>
  22.         </books>
  23. </stufflist>
  24.  

jrs@Laptop:~/SB/test$ scriba mxmltest.sb
Test1: This is a test!
Test2: And this is another test!

Image: madonna.jpg
Alt Image: Foligno Madonna, by Raphael

ID = 1
Name = Hello, world!
ID = 2
Name = Hello, China!
jrs@Laptop:~/SB/test$


The attached mxml_i386.tar.gz is for 32 bit versions of Linux.

599
What's New / ScriptBasic Hash Extension Module Fix
« on: April 10, 2011, 11:20:44 AM »
Armando fixed an age old issue with the hash extension module (memory error) and I tested it on both 32 and 64 bit Ubuntu.

Armando's test program
Code: [Select]
import hash.bas

h = hash::New()

for i=1 to 10
hash::SetValue h,"q"&i,i
next i

hash::Start h
while hash::Exists(h)
 print hash::ThisKey(h)," ", hash::ThisValue(h)
 print
 hash::Next h
wend

hash::Release h

jrs@Laptop:~/SB/test$ scriba hash.air
q1 1
q2 2
q3 3
q4 4
q5 5
q6 6
q7 7
q8 8
q9 9
q10 10
jrs@Laptop:~/SB/test$

600
Download / Re: ScriptBasic 64 Bit Linux
« on: April 09, 2011, 08:45:21 PM »
I created a 64 bit RPM for ScriptBasic 64 using alien to convert the .deb install file.

I included a tar file that can be used to install ScriptBasic if this method is preferred.

sudo tar xzvpf -C / scriba-v2.1.1_amd64.tgz


Pages: 1 ... 38 39 [40] 41 42 ... 59