Text from A Parameter file

I had to do a bunch of literal strings as global object parameters today.
You can use find and replace in a text editor to replace all the spaces with Alt-0160.

Quite possibly one of the most stupid looking things I have done in FTV but it works.
 
Space-Text Continuum...

ASF said:
...if you want to put spaces in your string you're going to have a bad time. Quote marks, double quote marks, nothing will save you except using ASCII spaces instead of regular spaces...

Yes Sir,

ALT + 0160 or ALT + 255 are known as, among other names, a "non-breaking space". Many text editor engines will attempt to add a line break after a normal space or "whitespace" (spacebar or ALT + 32) when typed at the end of the current line. A non-breaking space will prevent this from happening.

Example: We want to type 100 Hz but it is at the end of the current line and we have used the spacebar to create the "whitespace".
The text editor will leave 100 on the current line and shift Hz to the start of the next line...

The drive was running hot and the speed was noted as 100
Hz
.

To prevent this from happening, and keep the text together, we can instead use a non-breaking space ALT + 0160 or ALT + 255...

The drive was running hot and the speed was noted as
100 Hz.

Another function of these ALT codes is as a "non-collapsing space". Collapsing is where a number of "whitespace" characters have been typed in succession.
An editor may then attempt to collapse the sequence of "whitespace" characters down into one character of "whitespace".

Example: <<< Using the spacebar I have just typed 10 "whitespace" characters after the colon to the left, but the BBCode editor on the Forum has collapsed that sequence down into one "whitespace" character.

If we instead use a non-collapsing space ALT + 0160 or ALT + 255, then the "whitespace" characters will be visible....

Example:______<<< We can use the ALT codes to type 10 "whitespace" characters, but the non-collapsing spaces will prevent the sequence from collapsing.

Note: BBCode is enforcing its rules here on the Forum. So I am not actually typing in the ALT codes to create the "invisible" space above. I have used other "magic" to achieve this.
But such "magic" is handy when you want to demonstrate such "blank space" things on the Forum. So if anyone wants to know how I do that, just ask.
There may be other ways to do the same. Mine is just one method.

Moving on...

For FactoryTalk View SE, we can use a Literal String in an expression as an embedded variable for a text field to reference the static text defined in a parameter file.

Example:

Expression in text field: /*LS:0 {#1}*/

Static text in parameter file: #1 =I am literally a string

To reiterate what ASF has pointed out (& some of Ken's good advice) - When we use the spacebar to enter normal "whitespace" the runtime text will be displayed with " " quotation marks. When we use the Rockwell suggested ALT + 255 non-breaking space character via the numeric keypad, strings with spaces will display without the " " quotation marks...

Rockwell said:
...A non-breaking space can be entered by holding the ALT key and typing 255 on the numeric keypad (you may also need to hold the Fn key on laptop computers). This character will appear as a regular space but the string will display without the surrounding quotation marks. Note: Use numeric keypad on right side of computer keyboard. Do not use the number keys in the row across the top of the keyboard...

For FactoryTalk View ME, the same applies except we must define the static text in a HMI Tag, and not directly in the parameter file. We then reference the HMI Tag to define the static text to use.

Also, if we take a simple Text Object, for example, and open its properties, and type static text into the Text window, we can use the spacebar to enter "whitespace". As we know, this will simply display this static text on the Text Object. However, if you choose "Insert Variable..." and then choose "String...", we now have the "String Variable" window open. Here, whether we choose "Tag" variable, or "Literal string" embedded variable, you will notice that we are restricted from using the spacebar to enter "whitespace". We can only use ALT + 0160 or ALT + 255 codes to enter non-breaking spaces. This is intentional to prevent invalid syntax for an embedded variable. If you never knew that you could use the ALT codes here then you would probably always have been using something like the underscore "_" character to substitute for "whitespace"?

So that's just another small Pro Tip.

Regards,
George
 

Similar Topics

I'm having issues inserting a 'variable' into a global object item. In the "GLobal Object Parameter Definitions" window, I have #2 | Label One...
Replies
4
Views
9,120
I tried the click plus PLC to send emails today but could not get it to work over my network. I need a mass alert when a temperature reaches a...
Replies
2
Views
56
can the slc500 5/05 send a email and text over Ethernet ?
Replies
3
Views
149
Good morning. I'm doing a rehab and I need to recycle some part of the old code that won't change and that I need. This is a calculation that...
Replies
22
Views
1,163
I'm writing some structured text that's handling a data structure that comes from a PC. The PC structure is in the "new" LREAL 64-bit floating...
Replies
3
Views
437
Back
Top Bottom