Furia Script is based on a few basic elements to create and manage html and JavaScript elements that make it much easier to write applications. Html and JavaScript syntax is also valid in Furia Script.
@define $identifier (parameters list) {body}
Allows to define advanced and complex Furia Script components.
Parameters list is optional. Body of the definition will be taken from the {...} block content or from the rest of line if {...} block is missing. $identifier must begin with '$' or '@'.
Examples:
@define $color_blue #0000FF
@define $make_text_color ($clr) {color: $clr;}
@define $make_text_color_and_size ($clr, $s) {$make_text_color($clr); font-size: $s;}
@include "filepath"
Includes a specified file to the source code. Filepath may be an absolute path or relative to the main project file path.
@eval(expression)
Evaluates the specified expression. Beside typical numerical expressions, it is allowed to use elements such as RGB colors (#RRGGBB) and pixel values (e.g. 16px).
Examples:
@eval(2*2) // gives 4 :)
@define $my_favourite_color #112233
@define $multiply_color($clr, $mltp) @eval($clr * $mltp)
$multiply_color($my_favourite_color, 2)      // gives #224466
@define $count_y_position($line) @eval(100px + 32px * $line)
$count_y_position(2) // gives 164px
@if(condition) {commands1} @else {commands2}
Includes commands1 to source code if condition value is non-zero or commands2 otherwise. @else statement is optional.
Examples:
@define $position_x($x) @if ($x >= 0) { left : $x } @else { right : @eval(-$x) };
@define $position_y($y) @if ($y >= 0) { top : $y } @else { bottom : @eval(-$y) };
@define $position($x, $y) $position_x($x); $position_y($y);
Some results:
$position(20px, 30px) // gives left: 20px; top: 30px;
$position(-20px, 30px) // gives right: 20px; top: 30px;
$position(20px, -30px) // gives left: 20px; bottom: 30px;
$position(-20px, -30px) // gives right: 20px; bottom: 30px;
function function_name(parameters) {body}
JavaScript function declaration.
@div.identifier (properties) {
   @style {
      div css properties
      @hover {
         div css hover style
      }
      @active {
         div css active style
      }
   }   
   div content
}
Creates div element :
identifier (optional) - div ID. If no identifier is specified, Furia will generate a unique one.
properties (optional) - div properties (html).
@style {...} (optional) - defines div css style.
@hover {...} (optional) - defines div css hover style.
@active {...} (optional) - defines div css activity style (activity is a Furia extension - see below).
Example - button definition using @define and @div:
@define $user_button($button_txt) {
   @div (onclick='userButtonPressed(this);') {
      @style {
         margin-top:10px; margin-bottom:10px;
         font-family: Arial; font-size: 16px; height: 32px; line-height: 32px; width: 200px;
         text-align: center;   padding-left: 20px; padding-right: 20px;
         background-color: #10A0EF; color: #FFFFFF;
         border: 2px solid #10A0EF;
         cursor: pointer; cursor: hand;
         @hover {
            border: 2px solid #FFFFFF;
         }
         @active {
            background-color: @eval(#10A0EF*0.5);
            border: 2px solid @eval(#10A0EF*0.5);
         }
      }
      $button_txt
   }
}
@function userButtonPressed(item) {
   alert(item.innerHTML);
}
Usage:
$user_button("Hello Furia!")
$user_button("Hello User!")
Result:
Hello Furia!
Hello User!
@increment($variable, [value])
@decrement($variable, [value])
Increments or decrements the $variable (defined with @define) by 1 or by the optional value (value may be integer or the other variable defined with @define).
Example:
@define @point_count 1
@define @head1($txt) {
   </table>
   @div {
      @style {
         font-weight:bold;
         font-size:18px;
      }
      $txt
   }
   @define @point_count 1
   <table>
}
@define @end1 </table>
@define @point1($txt) {
   <tr>
      <td> </td>
      <td valign="top">
         @point_count.
         @increment(@point_count)
      </td>
      <td valign="top">
         $txt
      </td>
   </tr>
}
@div {
   @style {
      color:#FFFFFF;
      width:300px;
      border:2px solid #606060;
      border-radius:2px;
      background-color:#505050;
      padding:10px;
   }
@head1("Furia Script main features (part 1):")
   @point1("Easy Windows-compatible executables (EXE files) development and compilation using HTML, HTML5 and JavaScript elements")
   @point1("Easy Websites development")
   @point1("Files manipulation functions")
   @point1("System Registry access")
@head1("Furia Script main features (part 2):")
   @point1("Processes access functions")
   @point1("Network/Emails access functions")
   @point1("Win32 DLLs support")
   @point1("Wide set of libraries")
   @point1("Free support")
@end1
}
The result:
Furia Script main features (part 1):
|
1.
|
Easy Windows-compatible executables (EXE files) development and compilation using HTML, HTML5 and JavaScript elements
|
|
2.
|
Easy Websites development
|
|
3.
|
Files manipulation functions
|
|
4.
|
System Registry access
|
Furia Script main features (part 2):
|
1.
|
Processes access functions
|
|
2.
|
Network/Emails access functions
|
|
3.
|
Win32 DLLs support
|
|
4.
|
Wide set of libraries
|
|
5.
|
Free support
|
@activity_group {body}
Groups items with @active style defined and allows only one to be active at one time.
Example (using @user_button defined above):
@activity_group {
   $user_button("Hello Furia!")
   $user_button("Hello User!")
   $user_button("I'm here...")
   $user_button("I'm the last one.")
}
Result:
Hello Furia!
Hello User!
I'm here...
I'm the last one.
Note: Top menu and left menu of this webpage are created using this method.
@plane.identifier (properties) {body}
Declares content that only one of the planes at the same level can be visible at one time. @plane declaration is the same as @div.
Example - four planes switching each second:
@define $plane_color($id, $c, $plane_txt) {
   @plane.$id {
      @style {
         background-color: $c; color: #FFFFFF;
         width: 300px; height: 50px;
         line-height: 50px;
         text-align: center;
      }
      $plane_txt
   }
}
@div {
   @style {
      margin-top: 20px; margin-bottom: 20px;
      width: 300px; height: 50px;
   }
   $plane_color(plane-1, #10A1EF, 'One')
   $plane_color(plane-2, #2438F1, 'Two')
   $plane_color(plane-3, #FF8C04, 'Three')
   $plane_color(plane-4, #FFBB04, 'Four')
}
<script>
   var currentPlane = 1;
   setInterval(function() {f_showPlane('plane-' + (currentPlane++).toString()); if (currentPlane > 4) currentPlane = 1;}, 1000);
</script>
Result:
Note the function f_showPlane(...) - it switches the planes - read the description in Furia Functions section.
The navigation at this web page is also implemented using Furia planes method.
@repeat(expression) {body}
Repeats body content expression times.
@scheme {body}
Defines the invisible GUI element to store base items for creating other, repeatable items.
This example shows how the scheme items can be used as a source for nodes cloning:
@scheme {
   @div.id-base {
      @style {         
         position:relative;height:40px;@f_borderbox;border-bottom:1px solid #BABABA;font-family:"Courier New";@f_clickable;
         @hover {
            background-color:#E0E0E0;
         }
      }
      @div.id-filename {@style {@f_position(10px, 2px);height:16px;left:10px;right:10px;}}
      @div.id-virusname {@style {@f_position(10px, 20px);height:16px;left:10px;right:10px;color:#AA0000;}}
   }
}
@div.id-cont {
   @style {
      @f_position(20px, 20px);
      @f_size(-20px, -20px);
      border:1px solid #BABABA;
      overflow-y: scroll;
   }
}
@function user_main() {
   var parent = f_getItemEx('id-cont');
   for (var i = 0; i < 10; i++) {
      var child = parent.pushBackById('id-base');
      child.get('id-filename').setText("c:\\windows\\system32\\drivers\\samples.sys [" + i.toString() + "]");
      child.get('id-virusname').setText("Win32.NetFilter.A");
   }
}
The result is:
Images
Furia allows to use images as url and local files. Local files will be embedded into an output exe file while building.
To include an image as a url, prepare div element as follows:
@div.furia-image (image="http://furiascript.com/images/fs72.png") {}
Result:
To embed a local image into an output exe file, use image property as follows:
@div.furia-image-local (image="c:\images\fs72.png") {}
You can also embed an image as base64 string directly into html file:
@imageb64{image_path,[width,height]}
Example:
@imageb64{"c:\images\fs72.png",128px,100px}
Sounds
Furia can play sounds (in WAV and MP3 format). To use the WAV or MP3 file in your project you have to embed it:
@sound.sound-id {WAV/MP3 file path}
and to play it just call:
f_playSound("sound-id");
So - for example:
@sound.sound-id {"c:\windows\media\Ring06.wav"}
@function user_main() {
   f_playSound("sound-id");
}
Debugging
To debug or trace applications use
Debug View and macros which allow to output the debug strings:
   @f_debug(string); // outputs the string.
   @f_debugv(variable); // outputs the variable name and its value.
Example:
var test_variable = [1,2,3,4,5,6];
function test(a,b,c) {
   @f_debug("a="+a+", b="+b+", c="+c);
   var sum = a + b + c;
   @f_debugv(sum);
}
function user_main() {
   @f_debug("Start");
   @f_debugv(test_variable);
   test(10,20,30);
   @f_debug("Stop");
}
The Debug View will show (note that every line contains also the function name):
00000010   20:32:24   [4536] [FS] : user_main : Start   
00000011   20:32:24   [4536] [FS] : user_main : test_variable = 1,2,3,4,5,6   
00000012   20:32:24   [4536] [FS] : test : a=10, b=20, c=30   
00000013   20:32:24   [4536] [FS] : test : sum = 60   
00000014   20:32:24   [4536] [FS] : user_main : Stop   
Comments
Comments can be placed in the source code using:
// comment to the end of the line
or comment block:
/* ---------------------------------
   this is comment block
   --------------------------------- */
Furia Script offers a set of predefined macros to simplify the process of creating the applications.
@f_gui_frame($id, $head_txt, $x, $y, $sx, $sy) { content }
Creates the frame with the header and content. $head_txt may be empty.
Example:
   @f_gui_frame(sample-frame, "This is the sample frame header", 20px, 20px, 380px, 160px) { This is sample frame content }
The result:
This is sample frame content
@f_gui_button($id, $x, $y, $sx, $sy, $action) { button content }
Creates the button.
Example:
   @f_gui_frame(sample-frame, "The frame with the button", 20px, 20px, 380px, 160px) {
      @f_gui_button(sample-button, -20px, -20px, 150px, 32px, "alert('Hello!')") {Click me}
   }
The result:
@f_gui_label($id, $x, $y) { label content }
Creates the label.
Example:
   @f_gui_frame(sample-frame, "The frame with the labels", 20px, 20px, 380px, 160px) {
      @f_gui_label(label-1, 20px, 20px) { First important value : }
      @f_gui_label(label-2, 20px, 60px) { Second important value : }
      @f_gui_label(label-v1, 260px, 20px) { 42 }
      @f_gui_label(label-v2, 260px, 60px) { 44 }
   }
The result:
First important value :
Second important value :
42
44
@f_gui_progress($id, $x, $y, $sx, $sy)
Creates the progress bar.
Example:
   @f_gui_frame(sample-frame, "The frame with the labels", 20px, 20px, 380px, 160px) {
      @f_gui_label(label-1, 20px, 20px) { Scanning progress : }
      @f_gui_label(label-v1, 220px, 20px) { 0% }
      @f_gui_progress(prg, 20px, 60px, -20px, 32px)
   }
   <script>
   var p = 0;
   setInterval(function() {
      f_getItemEx('prg').setProgress(i % 100); // set the progress bar position
      f_getItemEx('label-v1').setText(Math.round(i % 100) + "%");
      i += 1; }, 100);
   </script>
The result:
@f_gui_edit($id, $x, $y, $sx, $sy)
Creates the text edit field.
Example:
   @f_gui_frame(sample-frame, "The frame with the text edit", 20px, 20px, 380px, 160px) {
      @f_gui_edit(edit-1, 20px, 60px, -20px, 32px)
      @f_gui_button(button-1, 20px, 80px, 200px, 32px, "alert(f_getItemEx('edit-1').value);") { What did I type? }
   }
The result:
@f_gui_checkbox($id, $x, $y, $checked) { content/text }
Creates the checkbox.
Example:
   @f_gui_frame(sample-frame, "The frame with the checkboxes", 20px, 20px, 380px, 160px) {
      @f_gui_checkbox(chk1, 20px, 20px, checked) { First option }
      @f_gui_checkbox(chk2, 20px, 40px, unchecked) { Second option }
      @f_gui_button(button-1, 20px, -20px, 200px, 32px, "change_checkboxes();") { Change state }
   }
   
   function change_checkboxes() {
      if (f_getItemEx('chk1').isChecked()) // check of the checkbox is checked or not
         f_getItemEx('chk1').setChecked(false); // disable it
      else
         f_getItemEx('chk1').setChecked(true); // or enable
      if (f_getItemEx('chk2').isChecked())
         f_getItemEx('chk2').setChecked(false);
      else
         f_getItemEx('chk2').setChecked(true);
   }
The result:
@f_gui_recolor($c1, $c2)
Changes the color scheme.
Example:
   @f_gui_recolor(#6B0000, #FFFFFF)
   @f_gui_frame(sample-frame, "The frame with the button", 20px, 20px, 380px, 160px) {
      The content
      @f_gui_button(sample-button, -20px, -20px, 150px, 32px, "alert('Hello!')") {Click me}
   }
The result:
   @f_gui_recolor(#003F00, #FFFFFF)
   @f_gui_frame(sample-frame, "The frame with the button", 20px, 20px, 380px, 160px) {
      The content
      @f_gui_button(sample-button, -20px, -20px, 150px, 32px, "alert('Hello!')") {Click me}
   }
The result:
   @f_gui_recolor(#FFFFFF, #000000)
   @f_gui_frame(sample-frame, "The frame with the button", 20px, 20px, 380px, 160px) {
      The content
      @f_gui_button(sample-button, -20px, -20px, 150px, 32px, "alert('Hello!')") {Click me}
   }
The result:
You can also control all the gui parameters by redefining the following values:
   
@define $f_gui_f_size_body
16px // main font size
@define $f_gui_f_size_head
20px // frame header font size
@define $f_gui_f_font
'Segoe UI', Frutiger,
'Frutiger Linotype',
'Dejavu Sans',
'Helvetica Neue', Arial, sans-serif
@define $f_gui_i_shadow
3 // shadow type
@define $f_gui_m_margin
10px // global margin
@define $f_gui_border_radius
0px // border radius
@define $f_gui_f_size_button
20px // button font size
@define $f_gui_c_bck_head
#10A0EF // frame header color
@define $f_gui_c_bck_body
#FFFFFF // main background color
@define $f_gui_c_frame
#DADADA // main frame color
@define $f_gui_c_font_body
#000000 // main font color
@define $f_gui_c_font_head
#FFFFFF // header font color
@define $f_gui_c_bck_button
#10A0EF // button color
@define $f_gui_c_font_button
#FFFFFF // button text color
@define $f_gui_c_progress_bck
#DADADA // progress bar background color
@define $f_gui_c_progress_bar
#10A0EF // progress bar color
@define $f_gui_c_progress_frame
#DADADA // progress bar frame color
@f_gradient_v($color1, $color2)
@f_gradient_h($color1, $color2)
Defines div style gradient (vertical or horizontal) property.
Example:
@div.gradient-div {
   @style {
      width: 200px; height: 60px;
      color: #000000;
      font-family: "Segoe UI"; font-size: 16px;
      line-height: 60px;
      text-align: center;
      @f_gradient_v(#10A1EF, #FFFFFF);
   }
   GRADIENT
}
Result:
GRADIENT
@f_rotation($angle)
Defines the div rotation.
Example:
@div.rotated-div {
   @style {
      width: 200px; height: 60px;
      color: #FFFFFF;
      font-family: "Segoe UI"; font-size: 20px;
      line-height: 60px;
      text-align: center;
      background-color: #10A1EF;
      @f_rotation(30);
   }
   Rotation
}
Result:
Rotation
Note: html5 has to be set to true (html5:true) in the application settings to enable rotation.
Furia Script provides the set of JavaScript functions to access and manipulate GUI components.
f_cout(t1, t2, t3, ...)
f_coutl(t1, t2, t3, ...)
Print the specified values to the default console (if any).
Example - the sample application that lists files in the folder passed as the parameter:
@application {
   visible : false; // to hide the Furia GUI window
}
function user_main() {
   @for_all_files_in_folder(f_getCommandLineString(), f, false) {
      f_cout(f, "\r\n");
   }
   f_exit();
}
f_getItem(id)
Returns the node with id identifier, or null if the item does not exist.
f_getAttr(item, attr)
Returns the item attribute attr.
f_setFocus(id)
Gives focus to an id element.
f_isChecked(id)
Returns true if the id checkbox is checked.
f_setChecked(id, checked)
Sets the id checkbox checked (checked = true) or unchecked (checked = false).
f_setText(id, txt)
Sets the inner text of the specified item.
f_getText(id)
Returns the inner text of the specified item.
f_show(id)
Shows the specified item.
f_hide(id)
Hides the specified item.
I'm modal. Click me to hide me.
f_showModal(id, [smooth])
f_hideModal(id)
Shows (or hides) the specified element as modal and disables all other elements.
The optional smooth parameter (integer, suggested value - 10) allows to show the dialog smoothly.
Example:
@div.id-modal-element (onclick="f_hideModal('id-modal-element');"){
   @style {
      @f_position_fixed(100px,100px);
      @f_size(300px,200px);
      padding:20px;
      font-size:32px;
      color:#ffffff;
      display:none;
      @f_clickable;
      border:4px solid #303030;
      background-color:#101010;
      @f_opacity(100);
      border-radius:2px;
   }
   I'm modal. Click me to hide me.
}
Click to show the modal element
f_setItemPos(item, x, y)
Sets the position of the specified item.
f_rotateItem(item, angle)
Rotates the specified item by the specified angle.
f_setOpacity(item, opacity)
Sets the opacity attribute of the specified item.
f_showPlane(id)
Shows specified plane and disables other planes at the same level.
f_jumpToPlane(id)
Shows specified plane and stores the last plane visible to the internal stack so the f_popPlane can be used to get back to the previous plane.
f_popPlane(id)
Returns to the last plane switched with f_jumpToPlane.
f_messageBox(title, message)
Displays a message box with title and message.
f_setProgressBar(id, progress_position)
Sets a progress bar (identified by id) position. Position range is <0, 1000>.
f_processEvents()
Forces the application to process the events queue and redraws GUI.
f_exitApplication()
Exits the current application.
Furia allows applications to interact with operating system and data stored in files, registry, web, etc.
f_getCommandLineString()
Returns command line string.
f_getCommandLineArray()
Returns command line parameters array (the same as string[] args).
f_loadFile(filename, [offset], [count])
f_loadFileToBase64(filename)
f_saveFile(filename, buffer, [offset], [count])
f_appendFile(filename, buffer, [offset], [count])
Loads, saves or appends to or from a specified file.
offset (optional) - the offset (in the file or in the buffer) - positive values mean the offset from the beggining, negative values - from the end.
count (optional) - the number of bytes to load or save.
Example:
function readFileTest() {
   var content = f_loadFile("c:\\files\\original-file.bin");
   f_saveFile("c:\\files\\original-file-copy.bin", content);
}
function appendTest() {
   var line = "Hello dear user!\r\n";
   f_appendFile("c:\\files\\log.txt", line);
   f_appendFile("c:\\files\\log.txt", line);
   f_appendFile("c:\\files\\log.txt", line);
}
The simple tool to remove UTF-8 BOM (if exists) from the file passed as the command line argument:
function user_main() {
   var fn = f_getCommandLineString();
   if (f_loadFile(fn, 0, 3) == "\xef\xbb\xbf")
      f_saveFile(fn, f_loadFile(fn, 3));
   f_exit();
}
f_fileSize(filename)
Returns a size of filename file or 0 when filename file does not exist.
f_deleteFile(filename)
Deletes the specified file.
f_listFolders(folder)
f_listFiles(folder)
Functions return an array of folders or files in a specified folder.
Example:
@function showFilesInWindows() {
   var filesInWindows = f_listFiles("c:\\windows");
   alert(filesInWindows);
}
f_selectFile(title, mask)
Displays file selection dialog and returns the file selected or empty string when cancelled.
Example:
@function selectFileAndDisplay() {
   var fileSelected = f_selectFile("Select text file", "Text files|*.txt");
   alert(fileSelected);
}
f_selectFolder(title)
Displays folder selection dialog and returns the folder selected or empty string when cancelled.
Example:
@function selectFolderAndDisplay() {
   var folderSelected = f_selectFolder("Select folder");
   alert(folderSelected);
}
f_getFileIcon(filename)
Returns the temporary path to the png file that contains the specified file (filename) icon.
f_hasValidSignature(filename)
Returns true if the specified binary file has the valid signature.
f_getFileSigner(filename)
Returns the file signer information.
f_getFileInfo(filename)
Returns the file resource information.
@for_all_files_in_folder(path, filename_variable, subfolders) important - this is macro
The macro enumerates all files in the specified folder (path) as the variable filename_variable. If subfolders is set to true all subfolders will be also processed.
Example:
function user_main() {
   @for_all_files_in_folder("c:\\program files", fnm, true) {
      alert(fnm);
   }
}
@for_all_lines_in_file(filename, line) important - this is macro
The macro enumerates all lines (as the variable line) in the file specified by filename.
Example:
function user_main() {
   @for_all_files_in_folder("c:\\Text Documents", fnm, true) {
      @for_all_lines_in_file(fnm, line) {
         alert(line);
      }
   }
}
f_async_countFiles(folder, subfolders, callback)
Asynchronously counts files in the specified folder (with subfolders if the subfolders is set to true) and calls callback function when finished.
Example:
@function user_main() {
   f_async_countFiles("c:\\windows", true, function(c){alert(c);});
}
f_async_listFiles(folder, subfolders, callback)
Asynchronously calls the callback function for all files in the specified folder (with subfolders if the subfolders is set to true) and passes the filename as the function parameter.
When enumeration is finished the empty string is passed as the parameter to the callback function.
Example:
@function user_main() {
   var enumid = f_async_listFiles("c:\\windows\\system", true, function(fname){alert(fname);});
}
Note: To stop the enumeration call the f_stop_async_listFiles(id) function:
   f_stop_async_listFiles(enumid);
f_writeRegString(root, path, key, value)
f_readRegString(root, path, key, default_value)
f_writeRegDword(root, path, key, value)
f_readRegDword(root, path, key, default_value)
Functions read and write string or dword values to/from specified registry keys.
Example:
@function registryManipulation() {
   f_writeRegString("HKEY_CURRENT_USER", "Software\\FuriaScript", "message", "This is stored message");
   var valueStored = f_readRegString("HKEY_CURRENT_USER", "Software\\FuriaScript", "message", "This is default value");
   alert(valueStored);
}
f_download(url)
Downloads data from the specified url.
Example:
var furia_builder = f_download("http://furiascript.com/download.php");
f_download_to_file(url, filename)
Downloads data from the specified url and saves it to the file specified by filename. Returns the number of bytes downloaded.
Example:
var bytes_downloaded = f_download_to_file("http://furiascript.com/download.php", "c:\\fs.exe");
f_async_download(url, progress_callback, finish_callback)
Asynchronously downloads data from the specified url. Reports download progress via the progress_callback function and calls the finish_callback function when a download process is complete.
f_async_download_to_file returns the id of a downloading process (see the example below).
progress_callback and finish_callback have to be declared as follows:
   // this application shows how to use the f_async_download function in Furia Script
   // the progress bar
   @f_progressBar('main-progress',20px,20px,-20px,32px,#BABABA,#10A0EF,#606060)
   // progress callback
   @function downloadProgress(id, url, progress) {
      f_setProgressBar('main-progress', progress);
   }
   // finish callback
   @function downloadFinished(id, url, content, result) {
      //--------------------------------------------------------------
      // note: the content is encoded. To get the original data
      // call the f_decode_content(content) function.
      //--------------------------------------------------------------
      if (result == "ok")
         f_saveFile("c:\\downloaded\\fs.exe", f_decode_content(content));
      alert("Url : " + url + "\r\nId : " + id + "\r\nResult : " + result);
   }
   @function user_main() {
      var id = f_async_download("http://furiascript.com/download.php", downloadProgress, downloadFinished);
   }
f_async_download_to_file(url, filename, progress_callback, finish_callback)
Works almost the same as the f_async_download.
Asynchronously downloads data from the specified url and saves it to the file specified by filename. Reports download progress via the progress_callback function and calls the finish_callback function when a download process is complete.
f_async_download_to_file returns the id of a downloading process (see the example above).
progress_callback and finish_callback have to be declared as for the f_async_download.
The main difference in the downloadFinished callback is that content contains the name of the saved file and do not has to be decoded using f_decode_content.
f_portListen(port, user_callback)
f_portListenEx(port, timeout, user_callback)
Starts the listener thread on the specified port. If data is received the user_callback is called with the client address and the received buffer. The buffer returned from callback will be send back to the client as the answer to the request.
f_portListenEx variant allows to define the timeout parameter for the DataAvailable flag.
Example (simple echo server on the port 80 returning the buffer received to the client):
   @function data_received_callback(client_addr, buffer) {
      return buffer;
   }
   
   @function user_main() {
      f_portListen(80, data_received_callback);
   }
To test this code just execute the browser and type 127.0.0.1 in the address bar.
f_stopPortListen(port)
Stops the port listener thread.
f_tcpSendBuffer(host, port, buffer, user_callback)
Sends the buffer content to the specified host and receives the answer in the user_callback function.
Example:
   @function data_received_callback(client_addr, buffer) {
      return buffer;
   }
   
   @function data_received_callback_from_send(buffer) {
      alert(buffer);
   }
   
   @function user_main() {
      f_portListen(80, data_received_callback);
      f_tcpSendBuffer("127.0.0.1", 80, "Hello Furia!", data_received_callback_from_send);
   }
f_fileToHttpStream(filename)
Returns the buffer with the http header and the specified file content ready to return to the connected client.
Example (the simple http server that allows to download the specified file on the port 80):
   @function data_received_callback(buffer) {
      return f_fileToHttpStream("c:\\somefile.bin");
   }
   
   @function user_main() {
      f_portListen(80, data_received_callback);
   }
f_fileToHttpStreamDelegate(filename)
Works as the f_fileToHttpStream function (above) but delegates the request to the Furia Engine so the memory consumption is significantly reduced.
Example (the simple http server that allows to download the specified file on the port 80):
   @function data_received_callback(buffer) {
      return f_fileToHttpStreamDelegate("c:\\somefile.bin");
   }
   
   @function user_main() {
      f_portListen(80, data_received_callback);
   }
f_sendMail(mail_object)
Sends the email in accordance with the parameters specified in mail_object.
Details of use:
f_sendEmail({
         to:"user1@domain1,user2@domain2,...", // the list of recipients
         from:"user@domain", // the sender
         replyto:"user1@domain1,user2@domain2,...", // the reply-to field list
         subject:"The mail subject", // subject
         body:"The mail body", // body
         server:"server address", // the server address
         port:587, // the port number - 25, 587 etc.
         ssl:1, // ssl activation
         user:"user_name", // the user name
         password:"user_password", // password
         attachments:["c:\\folder\\attachment1","c:\\folder\\attachment2",...] // attachments array
});
The function returns "ok" string if the email was sent successfuly, or "error : comment" if the function failed.
f_getProcessesPids()
Returns the list of the active processes pids.
Example:
   var pids = f_getProcessesPids();
   alert(pids);
f_getProcessPathByPid(pid)
Returns the full path of the process identified by pid.
f_getProcessParentByPid(pid)
Returns the id of the parent process or 0 if parent process id cannot be found.
f_killProcessByPid(pid)
Kills the process identified by pid.
f_killProcessByName(name)
Kills the process identified by name (process path with filename has to include name).
f_getProcessPid(name)
Returns the pid of the process identified by name (process path with filename has to include name).
f_isProcess(name)
Checks if the process identified by name exists.
f_getCurrentProcessPid()
Returns the pid of the current process.
f_getCurrentProcessPath()
Returns the path of the current process.
f_createProcess(path, parameters, finish_callback, output_callback)
f_createProcessAsAdmin(path, parameters, finish_callback, output_callback)
Creates the process identified by path with parameters and returns the created process pid (or 0 if error occured).
finish_callback will be called when the process exits.
output_callback will catch the process output (if specified)
finish_callback and output_callback are optional.
Example (calling the dir command):
@function user_main() {
   var id = f_createProcess("cmd.exe", "/c dir c:\\windows", function(id){alert("Finished : " + id);}, function(id, output){alert("Output:\r\n" + output);});
}
Note: To see how these functions work refer to the Process Explorer project in the Examples section.
f_createMutex(name)
Creates the global mutex.
f_isMutex(name)
Checks if the mutex exists.
f_deleteMutex(name)
Deletes the specified mutex.
To access Windows services you have to use f_services object:
f_services.controlService(service_name, code)
Sends the specified code to the service dispatcher
Example:
   f_services.controlService("arcabitsv", 130);
f_services.getServiceStatus(service_name)
Returns (as string) the specified service status. The possible return values are:
   service_stopped
   service_start_pending
   service_stop_pending
   service_running
   service_continue_pending
   service_pause_pending
   service_paused
   // and the error codes:
   no_service
   query_error
   unknown_state
   general_error
f_services.stopService(service_name)
Stops the specified service.
f_services.startService(service_name)
Starts the specified service.
f_getUserName()
Returns the the current user name.
f_getUserAvatar(username)
Returns the user avatar file path for the username. If username is null function returns the avatar path for the current user.
Example:
@div.id-user-avatar {
   @style {
      @f_position(20px,20px);
   }
}
@function user_main() {
   var avatarFile = f_imageFileToInnerHtml(f_getUserAvatar(), 128, 128);
   f_getItem("id-user-avatar").innerHTML = avatarFile;
}
To manage tray/notify icons use the f_tray object.
To include the icon into the compiled project:
   @include_icon(icon_id, icon_path)
Example:
   @include_icon(main-icon, "c:\my_project\file_icon.ico")
To add icon to the system tray:
   f_tray.addIcon(   
      icon_id,    // included icon identifier specified in the @include_icon
      icon_text,   // icon tooltip
      left_click_function,   // the function to be called on the every single click
      left_double_click_function,   // the function to be called on the double click
      menu_items_object   // the array with menu items (look below)
   );
Note: When icon_id is null the project icon will be used.
menu_items_object is the JavaScript array containing all menu items, submenus and callbacks.
Example:
   @include_icon(id-main-icon, "icon1.ico") // first include the icon
   @function dblClick() {
      alert("dblClick");
   }
   @function funcOpen(id) {
      alert("funcOpen : " + id);
   }
   @function funcClose(id) {
      alert("funcClose : " + id);
   }
   @function funcOptions(id) {
      alert("funcOptions : " + id);
   }
   @function user_main() {
      var tid = f_tray.addIcon(
         'id-main-icon',
         'Tray icon example',
         null,   // no click event
         dblClick,   // the function to process double click
         ["Open", funcOpen, "Close", funcClose, "More", ["Option 1", funcOptions, "Option 2", funcOptions, "Option 3", funcOptions]]
      );
   }
The result is:
Note: Furia Script passes the internal option identifier to the specified callbacks as shown.
To change the existing icon to the other one:
   f_tray.setIcon(tid, new_icon_id);
To change the existing icon text:
   f_tray.setText(tid, new_text);
To change the existing icon menu:
   f_tray.setMenu(tid, new_menu);
To delete the existing icon:
   f_tray.deleteIcon(tid);
Example:
   @include_icon(id-main-icon, "icon1.ico")
   @include_icon(id-new-icon, "icon2.ico")
   
   @function user_main() {
      var tid = f_tray.addIcon('id-main-icon');    // the basic icon without menu and callbacks
      f_tray.setIcon(tid, 'id-new-icon');   // changes the icon
      f_tray.setText(tid, 'This is new icon text');   // changes the icon text
      f_tray.setMenu(tid, ["First option", funcOptions, "Second option", funcOptions]);   // changes the menu
   }
f_getWindowsVersion()
Returns the string containing the information about the system.
f_getWindowsLanguage()
Returns the object containing the information about the system language.
Example:
   var lv = f_getWindowsLanguage();
The object lv may be for example:
   {
      "installed" : "en-EN",
      "currentUI" : "en-EN",
      "current" : "en-EN"
   }
f_is64()
Determines whether the current operating system is a 64-bit operating system.
f_getEnv(variable)
Returns specified environment variable.
Example:
@function checkWinDir() {
   var winDir = f_getEnv("windir");
   alert(winDir);
}
f_openBrowser(url)
Opens the default browser and navigates to the url specified.
Example:
   f_openBrowser("http://furiascript.com");
f_bringToFront()
Brings the current application window into the foreground.
f_setDialogTitle(txt)
Sets the title of the application window.
Libraries are the Furia Script extensions. To include the selected library use the @include command as follows:
@include "furia:library name"
Note: Libraries are synchronized with Furia Server (furiascript.com) and downloaded/updated (if needed) when you compile the project that uses the libraries.
To compile the project properly, you have to allow the connection.
furia:canvas
Declares the HTML5 canvas component.
@f_canvas(id, x, y, sx, sy)
Canvas component declaration. Canvas is identified as $id.
f_getCanvas2d(id)
Returns the canvas objects with predefined set of expanded graphics functions.
f_3d_scene()
Returns the 3D scene object.
f_3d_point(_x, _y, _z)
Returns the 3D point object.
f_3d_polygon()
Returns the 3D polygon object.
f_3d_object()
Returns the 3D generic object.
Furia Script 3D Engine Example
Note: To see how does the Furia Script 3D library works refer to the 3D Engine example in the Examples section or click >here< .
furia:console
Declares the console GUI element that makes it easy to display messages and reports sequentially.
@f_console(id, x, y, sx, sy, color, bck_color, font, font_size, font_weight)
General console declaration. Console is identified as $id.
@f_consoleDefault(x, y, sx, sy)
Declares the console in the default style.
@f_consoleFull
Declares the entire window console
f_printEx(id, content)
Prints content on the console identified by id.
f_print(content)
Prints content on the default console.
furia:dom
Provides the set of additional functions to manipulate DOM.
function f_getSubItems(item, cls, chk)
Returns the array of first-level subitems of the given item with the class cls (optional) and checked (also optional) if chk is true.
f_getStyle(item, css_style)
Returns the css_style css value of the specified item. For example: f_getStyle("id-some-item", "right")
function f_scaleGui(scale, parent)
Rescales all interface components (children of parent if specified or the entire document). Can be used to fit the interface into the screen (may be useful for example in the PhoneGap-based applications to fit the different devices screens).
The scale factor is the positive number where 1 means "no rescale", 2 means two times bigger etc.
Note: To reuse f_scaleGui in the same application session you have to call f_resetScale (see below) first.
function f_resetScale()
Resets the scale state for the document.
furia:hash
Declares the f_HASH object that contains the set of hash functions.
f_HASH.sha1(buffer)
Returns the sha1 of the buffer.
f_HASH.sha1File(filename)
Returns the sha1 of the file filename.
f_HASH.md5File(filename)
Returns the md5 of the file filename.
furia:jquery
Includes jQuery to the source code (https://jquery.org/).
furia:paths
Declares the f_PATHS object - the set of file paths manipulation functions.
f_PATHS.pathOnly(path)
Returns the path without the file name. Assumes that the last part of the path is the file name.
f_PATHS.fileNameOnly(path)
Returns the file name only.
f_PATHS.fileExtension(path)
Returns the file extension.
f_PATHS.fileNameWithoutExtension(path)
Returns the file name without the extension.
f_PATHS.combinePaths(path1, path2)
Combines two paths to one path.
f_PATHS.getProgramDataPath()
Return the global ProgramData path.
furia:screen
Provides screen capture functions.
f_SCREEN.printScreen(max_height)
Returns the buffer with the screen (or screens if there are more than one desktop) in the PNG format.
If max_height is set the image is resized to fit the max_height.
f_SCREEN.printScreenToFile(max_height, filename)
Returns the path of the PNG file containing the screen (or screens if there are more than one desktop) capture.
If max_height is set the image is resized to fit the max_height. If max_height is set to -1 the original screen height will be used.
If filename is not set, the temporary file name is generated and returned.
furia:time
Provides date and time manipulation functions.
f_time(format_string)
Returns the current date and time, for example:
f_time("Y-m-d H:i:s") returns "2014-12-21 21:32:16"
f_time("YmdHis") returns "20141221213216"
etc.
Furia Script applications can load Win32 DLLs and use the exported functions.
To load the dll library and get the access to the exported functions you have to use the following Furia Script functions:
f_loadLibrary(dll_name)
- Loads the specified library and returns the handle or 0 if error occurs.
f_getProcAddress(dll_handle, function_name)
- Returns the address of the specified function from the dll represented by dll_handle.
f_callProc(proc_address, type_of_param1, value_of_param1, type_of_param2, value_of_param2, ... ) /* for stdcall calling convention */
f_callProc_cdecl(proc_address, type_of_param1, value_of_param1, type_of_param2, value_of_param2, ... ) /* for cdecl calling convention */
- These functions call the specified function with the list of parameters.
Valid parameters types are:
IntPtr
(input) Integer value
String
(input) String buffer
InBuffer
(input) Memory buffer
OutIntPtr
(output) Pointer value
OutInt
(output) Integer value (32 bit)
OutBuffer
(output) Memory buffer
IMPORTANT: The output variables have to be passed as the reference objects.
To get the objects references call:
var variable_reference_buffer = f_getObjectRef(buffer_size);
var variable_reference_integer = f_getObjectRef();
then call the function from the loaded DLL and pass the reference objects as the parameters:
var ret_value = f_callProc(function_address, ..., "OutBuffer", variable_reference_buffer, ..., "OutInt", variable_reference_integer, ...);
to get the variables values you have to dereference them:
var variable_buffer = f_derefObject(variable_reference_buffer);
var variable_integer = f_derefObject(variable_reference_integer);
f_callProcEx(proc_address, value_of_param1, value_of_param2, ... ) /* for stdcall calling convention */
f_callProcEx_cdecl(proc_address, value_of_param1, value_of_param2, ... ) /* for cdecl calling convention */
- Call the specified function with the list of parameters - use one of these functions if parameters are integers of strings (see the example below).
f_freeLibrary(dll_handle)
- Frees the loaded DLL module.
The following example shows, how to use DLLs in the Furia Script application. It contains the implementation of the files operations functions from the
kernel32.dll module:
The application also loads the
user32.dll module to get the
MessageBoxW function.
//----------------------------------------------------------------------------
// DLLs usage examples
//----------------------------------------------------------------------------
@application {
   title : DLLs usage example
}
@var dll = f_loadLibrary("kernel32.dll"); // global kernel32.dll module handle
@function msgBox(txt, title, icon) {
   var user_dll = f_loadLibrary("user32.dll");
   var proc = f_getProcAddress(user_dll, "MessageBoxW");
   f_callProcEx(proc, 0, txt, title, icon);
   f_freeLibrary(user_dll);
}
@function openFile(filename, write) {
   var proc = f_getProcAddress(dll, "CreateFileW");
   handle = f_callProcEx(proc, filename, write ? 0x40000000 : 0x80000000, 0, 0, write ? 2 : 3, 0, 0);
   return parseInt(handle);
}
@function closeFile(handle) {
   var proc = f_getProcAddress(dll, "CloseHandle");
   handle = f_callProcEx(proc, handle);
}
@function getFileSize(handle) {
   var proc = f_getProcAddress(dll, "GetFileSize");
   var length = f_callProcEx(proc, handle, 0);
   return length;
}
@function readFile(filename) {
   var handle = openFile(filename);
   if (handle == -1)
      return null;
   var length = getFileSize(handle);
   if (length == 0 || length == -1)
      return null;
   var p_rf = f_getProcAddress(dll, "ReadFile");
   var buffer = f_getObjectRef(length); // get the reference object for the output buffer
   var bytesRead = f_getObjectRef(); // get the reference object for the bytes read variable
   var result = f_callProc(p_rf, "IntPtr", handle, "OutBuffer", buffer, "IntPtr", length, "OutInt", bytesRead, "IntPtr", 0);
   buffer = f_derefObject(buffer);   // dereference buffer
   bytesRead = f_derefObject(bytesRead); // dereference bytes read variable
   closeFile(handle);
   return buffer;
}
@function writeFile(filename, buffer) {
   var handle = openFile(filename, true);
   if (handle == -1)
      return null;
   var p_wf = f_getProcAddress(dll, "WriteFile");
   var bytesWritten = f_getObjectRef(); // get the reference object for the bytes written variable
   var result = f_callProc(p_wf, "IntPtr", handle, "InBuffer", buffer, "IntPtr", buffer.length, "OutInt", bytesWritten, "IntPtr", 0);
   bytesWritten = f_derefObject(bytesWritten); // dereference bytes written variable
   closeFile(handle);
   return bytesWritten;
}
@function user_close() {
   f_freeLibrary(dll);
}
@function user_main() {
   var bytesWritten1 = writeFile("c:\\testfile.txt", "This is Furia Script test file content.");
   var buffer = readFile("c:\\testfile.txt");
   var bytesWritten2 = writeFile("c:\\testfile_copy.txt", buffer);
   msgBox("Bytes written : " + bytesWritten2, "DLLs example", 0x40);
   f_exitApplication();
}
Furia allows user to define various application parameters.
To define application settings use @application{...} block. All parameters are optional - if no value is specified, Furia will use a default value.
The @application{..} block can be placed anywhere in the source code.
@application {
   title_bar: true
      // or false - specify if the application dialog will have a title bar
      
   title: Application Title
      // text in application title bar
      
   window_size: 1024x768
      // initial window size
      
   min_window_size: 160x100
      // minimum window size
      
   max_window_size: 0x0
      // maximum window size (0x0 means that no maximum size is specified)
      
   center: true
      // or false - declare if initial window position has to be desktop centered
      
   as_admin: true
      // or false - declare whether the application require administrator privileges
      
   html5: true
      // or false - enable/disable HTML5 features
      
   visible: true
      // or false - declare whether the application window is visible or hidden
      
   background: #FFFFFF
      // dialog background color
      
   convert-px:pt,2.0
      // allows to change the units from px to (for example) pt and multiply all values by the specified factor
      
   // Executable file information fields :
   
   res.CompanyName : Your company name
   res.FileDescription : File description
   res.FileVersion : File version
   res.InternalName : Internal file name
   res.LegalCopyright : Copyright information
   res.OriginalFilename : Original file name
   res.ProductName : Product name
   res.ProductVersion : Product version
   res.AssemblyVersion : Assembly version
   res.icon : Icon file path
      
}
Application building in Furia Script is a single-step process that converts all source files into one executable file (EXE) or one HTML file.
Download and execute Furia Script Studio from Download section. To use Furia Script Studio you have to accept the Licence. You'll see Furia Script Studio with the basic file:
Type the sample
Hello World application:
@application {
   title: Hello World!
   window_size: 320x200
}
@div {
   @style {
      font-family:Arial;
      font-size:50px;
   }
   Hello World!
}
Then press Ctrl+R or select the 'Run' option from the Action menu in the upper-right corner.
Your file is still not saved so you have to save it first.
After saving you'll see the following dialog:
Note that you can also build the EXE file without executing it (Build EXE).
Furia Script Studio also allows you to build HTML file (Build HTML) that you can open in your browser.
To run the project without building the EXE file use the command:
fs.exe
project_name.fs
To build the EXE file from the command line:
fs.exe /b
project_name.fs [
project_name.exe]
To build the HTML file from the command line:
fs.exe /bh
project_name.fs [
project_name.html]