Forum

Carriage return in ...
 
Notifications
Clear all

Carriage return in Strings  

  RSS

 pjr
(@pjr)
New Member
Joined: 3 years ago
Posts: 4
December 20, 2017 4:03 pm  

Is there a way to encode a carriage return in a string variable? It would be nice to be able to display multiple lines in a variable display, like Gallons and Liters at the same time.

 

Thank you
Patrick


Quote
(@pbruno3)
Reputable Member Admin
Joined: 3 years ago
Posts: 271
December 20, 2017 4:55 pm  

Good question. Let me discuss it with the dev team!


ReplyQuote
(@piggles22)
Active Member
Joined: 2 years ago
Posts: 16
June 21, 2020 4:37 pm  

Has this been resolved? Page 82-83 in the manual says that "new line" codes can be added to display multiple lines via an Inspector but it didn't work when I tried it. I entered the example from the manual and it simply displayed the text as single line.


ReplyQuote
(@piggles22)
Active Member
Joined: 2 years ago
Posts: 16
June 21, 2020 6:03 pm  

Is it possible to concatenate a value (converted into text) into the middle of a string? I tried this and it does not display the second part of the string ("gallons of water" does not display). 

[Fill]
new value gal //Inspector variable
continue state = false //button element
wait continue state == true  //wait for user to enter a value in "gal" variable
continue state = false
new string str
str = gal //converts "gal" value to text
new string MT //Inspector variable to display message
MT = "Fill MT with " + str + "gallons of water"
sleep 500
[Next]


ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 3 years ago
Posts: 271
June 22, 2020 3:31 am  

@piggles22 Yes, I just tried the example and it worked correctly. Not sure why it didn't work for you. My script (which I changed slightly from the manual): And an inspector to report 'str', worked perfectly (see attached).

new string str
str = "King\nQueen"
sleep 10000

And an inspector to report 'str', worked perfectly (see attached).

 KingQueen.png

This post was modified 3 weeks ago 2 times by pbruno3

ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 3 years ago
Posts: 271
June 22, 2020 3:35 am  

For your second question, the interpreter can only do math on two objects at a time... try:

MT = "Fill MT with " + str

MT += "gallons of water"

ReplyQuote
(@piggles22)
Active Member
Joined: 2 years ago
Posts: 16
June 23, 2020 2:50 am  

@pbruno3 I've tried running the "new line" code on two different laptops: a Dell PC running Windows 10 and on a MacBook Pro running Windows 8 (virtual machine in VMWare Fusion) and I get the same results on both machines (no new line). I've even tried running this code in three different versions of BC (1.0, 1.1.0, and 1.1.4) and get the same results in each. Very puzzling.

new string str

str = "King\nQueen"

sleep 3000

 

As for the inline addition of more than two objects, thanks. That's an easy fix.

 

 


ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 3 years ago
Posts: 271
June 23, 2020 4:01 am  

Well shoot... I wonder if we added this along the way and didn't document it correctly.

We plan on releasing a 1.2 Beta within a few days... so perhaps you can grab that at that time.


ReplyQuote
Share: