  asked on

# Writing a formula in Crystal Reports

I am a bit out of practice in the use of Crystal and could use a jump start.  Been a long time since I wrote crystal formulas and could use help in correcting the code I have attached.

I need to pull the first three values in a string, determine if the first three values is all numeric and if so is it less then a 100 using a Crystal Formula.   If not a string or less than a 100 use the first concant of values, if greater then 100 then use the second.
Quick-Code.txt
Crystal ReportsOffice ProductivitySoftware Last Comment
James0628

8/22/2022 - Mon
Ido Millet

stringVar sTest := "023abc";
IF Len(sTest) < 3 Then "Too Short" Else
(
sTest := LEFT(sTest, 3);

IF NumericText(sTest) Then
(
IF val(sTest) < 100 Then " " & sTest & " " & sTest & " " & sTest
eLSE
sTest & " " & sTest & " " & sTest;
)
Else "Not Numric";
);
Mike McCracken

What does this part of your question mean?

>>If not a string or less than a 100 use the first concant of values, if greater then 100 then use the second

The final Else in the formula above should be

ELSE
sTest & " " & sTest & " " & sTest;

mlmcc
gilnari

I have a string as example 110 deg F or could be 70 deg F.
What I need to know if the first three characters is something like  (110, or 70<space>)
Then see if the value (which is numeric) is less than 100 (100 deg F) I want to add a space to a set of values I am concanting together at the beginning if less than 100.   Its a pretty lineup thing I am trying to accomplish.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Ido Millet

The text sample you provided indicates you want spaces inserted, but your latest message indicates otherwise.  Tough to follow, so please provide a couple of examples of input versus desired output.
Mike McCracken

Try something like

Local StringVar  TestString;
TestString := Left({YourFIeld},3);

If NumberText(YourString) then
If Val(YourString) < 100 then
" " & TestString
Else
TestString
Else
TestString

mlmcc