[ Prev | Index | Next ]
Japanese English
Now Loading...
Download
Please download on PC (not smartphone) and extract the ZIP file. Then double-click VCSSL.bat (batch file) to execute for Microsoft® Windows®, or execute VCSSL.jar (JAR file) on the command line for Linux® and other OSes.
For details, see How to Use.
You are free to use and modify this program and material, even for educational or commercial use. » Details

Wrapping a C Program with a GUI (1: Simple Edition)

This example invokes a C-language "Hello, World" program from VCSSL and displays the output on the screen.

How to Use

Download and Extract

At first, click the "Download" button at the above of the title of this page by your PC (not smartphone). A ZIP file will be downloaded.

If you are using Windows, right-click the ZIP file and choose "Properties" from the menu, and enable "Unblock" checkbox at the right-bottom (in the line of "Security") of the properties-window. Otherwise, when you extract the ZIP file or when you execute the software, security warning messages may pop up and the extraction/execution may fail.

Then, please extract the ZIP file. On general environment (Windows®, major Linux distributions, etc.), you can extract the ZIP file by selecting "Extract All" and so on from right-clicking menu.

» If the extraction of the downloaded ZIP file is stopped with security warning messages...

Execute this Program

Next, open the extracted folder and execute this VCSSL program.

For Windows

Double-click the following batch file to execute:

VCSSL__Double_Click_This_to_Execute.bat

For Linux, etc.

Execute "VCSSL.jar" on the command-line terminal as follows:

cd <extracted_folder>
java -jar VCSSL.jar

» If the error message about non-availability of "java" command is output...

After Launching

When you run this VCSSL program, a security warning like the one below appears first. Click "Yes" to continue.

Note: The "execute external programs" feature we use here runs outside VCSSL's security monitoring, so it is effectively able to do anything. The dialog is asking whether you want to allow that. Don't click "Yes" lightly for untrusted programs.

If this warning is annoying each time, open "Security" > "Allow executing system commands" from the VCSSL toolbar and check it to stop showing the dialog.

If you continue, a C program named program.exe will be invoked and executed internally.

Its output, "Hello, World!", appears in the VCSSL console (the black window).

Hello, World!

Because program.exe is compiled for Windows, it cannot run on other operating systems such as Linux. If you want to run the same logic on another OS, recompile the C source program.c and adjust the VCSSL invocation accordingly (the extension will likely be .out instead of .exe).

About This Example

It is common to want to call a program written in another language such as C from a lightweight scripting language like VCSSL.

A typical scenario when creating a small GUI tool is:

  • Write the user-facing UI in a scripting language
  • Write complex or heavy internal processing in C or a similar language

This series will follow that theme over the next few articles. This first entry simply calls a "Hello, World!" program.

Code Walkthrough

The main program is written in VCSSL. VCSSL uses a simple C-like syntax, so C programmers should read and write it without issue.

Full Code

Let's look at the VCSSL code. The entire script looks like this:

- `GUIWrapperSimple.vcssl` -

coding UTF-8;

// Load required libraries
import File;
import Process;

// Get the absolute path of the program file to run
string programPath = getFilePath("program.exe");

// Prepare the program so it can be executed
int processID = newProcess(programPath);

// If Japanese text in the I/O becomes garbled, specify encodings here
// setProcessInputEncoding(processID, "CP932");
// setProcessOutputEncoding(processID, "CP932");
// setProcessErrorEncoding(processID, "CP932");

// Run the program and wait for it to finish
startProcess(processID);
waitForProcess(processID);

// Get the program's output and print it to the VCSSL console (black window)
string output = getProcessOutput(processID);
println(output);
GUIWrapperSimple.vcssl

This script calls the Windows executable program.exe. The source code of that program is below:

- `program.c` -

#include 

int main() {
    printf("Hello, World!\n");
    return 0;
}
program.c

A plain Hello World program. When you execute it directly, it prints:

Hello, World!

Now let's walk through the VCSSL code step by step.

Importing Libraries

The script declares it is written in UTF-8 (to avoid misinterpretation) and loads the required libraries:


coding UTF-8;

// Load required libraries
import File;
import Process;
import.txt

The File library provides utilities for obtaining and converting file paths. Here it is used to get the absolute path of the target program.

The Process library handles executing and controlling external programs, which is what most of this script does.

Preparing the Target Program

We inform newProcess about the external program and have it prepare the program in an executable state:


// Get the absolute path of the program file to run
string programPath = getFilePath("program.exe");

// Prepare the program so it can be executed
int processID = newProcess(programPath);
new.txt

For newProcess, pass the file path of the external program. We recommend using an absolute path because relative paths or just a file name may fail depending on how the script is launched.

Here we use getFilePath to retrieve the absolute path of program.exe before passing it to newProcess.

newProcess returns a process ID, which we store in processID. This ID identifies the external program when executing and controlling it.

Optional Encoding Settings

Next are optional settings before running the external program. They remain commented out in this example but may be useful when handling Japanese text.


// If Japanese text in the I/O becomes garbled, specify encodings here
// setProcessInputEncoding(processID, "CP932");
// setProcessOutputEncoding(processID, "CP932");
// setProcessErrorEncoding(processID, "CP932");
set.txt

It is common to specify character encodings like this to avoid garbled text.

The encoding used by an external program depends on the program or compiler. If VCSSL reads the output with the wrong encoding, the text becomes garbled.

Programs compiled on Windows that print Japanese often use the CP932 (≈ Shift_JIS) encoding. If the output garbles, teach VCSSL to use CP932 as shown. If nothing is specified, UTF-8 is assumed.

Starting Execution and Waiting

We execute the external program with startProcess and wait for it to finish with waitForProcess:


// Run the program and wait for it to finish
startProcess(processID);
waitForProcess(processID);
start.txt

Waiting ensures the script pauses until the program completes, which is simple for programs that just print something and exit.

You could also continue running while exchanging I/O, but here waiting immediately after starting suffices; the output can be collected afterward.

Collecting Output and Displaying It in VCSSL

Finally, retrieve what the external program printed and display it in the VCSSL console:


// Get the program's output and print it to the VCSSL console (black window)
string output = getProcessOutput(processID);
println(output);
output.txt

getProcessOutput returns everything the external program has printed so far.

Alternatively, you can define an onProcessOutput event handler to capture output line by line in real time:


void onProcessOutout(int processID, string output) {
    print(output);
}
event.txt

Choose the method that best fits how you want to handle the output.

That concludes the code walkthrough.

If you continued further in the series, you would progressively expand this concept with richer GUI interactions.

License

This VCSSL/Vnano code (files with the ".vcssl" or ".vnano" extensions) is released under the CC0 license, effectively placing it in the public domain. If any sample code in C, C++, or Java is included in this article, it is also released under the same terms. You are free to use, modify, or repurpose it as you wish.

* The distribution folder also includes the VCSSL runtime environment, so you can run the program immediately after downloading. The license for the runtime is included in the gLicenseh folder.
(In short, it can be used freely for both commercial and non-commercial purposes, but the developers take no responsibility for any consequences arising from its use.) For details on the files and licenses included in the distribution folder, please refer to "ReadMe.txt".

* The Vnano runtime environment is also available as open-source, so you can embed it in other software if needed. For more information, see here.


Author of This Article

Fumihiro Matsui
[ Founder of RINEARN, Doctor of Science (Physics), Applied Info Tech Engineer ]
Develops VCSSL, RINEARN Graph 3D and more. Also writes guides and articles.

Japanese English
[ Prev | Index | Next ]
[an error occurred while processing this directive]
News From RINEARN
* VCSSL is developed by RINEARN.

Exevalator v2.4 Released — MCP Support Added, Now Usable as an AI Calculation Tool
2025-11-15 - We've released Exevalator v2.4, our expression-evaluation library. Starting with this version, it supports MCP, making it usable as a calculation tool for AI assistants.

Exevalator v2.3 Released — Now Usable from Python
2025-11-04 - We've released Exevalator v2.3. Starting with this version, you can now use it from Python! With growing demand around AI tool development in mind, we share the details here.

Exevalator Updated — Easy Japanese Localization for Error Messages
2025-10-31 - Exevalator 2.2.2 is out. You can now localize error messages to Japanese with a simple copy-and-paste, and we've included several bug fixes and minor parser adjustments.

Inside RINPn Online: Architecture Overview
2025-10-22 - An inside look at the architecture of the recently launched online version of the RINPn scientific calculator. It's open source, so you can freely modify and reuse it to build your own web calculator (maybe!).

Meet RINPn Online: Use the Scientific Calculator Anywhere, Instantly
2025-10-21 - RINPn, the free scientific calculator, now has an online version you can use instantly in your browser — on both PC and smartphones. Read the announcement for details.

The VCSSL Support AI is Here! — Requires a ChatGPT Plus Account for Practical Performance
2025-08-19 - A new AI assistant for the VCSSL programming language is here to answer your questions and help with coding. This article explains how to use it and showcases plenty of real Q&A and generated code examples.

English Documentation for Our Software and VCSSL Is Now Nearly Complete
2025-06-30 - We're happy to announce that the large-scale expansion of our English documentation with the support of AI — a project that began two years ago — has now reached its initial target milestone.

VCSSL 3.4.52 Released: Enhanced Integration with External Programs and More
2025-05-25 - This update introduces enhancements to the external program integration features (e.g., for running C-language executables). Several other improvements and fixes are also included. Details inside.