MoI discussion forum
MoI discussion forum

Full Version: Question about Java Script

From: fcwilt
11 Aug   [#1]
Hi,

You posted a file with this bit of code:

var path = moi.geometryDatabase.currentFileName;


// Strip off file extension.
var base = path.substring( 0, path.lastIndexOf('.') );

// Get file extension.
var ext = path.substring( path.lastIndexOf('.') );

My general purpose Windows development tool has a class for manipulating file names and such.

You can set the property which accepts an entire file specification (server, drive letter, path, name, extension, etc.).

Then you can access several properties for the parts, such as file name and extension.

I am assuming since you coded those function your Java Script has no such class.

Is it possible to write such a class to use in your Java Script, so you need not code functions like you did above?

Thanks.

Frederick
From: Michael Gibson
11 Aug   [#2] In reply to [#1]
Hi Frederick,

re:
> Is it possible to write such a class to use in your Java Script, so you need
> not code functions like you did above?

Yes, I will add in some more file name processing functions to be available to scripts.

- Michael
From: fcwilt
11 Aug   [#3] In reply to [#2]
Hi Michael,

Are classes even a thing in your Java Script?

If the exist can they be used in "end user scripts"?

JOOC is MoI written entirely in Java Script or is the some C++ code at the heart of it?

Thanks.

Frederick
From: Michael Gibson
11 Aug   [#4] In reply to [#3]
Hi Frederick,

re:
> Are classes even a thing in your Java Script?

They are, although the JavaScript engine that MOI uses is old and only supports the ES5 version of the JavaScript language.

In ES6 there is a new "class" keyword but it doesn't do a whole lot.

https://stackoverflow.com/questions/31908058/classes-in-javascript-ecmascript-5#31908169


> If the exist can they be used in "end user scripts"?

Yes, if you keep to the ES5 level.


> JOOC is MoI written entirely in Java Script or is the some C++ code at the heart of it?

There is a lot of C++ code at the core level, JavaScript is used for for controlling program flow, UI, and glue logic.

- Michael
From: fcwilt
11 Aug   [#5] In reply to [#4]
Hi Michael,

So in addition to being a GUI wizard, a Java Script connoisseur, you are a C++ master?

Amazing.

Once I discovered Delphi I said goodbye to C++ and never looked back. Any one that can deal with C++ deserves applause.

Is a "Java Script Engine" something that is compiled into your program or is it something else?

Thanks for the ongoing education.

Frederick
From: Michael Gibson
11 Aug   [#6] In reply to [#5]
Hi Frederick,

> Is a "Java Script Engine" something that is compiled into your program or is it something else?

It's a library written itself in C++ that implements the JavaScript language.

- Michael
From: fcwilt
11 Aug   [#7] In reply to [#6]
Hi Michael,

OK I think all is clear.

Frederick