Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Edster

Pages: [1]
1
QB64 Discussion / Re: simple SUB-procedure doesn't work
« on: February 24, 2018, 08:16:55 am »
Now that could be a bug. Give us some time to look into to it.

Edit:
No, not a bug. You're trying to return a string but your function is of type SINGLE. Fix it like this:

Code: QB64: [Select]
  1. FUNCTION Answer$(passedReply() AS STRING)
  2.     Answer$ = passedReply(i)

My bad, if I taken a closer look on wiki then I'd have seen the need for a type suffix for functions.

Thanks for pointing that out to me.


2
QB64 Discussion / Re: simple SUB-procedure doesn't work
« on: February 24, 2018, 07:05:21 am »
I have a similar question so I thought I would tack it to the end of this thread.

DIM reply(i) AS STRING
CALL Answer(reply())
.
.
.
SUB Answer(passedReply() AS STRING)
    PRINT passedReply(i)
END SUB

The above code works just fine ...

DIM reply(i) AS STRING
PRINT Answer(reply())
.
.
.
FUNCTION Answer(passedReply() AS STRING)
    Answer = passedReply(i)
END FUNCTION

This code produces IILEGAL STRING-NUMBER CONVERSION error

However, if 'DEFSTR A' is used, then the above function works fine. The function name needs to be defined as string.

Should FUNCTIONS and SUBS differ in this way? It took me some time to figure out why the FUNCTION wouldn't work.

Pages: [1]