New Feature: StringFormatter

I believe it will be very helpful if a Splitformatter component is added to the Text plugins.

This component is used extensively in Linx4

Kobus, please describe what this component will be used for and give us some example data.

As an example, building a csv string of values that need to be written to a file, once would specify the delimiter(,).
Then defined the fields mapped. Padding, field length, alignment, formatting can be easily applied to each field.

This component also allows one to create fixed length data lines for writing to a file: eg the formatted string for a fileformat defined as the following is built within minutes and minimal effort:

Ultimately the component must have the same features as per the L4 component

When you’re writing these files do you write header and footers as well?

There are several ways to achieve this in Linx 5. Here are some samples.

Use an Expression to format the string
This is probably the closest to how you would use the old Linx 4 component but in this case we use the built-in Expression functionality instead of a separate component. The Contents property of the FileWrite

contains this Expression

"{0},{1},{2}\r\n".FormatWith(ExecuteSQL1.ForEachRow.CustomerID,ExecuteSQL1.ForEachRow.CompanyName,ExecuteSQL1.ForEachRow.City)

or for fixed length fields

"{0}{1}{2}\r\n".FormatWith(ExecuteSQL1.ForEachRow.CustomerID.PadRight(10).Substring(0,10),ExecuteSQL1.ForEachRow.CompanyName.PadRight(30).Substring(0,30),ExecuteSQL1.ForEachRow.City.PadRight(30).Substring(0,30))

Use a RazorTemplate to build a complete file

The RazorTemplate function takes a Model (an ExecuteSql result in this case) and applies a template using the Razor syntax to build the complete file with headers and footers. The Template property

contains

this is my heading
and here is another one
========================
@foreach(var item in Model)
{
@:@item.CustomerID,@item.CompanyName,@item.City
}
------------------------
this is my footer

Conclusion

We can do the same and more with Linx 5. In this case there is a slight learning curve but once you get it you’ll be able to do much more than the old Linx 4 component could.