String literal cheat sheet

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
User avatar
VLNinja70
Posts: 15
Joined: Thu Nov 26, 2015 1:41 am

String literal cheat sheet

Post by VLNinja70 » Thu Oct 12, 2017 3:49 am

Hey guys,
So this isn't really much of a question but more of a what do you think post... ;)

So I was screwing around with my message box that popup errors for logging in.
I wanted to format the text in the message where there is a new line between sentences int he message.
Coming from the world of Javas, Python and C, I figured that I just stick a /n in my string and everything would be good.
But, in LANSA, it actually took my /n literally.

So digging around in the forum searching for new line I found this post
viewtopic.php?f=3&t=1399&p=2928&hilit=new+line#p2928

So now my message shows up the way I like it.
One thing thats bugging me about this was hunting for this on the doco site.

First you have to search for carriage return (not new line) to find something about this.
http://docs.lansa.com/14/en/lansa016/PR ... INSICS.htm

Then when you find asUnicodeString, turns out thats under the Integer Primitive.
I get that you are modding a integer to a special character but my brain was working with strings so I wouldn't think to look there.

*/ Rant mode: offline */

Anyway I was thinking that to make this much easier for the future LANSA n00bs out there (like myself :D ), I'd think it be great to have a LANSA Literal character translator.
Just a page in the doco that says, here is all the basic literals in LANSA and quick examples in how to use them.
Want to use /n? use (10).AsUnicodeString
How about /t? use (9).AsUnicodeString

What do you guys think?
Image

User avatar
HMJust
Posts: 49
Joined: Wed May 11, 2016 7:23 pm
Contact:

Re: String literal cheat sheet

Post by HMJust » Thu Oct 12, 2017 6:19 pm

I agree with you, and thank you for reminding me how to get these characters as strings. I forgot that...

About strings and integers, my "favorite" feature is the string intrinsics AsInteger and AsNumber which I wrote about here: https://lansa123.wordpress.com/2017/03/ ... -asnumber/

(for those that can't remember exactly, AsInteger returns the character code of the first character in the string, where as AsNumber tries to convert the string into a numeric value)

If you read the documentation, you see that AsInteger is "Return the variable as an integer" whereas AsNumber is "Return the variable as a number" and for a long time I missed the subtle difference between "integer" and "number" in this context.
I don't know what I am doing, nor how I did it. If it works, luck was involved :geek:

Post Reply