Accessing resources at run time with SPL APIs

You can access resources at run time with SPL APIs.

Procedure

To load and format a resource from a resource bundle, use one of these SPL APIs:
  • rstring loadAndFormatResource(ToolkitName, BundleName, rstring resname, T tuple)
  • rstring loadAndFormatResource(ToolkitName, BundleName, rstring resname, T tuple, rstring locale)
  • rstring loadAndFormatResource(ToolkitName, BundleName, rstring resname)
  • rstring loadAndFormatResource(ToolkitName, BundleName, rstring resname, rstring locale)

Example

composite Main() {
  graph
    stream<rstring cost> S = FileSource() {
      param file : "in.dat";
    }
    stream<rstring cost> F = Filter(S) {
      logic state : {
        tuple<int32 cost> _t = { cost = 101 };
        rstring _cost = loadAndFormatResource("MyToolkit", "MyResource", "MSG0001", _t);
      }
      param filter : cost == _cost;
    }
    () as Out = FileSink(F) {
      param file : "Results.txt";
    }
}

In this example, the input file might contain cost data that is formatted in a locale-sensitive way. You want to filter out the tuples that have a cost that is a specific value. The value that you want is 101 formatted in a locale-sensitive way, for example $1.01 or 101,00 TL (Turkish).