ReadValue

file,-folder-and-read-functions ReadValue

syntax

  • ReadValue(source, valuetype, startposition)

definition

ReadValue(source, valuetype, startposition) results in a single parameter value, read from the source argument.

The second argument valuetype configures the value-type of the resulting parameter.

The third argument startposition configures the read position in the source. Spaces/tabs are used as delimiter.

The numbering of the positions is counted from left to right, meaning position two is the position of the second character in the first row.

The ReadValue function also generates a uint32 parameter subitem, called ReadPos. This parameter indicates the position of the next value after the value being read by the ReadValue function, see the example.

description

The ReadValue function is used to read a specific value from a text file, like an ini file.

Use the readarray function to read whole rows from a text file.

applies to

  • parameter source with string value type
  • valuetype can be any value type
  • parameter startposition with uint32 value type

example

container ReadValue
{
   parameter<string>  file: StorageName = "%projDir%/data/text.txt",  StorageType = "str";

   parameter<uint32>  Value1 := ReadValue(file, uint32,  0);              result = 6
   parameter<float32> Value2 := ReadValue(file, float32, Value1/ReadPos); result = 9.02
   parameter<string>  Value3 := ReadValue(file, string,  Value2/ReadPos); result = Test
   parameter<bool>    Value4 := ReadValue(file, bool,    Value3/ReadPos); result = True
   parameter<uint32>  Value5 := ReadValue(file, uint32,  Value4/ReadPos); result = 25000
};
             
6 9.02 Test True      
25000 27500 11000 6100 14400 300 70
30000 32500 12000 6200 14500 320 72
35000 37500 13000 6300 14600 340 74
40000 42500 14000 6400 14700 360 76
45000 47500 15000 6500 14800 380 78
50000 52500 16000 6600 14900 400 80

text.txt

see also