HP Forums
newline not parsed in strings [Android] - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: newline not parsed in strings [Android] (/thread-4644.html)



newline not parsed in strings [Android] - StephenG1CMZ - 09-04-2015 06:32 PM

Example in the User guide suggest that \n is parsed as a newline escape sequence (of size 1).
Using the 092 backslash between the square brackets in the Shift/Vars table, the \n is not parsed as an escape sequence and is printed as normal text.

What am I doing wrong?
Code:

 EXPORT BS()
BEGIN
 PRINT("A\nB");
END;



RE: newline not parsed in strings [Android] - eried - 09-04-2015 06:45 PM

(09-04-2015 06:32 PM)StephenG1CMZ Wrote:  Example in the User guide suggest that \n is parsed as a newline escape sequence (of size 1).
Using the 092 backslash between the square brackets in the Shift/Vars table, the \n is not parsed as an escape sequence and is printed as normal text.

What am I doing wrong?
Code:

 EXPORT BS()
BEGIN
 PRINT("A\nB");
END;

You can just use enter:

Code:
 EXPORT BS()
BEGIN
 PRINT("A
B");
END;



RE: newline not parsed in strings [Android] - StephenG1CMZ - 09-04-2015 07:01 PM

This appears to work too:
Code:

LOCAL LF:=CHAR(10);
PRINT("a"+LF+"b");
Which would be more useful if you wanted a variable number of lines.
LF is the line feed character, but it actually has the effect of a Carriage Return too within the PRINT.

SO
(1) why doesn't \n newline?
(2) what if I actually wanted just a line feed? So that B is positioned after A but 1 line down, rather than 1 line down and to the left.


RE: newline not parsed in strings [Android] - Tim Wessman - 09-04-2015 07:26 PM

(09-04-2015 07:01 PM)StephenG1CMZ Wrote:  (1) why doesn't \n newline?

It is actually leftover from the 39gII and the feature/documentation is not in sync at the moment. It is on "the list" for correction though at some point in the future.


RE: newline not parsed in strings [Android] - StephenG1CMZ - 09-04-2015 07:48 PM

(09-04-2015 07:26 PM)Tim Wessman Wrote:  
(09-04-2015 07:01 PM)StephenG1CMZ Wrote:  (1) why doesn't \n newline?

It is actually leftover from the 39gII and the feature/documentation is not in sync at the moment. It is on "the list" for correction though at some point in the future.

Thanks for that explanation. I had thought I must have selected the wrong backslash or something. The use of line feed provides an effective workaround.