Please enable JavaScript to view this site.

 

Navigation: Macros > Macro Language > Compiler Messages > Warnings

The value of sRESULT may be, or is, undefined at the end of the Macro

Scroll Prev Up Next More

This compiler warning is generated if it is possible for the value of sRESULT to be undefined at the end of a macro.

 

In the example below, sResult is undefined if the function HolidayOfListOnDate returns false.

var
begin
    if HolidayOfListOnDate('a', n_TokenDate)
        sRESULT = EvalToken(n_TokenDate, s_TokenRoot)
    endif
end

Usually this type of warning occurs using branching without specifying what happens in the else case.

 

There are 2 way to address this warning, using the above example:

var
begin
    bRESULT = HolidayOfListOnDate('a', n_TokenDate)  
    if HolidayOfListOnDate('a', n_TokenDate)
          sRESULT = EvalToken(n_TokenDate, s_TokenRoot)
    else
          sRESULT = ''
    endif
end

or alternatively

var
begin
   sRESULT = ''
   if HolidayOfListOnDate('a', n_TokenDate)
       sRESULT = EvalToken(n_TokenDate, s_TokenRoot)
   endif
end

Note that you should also include an else statement in switch statements.

 


Topic 110123, last updated on 18-Apr-2020