### Installation: Step 1 Source: https://4js.com/online_documentation/fjs-fgl-manual-html/sitemap.html First step in the installation process. This typically involves prerequisites or initial setup. ```bash # Step 1: Download the installer curl -O http://example.com/installer.tar.gz ``` -------------------------------- ### Installation: Step 3 Source: https://4js.com/online_documentation/fjs-fgl-manual-html/sitemap.html Third step in the installation process. This might involve configuration or starting services. ```bash # Step 3: Configure the environment variables export FGLDIR=/opt/4js/fgl ``` -------------------------------- ### Get Submatch Index All Example Source: https://4js.com/online_documentation/fjs-fgl-manual-html/fgl-topics/c_fgl_ext_util_Regexp_getSubmatchIndexAll.html Demonstrates how to use getSubmatchIndexAll to find the start and end positions of all whole matches and their sub-matches within a string. ```fgl IMPORT util MAIN DEFINE re util.Regexp DEFINE arr DYNAMIC ARRAY WITH DIMENSION 2 OF INTEGER LET re = util.Regexp.compile(`([A-Z]*)([0-9]*)`) LET arr = re.getSubmatchIndexAll("ABC678EFG99") DISPLAY "First whole match:" DISPLAY arr[1,1], arr[1,2] DISPLAY arr[1,3], arr[1,4] DISPLAY arr[1,5], arr[1,6] DISPLAY "Second whole match:" DISPLAY arr[2,1], arr[2,2] DISPLAY arr[2,3], arr[2,4] DISPLAY arr[2,5], arr[2,6] END MAIN ``` -------------------------------- ### os.Path.mkDir example Source: https://4js.com/online_documentation/fjs-fgl-manual-html/index.html?q=%2Fonline_documentation%2Ffjs-fgl-manual-html%2Ffgl-topics%2Fc_fgl_dialog_AFTER_DISPLAY.html Demonstrates creating a new directory at the specified path using os.Path.mkDir. It also shows how to check for existence before creation. ```fgl DEFINE new_dir_path STRING LET new_dir_path = "/path/to/new/directory" IF NOT os.Path.exists(new_dir_path) THEN IF os.Path.mkDir(new_dir_path) = 0 THEN MESSAGE CONCAT("Directory created: ", new_dir_path) ELSE MESSAGE CONCAT("Failed to create directory: ", new_dir_path) END IF ELSE MESSAGE CONCAT("Directory already exists: ", new_dir_path) END IF ``` -------------------------------- ### Java Interface Source: https://4js.com/online_documentation/fjs-fgl-manual-html/index.html?q=%2Fonline_documentation%2Ffjs-fgl-manual-html%2Ffgl-topics%2Fc_fgl_ClassChannel.html Details on how to extend Genero FGL using the Java interface, including prerequisites, getting started, advanced programming techniques, and examples. ```APIDOC ## Java Interface ### Description This section details the process of extending Genero FGL using the Java interface. It covers prerequisites, installation, getting started with basic operations like importing classes and calling methods, and advanced programming concepts. ### Prerequisites and Installation * Learn about Java and OOP * Java software requirements for FGL * How to set up Java * Platform-specific notes for the JVM ### Getting Started with the Java Interface * Import a Java class * Define an object reference variable * Instantiate a Java class * Calling a method of a class * Calling a method of an object ### Advanced Programming * Using JVM options * Case sensitivity with Java * Method overloading in Java * Java objects as function parameters and returns * Garbage collection of unused objects * Using the method return as an object * Ignorable return of Java methods * Static fields of Java classes * Mapping native and Java data types (DATE, DATETIME, DECIMAL, TEXT, BYTE, INTERVAL) * Identifying Genero data types in Java code * Using Genero records * Formatting data in Java code * Character set mapping * Using Java arrays * Passing variable arguments (varargs) * The CAST operator * The INSTANCEOF operator * Java exception handling * Troubleshooting Java interface issues * Executing Java code with GMA (Standard Java and Android library usage, Implement Java user extensions in GMA, Implement Androidâ„¢ activities in GMA, Packaging custom Java extensions for GMA) ### Examples * Example 1: Using the Calendar package * Example 2: Using the Apache POI framework * Example 3: Using Java on Androidâ„¢ ``` -------------------------------- ### Start Android Activity and Get Result Source: https://4js.com/online_documentation/fjs-fgl-manual-html/fgl-topics/c_fgl_frontcall_android_startactivityforresult.html Invokes the barcode scanner application to scan a barcode and retrieves the scanned value. If the scanner app is not installed, it launches the Play Store to prompt the user to install it. The returned data is parsed from a JSON string. ```fgl IMPORT util ... DEFINE data, extras STRING, json_object util.JSONObject, scanned_value STRING ... CALL ui.Interface.frontCall( "android", "startActivityForResult", [ "com.google.zxing.client.android.SCAN", NULL, "android.intent.category.DEFAULT" ], [ data, extras ]) IF extras IS NULL THEN -- If the application isn't installed invoke -- the Play Store to give the user a chance to install it CALL ui.Interface.frontCall("standard", "launchurl", ["market://details?id=com.google.zxing.client.android"], []) ELSE LET json_object = util.JSONObject.parse(extras) -- Fetch the scanned value LET scanned_value = json_object.get("SCAN_RESULT") END IF ``` -------------------------------- ### Example: os.Path.mkDir Source: https://4js.com/online_documentation/fjs-fgl-manual-html/index.html?q=%2Fonline_documentation%2Ffjs-fgl-manual-html%2Ffgl-topics%2Fc_fgl_BuiltInFunctions_FGL_GETWIN_WIDTH.html Shows how to create a new directory using the `os.Path.mkDir` method. It can create intermediate directories if they do not exist. ```fgl MAIN DEFINE dir_path STRING = "/tmp/my_new_directory/subdir" DEFINE rc INTEGER -- Create the directory, including intermediate directories if needed LET rc = os.Path.mkDir(dir_path) IF rc == 0 THEN DISPLAY "Directory created successfully: ", dir_path ELSE DISPLAY "Failed to create directory. Error: ", os.Path.describeLastError() END IF END MAIN ``` -------------------------------- ### os.Path.dirOpen and os.Path.dirNext example Source: https://4js.com/online_documentation/fjs-fgl-manual-html/index.html?q=%2Fonline_documentation%2Ffjs-fgl-manual-html%2Ffgl-topics%2Fc_fgl_dialog_AFTER_DISPLAY.html Demonstrates opening a directory for iteration using os.Path.dirOpen and reading directory entries one by one using os.Path.dirNext. ```fgl DEFINE dir_handle INTEGER DEFINE entry_name STRING DEFINE dir_path STRING LET dir_path = "/path/to/directory" LET dir_handle = os.Path.dirOpen(dir_path) IF dir_handle > 0 THEN MESSAGE CONCAT("Contents of ", dir_path, ":") LOOP LET entry_name = os.Path.dirNext(dir_handle) IF entry_name IS NULL THEN EXIT LOOP END IF MESSAGE entry_name END LOOP LET rc = os.Path.dirClose(dir_handle) ELSE MESSAGE CONCAT("Failed to open directory: ", dir_path) END IF ``` -------------------------------- ### Get Previous Sibling Example Source: https://4js.com/online_documentation/fjs-fgl-manual-html/index.html?q=%2Fonline_documentation%2Ffjs-fgl-manual-html%2Ffgl-topics%2Fc_fgl_ui_tables_aggregates.html Example of getting the previous sibling of a node. ```javascript var node = xmlDoc.getElementById("nodeId"); var prevSibling = node.getPreviousSibling(); ``` -------------------------------- ### Get Attributes Count Example Source: https://4js.com/online_documentation/fjs-fgl-manual-html/index.html?q=%2Fonline_documentation%2Ffjs-fgl-manual-html%2Ffgl-topics%2Fc_fgl_form_responsive_hidden.html Example to get the number of attributes on a node. ```javascript var doc = new xml.DomDocument(); var element = doc.createElement("element"); element.setAttribute("attr1", "val1"); console.log(element.getAttributesCount()); // Output: 1 ``` -------------------------------- ### Example 1: SqlHandle with simple SQL Source: https://4js.com/online_documentation/fjs-fgl-manual-html/fgl-topics/c_fgl_JavaBridge_examples.html Demonstrates basic usage of SqlHandle for executing a simple SQL query. ```FGL MAIN DEFINE sc AS SQLCONNECTION DEFINE sh AS base.SqlHandle DEFINE rc AS INTEGER LET sc = base.connect("demodb") IF sc.isError() THEN MESSAGE "Connection error: " || sc.getErrorText() ESCAPE RETURN END IF LET sh = base.SqlHandle.create(sc) LET rc = sh.execute("CREATE TABLE my_table (id INT, name CHAR(20))") IF rc < 0 THEN MESSAGE "Error creating table: " || sh.getErrorText() ESCAPE ELSE MESSAGE "Table created successfully." END IF LET rc = sh.execute("DROP TABLE my_table") IF rc < 0 THEN MESSAGE "Error dropping table: " || sh.getErrorText() ESCAPE ELSE MESSAGE "Table dropped successfully." END IF LET sh.close() LET sc.close() END MAIN ``` -------------------------------- ### Creating a Directory using os.Path.mkDir Source: https://4js.com/online_documentation/fjs-fgl-manual-html/index.html?q=%2Fonline_documentation%2Ffjs-fgl-manual-html%2Ffgl-topics%2Fc_fgl_Migrate_to_200_dbi_informix.html Demonstrates how to create a new directory at the specified path using os.Path.mkDir(). ```esql DEFINE new_dir_path VARCHAR(255); -- Specify the path for the new directory LET new_dir_path = "/tmp/my_new_directory"; -- Replace with a desired path -- Attempt to create the directory IF os.Path.mkDir(new_dir_path) = 0 THEN DISPLAY "Directory created successfully: ", new_dir_path; ELSE -- Check if the directory already exists or describe other errors IF os.Path.exists(new_dir_path) THEN DISPLAY "Directory already exists: ", new_dir_path; ELSE DEFINE error_msg VARCHAR(255); LET error_msg = os.Path.describeLastError(); DISPLAY "Failed to create directory. Error: ", error_msg; END IF; END IF; -- To create parent directories if they don't exist, you might need to call mkDir recursively or use a different function if available. ``` -------------------------------- ### Get Next Sibling Element Example Source: https://4js.com/online_documentation/fjs-fgl-manual-html/index.html?q=%2Fonline_documentation%2Ffjs-fgl-manual-html%2Ffgl-topics%2Fc_gws_XmlSignature_createReference.html Example of getting the next sibling that is an element. ```javascript var doc = new xml.DomDocument(); var parent = doc.createElement("parent"); doc.appendChild(parent); var sibling1 = doc.createElement("sibling1"); parent.appendChild(sibling1); var sibling2 = doc.createElement("sibling2"); parent.appendChild(sibling2); var nextSiblingElement = sibling1.getNextSiblingElement(); console.log("Next sibling element: " + nextSiblingElement.getNodeName()); ```