JSSP [examples]

Execute a jssp script
EXECJSSP

 

execJSSP("test.jssp","test.html")

test.jssp

<%@ Language=JavaScript %>

<%
	db = Lianja.openDatabase("southwind");
	rs = db.openRecordSet("select * from customers");
	print("
");
	for (i=0; i<rs.fieldcount; ++i)
	{
		print("");
	}
	print("");
	rs.moveFirst();
	for (j=0; j<rs.reccount; ++j)
	{
		print("
");
		for (i=0; i<rs.fieldcount; ++i)
		{
			print("");
		}
		print("");
		rs.moveNext();
	}
	print("
“+rs.field(i).name+”
“+rs.field(i).value+”

“);
rs.close();
db.close();
%>


https://www.lianja.com/doc/index.php/EXECJSSP()


Example JavaScript Server Page (.jssp page) demonstrating basic data navigation.

<%@ Language=JavaScript %>

<%
	// Note that just as in PHP, JavaScript Server Pages can use include_once(filename) and include(filename)
	// The path of the filename is relative to the directory containing this script.
	include_once("library_example.js");
 
	// The Lianja global object provides embedded database access
	db = Lianja.openDatabase("southwind");
	print("
");
 
	// Lianja.openDatabase() returns a Database object so now we can open a RecordSet
	rs = db.openRecordSet("select * from customers");
	print("
");
	print("Fieldcount="+rs.fieldcount);
	print("
");
%>

<%
	print("");
	for (i=0; i<rs.fieldcount; ++i)
	{
		print("");
	}
	print("");
	rs.moveFirst();
	for (j=0; j<rs.reccount; ++j)
	{
		print("
");
		for (i=0; i<rs.fieldcount; ++i)
		{
			print("");
		}
		print("");
		rs.moveNext();
	}
	rs.close();
	db.close();
%>
“+rs.field(i).name+”
“+rs.field(i).value+”

 



Advertisements
Categories JS

JavaScript [examples]

Run multiple lines of JavaScript code
EXECJAVASCRIPT
// Character field
create table if not exists scripts (script char(200))
if not used("scripts")
	use scripts
endif
select scripts
append blank
replace script with 'for (var i=0; i<11; i++)' + CHR(13) + '{';
 + CHR(13) + '// process commands;' + CHR(13) + '}' + CHR(13)
execjavascript(script)
 
// Text constant
execjavascript('for (var i=0; i<11; i++)' + CHR(13) + '{';
 + CHR(13) + '// process commands;' + CHR(13) + '}' + CHR(13))
 
// Memory variable
m_script = 'for (var i=0; i<11; i++)' + CHR(13) + '{';
 + CHR(13) + '// process commands;' + CHR(13) + '}' + CHR(13)
execjavascript(m_script)

https://www.lianja.com/doc/index.php/EXECJAVASCRIPT()


JS:

To open a Lianja database from JavaScript you use the global Lianja function openDatabase().

db = Lianja.openDatabase("southwind");

https://www.lianja.com/doc/index.php/Working_with_data_in_JavaScript


JS:

After we have opened a recordset we can navigate through the data using any of the recordset data navigation methods of the Recordset class.

reference to an existing cursor in desktop, web or mobile apps. This is typically how you would inspect the Active record and it’s fields.

var orders = Lianja.getCursor("orders");
var name = orders.getData("name");
var unitcost = orders.getData("unitcost");
var quantity = orders.getData("quantity");
orders.setData("total", unitcode * quantity);
orders.update( 
    function() {    
        // onsuccess
        Lianja.showSuccessMessage("Record was updated");
        Lianja.showDocument("page:orders?action=refresh");
    },
    function() {
       // onerror
       Lianja.showErrorMessage("Record could not be updated", "Update failed");
    }
);

Create a Recordset

You can then access a table in the database using the openRecordSet() method of the Database class using SQL or noSQL. For example we can access the customers table using SQL like this:

rs = db.openRecordSet("select * from customers");

Or alternatively just open the customers table with noSQL like this:

rs = db.openRecordSet("customers");

Recordset data navigation

For example to position on the first record in a recordset use the moveFirst() method.

rs.moveFirst();

Extract data from the Recordset

When you are positioned on a particular record in a recordset you can extract data using the fields() method.

for (i=0; i‹rs.fields.count; ++i)
{
    name = rs.fields(i).name;
    value = rs.fields(i).value;
}

The fields() method can also take the field name as an argument as well as the column ordinal position.

value = rs.fields("amount").value;

Filtering selected data

When you open a recordset with an SQL select statement, the data selected is only that which matches the where condition of the select statement. If you open a table with noSQL e.g.

rs = db.openRecordSet("customers");

You can filter the records that are returned using the data restriction methods.

NoSQL keyed data access

When opening a table in noSQL mode, you can lookup records by keys.

rs = db.openRecordSet("customers"); 
rs.index = "id"; 
rs.seek("12345"); 
if (!rs.found()) 
{  
    // key was not found. 
}

Adding new records

You can add new blank records to a recordset using the addNew() method.

rs.addNew();

Note that after executing addNew() the record is not written until the update() method is called. This allows you to update the fields of the blank record prior to it being committed into the table.

Updating records

You can update records in a recordset using the update() method.

rs = db.openRecordSet("customers"); 
rs.index = "id"; 
rs.seek("12345"); 
if (rs.found()) 
{  
    rs.fields("amount").value = rs.fields("amount").value + 1000;  
    rs.update(); 
}

Deleting records

You can delete records in a recordset using the delete() method.

rs = db.openRecordSet("customers"); 
rs.index = "id"; 
rs.seek("12345"); 
if (! rs.noMatch()) 
{
    rs.delete(); 
}

Closing a Recordset

You close a recordset using the close() method.

rs.close();

https://www.lianja.com/doc/index.php/Working_with_data_in_JavaScript


 

Categories JS

Exports.conf [examples]

The exports.conf file enables a simplified approach for calling server-side business procedures directly from the JavaScript client.

This is accomplished by defining the libraries, functions and scripting language for the functions in the exports.conf file which can reside in the app and/or the library directory.

Example exports.conf file:

# This is an example exports.conf file
#
# Each line describes a function that will be available directly from JavaScript
# code in the client
#
# library, function, type
# (source library, name of the function, type: vfp or javascript)
# (php and python will be added later)
#
# or
#
# library, function 
# (implied type of vfp)
#
# or
#
# function 
# (file expected to exist with a .dbo extension)
#
mylib,myfunc1,vfp
myjslib,myfunc2,javascript
myfunc3

In the Lianja JavaScript Web/Mobile App the server-side functions can be called directly:

// Note that arguments are automatically converted into the correct format for the 
// remote function call and the function call is proxied
// using a synchronous  Lianja.evaluate() call
var result = myfunc1("hello world", 2015, true);
var result2 = myfunc2();

// When calling remote functions with objects as parameters the object is automatically 
// converted to JSON and sent base64 encoded
// This allows you to send and receive complete JSON encoded objects between the 
// client and the server
var result3 = myfunc3( {"name":"barry", "company":"Lianja" });

https://www.lianja.com/doc/index.php/Exports.conf


A function can be called directly if it is declared in exports.conf.

var result = myfunc();

 https://www.lianja.com/doc/index.php/Category:Lianja_Cloud_Server


 

Categories JS

JS

Q:

I created a file called javascriptfuntions.js.

In that file, I copied the example from the road map.

Code:
function page1_myDialog()
    var cont = createObject("myContainer", "container");
    cont.backcolor = "white";
    cont.addObject("myTextBox", "textbox");
return cont;

In the console – I tried to loadlibrary(‘javascriptfunctions.js’) – but it threw a parse error.

So I added the curly brackets around the javascript function as you would normally do, but still no luck.

A:

Yes, it should have the curly brackets – I have corrected the example in the roadmap.

Using a JavaScript generated container in a Lianja.showDialog() or Lianja.showDialogPanel() is supported in the web client. Your post title mentions VFP



Q:

add a blank grid section to an application.

In a JavaScript application, I am trying to add a blank grid and then populate it later from an array using additems().

A:

Here’s what I did in on app:

1) created a table with the required fields and also had a cSession field of C(26).
2) in the UI, I added a property to a public var oApp of cSessionID
3) this property was, on the INIT of the UI app, set to guid() (this was in VFP, but should work here)
4) I then set a filter on the grid of: cSessionID = oapp.cSessionID — which meant the grid was showing empty
5) Then I could “create” records from anywhere, making certain to use oapp.cSessionID as the cSessionID of the table.

The same could be done with a VT and a parameter for cSessionID of course.

In the close of the database (assuming you don’t close it in the UI), you can delete for cSessionID = oapp.cSessionID.


all objects in a JavaScript canvas must be named uniquely, throughout the application. Thus, from any page you are on, the lbltext object will be available.

This is due to the global nature JavaScript: either a var is scoped within the function, or is global everywhere.


Q:

For an RSP page – I can use the following code

HTML Code:
private m_embedded = getParameter("embedded", "false")
private m_libpath
set macros on
set fixed on 
if isServer()
	m_libpath = "../../library/"
else
	m_libpath = "lib:/"
endif
if m_embedded = "false"
	? '<html>'
	? '<head>'
	? '<link rel="stylesheet" href="&m_libpath/bootstrap-3.3.4/css/bootstrap.min.css">'
	? 'http://&m_libpath/jquery-1.10.2/jquery-1.10.2.min.js'
	? 'http://&m_libpath/bootstrap-3.3.4/js/bootstrap.min.js'
	? '</head>'
	
endif
%>

How do I accomplish the same thing for a .JSSP?

A:

Instead of using ? <expr> to output text you use print(<expr>) pr(<expr>) or echo(<expr>) in JavaScript.

The following associative arrays are available to you in JavaScript on each page request.

$_REQUEST
$_SERVER
$_COOKIE
$_ARGS
$_GET
$_POST
$_FILES
$_SESSION

So for example you can reference $_ARGS[“embedded”]

As per your requirements I have added:

Lianja.getUrl( “url…” ) to Lianja 3.4.1 which returns a string which is returned from the remote server.

This is available in desktop and web framework.

Note that you can also use this on the client.

Lianja.OData_Read(url, callback);

e.g.

Lianja.OData_Read(“http://xxxx…&#8221;, function(result)
{
});

This function returns JSON and can handle any URL.

You can use Lianja.evaluate( “vfp_expression” ) to evaluate any function not available in jssp pages.


Q:

I tried adding a “hello word” into a commandbutton.click delegate, but it keeps returning a “unterminated string” error”
Name:  untermstr.jpg Views: 28 Size:  62.8 KB

A:

You are writing JavaScript in a .prg library file.

You should write JavaScript in a .js library file.


Lianja provides many built-in Javascript functions. In terms of using Javascript libraries the CommonJS module standard is handled in desktop, web and mobile.

The CommonJS group defined a module format to solve JavaScript scope issues by making sure each module is executed in its own namespace.
This is achieved by forcing modules to explicitly export those variables it wants to expose to the “universe”, and also by defining those other modules required to properly work.

To achieve this CommonJS gives you two tools:

  1. the require() function, which allows to import a given module into the current scope.
  2. the module object, which allows you to export something from the current scope.


Further details of the Lianja/VFP functions available in JavaScript/TypeScript can be found at:
https://www.lianja.com/doc/index.php…/VFP_functions

The documentation on JavaScript Server Pages (.jssp) includes an example for require() with module.exports.
https://www.lianja.com/doc/index.php…t_Server_Pages


 

Categories JS

JS

Q:
I assume the server-side javascript file is ‘.js’ but how do I create a js file from the app builder? no matter where I click in the ‘Files’ section and choose ‘new file’, I always get a .prg file. I ended up creating the js file manually in the file system and then had to close + open the app to see the file under ‘JavaScript Files’ (clicking ‘refresh’ didn’t work).
A:
When entering the filename postfix .js


Q:
Once I had the js file & named it properly I could call my function just fine using evaluateJavaScript but what makes this js server-side as it is just another js file in the same folder as my click-handler js file?
Does evaluateJavaScript need the cloud server to work?
A:
This is for web/mobile apps so look at web app view and test in there using the JavaScript console if need be to test call your server-side functions, you don’t use this functionality in a desktop app and that us not a client/server web or mobile app, it’s all running in one exe.


Q:
Is there any way to debug server-side js files
A:
Test from the JavaScript console. No there is no remote debugger.


Q:
to import an external JS library into lianja
A:

Code:
var mylib = require("some_filename.js");
var mylib = require_once("some_filename.js");
include("some_filename.js");
include_once("some_filename.js");

require() and require_once() return the module.exports object for consistency. require_once() keeps an internal cache and knows if the library has been loaded already so its module.exports object is used rather than loading the library again. The same goes for include_once().
Also remember that filenames can be prefixed with app:/ or lib:/ which is expanded for you to the full filename path.


Q:
I understand the concept of calling a server script from the client and I can see that evaluateJavacsript will allow js code on both sides to work just fine.
What I don’t understand is which files are sent to the client and which stay on the server because both are defined in app builder in exactly the same way so there is nothing so say which is a ‘server’ file and which is a ‘client’ file.
A:
In development mode all JavaScript is referenced in the app or library directories as the “server” is embedded in the app builder.

When you switch to web app view and then “preview” your server side JavaScript is called using a RPC to the cloud server.

You can use Lianja.evaluateJavaScript() or setup the exports.conf file to handle the mapping from client to server function calls.
When using data binding you don’t need to perform any CRUD operations programmatically as it is done for you.
The only time I would perform evaluate() or evaluateJavaScript() RPCs is for validation or custom actions that require specialized CRUD code to be run on the server.

When binding URLs to webviews you can use {…} macros which are substituted as a Webview is refreshed.
The data binding hides a lot of the complexity of client/server operations.


Q:
In a js delegate this code gives the error “TypeError: undefined is not a constructor (evaluating ‘poSection.add()’) ”
Digging around in the web debug I can see that poSection appears to be a valid section object and I can see a few other properties but most fail eg ‘.count’

Code:
var poSection = Lianja.get("New_Purchase_Order.section1");
poSection.add();

A:
A best practice is to use Lianja.showDocument() which abstracts above all of this coding.


Q:
this line of code:
lianja.execute(‘lianja.get(“sup_Search.sectionPara meter.Valore”).text = “‘ + “Test” + ‘”‘);
type on command line, work fine
in a javascript script inside a rsp page no…
A:
Lianja.execute() runs a command on the server.

Lianja.get() is a client side API call.

You are executing Lianja.execute() on the client inside a script tag. The command it executes runs on the server. How can it access the client?
Work! the only problem?
Javascript is case sensitive… 🙂


Q:
Looking at the apps settings in v2.1Beta12, I noticed some options I don’t recall seeing.
HTML editor – has an option for Desktop, web or Mobile.
There is also another setting option called include in HTML Head.

So that got me thinking…..

Is there a combination that I could use to embed Jquery in a custom javascript section?
A:
A custom JavaScript section is created dynamically and has no meaningful HTML content.
To use jquery you would just need a WebView section.


Lianja v3.0 now includes a GUI JavaScript debugger.

This will be triggered when an error occurs in any of your JavaScript delegates, when you choose “Debug…” from the “Program” menu (or ModeBar button) and choose a JavaScript file, or when a debug() function call is encountered in any JavaScript code. Note that debug() is a noop in the Web/Mobile clients.


Q:
In a jssp page, I have created a simple navigation section.
All I am looking to do is step through a table.
I am missing something though.

I can MoveFirst(), MoveLast() without an issue.

MoveNext(), MovePrior(), MoveRelative() all seem to start from the first record each time they are clicked.

How do I keep the record pointer from resetting itself.

Below is my very simple jssp page. I am purposely mixing the Lianja and javascript code so I can understand how they interact.

Code:
<%@ Language=JavaScript %>
<html>
<head>




var moveLast = function(){

};


var moveFirst = function(){

};


var moveNext = function(){

};


var movePrevious = function(){

};

var moveRelative= function(){

};


window.onload = function(){
document.getElementById("btnMoveLast").onclick = moveLast;
document.getElementById("btnMoveFirst").onclick = moveFirst;
document.getElementById("btnMoveNext").onclick = moveNext;
document.getElementById("btnMovePrevious").onclick = movePrevious;
document.getElementById("btnMoveRelative").onclick = moveRelative;

};





</head>

<body>

<%

print('<label for ="firstname" >First Name</label>')
print('<input type = "text" id = "firstname" >')
print('<br>')
print('<label for ="lastname" >Last Name</label>')
print('<input type = "text" id = "lastname">')
print('<br>')
print('<label for ="recno" >Recno </label>')
print('<input type = "text" id = "recno">')
print('<br>')
%>
<input type ="button" id = "btnMoveFirst" value ="First">
<input type ="button" id = "btnMoveLast" value ="Last">
<input type ="button" id = "btnMoveNext" value ="Next">
<input type ="button" id = "btnMovePrevious" value ="Previous">
<input type ="button" id = "btnMoveRelative" value ="Relative 5">


</body>



</html>

How do I create a JavaScript function that can step through a table and populate my html <input> tags.
A:
Everything between <% and %> is processed and executed on the server as the html is being generated and sent to the WebView.

so the html you are generating does not look correct to me.
You build it as an App with one WebView that has the LianjaWebFramework in it and you can use Lianja.getCursor() etc to navigate the data.


Q:
I Have created a simple JavaScript function that I am using to populate a ShowDialog window.
I am having an issue trying to get a click event working properly.

I have tried both an anonymous function on a named function, but no luck.

Below is the code with the named function.

What seems to occur is that click events is triggered when dialog function is called, but then does not respond when I click the button.

Code:
function myDialog(){

var buttontest = function(){
myTextBox.text = "test";
}


var cont = createObject("myContainer", "container");
cont.backcolor = "silver";
cont.autosize = 1;
cont.layout = "horizontal";
cont.addObject("myTextBox", "textbox"); 

cont.addObject("myButton", "commandbutton");
myButton.text = "Update";
myButton.click = buttontest();


return cont;
};

Is there a different way I should be calling the click event on the button?
A:
you should be assigning buttontest not buttontest()

buttontest is the address of the function whereas buttontest() executes it and assigns the return value which in your case is undefined.
names of the objects need to be lowercase not mixed case.


There are times when you may need to use a percentage sign in your app.

In my case, I am filtering a grid using the like statement against SQL Server.
since the % sign is a mod function in javascript, you need to escape it out using %25.
So in my case, I concatenate the value to my textbox value.

Code:
function page1_section1_field2_click()
{
var m_filter1 = txtfilter.value;
var m_filter = '%25'+m_filter1+'%25';

Lianja.get("page1.Al_SQLServers").filter ="computername like '"+m_filter+"'";
Lianja.get("page1.Al_SQLServers").refresh();

};

Q:
I noticed you switched from VFP to JSCRIPT, any particular reason why?
A:
I chose JavaScript since I want the app to be able to run in a web browser.
Since I used txt1.value and txt2.value as parameters to the call, I wanted to make sure the browser would understand those values.


VFP and JS, side-by-side
http://www.lianja.com/community/show…ll=1#post14016


If you want to test some web code snippets on the fly look at https://jsfiddle.net/
CSS
HTML
JS (w/ jQuery)

Although you have not LOM in this case, it can help to learn JavaScript, CSS and HTML syntax.



 

Categories JS

JS

Q:
Say I have a .prg file set as:

Code:
proc A()
...
endproc

proc B()
...
endproc

proc C()
...
endproc

...

In VFP, if it’s not a library file, I can use something similar to:

Code:
set procedure to some_prgfile
C()
release procedure

How do I call a specific VFP procedure from a .prg file from javascript, such as C()?

I know that if I have a file named code.prg, I can use Code:

Code:
Lianja.execute("do code.prg");

This seems to only work if ‘proc’ is not declared and is to execute all code in the file (registration web app has an example of this).

A:
You could do this:

Code:
//some_prgfile.prg
proc A()
return 'retval from a'
endproc

proc B()
return 'retval from b'
endproc

proc C()
return 'retval from c'
endproc

parameters funcname
return &funcname()
//end

Then in JS:

Code:
var retval = Lianja.evaluate('some_prgfile("c")');

passing further parameters if required by the individual functions.
Here, some_prgfile is the .prg function library, compiled and deployed as some_prgfile.dbo to the Lianja Cloud Server. You pass in the name of the function (here c), which is picked up by the PARAMETERS statement in the function library and the function is called. If the function itself requires parameters, then you pass them in too. PCOUNT() will tell you how many parameters have been passed.
It needs to be in C:\Lianja\cloudserver\tenants\public\wwwroot\apps\ for the Web Client – is it there too?

You should be able to enter your equivalent of

Code:
Lianja.evaluate('some_prgfile("c")')

in the browser console and see what it comes back with.

I would put a check in to test whether the code is running on the desktop or live in the Web Client and just use the {} macro in the Web Client.

This is being called from a commandbutton click. I’m passing the txtsearch.text directly. The [] can be used as string delimiters ‘in dev’ as this is handled by the local Lianja/VFP scripting.

Code:
////////////////////////////////////////////////////////////////
// Event delegate for 'click' event
function page1_section1_field2_click()
{
        if (typeof LianjaAppBuilder === 'object')
        // in dev
        {
        var result = Lianja.evaluate('lib_webtest("get_brnum(['+txtsearch.text+'])")');
        }
        else
        // in live web/cloud
        {
        var result = Lianja.evaluate('lib_webtest("get_brnum(\'{txtsearch.text}\')")');
        }

        Lianja.writeLog(result);
};

In my original post about passing parameters into the library prg, when I mentioned PCOUNT(), I envisaged passing the parameters in individually to the library, rather than including them as a single parameter.

For example, if this is my procedure library, lib_webtest.prg:

Code:
proc get_brnum
parameters ptext
return ptext + " was passed"
endproc

parameters funcname, para1
do case
        case pcount() = 1
                return &funcname()
        case pcount() = 2
                return &funcname(para1)
endcase

I can pass 2 parameters to lib_webtest and it will treat the 2nd as a parameter to the function name in the 1st. Additional parameters can be added and handled with further PCOUNT() cases.

So my button click code becomes:

Code:
////////////////////////////////////////////////////////////////
// Event delegate for 'click' event
function page1_section1_field1_click()
{
        if (typeof LianjaAppBuilder === 'object')
        {
        var result = Lianja.evaluate('lib_webtest("get_brnum","' + txtsearch.text + '")');
        }
        else
        {
        var result = Lianja.evaluate('lib_webtest("get_brnum","{txtsearch.text}")');
        }

        Lianja.writeLog(result);
};

and is probably more readable.



Categories JS

JS

Q:
How would I do the following in Javascript?

Code:
oGrid = Lianja.get("page1.section2").grid
nActiveRow = oGrid.ActiveRow
nCommNum = oGrid.item(oGrid.ActiveRow,3)

if we need to get the value for a particular column on the current row, how might we do that?
My grid is bound to a virtual table.
Say VT name is QWERTY, active row is 5 and column data is in column 8.
A:
Web Client grid does not yet support the accessing of individual cells of the grid like that. furthmore it always uses pagination by design to provide acceptable performance on web and mobile devices.
The grid columns are data bound. Selecting a row makes that record active in the cursor. So you reference the columns from the cursor.

Code:
var orders = Lianja.getCursor("orders");
var customerid = orders.getData("customerid");

Double clicking a row in the web client will edit the row.
Clicking a grid row will select it. The record is made current in the cursor. The related sections are then refreshed.
You can click on a row and use the JavaScript console to access the cursor as I previously described to satisfy yourself.


JavaScript console in the browser. You can inspect the client environment


Q:
If I want to not worry with web compability it is much better to develop everything in Javascript. Is this also applicable to the development for mobile devices?
A:
Python, PHP and JavaScript are case sensitive. Lianja/VFP is case insensitive, so Lianja.showDocument() is what you need to use.
Web and Mobile use JavaScript on the client (delegates) but the client side code can call server side code written in Lianja/VFP or JavaScript. We will be adding PHP and Python into the cloud server in a point release after v2.0 is released.


Lianja framework includes most of the VFP built in functions in JavaScript and also that the LOM (Lianja Object Model) is available in desktop, web and mobile apps in all of the supported scripting languages.
The visual nature of Lianja development does not require extensive JavaScript coding so let’s not make it look like it does.
Apps are built out of pages and pages are built out of sections, all visually setting attributes to affect the appearance and behavior of the UI.
The only place you really need to do any JavaScript programming is if you need to handle special actions through delegates that act as a proxy to call server side Lianja/VFP procedures. This too was simplified in v2.0 with automatic proxying to server side business procedures.


Any server side business logic procedures can be used in validation expressions, used in {…} macros, called using Lianja.evaluate() or setup as remote procedure calls
Building Web and/or mobile Apps requires a separation between the UI presentation and the server side business logic.


JavaScript variables are scoped just like local in VFP.

if in a JavaScript function you type

Code:
var var1;

then its its local to that function.

It is good practice to place your own global variables in a global object called public. This prevents any references to the wrong variable from being made. It also simplifies debugging as you can just type public in the JavaScript console which will display the public object and all its members.

Code:
public = {};
public.var1 = "hello world";
public.var2 = 12345;

Q:
When I click any menu item, the console reports the following error:
**** Lianja JavaScript error ****
Traceback (most recent call last):
() at 1ReferenceError: Can’t find variable: Client_MainHeader_customsectionmenu

Here is the code in the function:

Code:
function client_mainheader_customsectionmenu(cItem)
{
        cItem = ALLTRIM(UPPER(cItem));
        messagebox("Menu item is: " + cItem);
};

Here are the errors being reported:
Traceback (most recent call last):
client_mainheader_customsectionmenu(cItem = ‘Reset’) at 3
() at 1
ReferenceError: Can’t find variable: ALLTRIM

**** Lianja JavaScript error ****
Traceback (most recent call last):
client_mainheader_customsectionmenu(cItem = ‘Reset’) at 3
() at 1ReferenceError: Can’t find variable: UPPER

A:
Most likely would be the ‘}’ missing from the end of a function or a line that needs to be terminated missing the ;.
Lianja functions need to be in lowercase in order to work properly.
JavaScript is a case sensitive scripting language whereas Lianja/VFP is case insensitive so you need to use the exact function name as it is documented.


Q:
I am trying to check if a section is visible or not and the boolean comparison seems to be the issue.

Code:
if Lianja.get("client.secSearch").visible == false

How should boolean values be fully written for comparison?
I have tried various ways including: = .F., == false, === false
A:
Try this:

Code:
if (Lianja.get("client.secSearch").visible == 0)


Categories JS