ReadArrayFromFile

From GECK
Jump to: navigation, search


A function added by the JIP NVSE Plugin.

Description

Reads data from the specified file and stores it in an array variable.

If the file contains a single line of data, the function returns a standard, list-type array. Otherwise, it returns a matrix, the layout of which depends on the 2nd, optional argument, transpose:

  • 0 (default) - The 1st index is the column number and the 2nd index is the row number (someArray[column][row]).
  • 1 - The 1st index is the row number and the 2nd index is the column number (someArray[row][column]).


The file must be formatted accordingly:

  1. Values must be separated with tabs (one or more).
  2. When using non-numeric types as values:
    • Strings must be prefixed with '$'. Example: $Brave men run, in my family.
    • Forms must be prefixed with '@', followed by the source file name, then ':', and finally the six-digit formID (i.e. without the mod index). Example (for Craig Boone): @FalloutNV.esm:096BCE

Syntax

[help]
(array_var) ReadArrayFromFile filePath:string transpose:1/0

Example

496	-1.26	-12	0.514	0	2009	-100.8004

A file with the same contents as the above will return an array of numbers, with 7 elements.

$they can lie	$to my face	$but not	$to my heart

The above will return an array of strings, with 4 elements.

@FalloutNV.esm:135F19	@LonesomeRoad.esm:003E43		@DeadMoney.esm:00A7A9

The above will return an array of forms, with 3 elements.

0.514	$if we all	-12	@DeadMoney.esm:00A7A9	@FalloutNV.esm:135F19	$stand together

The above will return an array of mixed-type values, with 6 elements.

52	14	7	9
110	2	20	51
10	99	0	61
-5	37	39	45
35	17	496	-12

The above will return a matrix of numbers, with 4 columns and 5 rows.

@FalloutNV.esm:135F19		496		$they can lie to my face
@LonesomeRoad.esm:003E43	-1.26		$but not to my heart
@DeadMoney.esm:00A7A9		-12		$if we all stand together
@FalloutNV.esm:022108		0.514		$it will just be the start

The above will return a matrix of mixed-type values, with 3 columns and 4 rows.

Notes

  • filePath is relative to the game's installation path.
  • Before calling this, make sure the file exists using FileExists. CAUTION: FileExists is relative the Data folder, not the Game's installation path.

See Also