Programmer Guide/Macro Library/CTemplates: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}} - Template Management}}
{{TOC limit|3}}
:'''File''': Classes.STX, linked to library STX.LIB
==CASegTemplate : CObj==
:'''Parent class''': [[Programmer Guide/Macro Library/COBJ|CObj]]


A class to manage segment templates (<code>ASegTemplate</code>)<code><code>.</code></code>
A class to manage templates (e.g. of type '''DialogTemplate''', '''ASegTemplate''' or '''attrTemplate''')


You can retrieve a list of templates available in the {{STX}} INI file. You can display a dialog offering the user the option of importing from or exporting templates to disk. You can delete templates from the {{STX}} INI file.
==Create Instance==
;Usage:
:<code>ctemplates [ <var>typetag</var> ]</code>
:<code>cobj new ctemplates [ <var>typetag</var> ]</code>
:;<var>typetag</var>selects the type of templates to be managed (default: '''ASegTemplate''')
;Result: an initialized instance


====CASegTemplate construction====
==Delete Instance==
;Usage: <code><var>instance</var> destroy</code>
;Result: none (void)


The <code>CASegTemplate</code> constructor takes no parameters but still needs to be called.
==GetTable==
;Usage: <code><var>instance</var> gettable</code>
;Result: an extended table containing the id's of the available templates of the selected type (one per entry, field '''id''')


====CASegTemplate Member Functions====
==GetList==
;Usage: <code><var>instance</var> getlist</code>
;Result: an semi-colon separated list of the id's of the available templates of the selected type


The <code>CASegTemplate</code> class has the following member functions. See CObj Member Functions for a list of functions implemented in the parent class.
==GetAttributeList==
;Usage: <code><var>instance</var> getattributelist <var>id</var></code>
:;<var>id</var>: the id of the template
;Result: an blank separated list of attributes defined in the selected template


===getList===
==GetValueListForAttribute==
;Usage: <code><var>instance</var> getvaluelistforattribute <var>type ; id ; attr</var></code>
:;<var>type</var>: selects type of result
::'''table''': return a simple table containing on value per line; the default value is stored in the first line
::'''list''': return a blank separated list of values
:;<var>id</var>: the id of the template
:;<var>attr</var>: the name of the attribute
;Result: an blank separated list of defined values or a simple table containing one value per line (see argument <var>type</var>)


List the available templates in either a table or a semi-colon separated list.
==GetDefaultValueForAttribute==
;Usage: <code><var>instance</var> getdefaultvalueforattribute <var>id ; attr</var></code>
:;<var>id</var>: the id of the template
:;<var>attr</var>: the name of the attribute
;Result: the default value


=====Usage:=====
==GetFlags==
;Usage: <code><var>instance</var> getflags <var>id ; attr</var></code>
:;<var>id</var>: the id of the template
:;<var>attr</var>: the name of the attribute
;Result: get the dialog flags defined for the attribute


<code><var>inst</var> getList</code>
==CheckFlag==
;Usage: <code><var>instance</var> getflags <var>id ; attr ; flag</var></code>
:;<var>id</var>: the id of the template
:;<var>attr</var>: the name of the attribute
:;<var>flag</var>: the flag to be tested
;Result: '''1''' if the flag is set, '''0''' otherwise


=====Result:=====
==Manage==
;Usage: <code><var>instance</var> manage</code>
;Result: none (void)
;Description: Display the template management dialog. This dialog implements functions to view, edit (using a text editor), rename and delete templates.


A list containing the ids of the segment templates currently loaded in {{STX}}.
==GetVars==
 
;Usage: <code><var>instance</var> getvars <var>id</var></code>
===getTable===
:;<var>id</var>: the id of the template
 
;Result: An extended table contains all the definitions of all variables of the selected template. The returns table has the string fields '''Type''', '''Name''', '''Default''', '''Values''' and '''Flags'''.
Retrieve a table of loaded templates. The table is an extended table with one field: 'id'
 
=====Usage:=====
 
<code><var>inst</var> getTable</code>
 
=====Result:=====
 
An extended table with one field (id) containing the templates currently loaded in {{STX}}.
 
===Reload===
 
Reload the list of templates from the {{STX}} INI file.
 
=====Usage:=====
 
<code><var>inst</var> Reload</code>
 
=====Result:=====
 
An empty string.
 
===Manage===
 
Show user a dialog asking user to select segment templates to import, export, delete or reload from file.
 
=====Usage:=====
 
<code><var>inst</var> Manage</code>
 
=====Result:=====
 
An empty string.
 
===Import===
 
Import a segment template from disk into the {{STX}} INI file. If no template path is specified, the user is asked to select one from disk.
 
=====Usage:=====
 
<code><var>inst</var> Import [ <var>path</var> ] [ ; <var>confirmReplace</var>=1 ]</code>
 
=====Parameters:=====
 
;<var>path</var>
 
:The path to the segment template to import. If this parameter is not specified, the user is asked to select a template from disk.
 
;<var>confirmReplace</var>
 
:<code>1</code> if the user should be prompted when replacing existing templates. <code>0</code> otherwise. The default is <code>1</code>.
 
Result:
 
The id of the valid segment template or an empty string
 
===Export===
 
Export an existing ASegTemplate to disk.
 
=====Usage:=====
 
<code><var>inst</var> Export <var>asegtemplate</var></code>
 
;<var>asegtemplate</var>
 
:The id of a segment template currently in the {{STX}} INI file.
 
=====Result:=====
 
An empty string.
 
===Remove===
 
Remove an existing segment template from the current {{STX}} INI file.
 
=====Usage:=====
 
<code><var>inst</var> Remove <var>asegtemplate</var></code>
 
;<var>asegtemplate</var>
 
:The id of a segment template currently in the {{STX}} INI file.
 
=====Result:=====
 
An empty string.
 
===ReloadFromFile===
 
Reload an existing segment template from file.
 
=====Usage:=====
 
<code><var>inst</var> Reload <var>asegtemplate</var></code>
 
;<var>asegtemplate</var>
 
:The id of a segment template currently in the {{STX}} INI file.
 
=====Result:=====
 
An empty string.
 
===ViewTemplate===
 
Display a dialog based on a segment template.
 
=====Usage:=====
 
<code><var>inst</var> ViewTemplate <var>asegtemplate</var></code>
 
=====Parameters:=====
 
;<var>asegtemplate</var>
 
:The id of a segment template currently in the {{STX}} INI file.

Revision as of 12:32, 7 March 2018

File: Classes.STX, linked to library STX.LIB
Parent class: CObj

A class to manage templates (e.g. of type DialogTemplate, ASegTemplate or attrTemplate)

Create Instance

Usage
ctemplates [ typetag ]
cobj new ctemplates [ typetag ]
typetagselects the type of templates to be managed (default
ASegTemplate)
Result
an initialized instance

Delete Instance

Usage
instance destroy
Result
none (void)

GetTable

Usage
instance gettable
Result
an extended table containing the id's of the available templates of the selected type (one per entry, field id)

GetList

Usage
instance getlist
Result
an semi-colon separated list of the id's of the available templates of the selected type

GetAttributeList

Usage
instance getattributelist id
id
the id of the template
Result
an blank separated list of attributes defined in the selected template

GetValueListForAttribute

Usage
instance getvaluelistforattribute type ; id ; attr
type
selects type of result
table: return a simple table containing on value per line; the default value is stored in the first line
list: return a blank separated list of values
id
the id of the template
attr
the name of the attribute
Result
an blank separated list of defined values or a simple table containing one value per line (see argument type)

GetDefaultValueForAttribute

Usage
instance getdefaultvalueforattribute id ; attr
id
the id of the template
attr
the name of the attribute
Result
the default value

GetFlags

Usage
instance getflags id ; attr
id
the id of the template
attr
the name of the attribute
Result
get the dialog flags defined for the attribute

CheckFlag

Usage
instance getflags id ; attr ; flag
id
the id of the template
attr
the name of the attribute
flag
the flag to be tested
Result
1 if the flag is set, 0 otherwise

Manage

Usage
instance manage
Result
none (void)
Description
Display the template management dialog. This dialog implements functions to view, edit (using a text editor), rename and delete templates.

GetVars

Usage
instance getvars id
id
the id of the template
Result
An extended table contains all the definitions of all variables of the selected template. The returns table has the string fields Type, Name, Default, Values and Flags.

Navigation menu

Personal tools