Formula to determine if text is all caps

Hello,

I’m trying to formula fill a new field with select text from two other fields where the text I want to retrieve is all caps. Something to the effect of the formula below which doesn’t work of course.

?(D notcontains [a-z],D,"")+?(E notcontains [a-z],E,"")

I’m sure there is a solution I’m missing.

Thanks,
Jeff

?(upper(D+E)=D+E,D+E,"")

Thanks Dave,

Here is what worked: ?(upper(D)=D,D,"")+?(upper(E)=E,E,"")

This is off-topic but related. Word (?) used to have a Title Case function that worked fairly well on book titles, so that I wouldn’t have to mess with my shift key most of the time. I set a lot of fields to auto cap, like authors, with a few manual fixes of course.

A title case function would always capitalize the first and last words, but not articles, prepositions, and conjunctions under 5 characters. Without being too elaborate, because I don’t expect PanX to know what an article or preposition is, the basic list would be a, an, the, and, for, etc. – “to” is a challenge because my style needs To Capitalize “to” when it is an infinitive but not when it is a preposition.

I fear I probably don’t have the skills to get a Rube Goldberg attempt up and running, but who knows.

I gave this a once over (ok, maybe more than once over) and came up with a somewhat heavy handed scheme that make a list of the articles, conjunctions and the most common prepositions under 5 characters. Here is what I have as a procedure for anything in the field or variable named theText:

let theExceptions=
	upperword("a an the and but for nor or so yet of at to in for on by but up out off as with from into upon like over plus down near")
arrayfilter upperword(theText),theText," ",
	?(arraycontains(theExceptions,import()," "),lower(import()),import())
theText=?(arraysize(theText," ")<3,upperword(theText),upperword(arrayfirst(theText," "))+" "+
	arrayrange(theText,2,-2," ")+" "+upperword(arraylast(theText," ")))

Using this with the fictitious tile “of mice and men nor some-other stuff as well” it will generate “Of Mice and Men nor Some-Other Stuff as Well”. Ok, seems to work pretty well but you asked for something to use in a formula. Here is the rather elaborate formula version which combines all the above statements into functions:

?(arraysize(theText," ")<3,upperword(theText),upperword(arrayfirst(theText," "))+
    " "+arrayfilter(arrayrange(upperword(theText),2,-2," ")," ",
    {?(arraycontains(upperword("a an the and but for nor or so yet of at to in for on by "+
    "but up out off as with from into upon like over plus down near"),import()," "),
    lower(import()),import())})+" "+upperword(arraylast(theText," ")))

I’ll leave it to others to convert this to a function if they want.

Changed my mind and did it myself:

registercustomfunction "TITLECASE(",1,|||?(arraysize(•1," ")<3,upperword(•1),upperword(arrayfirst(•1," "))+
	" "+arrayfilter(arrayrange(upperword(•1),2,-2," ")," ",
	{?(arraycontains(upperword("a an the and but for nor or so yet of at to in for on by "+
	"but up out off as with from into upon like over plus down near"),import(),
	" "),lower(import()),import())})+" "+upperword(arraylast(•1," ")))|||

Well Gary, since you teed that up so nicely I just had to put a bow on this. I have added this function to the next version of Panorama, and I also added this to the capitalization options in the Morph Field dialog and the Morph All Fields dialog.

Thank you to Stan for the suggestion, and a huge ginourmous thank you to Gary for the code.

Cool! I can hardly wait to try this out; thanks Gary.

More good news, thanks Jim!