Example Code

String Title Capitalisation Fixer

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
This program will allow you to capitalise any title string so that it capitalises the first letter of each word while ignoring prepositions as one should when creating titles.


Description
The code works by scanning the string for spaces to determine the index at which the string is the first letter of a word and then re writes it to contain a capital. The code then ignores the prepositions by using an array of predefined prepositions which it scans the string for and rewrites them to contain no capital.


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Write a string containing any combination of capitalised or non-capitalised letters and wire it to the Input String terminal.
  2. Place an indicator on the Result String terminal and see the magic happen.

 

Additional Information or References

 

VI Block Diagram

 Block Diagram.png

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

 

 


Larry Colvin
Associate Principal Engineer
Dyson Technology Ltd.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Richard_Ha
Member
Member
on

w

BruceMoyer
Member
Member
on

Where's the VI?

Larry.C
Active Participant
Active Participant
on

Sorry, I had forgotten to attach it. It is now up.


Larry Colvin
Associate Principal Engineer
Dyson Technology Ltd.

BruceMoyer
Member
Member
on

Thanks, I posted an edited version that also deals with articles and conjunctions that the previous VI was missing.  Also if the word is All Capitals then it deals with that differently (added an ALL Caps input terminal).

vishots.com
Member
Member
on

I'm not sure why you have 2 arrays for prepositions. Couldn't you just take the first array item and just convert it to lowercase on the fly?