HOME  NEWS  FORUM  DOWNLOAD  LINK
OpenCOBOL - an open-source COBOL compiler
Main Menu
Download
Documentation
Development
Who's Online
18 user(s) are online (6 user(s) are browsing Forum)

Members: 0
Guests: 18

more...
Powered by
SourceForge

Xoops

Creative Commons

OpenCOBOL Forum Index
   OpenCOBOL
     V8 javascript in OpenCOBOL
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
btiffin
Posted on: 2012/3/2 9:53
Home away from home
Joined: 2008/6/7
From: CANADA
Posts: 1196
Re: V8 javascript in OpenCOBOL
Ok, three tries.
OCOBOL >>SOURCE FORMAT IS FIXED
      *> ***************************************************************
      *> Author:    Brian Tiffin
      *> Date:      20120227
      *> Purpose:   Embed V8 javascript
      *> 
      *> Tectonics: from http://code.google.com/apis/v8/build.html
      *>            and in a fresh svn checkout directory
      *>    scons library=shared arch=x64
      *>    g++ -c ocv8js.cpp -Iinclude -L. -o ocv8js.o -lpthread
      *>    cobc -x ocv8.cob ocv8js.o -lv8 -lstdc++ -L .
      *> ***************************************************************
       identification division.
       program-id. ocv8.

       data division.
       77 result     usage binary-long.
       01 v8-value   pic x(32767).

      *> -*********-*********-*********-*********-*********-*********-**
       procedure division.
       display "Calling CBL_OC_V8JAVASCRIPT" end-display

       call "CBL_OC_V8JAVASCRIPT"
           using
               "'Hello' + ', world'"
               v8-value
               by value function length(v8-value)
           returning result
           on exception
               display "v8 linkage problem, result garbage" end-display
               continue
       end-call
       
       display "V8 gives :" function trim(v8-value) ":" end-display

       goback.
       end program ocv8.

Forgot the C string null on the CALL literal. I've updated the original post. The listing above is the unsafe version for context. Don't cut nor paste this one.

Plus: This discussion on LinkedIn has led to the idea of a new project to attempt to embed Node.js into OpenCOBOL. I'm going to try a CALL interface first.

Cheers,
Brian
Flat Previous Topic | Next Topic

Subject Poster Date
   V8 javascript in OpenCOBOL btiffin 2012/2/28 4:12
   » Re: V8 javascript in OpenCOBOL btiffin 2012/3/2 9:53

Register To Post
 
Copyright (C) 2005 The OpenCOBOL Project. All rights reserved.
Powered by Xoops2 | PHP | MySQL | Apache
ocean-net