Javascript.....

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ChristopherBodell
Posts: 52
Joined: Sun Jan 20, 2008 7:06 am

Javascript.....

Post by ChristopherBodell » Sun Mar 16, 2008 8:03 pm

Does anyone know how to run javascript from Revolution?

I hava some javascript code i want to use to email with.
Do i just put it into a field and run the command "do fld "Field_JS" as javascript"....

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Mon Mar 17, 2008 1:22 pm

Hi Christopher,

Your general idea is correct, you would use the 'do <script> as <language>' construct to execute a script in another language than Revolution.

But first you have to make sure that Javascript is supported on your platform. You can check the global property 'the alternateLanguages':

Code: Select all

answer the alternateLanguages
On MacOSX, you'll get a list of the OSA-compatible languages that were installed - OSA stands for Open Scripting Architecture, and is the underlying mechanism which allows you to automate tasks using AppleScript and other OSA-compatible languages.

On Windows, Revolution 2.9 will add support for the Windows Script Host system - a system similar to OSA, which allows scripters to automate COM-enabled applications and libraries.

On this Windows XP machine, among other languages, such as VBScript, I get "JScript" - which is the Microsoft implemenatation of ECMAScript, the official name for Javascript.

In short, there's no built-in Javascript, but you can use OSA/WSH to execute scripts in alternate languages, provided they are installed.

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply