IResourceItems.Key

Syntax

Key(Index: Integer): Integer;

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.

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.

See also:

IResourceItems