Generating strings that represent the values of data.

William Overington

Copyright 2001 William Overington

Suppose that one wishes to use 1456 object code to output to the screen area of an applet a message that states something such as follows.

Element 8 has the number 6.7 in it.

Suppose however that it may not be always element 8 and 6.7 may not be always the value. Suppose that it were element 14 and the data were 56.23972 or some such. That is, the number of characters in the integer and the number of characters in the double are different at different runs of the program.

The technique in 1456 object code is to form up a string containing the message and then print it out as a whole string.

In order to do this, three commands are provided in order to convert data values to strings representing those values. String concatenation can then be used to form up a string ready for outputting.

%D Places in bs1456 a string that represents the value that is in ad1456.
%I Places in bs1456 a string that represents the value that is in ai1456, treating the contents of ai1456 as an integer.
%B Places in bs1456 a string that represents the value that is in ai1456, treating the contents of ai1456 as a Boolean. This means that the string placed in bs1456 is either a four character string true or a five character string false and no other possibility.

Please consider the example output above, repeated here.

Element 8 has the number 6.7 in it.

This means to take the string "Element" and one space, concatenate a string that represents the value of the integer in ai1456, concatenate a space and the words "has the number" and another space, concatenate a string that represents the value of the double in ad1456, concatenate a space and the words "in it." complete with the full stop.

The 1456 object code to do this is as follows. Please note the use of one %w command and four %+ commands.

[Element ]%w%I%+[ has the number ]%+%D%+[ in it.]%+

This is a straightforward method to use. It is important to remember to allow sufficient space for the longest output string that is possible. Once a string has been produced using any of these three new commands it is an ordinary string within 1456 engine and so string moving and string manipulating commands may be applied to it.

1456 object code

Copyright 2001 William Overington