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.
Another option would be switching to a 'component lithology' setup. Instead of having one long expression that is difficult to read and troubleshoot, you would use library tables that gINT can set up for you. The tables have almost all the formatting options you will need. (For those it can't handle szang's excellent post of Jan 21 2013 above shows other options.) Most of our sample gINT Std libraries have these tables. The main one for soil lithology is called 'Description Soil Lithology'. Look in Help under 'Setting up Component Structures - component descriptions (how-to guide) for more information and/or contact me privately and I can help you get started.
Szang,
I have been playing around with the code that you gave me and was able to achieve the desired result to capitalize the first letter of every line; however, I have a hanging comma issue. Specifically, if there are no additional comments other than a material description, a comma still prints.
I have included my edited code below. I have also attached a preview of my log containing the hanging comma after the material description of gravel.
<<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)>>,_ <<Ucase(<<Left(<<Get(LayerDesc)>>,1)>>)>><<Mid(<<Get(LayerDesc)>>,2)>>_ )>>_ )>>_)>>
The preferred way to do this is with the ListBuildSepTrim command I described previously. This gets rid of all the HasData functions and avoids double commas and leading and trailing commas.
Working with what you have got, it is best to be consistent and always include the necessary separating punctuation as part of the data that will follow (ie PRECEDING the data). That way, if there is no data, the separating punctuation does not print. You started doing this with the "color" and "desc" variables but then abandoned it when you assembled the final description. In fact you ended up removing the leading coma from the "desc" variable. I would sugest the following revisions to your final code (identified by bold italics underline). I did not change your code, only commented on what should be changed
<<HasData(<<LITHOLOGY.Material_Description>>,_
"<<LITHOLOGY.Material_Description>>,"_ Delete the trailing comma from this line
)>>_
<<HasData(<<Get(Desc)>>,_
<<Mid(<<Get(Desc)>>,2)>> Remove the Mid command from this line to get the leading comma back
)>>_ It seems like this closing parenthesis is in the wrong place... Needs to be up about 7 lines to close out the "layerdesc" Let statement
<<HasData(<<LITHOLOGY.Overide_Description>>,_
<<LITHOLOGY.Overide_Description>>,_ Add a leading comma to this line
<<IIf(<<LITHOLOGY.Comment>>,_
" - <<LITHOLOGY.Additional_Descriptions>>",_ If the dash is the desired separator then this line is fine as is
<<HasData(<<Get(LayerDesc)>>,_
<<Ucase(<<Left(<<Get(LayerDesc)>>,1)>>)>><<Mid(<<Get(LayerDesc)>>,2)>>_ If you want a separator here, add it as a leading separator but if there might not be a material description then you will have an extraneous leading separator
)>>
Again, I do not know what type of data you have in your data fields and what the desired result so this may not give you the results you desire.
I am having a similar issue trying to capitalize the first word of my string. I believe I applied it based on your recommendation but I am not seeing any changes in the text. My text is listed below:
<<iif(<<lithology.description>>="No Recovery","No Recovery.","<<hasdata(<<lithology.soil name>>,"<<b>><<u>><<format(<<lithology.soil name>> (<<lithology.graphic>>),>)>><<B>><<u>><<listbuildseptrim(_"," ,_<<lithology.color>>,_<<lithology.moisture_content>>,_<<lithology.density_consistency>>,_<<lithology.soil_structure>>,_<<lithology.mineralogy>>,_<<lithology.description>>,_)>>","-<<N>><<Ucase1st(<<listbuildseptrim(_"," ,_<<lithology.color>>,_<<lithology.moisture_content>>,_<<lithology.density_consistency>>,_<<lithology.soil_structure>>,_<<lithology.mineralogy>>,_<<lithology.description>>,_)>>)>><<N>>")>>")>>
Hi Domnique,
As others in this thread have mentioned, the best solution might be the Component Description approach using a Component Description library table and the ComponentDesc function. See Help>Index>Setting up Component Structures - componenent descriptions (how-to guide) for more info. For a detailed explanation, see the Component Lithology Descriptions section in the Data Design Tutorial.
You could use a long expression such as above, but it might be more difficult to work with. If you would like to use that approach though, please provide more info or an example of what the final completed description should look like in Output, and we can provide better guidance for the best way to write the expression. I see a couple issues with the expression, and I'm not sure what the end goal is exactly.
Also, feel free to send me your gINT Library File (.glb) and a gINT Project File (.gpj) to jesse.greenwald@bentley.com. It might be easier to troubleshoot that way.
Thank you,
Jesse