[?]Does anyone have a set of examples of ways in which the FORMAT function can be used? Eg. How to print a code with a space in the middle of it? I find the on-line help in Navision extremely confusing, and lacking in useful examples.
Can you give us an example of what you are trying to do? Cristi
For example, I would like to output a code field containing 123ABC as 123/ABC. I know I can use COPYSTR to extract the substrings then add the separate strings together, but I feel there should be a more general way of doing this sort of thing with FORMAT. I also find date/day formats confusing. It is the actual syntax of the FORMAT statement which, beyond the simple: string := FORMAT(DecimalVariable) + ’ characters’ which I find hard to work out. In the last example, how do I make sure that the decimal is always formatted with 2 decimal places? Eg. if the decimal is 15.2, the output in string needs to be ‘15.20 characters’? Thanks for any help you are able to give.
In the last example you can try
Maybe it’s not very clean solution, but it works…
Hi Andy I know just what you mean. A few more meaningful examples in the help manual could save use new developers a lot of time. As for your date format you could try this:- MESSAGE (‘Date %1’,TODAY); MESSAGE(‘Date DDMMYY %1’,FORMAT(TODAY,6,’<Day,2><Month,2><Year,2>’)); MESSAGE(‘Date YYMM >%1<’,FORMAT(TODAY,10,’<Year,2><Month,2>’) ); Hope this helps Graham
Petr and Graham, Many thanks for your examples, which are a big help. The last example I am trying to work out is this: I have a value 123ABC in a code variable. I want to print it as 123/ABC. Can I do this with FORMAT? Andy
The format string should be FORMAT(‘123ABC’,0,’<Text,3>/<Text,3>’); but it does not work. It returns 123/123; I don’t know why…