{$DEFINE active_self}
close()
Closes the form or report.

createControl('ClassName', 'ParentPath', 'ControlName', left, top, width, height)
create a control in the named parent('ParentPath')
if 'ParentPath' = '' it will be created directly in the form

deleteControl('ControlName')
Remove the 'ControlName' control

getControls( [option])
return the list of controls
option is optional, 'text' by default
- if option = 'text' returns the names of the controls separated by CRLF
- if option = 'table' returns the names of the controls in an LUA table

getProperty('control.property ...')
getProperty('controlName.propertyName1.propertyName2.propertyNameN ...')
Returns the value of a property of an object in the window / report

setProperty('control.property ...','value')
nsbase.window.active.setProperty('controlName.propertyName1.propertyName2.propertyNameN ...','value')
Assign the value of a property of an object in the window / report.

setFocus('controlName')
Set focus to 'controlName'

refresh()
Refresh form display

{$END_DEFINE}

{$DEFINE dataset}
open()
Opens the dataset on the record set

close()
Closes the dataset

refresh()
Invokes data refresh.

first()
Position on the first record

previous()
Position on the previous record

next()
Position on the next record

last()
Position on the last record

Insert()
Adds a new record

delete()
Deletes the current record

post()
Post the data

edit()
Put the form in edit mode

cancel()
Cancels changes in progress

gotorecord(n)
Position at the n record

getItems([ 'fieldname' ['option']])
Returns the list of records in the "FieldName" field of the dataset
the CR, LF, TAB of the content of the recordings are encoded)
If 'FieldName' is not specified or = '', all values of all fields will be returned
-
option is optional, 'text' by default
- if option = 'text' returns the records separated by CRLF
- if option = 'table' returns the records in an LUA table

getFieldname('name')
Returns the value of the 'name' field

setFieldname('name','value')
Change value by 'value' in 'name' field

setParameter('name','value')
Assign the parameter 'name' of the value 'value' used for
parametric queries

locate('fieldname','value','options')
Try to position yourself on a record specified by the field 'fieldname' with value 'value'
Returns True if field 'fieldname' of value 'value' was found
-
Options:
- "first" => search from the beginning (default)
- "next" => next search
-
- "startwith" => Whose record starts with 'value'
- "anywhere" => Whose record contains the value 'value'
- "strict" => strict search on the value 'value' (default)
-
- "case" => search with the same case (default)
- "nocase" => search whatever the case
-
- "" => "first,strict,case"

recno
Returns the current registration number *

recordcount
Returns the total registrations

eof
Returns true if we reach the last record, otherwise false

state
Returns the state of the dataset
- 0: Inactive
- 1: Reading
- 2: Edition
- 3: Insertion
{$END_DEFINE}



nsbase
NSBase-specific APIs

nsbase.datasetCreate("name")
API for handling records in a dataset
-
dataset = nsbase.datasetCreate("name")
Creates an instance of a "dataset"
- If "name" is the name of a form or a report, in this case it will be the main dataset
- If "name" is the name of a dbgrid, this is the dataset of the dbgrid, it must name "form_name.name_of_dbgrid", self for the current form, example "self.dbgrid1"
- If "name" = "SQLQuery" the dataset will be a SQL querer

nsbase.dataset.SQL
dataset.SQL = application
Only if the dataset will be a SQL querer

nsbase.dataset.execSQL()
Execute the request
Only if the dataset will be a SQL querer


{$USE dataset nsbase.dataset}

nsbase.application
Methods and properties of the application

nsbase.application.getSQLFromDataSource("datasource")
Returns the SQL query from the "datasource"
"datasource" can be a table or a view

nsbase.application.width
Property width of the application

nsbase.application.clientWidth
Property useful width of the application

nsbase.application.height
Application height property

nsbase.application.clientHeight
Property useful height of the application

nsbase.application.top
Property position y on the app screen

nsbase.application.left
Property position x on the app screen

nsbase.application.getObjects([option])
return informations of objects application
option is optional, default 'text'
- If option = 'text' list in text format (\n)
- If option = 'table' list in table format (lua)

nsbase.application.windowState
Property of the state of the application
- 0 = Normal size
- 1 = Minimized (desktop icon)
- 2 = Maximum size (all the screen)

nsbase.application.centerForm()
Center the application on the screen

nsbase.application.console
Ownership of console visibility: 'true' = displayed,'false' = hidden

nsbase.application.runmode
If 'true' the program is in runtime mode: all editing tools are hidden,

nsbase.application.quit()
Quit the application

nsbase.application.getInfo('section', 'type')
Section
- 'executable' => returns the name of the application's executable file
- 'mainbase' => returns the name of the main database file
- 'database' => returns the name of the database file containing the data
-
Type of information
- 'path' => returns the path
- 'filename' => returns the name of the file
- 'fileext' => returns the extension of the file name
- 'fullname' => returns the full file name
-
Information type if section = 'database'
- 'protocol' => return the protocol
- 'library' => returns the library
- 'hostname' => returns the name of the server
- 'port' => returns the port number
- 'database' => returns the database
- 'user' => returns the name of the user

nsbase.dialog
Standard dialogue boxes

nsbase.dialog.showMessage('type','msg')
Displays a dialog box following type = error, info, confirmation.
Returns true if the yes button is pressed

nsbase.dialog.input('title','prompt','Default')
Display an input dialog box, return 2 values: the text and the state of the input, true if the Ok button is pressed
Sample:
rc,str=nsbase.dialog.input('title','prompt','Default')
rc => false or true
str => The string

nsbase.dialog.picklist('title','items',[selectedIndex])
Display a dialog box list (items)
Return index and value
Sample:
ix,value=nsbase.dialog.pickList('Select your item','item1\nitem2\n...')

nsbase.dialog.fileOpen('title','filter','InitialDir','filename')
Displays a file selection dialog box, returns 2 values: the complete file name and the state of the input, true if the Ok button is pressed

nsbase.dialog.fileSave('title','filter','InitialDir','filename')
Displays a dialog box for saving files, returns 2 values: the complete file name and the state of the input, true if the Ok button is pressed

nsbase.dialog.selectDirectory('title','InitialDir')
Displays a dialog box for directory selection, returns 2 values: the name of the directory and the state of the entry, true if the Ok button is pressed

nsbase.dialog.showDatasetFindReplace('dbgrid')
Displays a dialog box to search / replace in directories

nsbase.dialog.showExport()
Displays export dialog box

nsbase.fileSystem
Access to file system functions

nsbase.fileSystem.readFile('filename',['option'])
option is optional, default 'text'
if option = 'text' returns the contents text file
if option = 'bin' returns the contents of the hex encoded binary file
if option = 'table' returns the contents of the file in an LUA table

nsbase.fileSystem.writeFile('filename','content',['option'])
option is optional, default 'text'
if option = 'text' Write the string 'content' in a text file
if option = 'bin' Writes to a file the bit string 'content' encoded hex

nsbase.fileSystem.getDirectory([mask])
Returns the contents of a directory in an LUA table
the default mask / path is *
Example
[[
for n, item in ipairs(nsbase.filesystem.getDirectory()) do
  print(n, item.name, item.size, item.attr, item.date, item.time)
end
]]

nsbase.fileSystem.directoryExists('directory')
Returns true, if the directory exists

nsbase.fileSystem.fileExists('filename')
Returns true, if the file exists

nsbase.fileSystem.getSize('filename')
Return the file size in bytes

nsbase.fileSystem.getLastModified('filename')
Return file modification date

nsbase.fileSystem.mkdir('directory')
Create a directory

nsbase.fileSystem.copyFile('source','dest')
Copy the source file to dest

nsbase.filesystem.remove('filename')
Delete an empty file or directory
Returns true if ok
Equivalent to os.remove

nsbase.filesystem.removeDirectories('directory')
recursively delete a directory and its contents
BE CAREFUL with its use!

nsbase.filesystem.rename('oldname','newname')
Rename a file or directory
Returns true if ok
Equivalent to os.rename

nsbase.filesystem.export('datasource','format','filename'[,header])
Export the contents of a table or view (datasource) to a file (filename)
Returns true if ok
header: optional parameter, if = true write header, option only valid for text files
format:
- 'tab': text file with # 9 (tabulation) as column separator
- ';' : text file with; as column separator
- ',': text file with, as column separator
- 'html': file in html format
- 'xml': file in xml format

nsbase.internet
Access to internet functions

nsbase.internet.httpGet('url',['option'])
option is optional, default 'text'
- if option = 'text' returns the contents of the web page of the url specified
- if option = 'bin' Returns binary content in an encoded string (hexa)

nsbase.internet.httpPost('url', 'FormData [' option '])
FormData must contain the parameters to be transmitted in the form param1 = value & param2 = value ....
option is optional, default 'text'
- If option = 'text' returns the content of the web page of the specified url
- If option = 'bin' Returns the binary content in an encoded string(hexa)

nsbase.internet.URLEncode('url')
Returns the url encoded to the internet standard

nsbase.internet.URLDecode('url')
Returns the url decoded according to the internet standard

nsbase.internet.HTMLToText(html ')
Returns text from an HTML page, without tags ...

nsbase.internet.getValueAfter('Src','After')
Returns a string of 'Src' characters after 'After'

nsbase.internet.getValueBefore('Src','Before')
Returns a character string of 'Src' before 'Before'

nsbase.internet.json
Acces to JSON functions
-
Sample:
-
local json=nsbase.internet.json()
json.parse(nsbase.internet.httpGet('http://xxxxxx'))
print(json.count('rows'))
print(json.value('rows[0].name'))
-
json.parse(nsbase.internet.httpGet('https://world.openfoodfacts.org/api/v0/product/8480000341778.json'))
print(json.value('product.product_name'))
print(json.value('product.nutriments.sodium'))

nsbase.internet.json.parse('textjson')
Prepare the json component with 'textjson'

nsbase.internet.json.count('path')
Returns the number of occurrences of an element specified by the path 'path'

nsbase.internet.json.value('path')
Returns the value of an element specified by the path 'path'

nsbase.lang
Access to multilingual functions
-
Sample:
-
function frmMain:ActionOnLoaded()
  self.setProperty('cbxLang.items',nsbase.lang.getList())
  self.setProperty('cbxLang.text',nsbase.lang.get())
end
-
function frmMain:cbxLangActionOnChange()
  nsbase.lang.set(self.getProperty('cbxLang.text'))
end

nsbase.lang.getSys()
Returns the (installed) language of the system

nsbase.lang.get()
Returns the language activated in NSBase

nsbase.lang.set('lang')
Change the language of NSBase

nsbase.lang.getList()
Returns the list of languages installed

nsbase.lang.getAppList()
Returns the list of languages installed in the project

nsbase.lang.translate('section','property')
Translates the property 'property' of the 'section' with the active language of NSBase
-
'section' can be self which is the current object
Envoyer des commentaires

nsbase.system
Access to system functions

nsbase.system.openURL('url')
Open the internet browser of the system with the requested url

nsbase.system.openDoc('doc')
Open the specified document

nsbase.system.getVersion()
Return the NSBase version

nsbase.system.getOS()
Return the name of the system

nsbase.system.getCodeLang()
Returns the language code of the system

nsbase.system.getClipboardText()
return the text contained in the clipboard

nsbase.system.setClipboardText('text')
Put the text in the clipboard

nsbase.window
Functions of manipulation of the windows, their components and properties

nsbase.window.getProperty('window.control.property ...')
nsbase.window.getProperty('windowName.controlName.propertyName1.propertyName2.propertyNameN ...')
Returns the value of a property.

nsbase.window.setProperty('window.control.property ...','value')
nsbase.window.setProperty('windowName.controlName.propertyName1.propertyName2.propertyNameN ...','value')
Assigns the value of a property of an object in a specified window.

nsbase.window.show('name')
Displays a table, view, report, or form.

nsbase.window.close('name')
Closes a form or report.
'name' = form name

nsbase.window.getOpened()
Returns the list of open forms or reports.
-
option is optional, 'text' by default
- If option = 'text' list in text format (\n)
- If option = 'table' list in table format (lua)

nsbase.window.isOpen(windowName)
Returns true if the specified window is open

nsbase.window.active
Handling functions of the active window, its components and properties

{$USE active_self nsbase.window.active}

nsbase.window.active.dataset
Manipulate all data in the active window

{$USE dataset nsbase.window.active.dataset}

nsbase.self
Pointer on the object, allows manipulation of the window or report, its components and properties

{$USE active_self nsbase.self}

nsbase.self.name
Name of the object pointed by self

nsbase.self.dataset
Manipulate all the data of the object

{$USE dataset nsbase.self.dataset}

