Added REPEAT\$ Function

This commit is contained in:
AIR 2022-12-10 23:27:31 -05:00
parent e08e4035cc
commit 20e4c9aa6c
3 changed files with 14 additions and 6 deletions

View File

@ -33,7 +33,7 @@ ENDSELECT
ENDSUB ENDSUB
ENUM ENUM
EXIT EXIT
FALSE FALSE \nREGEX
FOR FOR
FORMAT$ FORMAT$
FUNCTION FUNCTION
@ -57,12 +57,11 @@ NEXT
NL NL
NOT NOT
OR OR
PRINT
PRINTNL PRINTNL
PTR PTR
REGEX
REGMATCH REGMATCH
REGQUERY REGQUERY
REPEAT$\nSPLIT \nPRINT
REPLACE$ REPLACE$
RETURN RETURN
REVERSE$ REVERSE$
@ -71,7 +70,6 @@ RTRIM$
SAVEFILE SAVEFILE
SELECT SELECT
SHORT SHORT
SPLIT
SPLITPATH$ SPLITPATH$
STEP STEP
STR$ STR$

View File

@ -8,14 +8,13 @@ LOADFILE$ (CSTRING N)
LTRIM$ (CSTRING s) LTRIM$ (CSTRING s)
MCASE$ (CSTRING S) MCASE$ (CSTRING S)
MID$ (CSTRING s, INT start, INT length) MID$ (CSTRING s, INT start, INT length)
PRINT (CSTRING A="")
REGEX (CSTRING src, CSTRING query) REGEX (CSTRING src, CSTRING query)
REPEAT$ (const std::string &str, unsigned int times)\nSPLIT (CONSTANT CSTRING input, CONSTANT CSTRING separators, BOOL remove_empty)\nPRINT (CSTRING A="")
REPLACE$ (CSTRING subject, CONSTANT CSTRING& search, CONSTANT CSTRING& replace) REPLACE$ (CSTRING subject, CONSTANT CSTRING& search, CONSTANT CSTRING& replace)
REVERSE$ (CSTRING src) REVERSE$ (CSTRING src)
RIGHT$ (CSTRING s, INT length) RIGHT$ (CSTRING s, INT length)
RTRIM$ (CSTRING s) RTRIM$ (CSTRING s)
SAVEFILE (CSTRING src, CSTRING fname) SAVEFILE (CSTRING src, CSTRING fname)
SPLIT (CONSTANT CSTRING input, CONSTANT CSTRING separators, BOOL remove_empty)
SPLITPATH$ (CSTRING FPATH, INT mask) SPLITPATH$ (CSTRING FPATH, INT mask)
TRIM$ (CSTRING s) TRIM$ (CSTRING s)
UCASE$ (CSTRING str) UCASE$ (CSTRING str)

View File

@ -19,6 +19,7 @@ DECLARE FUNCTION VECTOR<CSTRING> SPLIT (CONSTANT CSTRING input, CONSTANT CSTRING
DECLARE SUB PRINT (CSTRING); DECLARE SUB PRINT (CSTRING);
DECLARE SUB SAVEFILE(CSTRING src, CSTRING fname); DECLARE SUB SAVEFILE(CSTRING src, CSTRING fname);
DECLARE FUNCTION CSTRING REGEX (CSTRING src, CSTRING query); DECLARE FUNCTION CSTRING REGEX (CSTRING src, CSTRING query);
DECLARE FUNCTION CSTRING REPEAT$ (const std::string &str, unsigned int times);
FUNCTION CSTRING REGEX (CSTRING src, CSTRING query) { FUNCTION CSTRING REGEX (CSTRING src, CSTRING query) {
CSTRING result; CSTRING result;
@ -263,4 +264,14 @@ FUNCTION CSTRING GRAB$(CONSTANT CSTRING &src, CONSTANT CSTRING &start, CONSTANT
DIM AS size_t term = src.find(stop); DIM AS size_t term = src.find(stop);
return src.substr(end, (term - end)); return src.substr(end, (term - end));
}
FUNCTION CSTRING REPEAT$ (const std::string &str, unsigned int times) {
std::stringstream ss;
for(unsigned int i=0; i<times; ++i) {
ss << str;
}
return ss.str();
} }