Initializing help system before first use

# ins~getarrayelt

Purpose
Create an ins~entityfetch record for fetching a single array element into a Mosel variable.
Synopsis
`function getarrayelt(entity:text, keys:list of any, dst:any):ins~entityfetch`
Arguments

entity | The name of the entity to fetch
keys | The index of the array element to fetch
dst | A reference to a variable into which to write a single element from an array entity.

Return value
A value that can be passed to ins~getscendata to read the element into the given reference.
Example

    declarations
      SCENARIO_ID='2926e9a1-9568-4116-84ed-2e75190bc651'
      price: real
    end-declarations
    ins~getscendata(SCENARIO_ID, [ ins~getarrayelt('Prices', ['UK', 1], ->price) ] )
    if ins~haserror then
      writeln_('Error: ',ins~getlasterror)
    else
      writeln('Price in UK in January: ', price)
    end-if

Example of fetching an array element into a Mosel variable.

    declarations
      SCENARIO_ID='2926e9a1-9568-4116-84ed-2e75190bc651'
      Regions: set of string
      Months: set of integer
      Prices: dynamic array(Regions, Months) of real
    end-declarations
    ins~getscendata(SCENARIO_ID, [ ins~getarrayelt('Prices', ['UK', 1], ->Prices),
       ins~getarrayelt('prices', ['UK', 2], ->Prices) ] )
    if ins~haserror then
      writeln_('Error: ',ins~getlasterror)
    else
      writeln('Price in UK in January: ', Prices('UK', 1))
      writeln('Price in UK in February: ', Prices('UK', 2))
    end-if

Example of fetching array cells into a Mosel array.
Further information
1. The destination must be a reference to a string, text, integer, real, or boolean, or an array of one of those types, or an array of any.
2. If the destination is an array, the fetched element will be inserted into that array with the supplied index keys. In this case, the types of the index values must match the type of the index sets of the array.
3. If the array element type does not match the type of the reference, the value will be converted (e.g. a real type entity would be be rounded to be stored in an integer).
4. Any content in other array cells will not be affected.
5. If the requested array cell does not exist in the Insight scenario's data, the call to ins~getscendata will raise an error.
6. This function cannot fail; invalid parameter values will only cause an error when the returned value is passed to ins~getscendata.
Related topics
ins~getscendata
Parent Topic Reading Scenario Data

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.