Is there a particular reason why "#<STRING>MySub0002()" is technically incorrect? :o
OPENCONSOLE
DEF S:STRING
DEF T:POINTER
PRINT MySub0001()
T = MySub0002()
PRINT #<STRING>T
'PRINT #<STRING>MySub0002() 'undefined variable??
WAITCON
END
SUB MySub0001 (),STRING
RETURN "MySub0001"
ENDSUB
SUB MySub0002 (),POINTER
S = "MySub0002"
RETURN &S
ENDSUB
Because Emergence syntax doesn't support dereferencing a function directly, never has.
Quote...dereferencing a function directly...
When you say it that way it sounds really sophisticated I would say "dereferencing a return value". :D
Parker and I had a discussion about it a while back regarding Aurora. And I eventually gave in and added the capability to Aurora since it supports typed pointers....
sub main()
{
print( *test() );
while (GetKey() = "");
return;
}
sub test(),string *
{
return &"hello";
}
The discussion was how I felt it really was an unsafe "feature" of languages to allow this since there is no possibility of error checking for a null pointer before the dereference. Imagine a function that returns a pointer to an allocated string, you have to worry about deleting the string or if it is NULL and would end up assigning it to a variably anyway.
Paul.
It's ok I found a solution works for me.
Since you already have INT() I just introduced STRING_(). ;)
However I run into an other casting Q.
What this: "*<STRING>&MyString[0]" good for?
Certainly I did expect a char to get. :o
OPENCONSOLE
DECLARE MyString
DECLARE STRING_(str:POINTER),STRING
DEF S:STRING
S ="HelloString"
PRINT STRING_(MySub001())
PRINT STRING_(&MyString)
PRINT *<STRING>&MyString
PRINT *<STRING>&MyString[0]
PRINT *<STRING>&MyString[1]
WAITCON
END
SUB MySub001(),POINTER
RETURN &S
ENDSUB
_asm
STRING_:mov eax,[esp+4]
retn 4
_endasm
_asm
segment .data
MyString:
db "HeloMemory",0
_endasm