VisualParsic4: A C++ Library for Rapid HTML Generation
VisualParsic4 is a C++ library that allows you to create dynamic HTML pages without using any GUI toolkit. It uses simple content templates that define what and where the content should be inserted in the page using placeholders. You can also use VisualParsic4 to draw lines and shapes on SVG files.
In this article, we will show you how to install and use VisualParsic4 on Windows, and how to create a simple web page with it.
To install VisualParsic4, you need to download the ZIP file from this link and extract it to a folder of your choice. Then, run the visualparsic4_install.bat script to install the library and its dependencies. You will also need a C++ compiler, such as Visual Studio or MinGW.
To use VisualParsic4, you need to include the visualparsic4.h header file in your C++ source code. Then, you can create a VisualParsic4 object and call its init method with the following parameters:
The HTML element where you want to insert the content (such as a div or a span)
The path to the SVG file where you want to draw (optional)
The options for the content generation (such as color, font size, etc.)
For example, the following code creates a VisualParsic4 object and initializes it with a div element with id \"line1\" and an SVG file named \"file.svg\":
Then, you can use the VisualParsic4 object to generate content using placeholders. A placeholder is a string that starts with \"$\" and ends with \"$\". For example, \"$name$\" is a placeholder for the name of the user. You can define your own placeholders and assign them values using the set method of the VisualParsic4 object. For example, the following code sets the value of the \"$name$\" placeholder to \"John\":
vp.set (\"$name$\", \"John\");
You can also use predefined placeholders that are automatically filled by VisualParsic4. For example, \"$date$\" is a placeholder for the current date, and \"$time$\" is a placeholder for the current time. You can see the full list of predefined placeholders in the Visual Parsic 4 GitHub project.
To insert content into the HTML element, you need to use the insert method of the VisualParsic4 object. This method takes a string as an argument, which can contain plain text or placeholders. For example, the following code inserts a greeting message into the div element:
vp.insert (\"Hello, $name$. Today is $date$ and the time is $time$.\");
To draw lines and shapes on the SVG file, you need to use the draw methods of the VisualParsic4 object. These methods take two or more Kubeobjects as arguments, which are objects that represent points or vectors in 3D space. For example, the following code creates two Kubeobjects named line1 and line2, and draws a line between them:
var line1 = new Kubeobject (0, 0, 0);
var line2 = new Kubeobject (100, 100, 0);
vp.drawLine (line1, line2);
You can see more examples of drawing methods in the Visual Parsic 4 GitHub project.