QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: madscijr on December 22, 2020, 12:24:30 pm
-
I'm getting a "type mismatch" error on this line:
I can probably use a variable instead, but was just wondering why this is returning an error and if there is any error in my notation that could be slightly altered to make it work?
Thanks...
-
CONST doesn't handle string functions, I guess. It's a separate EVAL sub that Steve made to do CONSTs.
Work around is DIM SHARED that thing.
-
@madscijr @bplus
I'd change this to a function so that it is similar to a CONST in that you aren't able to change the value at runtime. DIM SHARED won't prevent you from changing it accidentally.
-
Yeah that's another way!
-
Thanks guys for your answers. I like the solution of using a function, it's simple but flexible.
-
I think coders overuse CONST. I seldom find a use for it.
Pete
-
Thanks guys for your answers. I like the solution of using a function, it's simple but flexible.
You are very welcome. Glad to be of assistance.
-
Hi
just to be clear this code doen't work in Qbasic
as soon as you RUN the program you get an error runtime!
Moreover this code takes no error
but as soon as you add this string to another string , you got the mismatch error!
-
I'm getting a "type mismatch" error on this line:
I can probably use a variable instead, but was just wondering why this is returning an error and if there is any error in my notation that could be slightly altered to make it work?
Thanks...
I think the type mismatch is saying that you can't use (and don't need to) the $ sign here. A CONST can contain strings or numbers.
It just seems that CONST does not like control characters in a string. I never use CONST, I just tested something, and peeked into the wiki: https://www.qb64.org/wiki/CONST (https://www.qb64.org/wiki/CONST)
-
I think the type mismatch is saying that you can't use (and don't need to) the $ sign here. A CONST can contain strings or numbers.
It just seems that CONST does not like control characters in a string. I never use CONST, I just tested something, and peeked into the wiki: https://www.qb64.org/wiki/CONST (https://www.qb64.org/wiki/CONST)
Nope, still broken:
print "hello" + crlf
+ crlf
+ crlf
+ crlf
+ crlf
+ crlf
+ crlf
+ crlf
-
CONST has very limited native support for what it does. When I wrote my math processor, I plugged it in to handle most math operations for us, but I never wrote it to process STRING manipulation. We don't calculate CHR$, LEFT$, RIGHT$, MID$, STR$, or VAL type commands at all. (At least, not as far as I'm aware. If so, whatever it is is just a special case that Galleon accounted for back before version 0.9 when I expanded CONST support.)
Easiest solution here is either DIM SHARED, or to create a function for CRLF$.