GetMsg

Far Manager

GetMsg

The GetMsg function returns a message from the language file. It is strongly recommended to use this function instead of hard-coding text constants directly in the program, because it allows to localize your plugin and switch the language of FAR and plugins simultaneously.
const char* WINAPI GetMsg(
  int PluginNumber,
  int MsgId
);

Parameters

PluginNumber
Number of the plugin module. It is passed to the plugin in the SetStartupInfo function.
MsgId
Index of the message in the message file.

Return value

The function returns the address of the requested message.

Remarks

All *.lng files in plugin directory are considered as language files. FAR selects the necessary *.lng file depending on the current language. Before using GetMsg first time, all messages are loaded into the memory, so they can be accessed later much faster and you don't need to store the messages in an additional buffers.

Example

In all the examples, as you can see, the following function is used:
C/C++:
const char *GetMsg(int MsgId)
{
  return(Info.GetMsg(Info.ModuleNumber,MsgId));
}
Delphi:
function GetMsg(MsgId: TMessageStrings): PChar;
begin
  result:= Info.GetMsg(Info.ModuleNumber,integer(MsgId));
end;
Info is declared as a global variable:
struct PluginStartupInfo Info;
...and initialized in the SetStartupInfo function:
void WINAPI _export SetStartupInfo(struct PluginStartupInfo *Info)
{
  ...
  ::Info=*Info;
  ...
}
See also: