Checking if a numeric variable is completly filled

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Eohmer
Posts: 17
Joined: February 26th, 2019, 8:47 am
Location: Costa Rica

Checking if a numeric variable is completly filled

Post by Eohmer »

Hello!

I was wondering if there's any function or something that can help me check if a numeric variable is completly filled.

For example:
"numericVariable" is a numeric variable of length 8. That variable must always have all its length filled. Does CSPRO have any function that checks that or anyone knows how it can be done?

Thank you!
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Checking if a numeric variable is completly filled

Post by htuser »

Hi,
This issue has been solved. Please see:
http://csprousers.org/forum/viewtopic.p ... eric#p5829
To have the length of entered value, please use mathematic function such as the Log Function .
Then compare the maxvalue and the result of the mathematical operation.
For more, please see https://stackoverflow.com/questions/306 ... teger-in-c

Best Regards,
Last edited by htuser on May 8th, 2019, 2:54 pm, edited 1 time in total.
G.VOLNY, a CSProuser from Haiti, since 2004
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Checking if a numeric variable is completly filled

Post by josh »

That depends on how you define "completely filled". Is it allowed to have leading zeros? If not then you can simply check if it is greater than or equal 10000000 since any 8 digit number must be at least that big. If it can have leading zeros then you really aren't talking about number in the mathematical sense. There you want a string of 8 digits like a phone number or an account number. In that case, make the item type alphanumeric and use a regular expression to check that it is 8 characters long and only numeric. Something along the lines of:
if not regexmatch(MYFIELD, "^[0-9]{8}$") = 0 then
Check out this blog post for more info on regular expressions: http://www.csprousers.org/posts/2019-02 ... sions.html
Post Reply