Hello.
I don't know why I am having this problem.
I can't create a String. I'm writting.
String magia="ABC";
And always getting the error in this line: cannot assign initial value to global pointer.
Why is this happening? :undecided:
Regards.
I think it's
string magia="ABC";
AGS is case sensitive. ;) and String does not equal string.
Quote from: Cassiebsg on Wed 22/04/2020 22:00:15
I think it's
string magia="ABC";
AGS is case sensitive. ;) and String does not equal string.
Lowercase
string is a deprecated type, modern code uses
String. Lowercase
string has a hard limit of 200 characters, and cannot be assigned directly at all, you have to use StrCopy function (but have to disable "Enforce new-style strings" option in the General Settings first).
The reason why assignment does not work is one of many limitations of AGS script. Assignment at declaration only works with simple types, such as int, float and char.
If you need to assign a string at startup, declare string unassigned (that creates empty string), then assign it in game_start function.
Quote from: Crimson Wizard on Wed 22/04/2020 22:30:05
Quote from: Cassiebsg on Wed 22/04/2020 22:00:15
I think it's
string magia="ABC";
AGS is case sensitive. ;) and String does not equal string.
Lowercase string is a deprecated type, modern code uses String. Lowercase string has a hard limit of 200 characters, and cannot be assigned directly at all, you have to use StrCopy function (but have to disable "Enforce new-style strings" option in the General Settings first).
The reason why assignment does not work is one of many limitations of AGS script. Assignment at declaration only works with simple types, such as int, float and char.
If you need to assign a string at startup, declare string unassigned (that creates empty string), then assign it in game_start function.
Hello. I think I don't uderstand.
I saw in tutorials Strings declared as example.
String mytext = "Hell";
mytext = mytext.AppendChar('o');
Display(mytext);
Why it doesn't works in that way?
If I declare an empty string then it gives an error anytime I want to change the value returning a
Parse Error. Unexpected magia.What do you mean about I need to assign a String at startup? DO you mean that I need to declare them in Global variables??
Ok, I've checked that if I insert it in Global Variables then it works. Thank you very much.
Quote from: nightmarer on Thu 23/04/2020 07:59:33
Hello. I think I don't uderstand.
I saw in tutorials Strings declared as example.
String mytext = "Hell";
mytext = mytext.AppendChar('o');
Display(mytext);
Why it doesn't works in that way?
These tutorials imply that you put the above code in the
function. It works inside a function, but not outside of it.
Quote from: nightmarer on Thu 23/04/2020 07:59:33
What do you mean about I need to assign a String at startup? DO you mean that I need to declare them in Global variables??
I meant "game_start" function. There's a "game_start" function in global script, where you can initialize anything for game start.
Global Variable work too, but AGS secretly converts them to real script, and AFAIK puts their initialization in game_start too.
Geez, when I finally think I understand AGS scripting, you go and change it. (laugh) Guess, forget everything I wrote above then. (roll)