@neqna function

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

memos
Posts: 9
Joined: Tue Jun 03, 2014 7:32 am

@neqna function

Postby memos » Tue Aug 19, 2014 7:51 am

In this code:

Code: Select all

%Str1 = "abc" %Str2 = "" if @neqna(%Str1, %Str2) then @uiprompt("Test 1") endif if not(@eqna(%Str1, %Str2)) then @uiprompt("Test 2") endif
I would expect both test messages to display, but only "Test 2" displays. Why?
I am using Eviews 8 Enterprise edition, July 29 2014 built.
In fact, the "Command and Programming Reference" document on page 71 says @neqna("", "def") returns a 1, but the following code returns a 0:
scalar aTemp = @neqna("", "def")

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: @neqna function

Postby EViews Gareth » Tue Aug 19, 2014 8:11 am

@neqna only applies to numbers.

memos
Posts: 9
Joined: Tue Jun 03, 2014 7:32 am

Re: @neqna function

Postby memos » Tue Aug 19, 2014 11:13 am

The documentation clearly states @neqna as a string function. Here are several examples from the Command and Programming Reference:

Page 543:
@neqna(str1, str2) tests for inequality of strings

Page 567:
@neqna ................tests for inequality of string values treating empty strings as ordinary
blank values (p. 579).

Page 579:
@neqna String Functions
Syntax: @neqna(str1, str2)
Argument 1: string, str1
Argument 2: string, str2
Return: integer
Tests for inequality of str1 and str2, treating null strings as ordinary blank strings, and not
as missing values. Strings which test as equal return a 0, and 1 otherwise.
Example:
@neqna("abc", "abc")
returns a 0, while
@neqna("", "def")
returns a 1.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: @neqna function

Postby EViews Gareth » Tue Aug 19, 2014 11:20 am

You're right. I was half asleep.

Looks like the function doesn't handle empty strings properly.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests