Pascal Viandier wrote:
Do you think it is possible to modify the prcedure "FillChar()" to make it work correctly with the type String(xx)?
For example the code: VAR S10 : String(10); .... FillChar(S10, 10, 'A');
That's not how it's meant to work ("defined" by UCSD/BP). Do:
SetLength (S10, 10); FilLChar (S10[1], 10, 'A');
Note the `[1]'.
This has chances to work with various string formats.
Or look at StringOfChar (GPC unit).
I ask this because I am working on (converting to GPC) a lot of existing code, with FillChar() spread everywhere (more than 1200 SUN Pascal sources), and it works as expected on strings on SUN Pascal. However, since there is no 'Capacity' field in SUN Pascal strings, it cannot be overridden. I understand this can be a big job since calling FillChar() on a record containing Strings should work as well. I think this would be a nice feature anyway, don't you?
Not really, sorry ...
Also, if this cannot be done or desirable from your point of view, is there a way to override the build-in FillChar() for one of mine
FillChar is not a reserved word, just a predefined identifier. You can override it as other identifiers.
that would be called for the type String(xx) only?
Just give it a `var s: String' parameter. The built-in version will then not be available anymore, of course.
Of course, you can rename your new routine. I don't know how easy or difficult it would be -- you only mentioned the total size of 600000 lines, but that's irrelevant as most of those lines do not contain FillChar, I suppose. You could do it semi-automatically, by first renaming all occurrences to the new name, and then renaming back those that do not compile with your routine (and therefore are not strings).
Does the case with arrays/records containing strings actually occur in the program?
Which kind of strings does Sun Pascal use? Strings with a length field (and if so, does its FillChar do what you want on an array/record containing such strings)? Or simply (packed) arrays of Char, as by ISO 7185. In this case, you can do the same in GPC and FillChar will work on them.
Frank