Announcement
Collapse
No announcement yet.
string equates versus string literals
Collapse
X
-
Here is code to demo the difference mentioned above:
Code:#COMPILE EXE #DIM ALL MACRO s1 = "lllllllllllllllllllllllll"&"ssssssssssssssssssssssss" $s2 = "rrrrrrrrrrrrrrrrrrrrooooo"&"rrrrrrrrrrrrrrrrrrrrrrrr" FUNCTION PBMAIN () AS LONG LOCAL ii AS LONG, s3 AS STRING, t, t1 AS SINGLE t = TIMER FOR ii = 1 TO 10000000 s3 = $s2 NEXT t = TIMER - t t1 = TIMER FOR ii = 1 TO 10000000 s3 = s1 NEXT t1 = TIMER - t1 ? STR$(t) & " vs " & STR$(t1) & " sec" ' WAITKEY$ END FUNCTION
Leave a comment:
-
-
I understand that string equates are calculated/concatenated at compile time. Is the same true for macros of string literals?
Leave a comment:
-
-
A MACRO may hold a string longer than the permitted maximum length of a string equate.
Leave a comment:
-
-
string equates versus string literals
What are the pros/cons of using macros for string literals versus using string equates?
I understand that string equates are calculated/concatenated at compile time. Is the same true for macros of string literals?
For example, what is the difference between:Code:$appname = "My App" $errmsg = " - Error" MSGBOX ERROR$( ERR),,$appname + $errmsg
Code:MACRO mappname = "My App" MACRO merrmsg = " - Error" MSGBOX ERROR$( ERR),,mappname + merrmsg
Tags: None
-
Leave a comment: