MEDITECH Reports, MEDITECH NPR Reports, NPR Report Writing, NPR Report Writer, NPR Report, MEDITECH Reporting, MEDITECH Report MEDITECH Reports, NPR Reports, NPR Report Writing, NPR Report Writer, MEDITECH NPR

Tuesday, March 25, 2008

IS.NOT.NUMBER

This elegant solution was posted by an astute, anonymous reader:

/TXT?0N


My original solution:

--IS.NOT.NUMBER
--; Input(s): /TXT
--; Output(s): /SKIP as nil
--; If /TXT is not a number return /SKIP as 1.
--0^Q,""^/SKIP,
--DO{(/TXT#Q^/CHR)&(/SKIP_.=.) E(/CHR)^/ASCII,
--IF{/ASCII<46 @SKIP;
--/ASCII>57 @SKIP;
--/ASCII=47 @SKIP},
--Q+1^Q},/SKIP
--
--SKIP
--1^/SKIP

4 Comments:

At 7:15 AM , Blogger marc said...

what is E as in E(/CHR) ?

Marc

 
At 9:18 AM , Blogger olesharpie said...

Hi Marc,

E is the encode program. Passing the character as parameter A will return the ascii code for a character.

For instance: E(",") returns a 44.

John

 
At 7:21 PM , Anonymous Anonymous said...

You can just use ?0D to find if something is a number. For example, 55?0D evaluates to 55, and "A2Z"?0D evaluates to nil.

 
At 7:24 PM , Blogger olesharpie said...

Great tip! I agree ?0D is much clearer and powerful. - John

 

Post a Comment

Links to this post:

Create a Link

<< Home