In my function, a wide string is returned by calculating the parameter. but
```
Function routine(array() As Integer) As WString
do something
End Function
```
says
```
a.bas(1) error 28: Expected pointer in 'Function routine(array() As Integer) As WString'
```
so how to fix it? Thanks
return wide string from function?
Re: return wide string from function?
wstring ptr?
Re: return wide string from function?
You can return a WString (or a ZString) from a function only by pointer or by reference:
Function routine(array() As Integer) As ZString Ptr
or
Function routine(array() As Integer) Byref As ZString
Function routine(array() As Integer) As ZString Ptr
or
Function routine(array() As Integer) Byref As ZString
-
- Posts: 805
- Joined: Jul 26, 2018 18:28
Re: return wide string from function?
You can also return your self-written UString type like this (строка 369):
https://github.com/XusinboyBekchanov/My ... g.bas#L369
ZString Ptr has a String type, but WString Ptr has no such type. There are many implementations of this type on this forum: DWString, CWStr, UString and etc.
https://github.com/XusinboyBekchanov/My ... g.bas#L369
ZString Ptr has a String type, but WString Ptr has no such type. There are many implementations of this type on this forum: DWString, CWStr, UString and etc.
Re: return wide string from function?
I don't know if this will work in your location oyster.
Code: Select all
shell "CHCP 65001"
cls
Function routine(array() As Integer) As WString ptr
static as wstring * 100 p
var q=!"\x53\x69\x7a\x65\x20\x6f\x66\x20\x74\x68\x65\x20\x61\x72\x72\x61\x79\x20\x3d\x20"
p= q+wstr(ubound(array)-lbound(array)+1)
return @p
End Function
function finish() as wstring ptr
static as wstring * 100 f=!"\x50\x72\x65\x73\x73\x20\x61\x6e\x79\x20\x6b\x65\x79\x20\x74\x6f\x20\x66\x69\x6e\x69\x73\x68\x20\x2e\x20\x2e\x20\x2e"
return @f
end function
dim as integer b(1 to 400)
print *routine(b())
print *finish()
sleep
Re: return wide string from function?
thank you guys