FTE String question

Discuss programming in the QuakeC language.
Post Reply
ratbert
Posts: 37
Joined: Thu Nov 19, 2009 3:47 pm

FTE String question

Post by ratbert »

FTE STRINGS WIKI
================

float(string str, string sub, float startpos) strstrofs = #221; // returns the offset into a string of the matching text, or -1 if not found, case sensitive
float(string str, float ofs) str2chr = #222; // returns the character at the specified offset as an integer, or 0 if an invalid index, or byte value - 256 if the engine supports UTF8 and the byte is part of an extended character
string(float c, ...) chr2str = #223; // returns a string representing the character given, if the engine supports UTF8 this may be a multi-byte sequence (length may be more than 1) for characters over 127.
string(float ccase, float calpha, float cnum, string s, ...) strconv = #224; // reformat a string with special color characters in the font, DO NOT USE THIS ON UTF8 ENGINES (if you are lucky they will emit ^4 and such color codes instead), the parameter values are 0=same/1=lower/2=upper for ccase, 0=same/1=white/2=red/5=alternate/6=alternate-alternate for redalpha, 0=same/1=white/2=red/3=redspecial/4=whitespecial/5=alternate/6=alternate-alternate for rednum.
string(float chars, string s, ...) strpad = #225; // pad string with spaces to a specified length, < 0 = left padding, > 0 = right padding
string(string info, string key, string value, ...) infoadd = #226; // sets or adds a key/value pair to an infostring - note: forbidden characters are \ and "
string(string info, string key) infoget = #227; // gets a key/value pair in an infostring, returns value or null if not found
float(string s1, string s2, float len) strncmp = #228; // compare two strings up to the specified number of characters, if their length differs and is within the specified limit the result will be negative, otherwise it is the difference in value of their first non-matching character.
float(string s1, string s2) strcasecmp = #229; // compare two strings with case-insensitive matching, characters a-z are considered equivalent to the matching A-Z character, no other differences, and this does not consider special characters equal even if they look similar
float(string s1, string s2, float len) strncasecmp = #230; // same as strcasecmp but with a length limit, see strncmp
//string(string s, float start, float length) substring = #116; // see note below for why this is commented out


Got a question on using FTE strings specifically with #225. One thing is throwing me on how to use it. I see the values that go into the function per say with "float char" = number characters
to pad, "string s" = string to you want to pad, "..." = ??????????????????? It the three periods that are in last position that is throwing me?
Always thought you had to have some kind declared variable type/name in QC.



So I thinking that QC code as follows (rough idea)
--------------------------------------------------------------------------
void(string instring) somefunction =
{

local string tstring1;

tstring1 = strpad(10, instring) // pad string with 10 spaces on end

centerprint (other, tstring);


}
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

an elipsis within function definitions in C-like programming languages denote 'variable arguments'. Typically in QuakeC that means a list of strings which will be concatinated (note that a builtin cannot accept more than 8 args).

In other words, the three dots means that it has an strcat built in, if you wish to use it.
Post Reply