# MakeChangesInTable

## Command MakeChangesInTable

MakeChangesInTable is a typescript command that can change individual cells within variable defined as a Table, IntraTable, DetermTable or ProbTable. It was introduced into the Analytica 4.2 release for internal purposes -- specifically for the purpose of recording small changes to very large edit tables in the auto-recovery change log. Prior to this command's introduction, when a single cell was changed in a large edit table, the entire new table definition has to be written to the auto-recovery change-log. For large edit tables (like an edit table with 1M cells), the created a sizeable delay. With Analytica 4.2, by using MakeChangesInTable, Analytica is able to write only the cells that actually changed to the change log.

Although it is not intended for other uses beyond this, it could be used from a button script or from the typescript window to change individual cells in an edit table. It can also be used to change the table type (e.g., converting a DetermTable to a Table, etc.

MakeChangesInTable ident tableType(indexList) changes

## Parameters

«ident»
The variable defined as a table
«tableType»
One of Table, IntraTable, DetermTable or ProbTable
«indexList»
Comma-separate list of the table indexes. It must contain all table indexes (but the order does not have to match the order in the original definition). The order they are listed here determines the order of representation in «changes».
«changes»
Specifies the coordinates of changed values and the new values.

To describe the format of «changes», note first that the order in which coordinates are specified follows the order that indexes appear in «indexList». To capture this, we'll number the indexes in «indexList» as (In, In-1,..., I2, I1). The full coordinate of a cell requires the position to be given for all n indexes. To specify the coordinate for all n indexes, we'll specify the coordinate for index n, and then a list of changes for the remaining n - 1 indexes that apply at that coordinate. Thus, a coordinate specified for the ith level can then contain a recursive specification of the changes that apply to the remaining levels i - 1..1. The syntax of «changes» is then described as follows:

«expr» := /* denotes an Analytica expression -- a cell contents */
«changes0» := «expr»{,«expr»}*
«changesi» := «changeRuni»{,«changeRuni»}*
«changeRuni» := «pos»(«changesi-1{,«changesi-1}*)

In the above BNF-grammar, { } are BNF-groupings and are not part of the syntax, and * denotes zero or more repetitions. The parens, ( and ), are literals in the syntax.

Once all coordinates have been specified, we are at level zero. At that point, a list of cell values can be specified, such that the last index (level-1) increments implicitly. This is demonstrated by:

MakeChangesInTable X Table(I) 11(4.2, 6.6, 7.7, Sum(Y, Time), 8, , Null)

Here starting with cell X[@I = 11] set to 4.2, the successive cells along @I are also changed. This would also be equivalent to the more verbose variation:

MakeChangesInTable X Table(I) 11(4.2), 12(6.6), 13(7.7), 14(Sum(Y, Time)), 15(8), 16(), 17(Null)

## Examples

Before describing the full syntax, which is fairly complex, a few simple examples will be shown first.

MakeChangesInTable X Table(I) 2(4.7)
Changes X[@I = 2] to 4.7
MakeChangesInTable X Table(I) 8(1 + 2,'a')
Changes X[@I = 8] to 1 + 2, and X[@I = 9] to 'a'

In the second example, notice that 1 + 2 is the cell contents plugged into the edit table. It is an expression, but MakeChangesInTable just places it in the cell, it does not evaluate it when doing so.

MakeChangesInTable X Table(I) 4('a'), 7('b')
Sets X[@I = 4] to 'a' and X[@I = 7] to 'b'
MakeChangesInTable Y Table(I, J) 9(11('c'))
Sets Y[@I = 9, @J = 11] to 'c'
MakeChangesInTable Y Table(I, J) 9(11('c', 'd')), 7(4('e'), 6('f'))
Sets Y[@I = 9, @J = 11] to 'c'
Y[@I = 9, @J = 12] to 'd'
Y[@I = 7, @J = 4] to 'e'
Y[@I = 7, @J = 6] to 'f'

## History

Introduced in Analytica 4.2.