Checking if a numeric variable is completly filled

Discussions about CSEntry
Eohmer
Posts: 3
Joined: February 26th, 2019, 8:47 am

Checking if a numeric variable is completly filled

Postby Eohmer » May 8th, 2019, 12:36 pm

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: 375
Joined: December 19th, 2011, 6:26 pm
Location: HAITI

Re: Checking if a numeric variable is completly filled

Postby htuser » May 8th, 2019, 2:47 pm

Hi,
This issue has been solved. Please see:
viewtopic.php?f=1&t=1875&p=5832&hilit=length+numeric#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.

josh
Posts: 1827
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Checking if a numeric variable is completly filled

Postby josh » May 8th, 2019, 2:54 pm

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


Return to “Entry”