<cHash>.Add

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > Data Structures > cHash > cHash Methods >

<cHash>.Add

 

Description

 

Add KeyName/Value pairs inside a cHash object.

 

Syntax

 

<cHash>.Add( KeyName : Value [, KeyName : Value [, ...]])

 

A cHash object support a free and dynamic form to specify key names: Add method can be omitted.

 

The following statements are equivalent:

<cHash>.Add(KeyName: %TRUE)

<cHash>.KeyName = %TRUE

 

Returns

 

None

 

Parameters

 

Name

Type

Optional

Meaning

KeyName



Any sequence of chars will be recognized as key name.

Special chars can be used as part of the key name: \ and . (point)

 

KeyName will always internally converted into capital letters. If you need to keep the KeyName as typed, please include it into double quoted string.

Value

String


Any expression that will be converted into string before assigning to the key

 

Remarks

 

Similar to <cHash>.Set()

 

Like in Javascript, the last property in the list may end with a comma:

dim User as new cHash
User.Init (
  name: "John",
  age: 30,
)

That is called a “trailing” or “hanging” comma. Makes it easier to add/remove/move around properties, because all lines become alike.

 

Restrictions

 

See also

 

Examples

 
dim ExportCsvOpt as new cHash
ExportCsvOpt.Set(
                    Filename: APP_SourcePath + "Test_Export_Out.csv",
                    ColumnNames: %TRUE,
                    FieldSeparator: ";",
                    RecordSeparator: $crlf,
                    StringDelimiter: $dq,
                    DecimalSeparator: ".",
                    RecordBuffer: 1000,
                    MaxRecords: -1,
                    Replace_CR: %TRUE,
                    Replace_CR_Char: "",
                    Replace_LF: %TRUE,
                    Replace_LF_Char: "",
                    Replace_CRLF: %TRUE,
                    Replace_CRLF_Char: "",
                    Replace_DQ: %TRUE,
                    Replace_DQ_Char: "'"
                 )

 

ExportCsvOpt.Add(
                    Index: %TRUE,
                    IndexBase: 1
                 )