Title
Let Function Help
Post
I'm trying to set up an input field that upon saving the data will evaluate if there's a letter at the end of the input. If there is I need it to then choose the long version of the unit. For the sake of testing it out I used the value "50r". I was expecting to get back "Reps" but I'm getting "r" as a return. What am I doing wrong? I know if I were just put in "r" as my calc I would get "Reps" returned.
Let (
[
r="Reps";
s="Secs";
m="Mins";
h="Hrs";
e="Meters";
k="KMs";
f="Feet";
t="Miles";
j="Jumps";
l="Lengths";
o="Rotations";
p="Laps"
] ;
Right ( "50r"; 1 ) )
You have the r in quotes and thus it does not refer to the let variable but to the literal text string "50r".
Try:
Let (
[
r="Reps";
s="Secs";
m="Mins";
h="Hrs";
e="Meters";
k="KMs";
f="Feet";
t="Miles";
j="Jumps";
l="Lengths";
o="Rotations";
p="Laps"
] ;
50 & r )
I think you want this auto-enter calculation:
Let ( units = right ( self ; 1 ) ;
GetAsNumber ( self ) & Case ( units = "r" ; "Reps";
units = "s" ; "Secs";
units = "m" ; "Mins";
units = "h" ; "Hrs";
units = "e" ; "Meters";
units = "k" ; "KMs";
units = "f" ; "Feet";
units = "t" ; "Miles";
units = "j" ; "Jumps";
units = "l" ; "Lengths";
units = "o" ; "Rotations";
units = "p" ; "Laps"
) ; // Case
) //Let
Make sure to clear the "do not replace existing value..." check box.