Archive: Variables and Memory


Variables and Memory
Quick question about variables and memory.

I've seen some references that:
StrCpy $1 1024

Would allocate 1024 bytes to the variable. Is that right?

If so, what's the default number of bytes allocated to any of the variables? Also, is the variable automatically expanded as needed, or is there a certain value it starts out.

For instance, if $Var1 is a 2000 character long string, then is:
StrCpy $4 $Var1
valid?
How about "StrCpy $4 "$4$Var1""?

Also, are variables always strings? What happens in this case:

StrCpy $4 "2000"
StrCpy $2 $4

Is $2 now:
- The String "2000"
- The integer "2000"
- A variable that has 2000 bytes allocated to it?

Oh, and if you want string values should you always use quotes?

Thanks for the help!


Not sure what gave you that idea but StrCpy does what it says; copies a string. In your first example, the value of $1 will be set to 1024.

1024 is the default string length of any variable. If you need more memory, use the 8192 special build.

Stu


"StrCpy $1 1024" does not allocate any memory, it just copies the string "1024" into the $1 variable/register. All variables are 1024 bytes in the default build (You can get a special build with longer strings if needed) Everything is treated as a string, when you use IntOp and IntCmp, the strings are converted to numbers, the operation is performed and in the case of IntOp, the result is converted back to a string and saved in the output variable