>Subject: 'RETURN'ing > 512
>Date: Thu, 10 Feb 1994 17:52:10 -0800 (PST)
>From: Robert Minter <rob@dssmktg.com>
>X-Informix-List-Id: <list.3496>
>
>Is it just weird to me or why is it that you can pass a variable > 512 bytes
>to another function, and you can return INTO a variable defined > 512 bytes,
>but you can't return a variable > 512 bytes?
It was just a weird consequence of the way that strings were returned from
functions. When error -4518 was expunged in version 4.12, the recoding
also permitted error -4517 to be removed, and any string which you can
declare can also be returned in its entirety. As a separate bug removal
exercise, you cannot declare character strings with lengths outside the
range 1..32767.
A minor critique of the coding style:
> FOR i = 2 to 2048
> LET str = str CLIPPED,"A"
> END FOR
This would be better written as:
FOR i = 2 TO 2048
LET str[i] = "A"
END FOR
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
# Here is a revised version of Robert Minter's program which works without
# error on 4.12, but produces error -4517 in 4.11.
MAIN
CALL func1()
END MAIN
FUNCTION func1()
DEFINE
str CHAR(2048),
i SMALLINT
LET str = "A"
FOR i = 2 to 2048
LET str[i] = "A"
END FOR
LET str = func2(str)
DISPLAY "String = ", str
END FUNCTION
FUNCTION func2(str)
DEFINE
str CHAR(2048),
i SMALLINT
DISPLAY "String = ", str CLIPPED
LET str = "B"
FOR i = 2 to 2048
LET str[i] = "B"
END FOR
RETURN str
END FUNCTION