format is broken

I have an app (and a few more in the pipeline) where I need to write a parameter file in a fixed format. I’m not in control of the format: it’s an international standard.

It has been designed with fixed positions for the various parameters, such as is easy to do with C (or, for those old enough to remember, FORTRAN).

My previous versions of the app were able to get by with the use of Format(x, “…”). But now, this is broken: the number representation now takes on the local locale, so, often as not, a numeric field which needs a point (.) as a decimal point, gets a comma (,). In the fixed format I must use, that is forbidden.

To try to overcome this I have defined a locale (en-GB) and use [double].toText(locale, “…”) where “…” is the format string.

But the old format strings no longer give usable results. and try as I might, I cannot get a consistent field length nor sign placement, even if I resort to using if … else … end if structures to try to format them.

Please can somebody explain how to get predictable and reliable field width definitions, tolerant of positive and negative quantities (with decimal places).

I never thought I would long for the old days of C and FORTRAN ;-(

thanks,
Richard

Did you try https://documentation.xojo.com/api/os/locale.html#locale-raw

Format has always been the locale specific version. Use Str() instead. It can take a format string, too.

Jeremie: thanks for the extremely quick response. I didn’t but I don’t believe it would help. I solved the locale problem but the issue remains with the new approach to format strings in .toText

Tim: that might be the way out. Thanks (also for the quick response). I wasn’t aware that str() could take a format. I’ll try it tomorrow (must go to bed now).

cheers,
Richard

Thanks Tim, that did the trick!