Walter wrote: ↑Wed Jan 05, 2022 6:54 pm
2. It doesn't really matter. I think
X may be a little easier to handle. [/list]
Well let's look to a use case when a program has to return results within strings, using the example on page 201 of the OM about a train arrival time.
So your program has calculated the exact arrival time and you have 23:55 in X, now let's look at the two cases (X or K):
A. Strings in program steps are sent to K as described in the OM, here are the program steps to build the result string:
Code: Select all
001 'The train will arrive at ' @ this string will be sent to K - K='The train will arrive at '
002 STO+ K @ the result in X is concatenated to the string in K - K='The train will arrive at 23:55'
003 RCL K @ AFAIK there is no Append character on the 43S as on the 41C or 42S to append directly a string to K
004 ' sharp at Victoria station.' @ this string will be sent to K - K=' sharp at Victoria station.'
005 RCL+ K @ the string is K is concatenated to the string in X, we have now the full result string in X:
@ 'The train will arrive at 23:55 sharp at Victoria station.'
B. Strings in program steps are sent to X as currently implemented, which is similar to RPL where everything is done on the stack:
Code: Select all
001 'The train will arrive at ' @ this string will be sent to X - X='The train will arrive at ' - Y=23:55
002 X<>Y @ We need to have the string in Y
002 + @ the result in X is concatenated to the string in Y - X='The train will arrive at 23:55'
004 ' sharp at Victoria station.' @ this string will be sent to X - X=' sharp at Victoria station.' - Y='The train will arrive at 23:55'
005 + @ the string in Y is concatenated to the string in X, we have now the full result string in X:
@ 'The train will arrive at 23:55 sharp at Victoria station.'
For comparison, the same thing with an Alpha register as on the 41C/42S takes only 3 steps and don't touch the stack:
Code: Select all
001 'The train will arrive at ' @ this string will be sent to Alpha - Alpha='The train will arrive at ' - Y=23:55
002 ARCL X @ the result in X is concatenated to the string in Alpha - Alpha='The train will arrive at 23:55'
003 'ᵀ sharp at Victoria station.' @ the string is concatenated to the string in Alpha, we have now the full result string in Alpha:
@ 'The train will arrive at 23:55 sharp at Victoria station.'
I find
A et
B quite cumbersome.
A could be done in 3 steps if we had an Append character but
B requires anyway the extra X<>Y and changes the stack content, so if you want to reuse the result for further calculation you need to save it somehow which is an additional step.
Is there any other simpler way to do this on the 43S?