#] #] #] #] ********************* #] #] "$d_Qndfs"'strings TblOfContents.txt' #] #] www.BillHowell.ca 08Sep2022 initial #] #] view in text editor, using constant-width font (eg courier), tabWidth = 3 #] #] #] #] #48************************************************48 #] #] #] #] #] #] #] #] #] #] #**************************** #] #] # Table of Contents, generated with : #] #] # $ grep "^#]" "$d_Qndfs""strings.ndf" | sed 's/^#\]/ /' #] #] # ********************* loaddefs link d_Qndfs 'strings.ndf' Many str [expr, optr, trans]s have direct [lst, ary] equivalents 25Oct2021 half of this file was moved to lists.ndf as it was directly applicable to lists 21Nov2021 moved back here, as redundancy is helpful, and much ,ore clear to programmers (me) +-----+ Setup +-----+ [in, is] for strings : [in, is] normally [o,l] (but can be faultL), check [faultL, null] chr_in_str IS OP chr str - boolean indication of whether chr is in str chrL_anyIn_str IS OP chrL str - boolean indication of whether any of chrA are in strA because chrL_anyIn_str does NOT use grep, it easily handles '$.*/[\]^' characters, chrLL_anyIn_strL IS OP chrL str - boolean indication of whether any of chrA are in strA chrA_anyIn_strA IS OP chrA strA - boolean indication of whether any of chrA are in strA chrA may be [chr, str, ary with chr at top-most level (not str with matching chrs)] will not match for nested parts of [chr, str]A - need a different optr, or upgrade this one chrL_in_str_to_charrepL IS OP chrL str flag_chrs_include - returns charrepL [in, NOT in] use to produce a charrepL by [in,ex]cluding chrSet, eg program [symbol names, optrs, etc] charrepL shows that special chrs are in a [str, line] ?11Oct2021 subL_anyIn_lst IS OP subStrL str - returns true if ANY of subStrL are in str str_in_path IS OP Substr p_name p_hostCmdRslt - boolean indicator that Substr is in file p_name see fileops.ndf str_isOf_chrSet IS OP str chrSet - true if all chrs in str are in chrSet str_option_isOf_chrSet IS OP str options chrSet - returns true if entire string is made up of chrSet use to produce a charrepL by [in,ex]cluding chrSet, eg program [symbol names, optrs, etc] charrepL shows that special chrs are in a [str, line] ?11Oct2021 str_isSpcTabs IS OP Str - test that string is entirely [space, tab] str_isOfSpcTabCrNl IS OP line - tests if a line is all "whitespace" [space, tab, CR, \n] +-----+ [check, fault]s for [chr, str]s : str_checkIs IS OP str - check if str, uses QNial 'isstring' optr strPL_checkIs IS OP strPairL - check if strPairL is a list of pairs, each pair is two strings strPL_checkIsUnique IS OP strPairL - check if strPairL is a UNIQUE list of strPairs [EACH str_checkIs, strOld EACHBOTH ~= strNew, = [cull, pass] strNew] str_checkIs IS OP str - check if str isstring strPL_checkIs IS OP strPairL - check if strPairL is a list of pairs, each pair is two strings +-----+ see 'lists.ndf', NOT suited to 'arrays.ndf'!! split strings [hold, insert, replace, strip] list parts [cut, get, insert, take] - returns split up of strings, many now itm_option_cull_lst +-----+ regular expression (regexpr) [fix, check]s : 29Oct2021 optrs below do not handle [apo, unicode]s str_escape_regExprChrL IS OP str regExprChrL - do NOT use for pre-composed regexprs!! does not handle [apo, unicode]s str_escape_grepSearchChrL IS OP str str_escapeGrepSearchChrL - do NOT use for pre-composed regexprs!! does not handle [apo, unicode]s str_escapeSedSearchChrL IS OP str - do NOT use for pre-composed regexprs!! does not handle [apo, unicode]s str_escapeSedPutChrL IS OP str - do NOT use for pre-composed regexprs!! does not handle [apo, unicode]s fixCheck_grepOptions IS OP grepOptions - check for problematic grep search characters, l if true, fault if not str_fixCheck_regExprChrL IS OP str chrRegExprL - check str for non-escaped problematic regexpr chrs the result is either a strL OR a mix of [fault, str]s, with at least one fault does not handle [apo, unicode]s str_fixCheckGrepSearchL IS OP str - check str for non-escaped problematic grep search chrs does not handle [apo, unicode]s str_fixCheckSedSearchL IS OP str - check strSearch for non-escaped problematic grep chrs does not handle [apo, unicode]s str_fixCheckSedPutL IS OP str - check strPut for non-escaped problematic grep chrs does not handle [apo, unicode]s +-----+ convert strings [to, from] other types : str_to_typ IS OP str - convert a string to a typ, depending on [apo, quote, back-apo, etc] for use in reading tabSepFiles as strings, then converting for now only special treatment for strings (removes apos), rest are executed!! typ_to_str IS OP str - convert a string to a typ, depending on [apo, quote, back-apo, etc] for use in reading tabSepFiles as strings, then converting for now only special treatment for strings (removes apos), rest are executed!! atomL_strSep_cartLinkTo_str IS OP S A - creates one string from a list of atoms, separating each by S ary_atomsTo_strs IS OP A - convert atoms of A to strings (leaves strings as strings) ary_leafsTo_strs IS OP A - every atom is converted to a string, to enable symbolic processing atomStrA_convertTo_str IS OP atomStrAtomStrA - converts atomStrA to a (single) string list each item separated by one blank (Qnial lib), atoms includes [int, real, complex, phr, boolean] str_convertTo_phrL IS OP Str - returns the list of phrases of the words in the string. numL_convertTo_str IS OP numList - changes a list of reals to a string, each real followed by a space str_convertTo_numOrStr IS OP str - if str can be made numeric [boolean, integer, real] do so otherwise wrap with chr_apo then reduce double to single chr_apos, used by csvTable_readFrm_path strL_quoteUnifyForHostCmd IS OP strL - convert strL to a single string of [quote, space]d subStrs usable in QNial expressions for host commands example : ('bear' 'bull' 'pig' 'wolf') -> '"bear" "bull" "pig" "wolf"' +-----+ Unicode [chrs, sub-strings, etc] : many related string optrs are in lists.ndf str_to_unicodeL IS OP str - convert a string to a list of unicode characters (not unicode # sequences) str_cutUnicodeBy_chrL IS OP str chrUnicodeL - cuts str into words by removing chrL (unicode) str_getUnicode_chrL IS OP str chrL - cuts str into words by geting chrL (unicode) 18Oct2021 NEEDS FIXING!!!! +-----+ string cleanup str_wrapWithApos IS OP str - convert str to string with apostrophes, or if not a string return str_wrapWithAposAddTab IS OP str - convert str to string with apos & tab, or return input str_getLastNonSpcTabBefore_posn IS OP str posn - retrieves the last non-whitespace character chrAsStr_toUpperCase IS OP chr - convert a character to upper case, chrAsStr is compared to standard ASCII lower case, which is a unique (as in culled) set of chrs non-Unicode-capable coding chrAsStr_toLowerCase IS OP chr - convert a character to lower case, (non-Unicode) str_toUpperCase IS OP str - convert all letters in a string to upper case, (non-Unicode) str_toLowerCase IS OP str - convert all letters in a string to lower case, (non-Unicode) str_capitalize1stChrOnly IS OP str - capitalize 1st char of str, rest small, watch out for acronyms!, (non-Unicode) str_capitalize1stChrEachWord IS OP str - capitalise 1st char of each word, rest small, watch out for acronyms!, (non-Unicode) set_globalChrSets IS OP chrSet1 chrSet2 - redefine global chrSets[1,2] chrSets[1,2] are defined as globals to enhance the efficiency of chrSet operators!! note that one can link multiple charSets for g_chrSet[1,2], but must be in order, same shape chrAsStr_changeChrSet IS OP chrAsStr - return corresponding chrAsStr in newChrSet, or current chrAstr if no correspondance, must preset globals g_chrSet[1,2] 21Nov2021 because each chr is a string, I think this can handle unicode? chrL_changeChrSet IS OP chrL - change chrsAsStrs in chrL from g_chrSet1 to g_chrSet2 str_changeChrSet IS OP str oldChrSet newChrSet - change every oldChrSet in str to newChrSet str_swapChrSets IS OP str chrSet1 chrSet2 - change all chrSet1 in str to chrSet2, and visa-versa strURL_clean IS OP str - change all chrSet1 in str to chrSet2, and visa-versa str_stripAllSpacesQ IS OP Str - standard QNial library str_stripSpacesAll IS OP str - removes ALL spaces from a string str_removeExtra_SpcTab IS OP Str - removes [leading, multiple-sequence, trailing] SpcTabs +-----+ Words - are NOT "corrupted" by [search-&-replace, sed, other] replacements (eg QNial operator names) note that the sed -w option does better than my simple coding str_chrL_cutTo_wordL IS OP str chrL - returns the list of words in a string, chrL are wordChrs word_findPosnIn_str IS OP wrd str wType cList - returns a list of positions of a word in a string word_putIn_str IS OP sOld sNew str chrL - change word throughout string (safe for variables) +-----+ [self-return, file embedded] executables - embedded executables : markup language (eg html) coding in pre-processed text file '[#!: ' is for full-line embeds; '[#=; ' is for embeds within a line a bit like javascript etc, but not "live", just for "compilation" strL_to_strExecuteMirror IS OP strL - convert strL to a self-return executable (eg for writefile) strLL_to_strExecuteMirror IS OP strLL - convert strLL to a self-return executable (eg for writefile) str_executeEmbeds IS OP str phraseValueList - execute embeds in line, return a str '[#!: ' is for full-line embeds; '[#=; ' ' ;=#]' are for embeds within a line +-----+ Test comment optrs (antique stuff, retained in case...) : write_testStr IS OP t_name t_input t_standard t_result - means of testing string answers test_comment IS OP t_name t_input t_standard t_result - means of testing string answers write_test_head IS OP t_name t_input t_standard t_result - output header for test? +-----+ Date-related [timestamps, strings, waits] : time conversions t_year_to_millisecs := 365.25*24*60*60*1000 ; t_year_to_secs := 365.25*24*60*60 ; year_to_minutes := 365.25*24*60 ; year_to_hours := 365.25*24 ; year_to_days := 365.25 ; year_to_weeks := 52.1786 ; year_to_months := 12.0 ; now_secondsFrom01Jan1970 IS UnixMilliSecFrom01Jan1970_to_yFrac IS OP unixTimeDate secFrom01Jan1970_to_yFrac IS OP unix dateTime_to_UnixSecFrom01Jan1970 IS OP timeStamp sec_from_timestamp IS hhmmss_to_seconds IS OP hhmmss sec_to_hhmmss IS OP secs hhmmss_elapsed IS OP t_start_sec - elapsed time from a given t_start_sec waitSecs IS OP secs - uses Linux sleep, best to simply use host 'sleep 1s' ; wait_hhmmss IS OP secs - Linux sleep, converts hhmmss to ss waitLocal IS OP hhmmss - Linux sleep, converts hhmmss to ss waitVideo IS OP t_voice - used for video production software day_2digit IS OP day - day of month in 2-digit format days_in_month IS OP month - days in monthNumber, (jan = 1, not zero!) daysInYearTo_monthStart IS OP month - days in year up to start of month (not incl 1st day of month) YYMMDD_to_days IS OP YYMMDD - days from (20)000101 to (20)YYMMDD used for calculating days differences when YYMMDD all >= 21st century backTime IS OP YY MM day hur min minLess hurLess dayLess - calculate dateTime using Less values month_name IS OP monthNumStr - given 2-digit month number as text, returns 3 letter month name month_number IS OP month_name - given 3 letter month name , returns month's 2-digit number mmddyyyyStr_chrSepP_to_ddmmyyyStrL IS OP mmddyyyy chrSep - res ipsa loquitor ddMmmYyyyStr_to_yearFrac IS OP ddmmmyyyy - res ipsa loquitor, approximate (eg 365 days/year) emlDate_to_YYMMDD IS OP emlDate warning : depends on which unix date format!! eg uses 'Date: Wed, 7 Mar 2018 07:01:01 -0700' emlDate_to_YYMMDD_HHMMSS IS OP emlDate timestamp_YYMMDD IS - returns timestamp in obvious format timestamp_YYMMDD_HM IS - returns timestamp in obvious format timestamp_YYMMDD_HMS IS - returns timestamp in obvious format timestamp_to_YYMMDD_HMS IS OP sys_timestamp - format timestamp eg "dayOfWk MMM DD hh:MM:SS MST YYYY" timestamp_YYYY_MMM_DD_HH_MM_weekDay IS - return current timestamp as strList timestamp_DDMMMYYYY IS - returns timestamp in obvious format timestamp_DDMMMYYYY_HMS IS - returns timestamp in obvious format YYMMDD_to_DDMMMYYYY IS OP YYMMDD - converts dateStr format from fileOrder to manReadable YYMMDD_to_DDMMMYY IS OP YYMMDD - converts dateStr format from fileOrder to manReadable sleep_debug IS OP n_operator fname t_start t_wait - sleeps depending on timestamps