ToUpper() ? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: ToUpper() ? (/thread-3320.html) Pages: 1 2 |
RE: ToUpper() ? - Didier Lachieze - 03-12-2015 04:53 PM (03-12-2015 04:44 PM)bobkrohn Wrote: My Prime doesn't accept it seems that string should not be used as a variable name, try s instead. Btw there are two other changes required: add CHAR and replace +32 by -32. I also prefer to use a local variable for the loop index. Code: EXPORT ToUpper(s) RE: ToUpper() ? - bobkrohn - 03-12-2015 08:05 PM This ability to treat a String variable as a List was totally unknown to me. What threw me was, yes, the use of a Home variable (A). Awesome. I'm learning something new. A fresh tool in the toolbox. Love this kind of thinking. On this Forum I have seen several great "unintended uses" for functions that have been discovered. Is there a file document somewhere with a list of these useful gems?? I played a little with the SIZE function (versus DIM) According to Help: DIM is for Strings SIZE is for Lists str:= "ABCDEF"; DIM(str) returns 6 as expected SIZE(str) returns 6 as unexpected on Lists L1 := {31,32,33,34,35,36}; SIZE(L1) returns 6 as expected DIM(L1) returns {1,1,1,1,1,1} unexpected I guess it treats each number as an individual List? Now to try and find a use for DIM(list) Not everything that glitters is Gold and not everything that is Gold glitters RE: ToUpper() ? - DrD - 03-12-2015 08:44 PM If its about DIMensions, and SIZE matters, don't forget about: length(), for lists, strings, or objects -Dale- RE: ToUpper() ? - cyrille de brébisson - 03-13-2015 06:18 AM Hello, DIM and SIZE are synonyms (they point to the same function). length is a CAS function, so will be much slower as it needs to convert the string to a CAS object and to get the result back from CAS to numerical. variable indexing works for lists, matrices and strings. Note that if you have a string in a list of list, you can do var(1,2,3) to get the 3rd character of the 2nd list in the first list of the list stored in var! Codding this was a JOY! Enjoy, Cyrille RE: ToUpper() ? - bobkrohn - 03-13-2015 11:28 PM L1 := {31,32,33,34,35,36}; SIZE(L1) returns 6 as expected DIM(L1) returns {1,1,1,1,1,1} unexpected Educational Question. If SIZE and DIM are equal why do I get different results? (from Home Screen) RE: ToUpper() ? - DrD - 03-14-2015 04:45 AM The help description says that DIM() number of characters in a string. SIZE() number of elements in a list. length() number of elements in a list, string or object. SIZE and length both return 6 elements. DIM correctly reports 1 character for each element in the list if èach element is the CHAR number, in your example. RE: ToUpper() ? - cyrille de brébisson - 03-17-2015 07:11 AM with s being the string, here is another way to do a ToUpper.. L1:= ASC(s); return CHAR(L1-((97<=L1) AND (122>L1))*32); |