Servoy Properties Summary | |
---|---|
String | encoding |
String | quote |
Servoy Properties Details |
---|
encoding
String encoding
Get/Set the encodingReturns
String encoding String
Supported Clients
SmartClient, WebClient, NGClient
quote
String quote
Get/Set the Quote characterReturns
String quote String
Supported Clients
SmartClient, WebClient, NGClient
Servoy Methods Details |
---|
getArray
Array<Array<Object>> getArray( String )
Read a TXT file and return a 2D Array. The showHeader parameter defaults to true.Parameters
String filePath the file path
Returns
Array<Array<Object>> array Object[][]
Supported Clients
SmartClient, WebClient, NGClient
Sample
// set the name of the file
var file = plugins.file.showFileOpenDialog();
// check that we really selected a file
// if not ignore the rest of the code
if (file) {
var filePath = file.getAbsoluteFile();
var set = null;
var array = null;
// with the showHeader parameter set to true the first row will will show in the result
// create a dataset from the file
// the showHeader parameter is set to false by default
// REMARK: a header will always be constructed from the first row
set = plugins.it2be_data.txt().getDataSet(filePath);
// create a two dimensional array from the file
// the showHeader parameter is set to true by default
array = plugins.it2be_data.txt().getArray(filePath, true);
// when the dataset is NOT empty
if (set.getMaxRowIndex()) {
var message = "";
application.output("set.getMaxRowIndex() = " + set.getMaxRowIndex());
// because the set is a 'standard' JSDataSet all the functions and properties
// we can use the Database Manager to retrieve the column count and column names
var columncount = set.getMaxColumnIndex();
// limit the number of columns we show to 5 when columncount > 5
// 5 is an arbitrary value to limit the width of the dialog
columncount = (columncount > 5) ? 5 : columncount;
// loop through the columns
for (var i = 1 ; i <= columncount ; i++) {
// retreive the names
message += set.getColumnName(i) + "::";
}
message += "\n";
// JSDataSet.sort(number, boolean) is also valid
set.sort(1, false);
var rowcount = (set.getMaxRowIndex() > 5) ? 5 : set.getMaxRowIndex();
// loop through the rows of the JSDataSet
// REMARK: the JSDataSet starts counting at 1 instead of 0
for (var i = 1 ; i <= rowcount ; i++) {
// loop through the columns
for (var ii = 1 ; ii <= columncount ; ii++) {
// and retreive the column values
message += set.getValue(i, ii) + "::";
}
message += "\n";
}
// show the result
if (message) {
plugins.dialogs.showInfoDialog("JSDataSet", message);
}
} else {
// output to the debugger to show there is NO result
application.output("JSDataSet = null");
}
if (array) {
var message = "";
application.output("array.length = " + array.length);
// because the showHeader parameter is set to false with a (two dimensional) array
// the first row will NOT show in the array
// limit the column and row count again for display purposes
var columncount = (array[0].length > 5) ? 5 : array[0].length;
var rowcount = (array.length > 5) ? 5 : array.length;
// loop through the 3D array
// REMARK: an array starts at index 0
for (var i = 0 ; i < rowcount ; i++) {
for (var ii = 0 ; ii < columncount ; ii++) {
message += array[i][ii] + "::";
}
message += "\n";
}
// show the result
if (message) {
plugins.dialogs.showInfoDialog("Array", message);
}
} else {
// output to the debugger to show there is NO result
application.output("Array = null");
}
}
getArray
Array<Array<Object>> getArray( String, Boolean )
Read a TXT file and return a 2D Array. The showHeader parameter defaults to true.Parameters
String filePath the file path
Boolean showHeader the show header
Returns
Array<Array<Object>> array Object[][]
Supported Clients
SmartClient, WebClient, NGClient
Sample
// set the name of the file
var file = plugins.file.showFileOpenDialog();
// check that we really selected a file
// if not ignore the rest of the code
if (file) {
var filePath = file.getAbsoluteFile();
var set = null;
var array = null;
// with the showHeader parameter set to true the first row will will show in the result
// create a dataset from the file
// the showHeader parameter is set to false by default
// REMARK: a header will always be constructed from the first row
set = plugins.it2be_data.txt().getDataSet(filePath);
// create a two dimensional array from the file
// the showHeader parameter is set to true by default
array = plugins.it2be_data.txt().getArray(filePath, true);
// when the dataset is NOT empty
if (set.getMaxRowIndex()) {
var message = "";
application.output("set.getMaxRowIndex() = " + set.getMaxRowIndex());
// because the set is a 'standard' JSDataSet all the functions and properties
// we can use the Database Manager to retrieve the column count and column names
var columncount = set.getMaxColumnIndex();
// limit the number of columns we show to 5 when columncount > 5
// 5 is an arbitrary value to limit the width of the dialog
columncount = (columncount > 5) ? 5 : columncount;
// loop through the columns
for (var i = 1 ; i <= columncount ; i++) {
// retreive the names
message += set.getColumnName(i) + "::";
}
message += "\n";
// JSDataSet.sort(number, boolean) is also valid
set.sort(1, false);
var rowcount = (set.getMaxRowIndex() > 5) ? 5 : set.getMaxRowIndex();
// loop through the rows of the JSDataSet
// REMARK: the JSDataSet starts counting at 1 instead of 0
for (var i = 1 ; i <= rowcount ; i++) {
// loop through the columns
for (var ii = 1 ; ii <= columncount ; ii++) {
// and retreive the column values
message += set.getValue(i, ii) + "::";
}
message += "\n";
}
// show the result
if (message) {
plugins.dialogs.showInfoDialog("JSDataSet", message);
}
} else {
// output to the debugger to show there is NO result
application.output("JSDataSet = null");
}
if (array) {
var message = "";
application.output("array.length = " + array.length);
// because the showHeader parameter is set to false with a (two dimensional) array
// the first row will NOT show in the array
// limit the column and row count again for display purposes
var columncount = (array[0].length > 5) ? 5 : array[0].length;
var rowcount = (array.length > 5) ? 5 : array.length;
// loop through the 3D array
// REMARK: an array starts at index 0
for (var i = 0 ; i < rowcount ; i++) {
for (var ii = 0 ; ii < columncount ; ii++) {
message += array[i][ii] + "::";
}
message += "\n";
}
// show the result
if (message) {
plugins.dialogs.showInfoDialog("Array", message);
}
} else {
// output to the debugger to show there is NO result
application.output("Array = null");
}
}
getDataSet
JSDataSet getDataSet( String, Boolean )
Read a TXT file and return a JSDataSet. The showHeader parameter defaults to false.Parameters
String filePath the file path
Boolean showHeader the show header
Returns
JSDataSet set JSDataSet
Supported Clients
SmartClient, WebClient, NGClient
Sample
// set the name of the file
var file = plugins.file.showFileOpenDialog();
// check that we really selected a file
// if not ignore the rest of the code
if (file) {
var filePath = file.getAbsoluteFile();
var set = null;
var array = null;
// with the showHeader parameter set to true the first row will will show in the result
// create a dataset from the file
// the showHeader parameter is set to false by default
// REMARK: a header will always be constructed from the first row
set = plugins.it2be_data.txt().getDataSet(filePath);
// create a two dimensional array from the file
// the showHeader parameter is set to true by default
array = plugins.it2be_data.txt().getArray(filePath, true);
// when the dataset is NOT empty
if (set.getMaxRowIndex()) {
var message = "";
application.output("set.getMaxRowIndex() = " + set.getMaxRowIndex());
// because the set is a 'standard' JSDataSet all the functions and properties
// we can use the Database Manager to retrieve the column count and column names
var columncount = set.getMaxColumnIndex();
// limit the number of columns we show to 5 when columncount > 5
// 5 is an arbitrary value to limit the width of the dialog
columncount = (columncount > 5) ? 5 : columncount;
// loop through the columns
for (var i = 1 ; i <= columncount ; i++) {
// retreive the names
message += set.getColumnName(i) + "::";
}
message += "\n";
// JSDataSet.sort(number, boolean) is also valid
set.sort(1, false);
var rowcount = (set.getMaxRowIndex() > 5) ? 5 : set.getMaxRowIndex();
// loop through the rows of the JSDataSet
// REMARK: the JSDataSet starts counting at 1 instead of 0
for (var i = 1 ; i <= rowcount ; i++) {
// loop through the columns
for (var ii = 1 ; ii <= columncount ; ii++) {
// and retreive the column values
message += set.getValue(i, ii) + "::";
}
message += "\n";
}
// show the result
if (message) {
plugins.dialogs.showInfoDialog("JSDataSet", message);
}
} else {
// output to the debugger to show there is NO result
application.output("JSDataSet = null");
}
if (array) {
var message = "";
application.output("array.length = " + array.length);
// because the showHeader parameter is set to false with a (two dimensional) array
// the first row will NOT show in the array
// limit the column and row count again for display purposes
var columncount = (array[0].length > 5) ? 5 : array[0].length;
var rowcount = (array.length > 5) ? 5 : array.length;
// loop through the 3D array
// REMARK: an array starts at index 0
for (var i = 0 ; i < rowcount ; i++) {
for (var ii = 0 ; ii < columncount ; ii++) {
message += array[i][ii] + "::";
}
message += "\n";
}
// show the result
if (message) {
plugins.dialogs.showInfoDialog("Array", message);
}
} else {
// output to the debugger to show there is NO result
application.output("Array = null");
}
}
getDataSet
JSDataSet getDataSet( String )
Read a TXT file and return a JSDataSet. The showHeader parameter defaults to false.Parameters
String filePath the file path
Returns
JSDataSet set JSDataSet
Supported Clients
SmartClient, WebClient, NGClient
Sample
// set the name of the file
var file = plugins.file.showFileOpenDialog();
// check that we really selected a file
// if not ignore the rest of the code
if (file) {
var filePath = file.getAbsoluteFile();
var set = null;
var array = null;
// with the showHeader parameter set to true the first row will will show in the result
// create a dataset from the file
// the showHeader parameter is set to false by default
// REMARK: a header will always be constructed from the first row
set = plugins.it2be_data.txt().getDataSet(filePath);
// create a two dimensional array from the file
// the showHeader parameter is set to true by default
array = plugins.it2be_data.txt().getArray(filePath, true);
// when the dataset is NOT empty
if (set.getMaxRowIndex()) {
var message = "";
application.output("set.getMaxRowIndex() = " + set.getMaxRowIndex());
// because the set is a 'standard' JSDataSet all the functions and properties
// we can use the Database Manager to retrieve the column count and column names
var columncount = set.getMaxColumnIndex();
// limit the number of columns we show to 5 when columncount > 5
// 5 is an arbitrary value to limit the width of the dialog
columncount = (columncount > 5) ? 5 : columncount;
// loop through the columns
for (var i = 1 ; i <= columncount ; i++) {
// retreive the names
message += set.getColumnName(i) + "::";
}
message += "\n";
// JSDataSet.sort(number, boolean) is also valid
set.sort(1, false);
var rowcount = (set.getMaxRowIndex() > 5) ? 5 : set.getMaxRowIndex();
// loop through the rows of the JSDataSet
// REMARK: the JSDataSet starts counting at 1 instead of 0
for (var i = 1 ; i <= rowcount ; i++) {
// loop through the columns
for (var ii = 1 ; ii <= columncount ; ii++) {
// and retreive the column values
message += set.getValue(i, ii) + "::";
}
message += "\n";
}
// show the result
if (message) {
plugins.dialogs.showInfoDialog("JSDataSet", message);
}
} else {
// output to the debugger to show there is NO result
application.output("JSDataSet = null");
}
if (array) {
var message = "";
application.output("array.length = " + array.length);
// because the showHeader parameter is set to false with a (two dimensional) array
// the first row will NOT show in the array
// limit the column and row count again for display purposes
var columncount = (array[0].length > 5) ? 5 : array[0].length;
var rowcount = (array.length > 5) ? 5 : array.length;
// loop through the 3D array
// REMARK: an array starts at index 0
for (var i = 0 ; i < rowcount ; i++) {
for (var ii = 0 ; ii < columncount ; ii++) {
message += array[i][ii] + "::";
}
message += "\n";
}
// show the result
if (message) {
plugins.dialogs.showInfoDialog("Array", message);
}
} else {
// output to the debugger to show there is NO result
application.output("Array = null");
}
}
write
String write( String, Object )
Write a TXT (tab delimited) fileParameters
String filePath the file path
Object set the dataset
Returns
String fileName String
Supported Clients
SmartClient, WebClient, NGClient
Sample
// Get a dataset based on a query on the example (crm) database
// and it2be_companies/contacts tables
var query = "SELECT c.firstname, c.lastname, o.company_name, o.description FROM it2be_contacts AS c, it2be_companies AS o WHERE c.it2be_companiesid=o.it2be_companiesid";
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 1000);
// stop executing this method when the dataset is empty
// and show an error dialog
if (!dataset.getMaxRowIndex()) {
plugins.dialogs.showErrorDialog("Error.", "There are no records!", "OK");
Return;
}
// set the name of the file
var file = plugins.file.showFileSaveDialog();
// get the name of the operating system to know how to execute the,
// to the filetype attached,application
var osname = application.getOSName();
// check that we really selected a file
// if not ignore the rest of the code
if (file) {
var filePath = file.getAbsoluteFile();
// create the header as a 2 dimentional array
// it is also possible to create a 3 dimensional array (see example dbf)
// in that case the rest of the data is ignored when not creating a dbf file
var header = ["firstname","lastname","company","description"];
// we can use either a 2D array or a dataset for input
// you would typically use a 2D array from data you can not retreive from the database
// in the below example we will create a 2D array from a dataset
// just to show you how to do it
var selection = new Array();
var emptyRow = ["",""]
var counter = 0;
for (var i = 1 ; i <= dataset.getMaxRowIndex() ; i++) {
var row = dataset.getRowAsArray(i);
selection[counter++] = row; // add the row to the selection array and increment the counter
selection[counter++] = emptyRow; // add the empty row to the selection array and increment the counter
}
filePath = plugins.it2be_data.txt().writeArray(filePath, header, selection);
// open the data in the (to the filetype attached) application
// checking the os needs to be done via evaluation of a string
// you can also use the tools plugin that will give you an integer
if (osname.indexOf("Mac") > -1) {
// mac os x
application.executeProgram("open", filePath);
} else if (osname.indexOf("Windows") > -1) {
// windows
application.executeProgram("rundll32", "url.dll,FileProtocolHandler", filePath);
} else {
// linux etc. would love to know how to do this!
}
}
write
String write( String, Object, Object )
Write a TXT (tab delimited) fileParameters
String filePath the file path
Object value1 set:JSDataSet or header:Object[]
Object value2 header:Object[] or overwrite:boolean
Returns
String fileName String
Supported Clients
SmartClient, WebClient, NGClient
Sample
// Get a dataset based on a query on the example (crm) database
// and it2be_companies/contacts tables
var query = "SELECT c.firstname, c.lastname, o.company_name, o.description FROM it2be_contacts AS c, it2be_companies AS o WHERE c.it2be_companiesid=o.it2be_companiesid";
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 1000);
// stop executing this method when the dataset is empty
// and show an error dialog
if (!dataset.getMaxRowIndex()) {
plugins.dialogs.showErrorDialog("Error.", "There are no records!", "OK");
Return;
}
// set the name of the file
var file = plugins.file.showFileSaveDialog();
// get the name of the operating system to know how to execute the,
// to the filetype attached,application
var osname = application.getOSName();
// check that we really selected a file
// if not ignore the rest of the code
if (file) {
var filePath = file.getAbsoluteFile();
// create the header as a 2 dimentional array
// it is also possible to create a 3 dimensional array (see example dbf)
// in that case the rest of the data is ignored when not creating a dbf file
var header = ["firstname","lastname","company","description"];
// we can use either a 2D array or a dataset for input
// you would typically use a 2D array from data you can not retreive from the database
// in the below example we will create a 2D array from a dataset
// just to show you how to do it
var selection = new Array();
var emptyRow = ["",""]
var counter = 0;
for (var i = 1 ; i <= dataset.getMaxRowIndex() ; i++) {
var row = dataset.getRowAsArray(i);
selection[counter++] = row; // add the row to the selection array and increment the counter
selection[counter++] = emptyRow; // add the empty row to the selection array and increment the counter
}
filePath = plugins.it2be_data.txt().writeArray(filePath, header, selection);
// open the data in the (to the filetype attached) application
// checking the os needs to be done via evaluation of a string
// you can also use the tools plugin that will give you an integer
if (osname.indexOf("Mac") > -1) {
// mac os x
application.executeProgram("open", filePath);
} else if (osname.indexOf("Windows") > -1) {
// windows
application.executeProgram("rundll32", "url.dll,FileProtocolHandler", filePath);
} else {
// linux etc. would love to know how to do this!
}
}
write
String write( String, Array<Object>, Object, Boolean )
Write a TXT (tab delimited) fileParameters
String filePath the file path
Array<Object> header the header
Object set the dataset
Boolean overwrite the overwrite
Returns
String String
Supported Clients
SmartClient, WebClient, NGClient
Sample
// Get a dataset based on a query on the example (crm) database
// and it2be_companies/contacts tables
var query = "SELECT c.firstname, c.lastname, o.company_name, o.description FROM it2be_contacts AS c, it2be_companies AS o WHERE c.it2be_companiesid=o.it2be_companiesid";
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 1000);
// stop executing this method when the dataset is empty
// and show an error dialog
if (!dataset.getMaxRowIndex()) {
plugins.dialogs.showErrorDialog("Error.", "There are no records!", "OK");
Return;
}
// set the name of the file
var file = plugins.file.showFileSaveDialog();
// get the name of the operating system to know how to execute the,
// to the filetype attached,application
var osname = application.getOSName();
// check that we really selected a file
// if not ignore the rest of the code
if (file) {
var filePath = file.getAbsoluteFile();
// create the header as a 2 dimentional array
// it is also possible to create a 3 dimensional array (see example dbf)
// in that case the rest of the data is ignored when not creating a dbf file
var header = ["firstname","lastname","company","description"];
// we can use either a 2D array or a dataset for input
// you would typically use a 2D array from data you can not retreive from the database
// in the below example we will create a 2D array from a dataset
// just to show you how to do it
var selection = new Array();
var emptyRow = ["",""]
var counter = 0;
for (var i = 1 ; i <= dataset.getMaxRowIndex() ; i++) {
var row = dataset.getRowAsArray(i);
selection[counter++] = row; // add the row to the selection array and increment the counter
selection[counter++] = emptyRow; // add the empty row to the selection array and increment the counter
}
filePath = plugins.it2be_data.txt().writeArray(filePath, header, selection);
// open the data in the (to the filetype attached) application
// checking the os needs to be done via evaluation of a string
// you can also use the tools plugin that will give you an integer
if (osname.indexOf("Mac") > -1) {
// mac os x
application.executeProgram("open", filePath);
} else if (osname.indexOf("Windows") > -1) {
// windows
application.executeProgram("rundll32", "url.dll,FileProtocolHandler", filePath);
} else {
// linux etc. would love to know how to do this!
}
}
writeArray
String writeArray( String, Array<Object>, Array<Array<Object>> )
Write a TXT (tab delimited) fileParameters
String filePath the file path
Array<Object> header the header
Array<Array<Object>> array the array
Returns
String fileName String
Supported Clients
SmartClient, WebClient, NGClient
Sample
// Get a dataset based on a query on the example (crm) database
// and it2be_companies/contacts tables
var query = "SELECT c.firstname, c.lastname, o.company_name, o.description FROM it2be_contacts AS c, it2be_companies AS o WHERE c.it2be_companiesid=o.it2be_companiesid";
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 1000);
// stop executing this method when the dataset is empty
// and show an error dialog
if (!dataset.getMaxRowIndex()) {
plugins.dialogs.showErrorDialog("Error.", "There are no records!", "OK");
Return;
}
// set the name of the file
var file = plugins.file.showFileSaveDialog();
// get the name of the operating system to know how to execute the,
// to the filetype attached,application
var osname = application.getOSName();
// check that we really selected a file
// if not ignore the rest of the code
if (file) {
var filePath = file.getAbsoluteFile();
// create the header as a 2 dimentional array
// it is also possible to create a 3 dimensional array (see example dbf)
// in that case the rest of the data is ignored when not creating a dbf file
var header = ["firstname","lastname","company","description"];
// we can use either a 2D array or a dataset for input
// you would typically use a 2D array from data you can not retreive from the database
// in the below example we will create a 2D array from a dataset
// just to show you how to do it
var selection = new Array();
var emptyRow = ["",""]
var counter = 0;
for (var i = 1 ; i <= dataset.getMaxRowIndex() ; i++) {
var row = dataset.getRowAsArray(i);
selection[counter++] = row; // add the row to the selection array and increment the counter
selection[counter++] = emptyRow; // add the empty row to the selection array and increment the counter
}
filePath = plugins.it2be_data.txt().writeArray(filePath, header, selection);
// open the data in the (to the filetype attached) application
// checking the os needs to be done via evaluation of a string
// you can also use the tools plugin that will give you an integer
if (osname.indexOf("Mac") > -1) {
// mac os x
application.executeProgram("open", filePath);
} else if (osname.indexOf("Windows") > -1) {
// windows
application.executeProgram("rundll32", "url.dll,FileProtocolHandler", filePath);
} else {
// linux etc. would love to know how to do this!
}
}
writeArray
String writeArray( String, Array<Object>, Array<Array<Object>>, Boolean )
Write a TXT (tab delimited) fileParameters
String filePath the file path
Array<Object> header the header
Array<Array<Object>> array the array
Boolean overwrite the overwrite
Returns
String fileName String
Supported Clients
SmartClient, WebClient, NGClient
Sample
// Get a dataset based on a query on the example (crm) database
// and it2be_companies/contacts tables
var query = "SELECT c.firstname, c.lastname, o.company_name, o.description FROM it2be_contacts AS c, it2be_companies AS o WHERE c.it2be_companiesid=o.it2be_companiesid";
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 1000);
// stop executing this method when the dataset is empty
// and show an error dialog
if (!dataset.getMaxRowIndex()) {
plugins.dialogs.showErrorDialog("Error.", "There are no records!", "OK");
Return;
}
// set the name of the file
var file = plugins.file.showFileSaveDialog();
// get the name of the operating system to know how to execute the,
// to the filetype attached,application
var osname = application.getOSName();
// check that we really selected a file
// if not ignore the rest of the code
if (file) {
var filePath = file.getAbsoluteFile();
// create the header as a 2 dimentional array
// it is also possible to create a 3 dimensional array (see example dbf)
// in that case the rest of the data is ignored when not creating a dbf file
var header = ["firstname","lastname","company","description"];
// we can use either a 2D array or a dataset for input
// you would typically use a 2D array from data you can not retreive from the database
// in the below example we will create a 2D array from a dataset
// just to show you how to do it
var selection = new Array();
var emptyRow = ["",""]
var counter = 0;
for (var i = 1 ; i <= dataset.getMaxRowIndex() ; i++) {
var row = dataset.getRowAsArray(i);
selection[counter++] = row; // add the row to the selection array and increment the counter
selection[counter++] = emptyRow; // add the empty row to the selection array and increment the counter
}
filePath = plugins.it2be_data.txt().writeArray(filePath, header, selection);
// open the data in the (to the filetype attached) application
// checking the os needs to be done via evaluation of a string
// you can also use the tools plugin that will give you an integer
if (osname.indexOf("Mac") > -1) {
// mac os x
application.executeProgram("open", filePath);
} else if (osname.indexOf("Windows") > -1) {
// windows
application.executeProgram("rundll32", "url.dll,FileProtocolHandler", filePath);
} else {
// linux etc. would love to know how to do this!
}
}