Why isn't my character array working?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Why isn't my character array working?

Post by Nash »

Code: Select all

#include "zcommon.acs"

str char[4];

Script 1 Open
{
    char[0] = "w";
    char[1] = "h";
    char[2] = "a";
    char[3] = "t";
    print(a: char);
}
 
Nothing gets printed. Doing

Code: Select all

str char[4] = { "w", "h", "a", "t" };
 
doesn't work either.

Oh and it has nothing to do with Enter/Open, and whether I use print or printbold. All combinations don't work. Also, I know it's not working because when I open the console, the text that gets logged into it is empty (with the 2 red bars at the top and bottom of the text indicating that empty text is being logged into the console).
User avatar
Isle
Posts: 687
Joined: Fri Nov 21, 2003 1:30 am
Location: Arizona, USA

Re: Why isn't my character array working?

Post by Isle »

you need to use characters, those are still strings. you use characters by putting ' around them IE: 'x'
carlcyber
Posts: 163
Joined: Thu Jan 27, 2005 1:04 am

Re: Why isn't my character array working?

Post by carlcyber »

Looks like a: takes a character array instead of a string array. The difference is when reading them as numbers, it would be

Code: Select all

str char[4] = { "w", "h", "a", "t" }
str char[4] = { 0, 1, 2, 3 } 
That's the index in the string table instead of the characters in the string.

To correct this, use characters.

Code: Select all

int char[4] = { 'w', 'h', 'a', 't' } 
Numbers 0, 1, 2 and 3 in ascii table are unprintable characters.
This thread discussed your question as well.
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Why isn't my character array working?

Post by Nash »

Whoa I totally forgot that they need to be enclosed with ' instead of ". Last time I worked with this thing was like in 2010. Cheers!
Locked

Return to “Editing (Archive)”