String concatenation?

Discuss programming in the QuakeC language.
Post Reply
Downsider
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

String concatenation?

Post by Downsider »

I can't find much on this; can you do it in QC? o_O
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: String concatenation?

Post by Baker »

Downsider wrote:I can't find much on this; can you do it in QC? o_O
Cannot be done in standard QuakeC.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

without frik_file, only limited forms of string concatenation exist.
localcmds can be concatinated by just not using any \ns.
same with stuffcmds. so you can 'concatinate' map names and cfg names and stuff if you need to do that.
centerprint (with sprint, and bprint, but those are not interesting) can concatinate multiple input strings, up to the qcvm max of 8 args.
Just add additional clones of the builtin but with additional string arguments (and thus different names). This'll work with any engine/qcc.
full string concatination?... well there are some hacks... like stuffcmding the name cvar and then reading it back again in qc... but those are so hacky and unreliable that they're of no practical use. fun though.

otherwise, do without, or use FRIK_FILE.
Downsider
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Post by Downsider »

I can add my own builtin to do it, though? Didn't even think of that, really. I don't want to do anything I don't have to, including adding frik_file builtins, for the sake of joining strings.

Thanks for the suggestion :)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

the original strcat implementation is somewhat a 1-liner.

void PF_strcat(void)
{
G_INT(OFS_RETURN) = PF_VarString(0) - pr_strings;
}

but such a simple builtin is a real pain to use.
(basically a cross between centerprint and ftos)

A more useful implementation would be to adapt PF_VarString to cycle internal buffers (DP_MULTIPLE_TEMPSTRINGS mandates 16, but does also affect ftos).
lth
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

Post by lth »

FRIK_FILE is the defacto standard, isn't it? Better to just support the standard than come up with your own special way of doing things, if you want other people to be able to mod for your engine.
Downsider
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Post by Downsider »

lth wrote:FRIK_FILE is the defacto standard, isn't it? Better to just support the standard than come up with your own special way of doing things, if you want other people to be able to mod for your engine.
I don't really plan on making an engine so much as a game itself.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Post by ceriux »

is there any type of documentation of FRIK FILE?
MauveBib
Posts: 634
Joined: Thu Nov 04, 2004 1:22 am

Post by MauveBib »

ceriux wrote:is there any type of documentation of FRIK FILE?
dpextensions.qc has a reasonable explanation of how to use it.
Apathy Now!
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Post by ceriux »

MauveBib wrote:
ceriux wrote:is there any type of documentation of FRIK FILE?
dpextensions.qc has a reasonable explanation of how to use it.
ahh thank you! iv been posting about it every time it comes up. thank you for the info!
Post Reply