Author Topic: Why do you care that much about BASIC part in the name of a language?  (Read 33284 times)

ScriptBasic

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #135 on: September 01, 2016, 04:35:04 PM »
The plan was to mask C string functions with BASIC like syntax. Once again, I'm not interested in creating another BASIC. This is all about helping BASIC programmers becoming familiar with C.

Mike Lobanovsky

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #136 on: September 01, 2016, 04:38:43 PM »
Aye aye, Cap! :)

ScriptBasic

  • Guest
Re: Why do you care that much about BASIC part in the name of a language?
« Reply #137 on: September 01, 2016, 08:36:11 PM »
As an example, here is the beginning of the JS (JavaScript) extension module using C BASIC masking.

Code: [Select]
/*  V7 JavaScript Engine Extension Module */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include "../../basext.h"
#include "../../scriba.h"
#include "cbasic.h"
#include "v7.h"


/****************************
 Extension Module Functions
****************************/

besVERSION_NEGOTIATE
  RETURN_FUNCTION((int)INTERFACE_VERSION);
besEND

besSUB_START
  DIM AS long PTR p;
  besMODULEPOINTER = besALLOC(sizeof(long));
  IF (besMODULEPOINTER EQ NULL) THEN_DO RETURN_FUNCTION(0);
  p = (long PTR)besMODULEPOINTER;
  RETURN_FUNCTION(0);
besEND

besSUB_FINISH
  DIM AS long PTR p;
  p = (long PTR)besMODULEPOINTER;
  IF (p EQ NULL) THEN_DO RETURN_FUNCTION(0);
  RETURN_FUNCTION(0);
besEND


/*******
 V7 API
*******/

besFUNCTION(js_create)
  struct v7 *v7 = v7_create();
  besRETURN_LONG(v7);
besEND

besFUNCTION(js_destroy)
  DIM AS unsigned long v7;
  besARGUMENTS("i")
    AT v7
  besARGEND
  v7_destroy(v7);
  besRETURNVALUE = NULL;
besEND
 
besFUNCTION(js_exec)
  DIM AS unsigned long v7;
  DIM AS const char *js_code;
  DIM AS v7_val_t result;
  enum v7_err rcode = V7_OK;
  besARGUMENTS("iz")
    AT v7, AT js_code
  besARGEND
  rcode = v7_exec(v7, js_code, result);
  besRETURN_LONG(rcode);
besEND

js.bas include
Code: [Select]
MODULE JS

declare sub     ::CREATE         alias "js_create"         lib "js"
declare sub     ::DESTROY        alias "js_destroy"        lib "js"
declare sub     ::EXEC           alias "js_exec"           lib "js"

END MODULE