The main goal of Comet is to provide an easy-to-use development environment for numerical computing using the Lua programming language on Android, Linux and Windows. It integrates the Lua scripting engine with all Lua functionalities, and a lot of specific Comet functionalities including numerical functions (linear algebra, differential equations, mathematical optimization, etc.), data plotting and analysis modules and extended mathematical library.

Within the Comet environment, you can develop algorithms for science and engineering with one of the most elegant and fast scripting languages.

To learn the Lua programming language, you can visit the Lua official website: http://www.lua.org
Excellent tutorials, covering all Lua aspect from basics to advanced programming techniques, can be found here: http://lua-users.org/wiki/TutorialDirectory

Comet can also be used as a general purpose full-featured editor supporting C/C++, Bash/Text, Python, Octave, Fortran, LaTeX and Makefile with configurable tools (e.g. to run a compiler or a bash script).

1. Install

For setup version (on Windows): Download comet_setup_windows.msi, double-click on the setup file and it will install Comet.

The main goal of Comet is to provide an easy-to-use development environment for Lua on Android, Linux and Windows, suitable for numerical computing and data analysis. It integrates the Lua scripting engine with all Lua functionalities, and a lot of specific Comet functionalities including numerical functions (linear algebra, differential equations, nonlinear equations, etc.), data plotting and analysis modules and extended mathematical library. With Comet, you can develop algorithms for science and engineering with one of the most elegant and fast scripting languages.

With the toolbar, you can open, save, run/debug script, perform the standard editing actions (copy/cut/paste/undo/redo) or navigate in the document with bookmarks.
You can perform the same actions, and more, with the menu.
Comet includes code samples and snippets (Menu/Samples and Menu/Code menu). With code snippets, you can easily insert some pieces of code (for, switch, if, function, ...) in your script for better productivity.

For Android: If you want to change the font size, select menu/Settings. You can create a new script or save the current script to another location, by selecting menu. If you want to automatically run a script on startup (AutoRun), select menu/Settings/AutoRun and choose your script in the file explorer. If you long click the AutoRun button in menu/Settings, the AutoRun feature will be disabled. You can enable or disable the soft keyboard by selecting menu/Keyboard.

You can print text on the output area by using the Lua standard print or io.write function. To clear the output area, use the cls() function or select Clear in the context menu.

For Android: You can set the output area height by selecting S (small), M (median) or L (large) in Menu / Settings (Output).
As for Windows and Linux, Comet for Android has two graphical themes: light and dark, and syntax highlighting functionality. You can switch between themes, enable or disable syntax highlighting in menu/Settings.

You can create a new script or save the current script to another location, by selecting File/New (Menu/New on Android) or File/Save As (Menu/Save As on Android) menu or the toolbar corresponding buttons.

You can print text on the output area by using the Lua standard print function (or the io.write function).
To clear the output area, use the cls() function.

You can set bookmark in you code and navigate easily by clicking click Add/Remove Bookmark, Next or Previous Bookmark (either Menu/Search or the correspond toolbar buttons).
Bookmarks are saved with your document and are be restored next time you open it. The list of all active bookmarks can be displayed by selecting View/Bookmarks in the menu.
The bookmarks, modification and search markers can be saved alongside the document by checking the corresponding option: 'Options/Save Navigation Info' menu.

You can view end of lines, white spaces, long lines vertical indicator (long lines limit to set in Options/Indentation menu), file explorer, output window, script console, toolbar, statusbar… in the View menu.

The editor toolbar includes, in addition to the commonly used commands, an integrated edit zone to (i) navigate through the current document functions (or sections for LaTeX): just drop down the list and select a function; (ii) to search in the document: just type a text and click the toolbar button to the right (or press ENTER); (iii) go to a line: just type the line number and click the toolbar button to the right (or press ENTER). Note that the document functions list can be manually updated by clicking the 'Update List' toolbar button (this list is created when the document is loaded or executed).

Comet's execution mode is designed to perform long calculations, without user interaction. This feature makes it suitable for math and algorithms development.

For Android: you can activate the long calculations mode, which set the device processor to stay awake during script execution, by selecting Menu/Settings.

Comet can be executed from the command line:
$ comet -run input [-out outfile] [-show]
input may be a filename or a double-quoted expression and the outfile is the output filename:
$ comet -run "print(sin(math.pi/4))"
$ comet -run cometin.lua -out cometout.txt
Note that the plot functions and other GUI functions are only available in the Comet GUI.

Comet integrates a Lua script console (Menu View / Script Console). You can use it as an interactive programming console to perform quick tests for example. To use the script console, simply write a Lua valid statements (example: x = math.pi/3; y = sin(x); print(y); ), and press ENTER. You can enter multi-line statements: just press SHIFT+ENTER after each line and ENTER to run. You can use any standard Lua function or Comet module.

Example:

Copy the following script in the editor...

-- Lua first script
cls()
a = math.cos(math.pi/4)
print("a = ", a)

... and click Run (or press F12 on Windows and Linux)

Comet's execution mode is designed to perform long calculations, without user interaction. This feature makes it suitable for math and algorithms development.
For Android: you can activate the long calculations mode, which set the device processor to stay awake during script execution, by selecting Menu/Settings.
Comet is also available as command line executable: cometc.exe (Windows) or cometc (Linux).

4. Comet as a general purpose editor

Comet can be used as a general purpose full-featured editor supporting C/C++, Bash/Text, Python, Octave, Fortran, LaTeX and Makefile with configurable tool (e.g. to run a compiler or a bash script). The document language is automatically selected using the file extension. For unknown extension, you can manually select the document language in File/Current File/File Type menu. To configure the tools used, for example, to compile and execute code, select Options/External Tools menu. Comet supports configurable tools for C/C++, Python, LaTeX and Makefile.

To configure a specific tool, select menu Options/External Tools:

(i) For Windows, you can create a batch file (named build.bat for example), put the command in this file (example: pdflatex mydoc.tex) and add the batch command build.bat in the External Tools dialog after selecting the corresponding file type (example: LaTeX).
Example (create file build.bat and set the external tool command as build.bat) building LaTeX document under Windows (using MiKTeX):

(ii) For Linux, similarly you can create a bash file (named build.sh for example), put the command in this file (example: pdflatex mydoc.tex) and add ./build.sh in the External Tools dialog after selecting the corresponding file type (example: LaTeX).

(iii) For Python (for both Windows or Linux), just put a command like this (replace with your installed Python interpreter): C:\Python\python.exe -u %s.py (Windows) or python -u %s.py (Linux).

Comet includes a user-defined syntax highlighting template that can be customized for a specific language or file type: click Options/User-defined Syntax menu, enter the corresponding file extension (without dot) and the space-separated list of keywords to highlight. You can save the user-defined syntax highlighting template to a file (button Save…) or load the template from a file (button Load…).

5. GUI Functions

To interact with the user, one can use the graphical user interface functions:

You can extend Comet by writing you own specialized C modules. Comet integrates the main Lua headers to include in your source and you can link your shared library against the Lua Core library (luacore.dll under Windows and libluacore.so under Linux).

HowTo write and use C module:

Step 1. Write your C module and register the interface functions as in the following example:

Use Visual C++ on Windows or gcc or Clang on Linux, for example. Before compiling, add the Comet include directory (Comet Dir/include) in the compiler include path and set the linker to link against the Comet Lua Core library (luacore.dll under Windows and libluacore.so under Linux). Under Windows and for Visual C++, you can link against luacore.lib file (under Comet Dir/lib and compiled for Visual C++ 2013) or you can generate, for your specific VC version, the lib from luacore.dll and luacore.def by using the lib tool included with Visual C++:lib /def:"C:\Comet\luacore.def" /out:"C:\Comet\lib\luacore.lib" /machine:x86

Of course, if your module is already built or purchased you can use it as usual with the Lua ad hoc functions.

Step 3. When your module was built as dll (under Windows) or so (under Linux), you can load it and use it under Comet by using the standard Lua functions:

In addition of the built-in modules, Comet includes five useful C modules:

(i) lvisa module to control instruments through GPIB, USB, Serial, Ethernet ... This module is available only under Windows (it can be found under the examples directory). It requires the NI VISA drivers to be installed (these drivers can be freely downloaded from the NI site: http://www.ni.com/downloads/drivers/). The NI-VISA drivers are not available for Debian and Debian-based distributions.

Using lvisa is straightforward: load module with require , initialize, open visa connection, communicate and finally close connection. All functions are included in the visa namespace.

-- open the serial port and configure it
-- port_handle = lrs232.open(port_num, settings, verbose)
-- port_num: usually 1 (COM1) or 2 (COM2)
-- settings has the same meaning than in the Windows BuildCommDCB
-- function except that BuildCommDCB has no 'timeout' parameter
-- that is specific to this Comet module
-- verbose (optional): true to show detailed messages
-- returns the port handle
p = lrs232.open(1, "baud=4800 parity=n data=8 stop=2 timeout=1000", true)

-- write to the serial port
-- lrs232.write(port_handle, command)
-- port_handle: the port handle, as returned by lrs232.open
-- command to send to the device
-- returns the number of bytes written
lrs232.write(p, "*IDN?\n")

-- read from the serial port
-- r,n = lrs232.read(port_handle, bytes)
-- port_handle: the port handle, as returned by lrs232.open
-- bytes: number of bytes to read
-- returns the string read and the number of bytes read
r,n = lrs232.read(p, 128)

Comet integrates a Lua script console (Menu View / Script Console). You can use it as an interactive programming console to learn or quickly test concepts. To use the script console, simply write a Lua valid statements (example: x = math.pi/3; y = math.sin(x); print(y); ), and press ENTER. You can enter multi-line statements: just press SHIFT+ENTER after each line and ENTER to run. You can use any standard Lua function or Comet module.

8. Debugging

Comet provides debugging capabilities on Windows and Linux: you can set breakpoints in the code (Menu Run/Add Breakpoint or the toolbar corresponding button) and view the current variables set in the Watch window. To start debugging, click Debug (or Menu Run/Debug or Ctrl+F12). Debugger can 'Step Into' or 'Step Over' on a call depending on the option set by user in Menu Run/Step Into (unchecked for 'Step Over').

Comet runs on PC with Windows™ XP, Vista or Windows 7/8/10, or Linux 32bit or 64bit, or Android system.

The basic hardware requirements for PC are:

· Pentium or better microprocessor.

· 256 MB RAM.

· 20 MB of hard disk space.

· VGA monitor with 800x600 or higher resolution.

10.2 Contact

http://www.hamady.org

sidi@hamady.org

10.3 Copyright

Comet:
Copyright(C) 2010-2019 Sidi HAMADY
http://www.hamady.org
sidi@hamady.org
Comet is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. Comet is free of charge only for non-commercial use.
Sidi HAMADY expressly disclaims any warranty for Comet. Comet is provided ‘As Is’ without any express or implied warranty of any kind, including but not limited to any warranties of merchantability, noninfringement, or fitness of a particular purpose.
Comet may not be redistributed without authorization of the author.