Print Page | Close Window

Find letter type location in string

Printed From: Crystal Reports Book
Category: General Information
Forum Name: Job Postings
Forum Discription: Submit permanent and contract job openings for thousands to read.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22845
Printed Date: 03 Jul 2022 at 11:29am


Topic: Find letter type location in string
Posted By: EVSchmidt
Subject: Find letter type location in string
Date Posted: 10 Dec 2019 at 12:46pm
I am stumped and hope you can help.

I have a table of alphanumeric strings. The max length of each strings are 6 characters. There is at most one letter in each string. Its location within the string is inconsistent from record to record. The letter is never the first character. I would like to create a function in Crystal reports which will return the position of the letter within the string relative to the left side. 1 being the first character, 2 being the second etc. and 0 if no letters are found. Note: I do not know the actual letter in this string all I know is it not a number.

typical field looks like 102b02, 12d09, 9k12 etc.
for reference we can refer to the field name as {Inv.Bin}

ultimately I want to return the numbers to the left of the letters, but I can do this if I can find the position of the letters in each field.

I appreciate any help you can provide. Thank you all.
regards



Replies:
Posted By: kevlray
Date Posted: 11 Dec 2019 at 3:50am
This might work.  I makes an assumption that there is an non-numeric character.
numbervar i;

for i := 1 to len({somefield}) do (
if not(isnumeric(mid(somefield,i,1))) then exit for
);
left({somefield},i-1)

There maybe a better solution.


Posted By: EVSchmidt
Date Posted: 11 Dec 2019 at 5:16am
I declared the I variable and it worked perfect. Thankyou so much for your help



Print Page | Close Window