18.09.2014, 18:59
I played with this a really long time ago. It should work with the local.library just like any other C-style example.
I guess how you use it is:
[ab3]#ID_HELLOWORD = 1
*myCatalog.Catalog = OpenCatalogA_("English", "myprog", Null)
sting.s = Peek.s(GetCatalogStr_ (*myCatalog, #ID_HELLOWORLD, "Hello World"));
NPrint string
CloseCatalog_ *myCatalog
End[/ab3]
It doesnt matter if the catalog exists. It is transparent for you. You just provide the default sting. So there is no extra case if the catalog is missing. Same code.
You can make it more handy if you put it in a macro:
[ab3]SHARED *myCatalog.Catalog ; make it auto global
*myCatalog.Catalog = OpenCatalogA_("English","myprog", Null)
If (*myCatalog=Null) NPrint "Unable to create catalog!" : End
Statement CloseCatalog{}
If (*myCatalog) Then CloseCatalog_ *myCatalog : *myCatalog = Null
End Statement
!autoexit{CloseCatalog} ; this is called on "End" or Debugger End
Macro LocStr ; get the localized string
Peek.s(GetCatalogStr_ (*myCatalog, ('1), ('2)));
End Macro
; or, more safe:
Function.s LocStr{id.l, default.s}; get the localized string
If (*myCatalog=Null) Then Function Return default
stringP.l = GetCatalogStr_ (*myCatalog, id, &default);
If (stringP) Function Return Peek.s(stringP)
Function Return default
End Function
NPrint LocStr{#ID_HELLOWORLD, "Hello World"}
End[/ab3]
I guess how you use it is:
[ab3]#ID_HELLOWORD = 1
*myCatalog.Catalog = OpenCatalogA_("English", "myprog", Null)
sting.s = Peek.s(GetCatalogStr_ (*myCatalog, #ID_HELLOWORLD, "Hello World"));
NPrint string
CloseCatalog_ *myCatalog
End[/ab3]
It doesnt matter if the catalog exists. It is transparent for you. You just provide the default sting. So there is no extra case if the catalog is missing. Same code.
You can make it more handy if you put it in a macro:
[ab3]SHARED *myCatalog.Catalog ; make it auto global
*myCatalog.Catalog = OpenCatalogA_("English","myprog", Null)
If (*myCatalog=Null) NPrint "Unable to create catalog!" : End
Statement CloseCatalog{}
If (*myCatalog) Then CloseCatalog_ *myCatalog : *myCatalog = Null
End Statement
!autoexit{CloseCatalog} ; this is called on "End" or Debugger End
Macro LocStr ; get the localized string
Peek.s(GetCatalogStr_ (*myCatalog, ('1), ('2)));
End Macro
; or, more safe:
Function.s LocStr{id.l, default.s}; get the localized string
If (*myCatalog=Null) Then Function Return default
stringP.l = GetCatalogStr_ (*myCatalog, id, &default);
If (stringP) Function Return Peek.s(stringP)
Function Return default
End Function
NPrint LocStr{#ID_HELLOWORLD, "Hello World"}
End[/ab3]