Forum

Carriage return in ...
 
Notifications
Clear all

Carriage return in Strings

10 Posts
4 Users
0 Likes
5,022 Views
 pjr
(@pjr)
New Member
Joined: 6 years ago
Posts: 4
Topic starter  

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: 7 years ago
Posts: 343
 

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


   
ReplyQuote
(@piggles22)
Active Member
Joined: 6 years ago
Posts: 16
 

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: 6 years ago
Posts: 16
 

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: 7 years ago
Posts: 343
 

@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


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
 

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: 6 years ago
Posts: 16
 

@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: 7 years ago
Posts: 343
 

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
(@sedgington)
New Member
Joined: 4 years ago
Posts: 1
 

Did this turn out to ba a 1.2 upgrade issue? I needed to do exactly the same thing and had the same result as Piggles22 with your sample code.


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
 

No, this is working in v 1.1 Build 9.


   
ReplyQuote
Share: