How can I capitalize the first letter of the first word of a list?

How can I capitalize the first letter of the first word of a list?

I would like to capitalize the first letter of the first word of a list.

In this case, the first parameter may or may not be present.

eg Soil description - greyish brown sand vs brown silty sand vs silty sand vs sand, where sand is the primary major conmponent and silty in the secondary major component.

 

  • This is sentence case.

    If you are defining this in a component format table in Library Data (like DESCRIPTION SOIL LITHOLOGY in the gINT standard library), choose Uppercase 1st character for the row with the data expression that calls the first text into the description, then set the rest of the rows to "Lower case".

    If you are bringing a list from a text or memo field into your report, you can use the UCase1st() function:

    <<UCase1st(<<Field>>)>>

    which returns the <<Field>> text with the first character in upper case and the rest of the text in lower case.

    See gINT Help for the topics Setting up Component Structures - component descriptions (how-to guide), Merge Component Description fields (command) and UCase1st (function).



  • There are several ways to create an uppercase first letter in a text string obtained from a field or assembled using a function.  The method used will depend on the source of the text and the desired output.

    If the text string was assembled from a component description function you have 2 options.

    1. You can specify the upper case in the component description table as Pat suggests in his post.  This presumes that the component that you specify as upper case will be the first in the assembled description and that it will always have data.  If the first component does not have data the first component that does have data will not be capitalized as desired.

    2. Fortunately, the component description function itself has a provision for this.  The component description function takes 4 arguments with the last 3 being optional.

    <<ComponentDesc([Component Desc table name],[Uppercase first letter True/False],[End with period True/False],[search text = replacement text])>>

    The first argument is the component description table name

    The second argument is a true/false that if true, capitalizes the first letter of the assembled description.

    The third argument is a true/false that if true, adds a period to the end of the assembled description.

    The fourth argument will do a search and replace in the assembled description.

    Thus to have the first letter of your description capitalized even if the first component does not have data, the component description function in your output template would be something like

    <<ComponentDesc(Tablename,1)>>

    and if you also wanted a period at the end it would be

    <<ComponentDesc(Tablename,1,1)>>

    If the text string is from a field or assembled by other functions, you again have 2 options depending on the desired output.  In the examples below “[TextFunction]” refers to the field or function that creates the text string or list that you want to capitalize.

    1. As Pat stated in his post, you can use the Ucase1st function as in

    <<UCase1st([TextFunction])>>  

    This will force the first character to upper case but it will also force all but the first character to lower case.  Thus “brown silty CLAY, fine.” becomes “Brown silty clay, fine.”

    2. If the above is not the desired effect, I have used the following combination of functions:

    <<UCase(<<Left([TextFunction],1)>>)>><<Mid([TextFunction],2)>>  

    This will keep the original case of everything past the first character but will force the first letter to upper case.  Thus “brown silty CLAY, fine.” becomes “Brown silty CLAY, fine.”  If [TextFunction] is a long complicated formula you can use the Let and Get functions so you do not have to repeat it twice.

  • I tried both of the options above without success. I think I inserted the UCase code in the wrong place. I have pasted my code below. My goal is to get the first letter of each new line to be capitalized. Where should I insert the UCase code? I tried adding the UCase function just before <<Mid(<<Get(Desc)>>,2)>>, but that did not work. Advice?


    <<Let(Color = _
    <<HasData(<<LITHOLOGY.Overide_Color>>,_
    ", <<LITHOLOGY.Overide_Color>>",_
    <<HasData(<<LITHOLOGY.Additional_Color>>,_
    ", <<LITHOLOGY.Color>><<LITHOLOGY.Additional_Color>>",_
    <<HasData(<<LITHOLOGY.Color>>,_
    ", <<LITHOLOGY.Color>>"_
    )>>_
    )>>_
    )>>_
    )>>_
    <<Let(Desc = _
    <<HasData(<<Get(Color)>>,_
    <<Get(Color)>>_
    )>>_
    <<HasData(<<LITHOLOGY.Moisture>>,_
    ", <<LITHOLOGY.Moisture>>"_
    )>>_
    <<HasData(<<LITHOLOGY.Grain Size>>,_
    ", <<LITHOLOGY.Grain Size>>"_
    )>>_
    <<HasData(<<LITHOLOGY.Consistency>>,_
    ", <<LITHOLOGY.Consistency>>"_
    )>>_
    <<HasData(<<LITHOLOGY.Additional_Descriptions>>,_
    ", <<LITHOLOGY.Additional_Descriptions>>"_
    )>>_
    )>>_
    <<Let(LayerDesc = _
    <<HasData(<<LITHOLOGY.Additional_Geologic_Unit>>,_
    "<<B>><<LITHOLOGY.Geologic_Unit>> _
    (<<LITHOLOGY.Geologic_Unit_Symbol>>) / _
    <<LITHOLOGY.Additional_Geologic_Unit>> _
    (<<LITHOLOGY.Addl_Geologic_Unit_Symbol>>)<<B>><<CR>>",_
    <<HasData(<<LITHOLOGY.Geologic_Unit>>,_
    "<<B>><<LITHOLOGY.Geologic_Unit>><<B>><<CR>>"_
    )>>_
    )>>_
    <<HasData(<<LITHOLOGY.Material_Description>>,_
    "<<LITHOLOGY.Material_Description>>,"_
    )>>_
    <<HasData(<<Get(Desc)>>,_
    <<Mid(<<Get(Desc)>>,2)>>_
    )>>_
    )>>_
    <<HasData(<<LITHOLOGY.Overide_Description>>,_
    <<LITHOLOGY.Overide_Description>>,_
    <<IIf(<<LITHOLOGY.Comment>>,_
    " - <<LITHOLOGY.Additional_Descriptions>>",_
    <<HasData(<<Get(LayerDesc)>>,_
    <<Get(LayerDesc)>>_
    )>>_
    )>>_
    )>>
  • It is difficult for me to understand your intent without knowing the types of data in your fields or the intended output.  I am also not clear on what you mean by "My goal is to get the first letter of each new line to be capitalized" as I am not sure what is defined as a new line.  That being said I will try to summarize my understanding of you code and offer a few options to try.  The way I understand the code

    1. Assemble the color description into a variable called "color". this should result in a text string similar to ", black" or ", yellow red"

    2. Assemble a portion of the description into a variable called "desc".  The first component of this is the color assembled above.  This should result in a text string similar to ", yellow red, moist, fine grained, loose"

    3. Assemble the geologic unit description into a variable called "LayerDesc". This should result in bolded text similar to "Allegheny Formation (Pa)/Pottsville Formation(Pp)<<CR>>" or "Pottsville Formation<<CR>>".  Note there is a carriage return after this text that will start a new line for anything following it.  It will also force a vertical space after this text even if nothing follows it.

    At this point nothing has actually been printed yet.

    4. Print the material description followed by a comma.  I am assuming this will be something like "silty sand," or "sandstone,"

    5. Print the contents of the "desc" variable assembled in 2 above.  I am assuming the <<Mid(<<Get(Desc)>>,2)>>_ statement is a remnant from you trying to insert my example uppercase functions here and that what you really meant was <<HasData(<<Get(Desc)>>,<<Get(Desc)>>)>>_.  Also there seems to be an extra right parenthesis in the code here so I am thinking the code pasted was your working copy.  Finally, this seems to double up on commas since the material description has a trailing comma and the desc has a leading comma.

    6. Print the contents of the "LayerDesc" variable assembled above or some type of override description or some type of additional description. For the purposes of this explanation I will assume only the Layer description variable gets printed.

    Thus what finally gets printed is:

    silty sand,, yellow red, moist, fine grained, looseAllegheny Formation (Pa)/Pottsville Formation(Pp)<<CR>>

    My interpretation is that this is what you are considering a "line" thus if you want to capitalize the first character of this line you would place the Ucase function on the material description.  So your code:

    <<HasData(<<LITHOLOGY.Material_Description>>,_
                    "<<LITHOLOGY.Material_Description>>,"_
          )>>_

    Will be modified to(option 1):

    <<HasData(<<LITHOLOGY.Material_Description>>,_
                    "<<Ucase1st(<<LITHOLOGY.Material_Description>>)>>,"_
          )>>_

    Or (option 2):

    <<HasData(<<LITHOLOGY.Material_Description>>,_
                    "<<Ucase(<<Left(<<LITHOLOGY.Material_Description>>,1)>>)>><<Mid(<<LITHOLOGY.Material_Description>>,2)>>,"_
          )>>_

    For the above example either option would print

    Silty sand,, yellow red, moist, fine grained, looseAllegheny Formation (Pa)/Pottsville Formation(Pp)<<CR>>

    This would not work if there was no data in the material description field.  If you want to account for this possibility, I recommend you assemble the final print text string into another variable, say "FinalPrint", using the let function that combines the results of step 4, 5, and 6 above.  Then simply end the code with either:

    <<Ucase1st(<<Get(FinalPrint)>>)>>

    Or

    <<Ucase(<<Left(<<Get(FinalPrint)>>,1)>>)>><<Mid(<<Get(FinalPrint)>>,2)>>

    Note however that both options only look at the first character in the string and makes it upper case if it is a letter.  If the first character is a space, or a comma then a space, nothing will be changed.  There are other text functions that can check for this and deal with it as appropriate but the best way is to avoid the condition. One way to do this is to use the ListBuildSepTrim function

    <<ListBuildSepTrim(<separator>,<<expression 1>>,<<expression 2>>,...)>>

    This allows you to build a string of words separated by a separator, say a comma, that has no leading spaces and no leading comma regardless of which field has data or not.

    Hope this helps.  If I have misinterpreted your intent let me know.

    Note, I have not tested the code I placed above so There may be some typos or other inconsistencies that you will have to work out.

     

  • Thank you for your help.  I will try to implement your suggestions and let you know how it goes.
     
    Eva E. von Thury
    Padre Associates, Inc.
    Project Geologist / GIS Analyst
    Direct: 805-683-1233x5
    Cell: 805-450-9381