IResourceItems.Key

Fore Syntax

Key(Index: Integer): Integer;

Fore.NET Syntax

Key(Index: Integer): uinteger;

Parameters

Index. Object index.

Description

The Key property returns the object key with the specified index.

Comments

To search for object index by the specified key, use the IResourceItems.FindByKey property.

Fore Example

Executing the example requires that the repository contains resources with the APP_RESOURCE identifier. These resources contain default language as Russian and translation language as English.

Add links to the IO, Metabase system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    Resource: IResourceObject;
    ResStrs: IResourceStrings;
    ResStrKey: Integer;
    Locales: IResourceLocales;
    Locale: IResourceLocale;
Begin
    
// Get current repository
    mb := MetabaseClass.Active;
    
// Get resources
    Resource := mb.ItemById("APP_RESOURCE").Edit As IResourceObject;
    
// Get string elements for default language
    ResStrs := Resource.Strings;
    
// Get first string element
    ResStrKey := ResStrs.Key(0);
    
// Set string element value for default language
    ResStrs.ValueByKey(ResStrKey) := "Cancel";
    
// Get resource languages collection
    Locales := Resource.Locales;
    
// Get first translation language
    Locale := Locales.Item(1);
    
// Get string elements for translation language
    ResStrs := Locale.Strings;
    
// Set string element value for translation language
    ResStrs.ValueByKey(ResStrKey) := "Cancel";
    
// Save changes
    (Resource As IMetabaseObject).Save;
End Sub UserProc;

After executing the example default language value and translation language value are changed for resource string element.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.ForeIO;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    Resource: IResourceObject;
    ResStrs: IResourceStrings;
    ResStrKey: uinteger;
    Locales: IResourceLocales;
    Locale: IResourceLocale;
Begin
    // Get current repository
    mb := Params.Metabase;
    // Get resources
    Resource := mb.ItemById["APP_RESOURCE"].Edit() As IResourceObject;
    // Get string elements for default language
    ResStrs := Resource.Strings;
    // Get first string element
    ResStrKey := ResStrs.Key[0];
    // Set string element value for default language
    ResStrs.ValueByKey[ResStrKey] := "Cancel";
    // Get resource languages collection
    Locales := Resource.Locales;
    // Get first translation language
    Locale := Locales.Item[1];
    // Get string elements for translation language
    ResStrs := Locale.Strings;
    // Set string element value for translation language
    ResStrs.ValueByKey[ResStrKey] := "Cancel";
    // Save changes
    (Resource As IMetabaseObject).Save();
End Sub;

See also:

IResourceItems