#] #] ********************* #] "$d_Qtest"'QNial [symbol, arg] changes/Qndfs optr symbol changes - develop tests.txt' - #] develop tests for system to change optr names for [clarity, consistency] # www.BillHowell.ca ?Sep2021 initial? # see also "$d_Qtest"'QNial [symbol, arg] changes/Qndfs optr symbol changes - tools, ToDos.txt # directory "d_Qndfs"'QNial [symbol, arg] changes/' - optrs etc to change symbols across system # '0_QNial symbol notes.txt' # '1_QNial symbol plan.txt' # '3_QNial symbol - draft listings to use for changes.txt' # testing optrs : # for all QNial programming : # "$d_Qtest"'QNial test optrs.ndf' # "$d_Qtest"'QNial test notes.txt' # for the project to revamp all my QNial symbol [name, arg[order, number]] : # "$d_Qtest"'QNial [symbol, arg] changes/' # 'Qndfs optr symbol changes - develop tests.txt' # 'Qndfs optr symbol changes - tools, ToDos.txt' # other .ndf test [files, subDirs] # pinn_chr_writeScreen_strLChrUnbalanced (link d_Qndfs 'QNial optr symbol changes.ndf') `( # QNial_user_symbol_changes_backup IS - pth_backupDatedTo_zArchive of "core" ndfs for a project # QNial_user_symbol_changes_loaddef_core IS - loaddef core working files for this project 24************************24 24************************24 #] Table of Contents : # $ grep "^#]" "$d_Qtest"'QNial [symbol, arg] changes/Qndfs optr symbol changes - develop tests.txt' | sed 's/^#\]/ /' # ********************* "$d_Qtest"'QNial [symbol, arg] changes/Qndfs optr symbol changes - develop tests.txt' for [clarity, consistency] Table of Contents : +-----+ "Guide" content moved to 'Qndfs optr symbol changes - tools, TableOfContents, ToDos.txt' - too long, hard to reference here +-----+ Work log : 10Nov2021 build search-replace lists in "$d_Qndfs"'QNial symbolOldNew [lists, strings, fileops].txt' 06Nov2021 'file_ops.ndf' - upgrade optrs pth_replace_str IS OP pth strOld strNew flag_backup - res ipsa loquitor defaults to pth_backupDatedTo_zArchive str_eachChrIs_white IS OP Str - boolean list of text - l for whitespace, o for other subStr_split_str IS OP str subStrOld subStrNew - splits str at each subStrOld replace subStrOld with subStrNew subStr_split_str IS OP str subStrOld subStrNew - splits str at each subStrOld replace subStrOld with subStrNew str_extractBetween_StrtEnd IS OP str strStrt strEndr - extracts sub-strings between [strStrt,strEndr] screws up! - needs fixing... DUPLICATE OF str_takeBetween_strFrontEnd? test_simple1Arg IS OP simple1Arg - really simple test of operators with 1 argument test_simple2Arg IS OP simple2Arg - really simple test of operators with 2 arguments test_simple3Arg IS OP simple3Arg - really simple test of operators with 3 arguments pold_exists IS OP pold - returns true if pold exists, not for directories pnew_exists IS OP pnew - returns true if pnew exists, will NOT be over-written if it exists not for directories povr_exists IS OP povr - returns true if povr exists, WILL be over-written if it exists subStr_in_str IS OP Substr Str - simple indication of whether a Substr is in str subStrL_anyIn_str IS OP subStrL str - returns true if ANY of subStrL are in str +-------------------+ Position of [chrs, sub-strings, etc] : chr_posnLIn_str IS OP chr str - posnL of chr in Str, or null subStr_posn1stChrIn_str IS OP subStr str - 1st posn of 1stChr of Substr in Str, or null?? a single position is returned as a solitary so it can be used in subsequent EACH expressions etc.... subStr_posnLLChrAllIn_str IS OP subStr str - posnLL of all itms of Substr in Str, or null a single position is returned as a solitary so it can be used in subsequent EACH expressions etc.... subStrL_posn1stChrIn_str IS OP subStr str - all subStrL 1s chr positions, for EACH subStrL, in str returns initial 1st char positions for each subStr, or a [null, error] subStrL_posnLLChrAllIn_str IS OP subStr str - all subStr positions, for EACH subStr, in Str just returns initial char positions for each subStr, or a [null, error] +-------------------+ [add, take, replace] [chr, subStr] - return single string : aryList_extractMulplicate_subArys IS OP selectOp strL - find mulplicates in strL by selectOp see d_Qroot 'setup.ndf' - works with strLs, or any array type (in form of list) chr_prepad_str IS OP str len chr - example: zero-prepadding numbers to get constant str length if str_length >= len, returns str, often used for chr_prepad_str_to_length IS OP str chr length - prepads str with chrs to get length chr_postpad_str_to_length IS OP str chr length - postpads str with chrs to get length str_subStrs_takeLenMatches_subStrPairs IS OP str subStrs - return (str = link subStrPairs) str_takeBetween_StrtEnd IS OP str strStrt strEndr - take between strFront & strEndr (list) strL_takeOddNum IS OP strL - useful list for [terminal, file] output subStr_insertBetweenThenLink_strL IS OP subStr strL - link (insert subStr between strL items) str_repeatNtimesTo_strL IS OP str n - repeats str n times str_replace_subStr IS OP str subOld subNew - substitutes sub_new for sub_old in str strL_replace_str IS OP strL subOld subNew - replace all subStrOld by subStrNew in strL str_replaceAll_strOld IS OP str strOld strNew - strOld is replaced by strNew in str str_takeBefore_subStr IS OP str subStr - take to the 1st occurence of subStr, else return str ? no good!!! str_takeAfter_subStr IS OP str subStr - take after the 1st occurence of subStr, else return null? ? no good!!! winID_copyAllTextTo_poutNew IS OP winID pname - copy text of webPage and pre-pend to file see 'windows [open, close, ID, title], [get,set,move] cart [posn,size].ndf' +-------------------+ split[Separate,[At[Front,End]], ] - return list of strings : subStr_splitSeparate_str IS OP subStr str - subStr [splits str, separate] subStrL_splitSeparateRecurse_str IS OP subStr str - recursively separate str where subStr occurs, subStr separate subStr_splitAtEnd_str IS OP subStr str - split str where subStr occurs, subStr @end of each split subStr_splitAtFront_str IS OP subStr str - splits str at each point that subStr occurs subStr in strLOut combined with next item subStr_splitAtFront_strL IS OP subStr str - splits str at each point that an item of subStrL occurs each subStr in strLOut as a separate item str_splitLftRgtTo_midIndxs_to_strL IS OP str strLft strRgt - split str, return [indxs, strLst] +-------------------+ [cut, keep, strip] [chr, subStr, width] - return string lists : chr_cut_str IS OP str chr - cut a string at each chr, omitting chr, returns a LIST! chr_cut_strL IS OP str chrL - cut a string at each chr, omitting chr, returns a LIST! chrL_cutEACH_strL IS OP chrL strL - cut each strL by each chrL, omitting chrL note that a character list is just a string, but I use "chrL" to emphasize that each chr cuts subStr_cut_str IS OP subStr str - splits str at each point that subStr occurs, omit subStr width_cut_str IS OP width str - cut str into strings of equal width, with leftover broken on word boundaries str_keep_chrL IS OP str chrL - cut a string at each chr, omitting chr, returns a LIST! strL_keep_chrL IS OP strL chrL - cut each strL by including chrL, omitting non-chrL, str_endStripChrsOrAddSpaces_to_width IS OP str1 sw - cut string to fixed length, or pad end with spaces to make length str_strip_chr IS OP chr str - remove chr from string, standard QNial library str_strip_subStr IS OP str subStr - removes subStr from str 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 subAryN_find1stIn_ary IS OP sub aryN - addr of 1st subArray in array, error if not found find_Howell IS subAryN_find1stIn_ary - legacy optrName, don't use any more! subL_in_lst IS OP subL lst - simple indication of whether a subL is in lst subLL_anyIn_lst IS OP subLL lst - returns true if ANY of subLL are in lst +-----+ Individual test set : setStr_dir_test IS OP testTyp setStr dir testDataL - run a set of tests, saveDated to dir 01Nov2021 [fault, check]s generic code - create basic system check_argL IS OP optrPhr argPhrL argL - special checks for optrPhr, generic checks for args check_pthOrStdout IS OP pthOrStdout - returns EITHER [result, fault] build_userWkspSymbol IS - create [noun, adjective, verb, adverb, checkArg, etc] lists pinn_strL_options_grepTo_pout IS OP pinn grepSearchL grepOptions pthOrStdout - (pthOrStdout = 1) for stdOut, assumes that special grepSearchChrL have been escaped, if needed resultFaultL_separate IS OP resultFaultL - res ipsa loquitor lst_splitAtFront_subLstL IS OP lst subLstL - splits lst at each point that an item of subLstL occurs 04Nov2021 corrupted? loaddefs link d_Qtest 'strings/strings- tests.ndf' 04Nov2021 many more tests converted to current approach check_examples IS OP strL_name - to facilitate [setup, calc, display, check] of examples userQndfs_extract_checks IS OP qndfPthL - gather all qndfPthL check declarations (IS OPs) (concept only) QNial_user_symbol_changes_loaddef_postStartup IS - loaddef working files post-startup core str_head_midl_tail IS OP str - separate str into parts given end substrings 20Nov2020 this is defunct, I think 28Oct2021 opl_sed item, userSymbol grammar list "$d_Qtest"'Qndfs optr symbol changes - tools, TableOfContents, ToDos.txt' - tools elated to 'Qndfs optr symbol changes - develop tests.txt' link d_Qndfs 'QNial userWkspSymbol header.ndf userWkSpcSymNameL := standard symbol [name, [pre, post]fix, [adverb, ]] in the user workspace, with [grammar, syntax] to build symbol names bug hunt : pinn_strL_options_grepTo_pout - grep search for each string in strL, for all paths in pthL : pinn_strL_options_grepTo_pout IS OP pinn strL grepOptions pout - pinn_strL_options_grepTo_pout_output IS OP pinn strL grepOptions - pinn_strL_options_grepTo_pout_test IS OP pout str_checkGrepSearchChrs IS OP strSearch - check str for problematic grep search chrs str_checkSedSearchChrs IS OP strSearch - check strSearch for problematic grep chrs str_checkSedReplaceChrs IS OP strReplace - check strReplace for problematic grep chrs >> updated lists of special chrs for all the above >> integrated backslash modifications pthL_replace_wordL IS OP pthL wordOldNewL flag_word flag_backup - change [str, word]L each pthL uses sed, therefore cannot simply handle sed restricted : search $.*/[\]^ replace &\/\n strSedReplace_escapeProblemChrs IS OP strSedReplace - do NOT use for pre-composed regexprs!! 27Oct2021 pinn_strL_options_grepTo_pout[, _output, _test] 24Oct2021 adapt [pth_find_latestZarchive, pZarchive_restore, pth_backupDatedTo_zArchive] 24Oct2021 upgrade greatly : pth_typ_exists[, _test], created : pthL_faultL_resultL_shortenTo_Codes IS OP pthL resultLL faultL - for fairly general use in _tests pthL_typ_check IS OP pthL typ - check if all pthL are legitimate paths of the same type typ 22Oct2021 pthL_strL_options_grepTo_pout IS OP pthL strL grepOptions pout - search for strL in pthL "$d_Qndfs"'QNial symbol names - computability.txt' - [typeCheck, consistency, etc] www.BillHowell.ca 22Oct2021 initial pth_get_optrDescL IS OP pth - find optrDescL in path, recursive find user [op,expr] optrDescL is a list of operator symName descriptions, pth is normally a QNial ndf file descriptions are the one-line comments that precede declarations pth_typ_checkExists must be done BEFORE calling this optr pth_get_exprDescL IS OP pth - find exprDescL in path, recursive find user [op,expr] exprDescL is a list of expression symName descriptions, pth is normally a QNial ndf file descriptions are the one-line comments that precede declarations pth_typ_checkExists must be done BEFORE calling this optr This will "drag in" operators, when there are two or more spaces between "IS" and "OP" 21Oct2021 [new, modified] code for 'QNial setup.ndf' Moved optrs in incomplete state (but ease of reference) [qNial_get_userSymLL, userWkSpc_extract_symLL, pthL_existsCheck, strL_check IS OP strL, strOldNewL_pairCheck, options_findGrepSedPhr_regexprCheck, searchReplaceL_findGrepSedPhr_regexprCheck] 21Oct2021 clean up 'QNial setup[, header].ndf', upgrade several Table of Contents" for easier tracking "$d_Qtest""fileops/file_ops- development.txt" 21Oct2021 these old optrs are really NOT the way to go! They were removed from 'file_s.ndf' : 20Oct2021 move optr[declaration, test]s t"standard files" pth_backupDatedTo_zArchive_output IS OP i_test pinn - common optr to execute & ouput diff to log file pth_backupDatedTo_zArchive IS OP pth - SAFE WORKING backup file to a z_Archive dated today (create?) pth_backupDatedTo_zArchive_test IS - res ipsa loquitor pth_exists_test IS - res ipsa loquitor, types = [p_ = path, d_ = dir]cart[old, new] HDdrive_mountCheck IS OP dir_to_test - checks if hard drive is mounted (dumb coding?) pthL_strL_grepOptions_linesTo_pout_test IS - search strL in pathL, return lines that hit 19Oct2021 pth_backupDatedTo_zArchive_test - revamp with standard test files! pth_backupDatedTo_zArchive IS OP pth - SAFE WORKING backup file to a z_Archive dated today (create?) pth_typ_exists IS OP pth typer - returns true if a [dir, pth] exists, or can be created pth_size IS OP pth - returns the filesize pth_size_human IS OP pth - returns the filesize in human-readable [T, GM, k]-bytes 18Oct2021 pth_size_test, pth_backupDatedTo_zArchive - fix!! pth_backupDatedTo_zArchive_test IS - res ipsa loquitor pZarchive_restore IS OP pth - restore most recent pth_backupDatedTo_zArchive of a file, retain the backup pth_typ_exists_test IS - I revamped to provide footnote long form of error, all tests OK 18Oct2021 pth_isEmpty[, _test] "p_ovr typer in pth_exists works -> prevents overwrite unless "p_ovr is specified but what will effect on legacy code be? 17Oct2021 path_[exists, isEmpty] continued...tests pth_exists_test IS - res ipsa loquitor 16Oct2021 further symName cleanups... pth_exists IS OP typer path - returns true if a [directory, path] exists, or can be created pth_retrieve_subDirFname IS OP pth dirBase - returns (subDir fname) from a path 17Oct2021 Too many optrs in many files have been affected - rely on mass opName replacnts! path_isEmpty IS OP path - returns l if true and o if false path_exists IS OP typer path - returns true if a [directory, path] exists, or can be created pth_retrieve_subDirFname IS OP pth dirBase - returns (subDir fname) from a path 15Oct2021 path_getOptrExpr_declDescLines[,_[output, test]] path_getOptrExpr_declDescLines IS OP path - find user [op,expr]cart[Decl,Desc]s in path boolean IS OP BoolChrIntPhrStr - convert [chr, str, int] to boolean 14Oct2021 path_getOptrExpr_declDescLines[,_[output, test]] boolean.ndf boolA_cut_ary IS OP boolA ary - extract an ary (array) of subArys from booleanL array, table.ndf atomA_restructSameAs_ary IS OP atomA ary - only effective for top-most structure of ary strings.ndf strL_cutBy_chrL IS OP strL chrL - cut each strL by all chrL, omitting chrL, lists only fileops.ndf pZarchive_restore IS OP path - restore most recent path_backupDatedTo_zArchive of a file, pathL_replace_wordL IS OP pathL wordOldNewL flag_word flag_backup - change [str, word]L each pathL pathL_replace_strL IS OP pathL wordOldNewL flag_backup - change strL each pathL pathL_strL_grepOptions_linesTo_pout IS OP pathL strL grepOptions pout - search strL in pathL [first, stupid] approach! it became clear a day or two later that the QNial 'see "symbol' is perfect! 11Oct2021 opPhr_ary_LEAFreplaceWith_aryStatic 11Oct2021 continue [test, new, revise old] [strings, fileops, array, boolean] cart [optr, test]s 07Oct2021 NEW test format for all Qndfs_optr_symbol_changes_test 07Oct2021 further work on optr_names_raw, adapt some optrs word_replaceIn_path IS OP sOld sNew p_inn cList flag_backup - pathL_replace_wordL IS OP pathL wordOldNewL flag_backup d_backup - pathL_replace_wordL IS OP pathL wordOldNewL flag_word flag_backup - 05Oct2021 '210929 Qndfs optr symbol changes.ndf' - change optr names for [clarity, consistency] ??Sep2021 list of optr name changes planned 29Sep2021 change [symbol, arg]s of [strings, fileops, QNial setup].ndf 24************************24 #] +-----+ #] "Guide" content moved to 'Qndfs optr symbol changes - tools, TableOfContents, ToDos.txt' - #] too long, hard to reference here # Table of Contents, generated with : # Quick tools to help with symbol changes : # ToDos : 08********08 #] +-----+ #] Work log : 08********08 #] 10Nov2021 build search-replace lists in "$d_Qndfs"'QNial symbolOldNew [lists, strings, fileops].txt' 08********08 #] 06Nov2021 'file_ops.ndf' - upgrade optrs $ diff "$d_Qtest"'QNial test optrs.ndf' "$d_Qtest"'QNial test optrs old.ndf' --suppress-common-lines $ diff "$d_Qndfs"'faults.ndf' "$d_Qndfs"'faults, checks.ndf' --suppress-common-lines pinn_chr_writeScreen_strLChrUnbalanced (link d_Qndfs 'QNial userWkspSymbol header.ndf') chr_apo file_ops.ndf change : +.....+ STR_POSNLOFCHR1ST_SUBSTR +.....+ To : +.....+ subStr_posn1stChrIn_str +.....+ > fix argOrder!! +-----+ 08Nov2021 +-------------------+ [in, is] tests of strings : +-------------------+ string cleanup : +-------------------+ Position of [chrs, sub-strings, etc] : +-------------------+ [add, take, replace] [chr, subStr] - return single string : +-------------------+ split[Separate,[At[Front,End]], ] - return list of strings : +-------------------+ [cut, keep, strip] [chr, subStr, width] - return string lists : +-------------------+ convert strings [to, from] other types : +-------------------+ Unicode tests : +-------------------+ [self-return, file embedded] executables : +-----+ 09Nov2021 pinn_chr_writeScreen_strLChrUnbalanced (link d_Qndfs 'file_ops.ndf') `( optr change : +.....+ +.....+ To : +.....+ +.....+ optr change : +.....+ +.....+ To : +.....+ +.....+ optr change : +.....+ +.....+ To : +.....+ +.....+ +-----+ olde code # but this only runs the new str_splitAtFront_subStr_test for some reason ??? % numberBase_all_tests ; - maybe this causes it >> OK!! output is to log file only for strings_alltest >> some time in distant future I need to upgrade the new, simple tests??? # olde code # 06Nov2021 no use! - strOldNew must be hand-crafted for now % test for illegal characters in wordOldNewL ; IF (OR ('$.*/[]^' chrA_anyIn_strA (EACH first wordOldNewL)) ('&/' chrA_anyIn_strA (EACH second wordOldNewL)) ) THEN noerror := o ; write '?pthL_replace_wordL error: $.*/[]^ or &/ chrs in strOldNewL' ; ENDIF ; IF flag_debug THEN write 'loading pth_replace_str' ; ENDIF ; #] pth_replace_str IS OP pth strOld strNew flag_backup - res ipsa loquitor #] defaults to pth_backupDatedTo_zArchive # 09Oct2021 replaced by using pthL_replace_wordL # 06Nov2021 revamped pth_replace_str IS OP pth strOld strNew { pthL_replace_wordL [pth] [strOld strNew] o ; } # If flag_strings_debug THEN write 'test: str_eachChrIs_white' ; write EACH str_eachChrIs_white ' NONLOCAL chr_tab chr_newline chr_carriagereturn chr_space ; ' 'IF (= o non_whitespace_list@i) THEN first_chr := i ; EXIT ; ENDIF ;' (link `k `r 'hello world' chr_tab chr_space ' hhrr ' ' ') ; write ' ' ; ENDIF ; IF flag_debug THEN write 'loading str_eachChrIs_white' ; ENDIF ; #] str_eachChrIs_white IS OP Str - boolean list of text - l for whitespace, o for other str_eachChrIs_white IS OP Str { NONLOCAL chr_tab chr_newline chr_carriagereturn chr_space ; %charrep_list := each charrep Str ; test_chr_tab := link (chr_tab EACHRIGHT match Str ) ; test_chr_newline := link (chr_newline EACHRIGHT match Str ) ; test_chr_carriagereturn := link (chr_carriagereturn EACHRIGHT match Str ) ; test_chr_space := link (chr_space EACHRIGHT match Str ) ; OR test_chr_tab test_chr_newline test_chr_carriagereturn test_chr_space } # 06Sep2021 for deletion : whitespace_flags_z IS z_str_eachChrIs_white # 04Nov2021 a := 'Markets now largely expect that the Fed will begin slowing these purchases, which consist of Treasury securities and agency mortgage-backed securities, ' # $ cd "/media/bill/SWAPPER/Qnial/MY_NDFS" # $ grep "string_in" * # simple tests qnial> subStr_in_str '|Ei(ro - vo*t,t)|' ' + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] ' l qnial> subStr_in_str 'Ei(ro - vo*t,t)' ' + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] ' l IF flag_debug THEN write 'loading subStr_split_str' ; ENDIF ; #] subStr_split_str IS OP str subStrOld subStrNew - splits str at each subStrOld #] replace subStrOld with subStrNew Howell: from ary_convertTo_str above old code - retained for legacy stuff (symbolics) # 12Jul2021 re-ordered args (still have to fix code in programs) subStr_split_str IS lst_replaceSubTo_lstL # 06Sep2021 for deletion : string_split_by_string_with_sub_z IS z_str_replace_strSub_to_strL # subStr_split_str 'and' 'jump' 'This and that and the other thing' IF flag_debug THEN write 'loading subStr_split_str' ; ENDIF ; #] subStr_split_str IS OP str subStrOld subStrNew - splits str at each subStrOld #] replace subStrOld with subStrNew Howell: from ary_convertTo_str above old code - retained for legacy stuff (symbolics) # 12Jul2021 re-ordered args (still have to fix code in programs) subStr_split_str IS lst_replaceSubTo_lstL # 06Sep2021 for deletion : string_split_by_string_with_sub_z IS z_str_replace_strSub_to_strL # subStr_split_str 'and' 'jump' 'This and that and the other thing' IF flag_debug THEN write 'loading str_extractBetween_StrtEnd' ; ENDIF ; #] str_extractBetween_StrtEnd IS OP str strStrt strEndr - extracts sub-strings between [strStrt,strEndr] #] screws up! - needs fixing... DUPLICATE OF str_takeBetween_strFrontEnd? str_extractBetween_StrtEnd IS lst_extractBetween_StrtEnd # 06Sep2021 for deletion : strings_between_z IS z_str_extractBetween_StrtEnd # 26Oct2021 # (first str_extractBetween_StrtEnd) '?pth_typ_exists error |1| [dir,path] not found' '|' '|' # loaddefs link d_Qtest 'QNial test optrs.ndf' IF flag_debug THEN write 'loading test_simple1Arg' ; ENDIF ; #] test_simple1Arg IS OP simple1Arg - really simple test of operators with 1 argument # 05Nov2021 initial, from 05Sep2021, and years before # 05Nov2021 haven't been able to get good formating when printing to file... test_simple1Arg IS OP simple1Arg { LOCAL inputs n_cols n_rows OKL optr resultL test_tbl testNumL dat1L stdResultL commentL ; % ; testTyp testOptr tstDat := simple1Arg ; % EACH write '' '+-----+' (link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS) ; strL_write_pth_pthTyp ('' '+-----+' (link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS) ) "povr ; % ; n_cols := 4 ; n_rows := floor ((gage shape inputs) / n_cols) ; testNumL dat1L stdResultL commentL := cols (n_rows n_cols reshape inputs) ; % ; resultL := optr EACHRIGHT apply dat1L ; OKL := stdResultL EACHBOTH = resultL ; test_tbl := transpose mix (OKL testNumL dat1L resultL commentL) ; test_tbl := table_add_colTitles test_tbl ('OK' 'test#' 'dat1' 'calc' 'comments') ; % ; % EACH write test_tbl '' ; strL_write_pth_pthTyp (picture test_tbl) "povr ; strL_write_pth_pthTyp [' '] "povr ; optr (sum OKL) n_rows } # loaddefs link d_Qtest 'QNial test optrs.ndf' IF flag_debug THEN write 'loading test_simple2Arg' ; ENDIF ; #] test_simple2Arg IS OP simple2Arg - really simple test of operators with 2 arguments # 05Nov2021 haven't been able to get good formating when printing to file... test_simple2Arg IS OP simple2Arg { LOCAL dir inputs n_cols n_rows OKL optrStr pout resultL pout test_tbl testNumL dat1L dat2L stdResultL commentL ; % ; testTyp optrStr dir testDat := simple2Arg ; strL_write_pth_pthTyp ('' '+-----+' (link '#] ' optrStr ' test ' timestamp_DDMMMYYYY_HMS) ) "povr ; % ; n_cols := 5 ; n_rows := floor ((gage shape inputs) / n_cols) ; testNumL dat1L dat2L stdResultL commentL := cols (n_rows n_cols reshape inputs) ; % ; resultL := optr EACHRIGHT apply (rows transpose mix dat1L dat2L) ; OKL := stdResultL EACHBOTH = resultL ; test_tbl := transpose mix (OKL testNumL dat1L dat2L resultL commentL) ; test_tbl := table_add_colTitles test_tbl ('OK' 'test#' 'dat1' 'dat2' 'calculated result' 'comments') ; % ; % EACH write test_tbl '' ; pout := link dir timestamp_DDMMMYYYY_HMS optrStr ' test log.txt' ; strL_write_pth_pthTyp (picture test_tbl) pout "povr ; strL_write_pth_pthTyp [' '] pout "povr ; optr (sum OKL) n_rows } # EACH (gage shape) testNumL dat1L dat2L stdResultL commentL # loaddefs link d_Qtest 'QNial test optrs.ndf' IF flag_debug THEN write 'loading test_simple3Arg' ; ENDIF ; #] test_simple3Arg IS OP simple3Arg - really simple test of operators with 3 arguments # 05May2018 based on in_string, 04Nov2021 revamped to current approach test_simple3Arg IS OP simple3Arg { LOCAL inputs n_cols n_rows OKL optr resultL test_tbl testNumL dat1L dat2L dat3L stdResultL commentL ; % ; testTyp testOptr tstDat := simple3Arg ; % EACH write '' '+-----+' (link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS) ; strL_write_pth_pthTyp ('' '+-----+' (link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS) ) "povr ; % ; n_cols := 6 ; n_rows := floor ((gage shape inputs) / n_cols) ; testNumL dat1L dat2L dat3L stdResultL commentL := cols (n_rows n_cols reshape inputs) ; % ; resultL := optr EACHRIGHT apply (rows transpose mix dat1L dat2L dat3L) ; OKL := stdResultL EACHBOTH = resultL ; test_tbl := transpose mix (OKL testNumL dat1L dat2L dat3L resultL commentL ) ; test_tbl := table_add_colTitles test_tbl ('OK' 'test#' 'dat1' 'dat2' 'dat3L' 'calculated result' 'comments') ; % ; % EACH write test_tbl '' ; strL_write_pth_pthTyp (picture test_tbl) "povr ; strL_write_pth_pthTyp [' '] "povr ; optr (sum OKL) n_rows } IF flag_debug THEN write 'loading pold_exists' ; ENDIF ; #] pold_exists IS OP pold - returns true if pold exists, not for directories # 06Nov2021 revamped pold_exists IS OP pold { pth_typ_exists pold "pold } IF flag_debug THEN write 'loading pnew_exists' ; ENDIF ; #] pnew_exists IS OP pnew - returns true if pnew exists, will NOT be over-written if it exists #] not for directories # 06Nov2021 revamped pnew_exists IS OP pnew { pth_typ_exists pnew "pnew } IF flag_debug THEN write 'loading povr_exists' ; ENDIF ; #] povr_exists IS OP povr - returns true if povr exists, WILL be over-written if it exists # 06Nov2021 revamped povr_exists IS OP povr { pth_typ_exists povr "povr } % ; IF (OR (= "dold typ) (= "dnew typ)) THEN typet := '-type d' ; ELSEIF (OR (= "pold typ) (= "pnew typ) (= "padd typ) (= "povr typ)) THEN typet := '-type f' ; ELSE faultL := link faultL (fault link '?pth_typ_exists error unknown type') ; ENDIF ; IF flag_debug THEN write 'loading subStr_in_str' ; ENDIF ; #] subStr_in_str IS OP Substr Str - simple indication of whether a Substr is in str # without giving position # 04May2018 Because subStr_in_str_in does NOT use grep, it easily handles '$.*/[\]^' characters, # they should be NOT escaped!! # 29Sep2021 see find_strings in "$d_ndfs""Qnial_bag/niallib/FINDSTRI.NDF" - simpler approach # it would be interesting to compare the performance of the two approaches # Findstring is an operation that compares two strings to see if one is contained in the other. Substr is a string. If Substr is in Str, True is returned. find_string IS OP ERATION Substr Str { Position := first Substr findall Str ; Substr in ( tally Substr EACHRIGHT take ( Position EACHLEFT drop Str ) ) } # Find_strings is an operation that compares a group of strings to see if any of them is contained in another string. Substrs is a list of strings. If any string in Substrs is in Str, True is returned. find_strings IS OP ERATION Substrs Str { Position := EACH first Substrs EACHLEFT findall Str ; or ( Substrs EACHBOTH in ( EACH tally Substrs EACHBOTH EACHRIGHT take ( Position EACHLEFT EACHLEFT drop Str ) ) ) } subStr_in_str IS subLst_in_lst # 06Sep2021 for deletion : in_string_z IS z_subStr_in_str # 06Sep2021 for deletion : string_in_z IS z_subStr_in_str IF flag_debug THEN write 'loading subStrL_anyIn_str' ; ENDIF ; #] subStrL_anyIn_str IS OP subStrL str - returns true if ANY of subStrL are in str # 06Sep2021 renamed, new code, old version was a mixup of [code, intent]? # 10Sep2021 see 'strings- tests.ndf' for checks subStrL_anyIn_str IS subLstL_anyIn_lst # 06Sep2021 for deletion : find_string_z IS z_str_posnLOfChr1st_subStr #] +-------------------+ #] Position of [chrs, sub-strings, etc] : IF flag_debug THEN write '+-----+' ; ENDIF ; IF flag_debug THEN write 'Position of [chrs, sub-strings, etc]' ; ENDIF ; IF flag_debug THEN write 'loading chr_posnLIn_str' ; ENDIF ; #] chr_posnLIn_str IS OP chr str - posnL of chr in Str, or null # 29Oct2021 re-incarnated < a := 're-incarnated initial date - I must have done this jillions of times before!' # a EACHRIGHT chr_posnLIn_str 'r!z' +------+--++ |0 7 71|73|| +------+--++ IF flag_debug THEN write 'loading subStr_posn1stChrIn_str' ; ENDIF ; #] subStr_posn1stChrIn_str IS OP subStr str - 1st posn of 1stChr of Substr in Str, or null?? #] a single position is returned as a solitary so it can be used in subsequent EACH expressions etc.... # from niallib File: findstri.ndf BUT MODIFIED - to return the starting position(s) of substrings! # 26Jul2018 This works with lists of any type! (uniLists of unicode, lists of numbers etc) # subStr_posn1stChrIn_str returns a LIST! # 06Sep2021 rewritten # 10Sep2021 see 'strings- tests.ndf' for checks # 16Oct2021 findall returns null if s NOT in str, and this yields null for (positionL EACHLEFT drop str) # 07Nov2021 revamped symbol names subStr_posn1stChrIn_str IS subLst_posnL1stItmIn_lst # qnial> a := 're-incarnated initial date - I must have done this jillions of times before!' # qnial> b := 'in' # subStr_posn1stChrIn_str b a IF flag_debug THEN write 'loading subStr_posnLLChrAllIn_str' ; ENDIF ; #] subStr_posnLLChrAllIn_str IS OP subStr str - posnLL of all itms of Substr in Str, or null #] a single position is returned as a solitary so it can be used in subsequent EACH expressions etc.... # from niallib File: findstri.ndf # BUT MODIFIED - to return the starting position(s) of substrings! # 26Jul2018 This works with lists of any type! (uniLists of unicode, lists of numbers etc) # subStr_posnLLChrAllIn_str returns a LIST! # 06Sep2021 rewritten # 10Sep2021 see 'strings- tests.ndf' for checks # 07Nov2021 revamped symbol names subStr_posnLLChrAllIn_str IS subLst_posnLLItmAllIn_lst #! 11Oct2021: str_findPositionsOf_subStr_z IS z_str_posnLLOfChrAll_subStr IF flag_debug THEN write 'loading subStrL_posn1stChrIn_str' ; ENDIF ; #] subStrL_posn1stChrIn_str IS OP subStr str - all subStrL 1s chr positions, for EACH subStrL, in str #] returns initial 1st char positions for each subStr, or a [null, error] # a list of listsults, eg : # s03 := [[6]] ; % very interesting - a solitary at each level!! ; # 07Sep2021 just use subStr_posn1stChrIn_str # 10Sep2021 see 'strings- tests.ndf' for checks # 07Nov2021 revamped symbol names subStrL_posn1stChrIn_str IS subLst_posn1stItm1stIn_lst #! 11Oct2021: str_find1stChrOf_subStrL_z IS z_str_posnLOfChr1st_subStrL IF flag_debug THEN write 'loading subStrL_posnLLChrAllIn_str' ; ENDIF ; #] subStrL_posnLLChrAllIn_str IS OP subStr str - all subStr positions, for EACH subStr, in Str #] just returns initial char positions for each subStr, or a [null, error] # 07Sep2021 just uses subStr_posnLLChrAllIn_str # 10Sep2021 see 'strings- tests.ndf' for checks # 07Nov2021 revamped symbol names subStrL_posnLLChrAllIn_str IS subLstL_posnLLItmAllIn_lst #] +-------------------+ #] [add, take, replace] [chr, subStr] - return single string : IF flag_debug THEN write '+-----+' ; ENDIF ; IF flag_debug THEN write 'string [add, remove, replace] parts' ; ENDIF ; #] aryList_extractMulplicate_subArys IS OP selectOp strL - find mulplicates in strL by selectOp #] see d_Qroot 'setup.ndf' - works with strLs, or any array type (in form of list) # 14Dec2020 initial IF flag_debug THEN write 'loading chr_prepad_str' ; ENDIF ; #] chr_prepad_str IS OP str len chr - example: zero-prepadding numbers to get constant str length #] if str_length >= len, returns str, often used for chr_prepad_str IS lst_prepadWith_itm # 06Sep2021 for deletion : str_prepadWith_chr_z IS z_str_prepadWith_chr IF flag_debug THEN write 'loading chr_prepad_str_to_length' ; ENDIF ; #] chr_prepad_str_to_length IS OP str chr length - prepads str with chrs to get length chr_prepad_str_to_length IS lst_prepadWith_itm_toLength # string_prepad_z IS z_str_prepadWith_chr_toLength IF flag_debug THEN write 'loading chr_postpad_str_to_length' ; ENDIF ; #] chr_postpad_str_to_length IS OP str chr length - postpads str with chrs to get length chr_postpad_str_to_length IS lst_postpadWith_itm_toLength # 06Sep2021 for deletion : string_postpad_z IS z_str_postpadWith_chr_toLength IF flag_debug THEN write 'loading str_subStrs_takeLenMatches_subStrPairs' ; ENDIF ; #] str_subStrs_takeLenMatches_subStrPairs IS OP str subStrs - return (str = link subStrPairs) # 20Jun2021 initial, 22Jun2021 make optr very specific & clear # should this return a result : # if str is in subStrs? NO!?? (at present this doesn't happen) # if null is in subStrs? Definite NO! I think the null will cause problems!? eliminate that possibility str_subStrs_takeLenMatches_subStrPairs IS lst_subLsts_takeLenMatches_subLstPairs # EACH (gage shape) iL indxs pairs keepL result # iL indxs pairs keepL result IF flag_debug THEN write 'loading str_takeBetween_StrtEnd' ; ENDIF ; #] str_takeBetween_StrtEnd IS OP str strStrt strEndr - take between strFront & strEndr (list) # 23Apr2020 - gives error when one of [strStrt, strEndr] is missing : # 29Sep2021 not converted yet from str_takeAfter_subStr - I have another optr to do this!!! sh: 1: Syntax error: Unterminated quoted string I added the flag_pairs part. Seems to work - nyet It may have been an apostophe in a filename that was later used to do updates : see 'Website updates.ndf' # IF flag_break THEN BREAK ; ENDIF ; str_takeBetween_StrtEnd IS lst_takeBetween_StrtEnd IF flag_debug THEN write 'loading strL_takeOddNum' ; ENDIF ; #] strL_takeOddNum IS OP strL - useful list for [terminal, file] output strL_takeOddNum IS lstL_selectOddNum_subLstL IF flag_debug THEN write 'loading subStr_insertBetweenThenLink_strL' ; ENDIF ; #] subStr_insertBetweenThenLink_strL IS OP subStr strL - link (insert subStr between strL items) # 25Oct2021 initial subStr_insertBetweenThenLink_strL IS subLst_insertBetweenThenLink_lstL # subStr_insertBetweenThenLink_strL '\|' ['hello'] # subStr_insertBetweenThenLink_strL ['hello'] '\|' # subStr_insertBetweenThenLink_strL '\|' ('hello' 'Dolly,' 'well hello' ' Dolly.') # subStr_insertBetweenThenLink_strL '\|' ('My name is Sue.' ' ' 'How do you do?') IF flag_debug THEN write 'loading str_repeatNtimesTo_strL' ; ENDIF ; #] str_repeatNtimesTo_strL IS OP str n - repeats str n times str_repeatNtimesTo_strL IS lst_repeatNtimesTo_lstL IF flag_debug THEN write 'loading str_replace_subStr' ; ENDIF ; #] str_replace_subStr IS OP str subOld subNew - substitutes sub_new for sub_old in str # 05May2018 based on subStr_in_str # 25May2021 needed to fix str_replace_subStr - was igoring null replacement, and returning original str # 12Jul2021 rewrite with re-ordering of args # 07Sep2017 just use sed??? str_replace_subStr IS lst_replace_subLst # 06Sep2021 for deletion : string_sub_z IS z_str_replace_subStr IF flag_debug THEN write 'loading strL_replace_str' ; ENDIF ; #] strL_replace_str IS OP strL subOld subNew - replace all subStrOld by subStrNew in strL # 07Oct2020 initial # 12Jul2021 re-ordered args (still have to fix code in programs) IF flag_break THEN BREAK ; ENDIF ; strL_replace_str IS lstL_replace_lst # 06Sep2021 for deletion : str_replaceIn_strList_z IS z_strL_replace_str # strLtest := '
  • ' 'QNial program to update "raw" conference guides to "full" format with [menues, sponsors, explanations] that is ready to upload to ' 'Conference Guides website.
    ' # strL_replace_str '' ' ' # strL_replace_str 'SRC="' '||' strLtest IF flag_debug THEN write 'loading str_replaceAll_strOld' ; ENDIF ; #] str_replaceAll_strOld IS OP str strOld strNew - strOld is replaced by strNew in str Howell: from ary_convertTo_str above loaddefs 'C:\Documents and Settings\William Neil Howell\My Documents\Qnial\MY_NDFS\strings.ndf' 23Apr2020 problem with 'Segmentation fault', added LOCAL declarations, modified ?what? # 12Jul2021 rewrite with re-ordering of args # 07Sep2017 just use sed??? str_replaceAll_strOld IS lst_replace_subLst # 06Sep2021 for deletion : strOld_sub_strNew_in_strFull_z IS z_str_replaceAll_strOld # subStr_split_str legacy name - this will cause trouble!!! IF flag_debug THEN write 'loading str_takeBefore_subStr' ; ENDIF ; #] str_takeBefore_subStr IS OP str subStr - take to the 1st occurence of subStr, else return str #] ? no good!!! # 24Sep2018 initial str_takeBefore_subStr IS lst_takeBefore_subLst IF flag_debug THEN write 'loading str_takeAfter_subStr' ; ENDIF ; #] str_takeAfter_subStr IS OP str subStr - take after the 1st occurence of subStr, else return null? #] ? no good!!! # 24Sep2018 initial str_takeAfter_subStr IS lst_takeAfter_subLst # <<09Oct2021 (earlier): str_extractPast_strFront_z IS z_str_takeAfter_subStr # examples # str_takeAfter_subStr '/media/bill/SWAPPER/Website/Neural nets/Conference guides/Sponsors website/' '/media/bill/SWAPPER/Website/Neural nets/Conference guides/' # str_takeAfter_subStr (link d_webRaw 'Pandemics, health, and the Sun/influenza/Howell - influenza virus.html') d_webRaw #] winID_copyAllTextTo_poutNew IS OP winID pname - copy text of webPage and pre-pend to file #] see 'windows [open, close, ID, title], [get,set,move] cart [posn,size].ndf' #] +-------------------+ #] split[Separate,[At[Front,End]], ] - return list of strings : IF flag_debug THEN write '+-----+' ; ENDIF ; IF flag_debug THEN write 'str_cut[By,Incl]_subStr[,L] (Unicode? - not yet): ' ; ENDIF ; IF flag_debug THEN write 'loading subStr_splitSeparate_str' ; ENDIF ; #] subStr_splitSeparate_str IS OP subStr str - subStr [splits str, separate] # 06Oct2020 Howell routine based on string_split, to make it more general # subStr_splitSeparate_str_test # each segment starts with subStr, if subStr doesn't appear - returns entire str # 16Jun2021 Do legacy optrs must be changed to reverse position of [str, subStr] arguments??!!! subStr_splitSeparate_str IS lst_splitSeparate_subLst IF flag_debug THEN write 'loading subStrL_splitSeparateRecurse_str' ; ENDIF ; #] subStrL_splitSeparateRecurse_str IS OP subStr str - recursively separate str where subStr occurs, #] subStr separate # 16Jun2021 initial - very incomplete!! # each segment starts with subStr, if subStr doesn't appear - returns entire str subStrL_splitSeparateRecurse_str IS lst_splitSeparateRecurse_subLstL # 10Dec2021 rename, argOrder OK : str_splitWith_subStrL_z IS z_subStr_splitSeparate_strL IF flag_debug THEN write 'loading subStr_splitAtEnd_str' ; ENDIF ; #] subStr_splitAtEnd_str IS OP subStr str - split str where subStr occurs, subStr @end of each split # formal tests - see link d_Qtest 'strings/strings- tests.ndf' # 11Jun2021 adapted from earlier [string_split_by_string, string_splitWith_string, subStr_splitWith_subStr] # 16Jun2021 Do legacy optrs must be changed to reverse position of [str, subStr] arguments??!!! subStr_splitAtEnd_str IS lst_splitAtEnd_subLst # 10Dec2021 rename, argOrder OK : str_splitWithEnd_subStr_z IS z_subStr_splitAtEnd_str # subStr_splitAtEnd_str 'abcdefghij' 'def' >> 16Jun2021 WRONG! # str := 'Fauci, Anthony (NIH/NlAID) (E] <{-----Subject : Coronavirus on surfaces' # subStr := 'Subject : ' qnial> subStr_splitAtEnd_str subStr str +--------------------------------------+--------------------------------+ |Fauci, Anthony (NIH/NlAID) (E] <{-----|Subject: Coronavirus on surfaces| +--------------------------------------+--------------------------------+ >> 04Nov2021 wrong! IF flag_debug THEN write 'loading subStr_splitAtFront_str' ; ENDIF ; #] subStr_splitAtFront_str IS OP subStr str - splits str at each point that subStr occurs #] subStr in strLOut combined with next item # formal tests - see link d_Qtest 'strings/strings- tests.ndf' # 16Jun2021 legacy optrs MUST be changed to reverse position of [str, subStr] arguments!!! subStr_splitAtFront_str IS lst_splitAtFront_subLst # str := 'Fauci, Anthony (NIH/NlAID) (E] <{-----Subject: Coronavirus on surfaces' # subStr := 'Subject: ' # splits := subStr subStr_splitAtFront_str str IF flag_debug THEN write 'loading subStr_splitAtFront_strL' ; ENDIF ; #] subStr_splitAtFront_strL IS OP subStr str - splits str at each point that an item of subStrL occurs #] each subStr in strLOut as a separate item # 16Jun2021 initial # each segment starts with subStr, if subStr doesn't appear - returns entire str subStr_splitAtFront_strL IS lst_splitAtFront_subLstL # str := 'Fauci, Anthony (NIH/NlAID) (E] <{-----Subject: Coronavirus on surfaces' # subStr := 'Subject: ' # splits := subStr subStr_splitAtFront_str str IF flag_debug THEN write 'loading str_splitLftRgtTo_midIndxs_to_strL' ; ENDIF ; #] str_splitLftRgtTo_midIndxs_to_strL IS OP str strLft strRgt - split str, return [indxs, strLst] # by paired [left, right]-end-marks, return [Indxs of mids, strL] # 31Oct2020 IMPORTANT - use [strL, NOT indxs] for shape-related optrs, as atomic indxs screw up # 20Oct2020 # a strLft right at the beginning of the line isn't picked up! # 19Oct2020 initial, based on str_splitLftRgtTo_midIndxs_to_strL # strRgt must be 2 positions from strLft or that strHead is not valid ; # in real life, some strRgt will occur in the next split, without a "middle" (null) # this does not account for nesting of [strLft, strRgt] # 06Oct2020 essentially assumes every strLft has only one strRgt # 16Nov2020 fudge to cover "unique", versus "convoluted" strRgt str # eg ['' '[#=; ' ' ;=#]' #] +-------------------+ #] [cut, keep, strip] [chr, subStr, width] - return string lists : IF flag_debug THEN write '+-----+' ; ENDIF ; IF flag_debug THEN write '[cut, keep, strip] - see also "lists.ndf" : ' ; ENDIF ; IF flag_debug THEN write 'loading str_cutBy_char' ; ENDIF ; #] chr_cut_str IS OP str chr - cut a string at each chr, omitting chr, returns a LIST! # 11Jun2021 initial # d_Qtest 'strings/strings- tests.ndf' # 18Oct2021 as per "principle of generality", checks of [str, crL] not done (can apply more generally) # use checks in equivalent "checked version" of [ary, subAry] chr_cut_str IS lst_cutBy_itm IF flag_debug THEN write 'loading str_cutBy_char' ; ENDIF ; #] chr_cut_strL IS OP str chrL - cut a string at each chr, omitting chr, returns a LIST! # 18Oct2021 initial # 18Oct2021 no formal test yet # 18Oct2021 as per "principle of generality", checks of [str, crL] not done (can apply more generally) # use checks in equivalent "checked version" of [ary, subAry] chr_cut_strL IS lst_cutBy_itmL # chr_cut_strL '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' chrs_QNialSymbols IF flag_debug THEN write 'loading chrL_cut_strL' ; ENDIF ; #] chrL_cutEACH_strL IS OP chrL strL - cut each strL by each chrL, omitting chrL #] note that a character list is just a string, but I use "chrL" to emphasize that each chr cuts # 11Jun2021 inital # chrL_cut_strL_test # NOT WORKING!! # 18Oct2021 as per "principle of generality", checks of [str, crL] not done (can apply more generally) # use checks in equivalent "checked version" of [ary, subAry] # maybe generalize to arrays (sveral years hence) chrL_cut_strL IS lst_cutBy_itmL # chrL_cut_strL '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' chrs_QNialSymbols IF flag_debug THEN write 'loading subStr_cut_str' ; ENDIF ; #] subStr_cut_str IS OP subStr str - splits str at each point that subStr occurs, omit subStr # 06Sep2021 initial from subStr_splitSeparate_str # 10Sep2021 see also str_strip_subStr # subStr_cut_str_test subStr_cut_str IS lst_cutBy_subLst IF flag_debug THEN write 'loading width_cut_str' ; ENDIF ; #] width_cut_str IS OP width str - cut str into strings of equal width, with leftover #] broken on word boundaries # - standard QNial library cuttext.NDF width_cut_str IS lst_cutByWidthTo_lstL # 06Sep2021 for deletion : cuttext_z IS z_width_cut_str # Example # Txt := 'Now is the time for all good men to come to the aid of the party.' ; # width_cut_str txt 18 +------------------+------------------+------------------+------------------+ |Now is the time |for all good men |to come to the |aid of the party. | +------------------+------------------+------------------+------------------+ IF flag_debug THEN write 'loading str_keep_chrL' ; ENDIF ; #] str_keep_chrL IS OP str chrL - cut a string at each chr, omitting chr, returns a LIST! # 11Jun2021 initial # d_Qtest 'strings/strings- tests.ndf' # 18Oct2021 as per "principle of generality", checks of [str, crL] not done (can apply more generally) # use checks in equivalent "checked version" of [ary, subAry] str_keep_chrL IS lst_keep_itmL # str_keep_chrL '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' chrs_QNialSymbols IF flag_debug THEN write 'loading strL_keep_chrL' ; ENDIF ; #] strL_keep_chrL IS OP strL chrL - cut each strL by including chrL, omitting non-chrL, # 11Jun2021 inital # 18Oct2021 as per "principle of generality", checks of [str, crL] not done (can apply more generally) # ??lists only (not arys, maybe generalize to arrays (several years hence))?? # note that a character list is just a string, but I use "chrL" to emphasize that each chr cuts # use checks in equivalent "checked version" of [ary, subAry] strL_keep_chrL IS lstL_keep_itmL # strL_keep_chrL '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' chrs_QNialSymbols IF flag_debug THEN write 'loading str_endStripChrsOrAddSpaces_to_width' ; ENDIF ; #] str_endStripChrsOrAddSpaces_to_width IS OP str1 sw - cut string to fixed length, #] or pad end with spaces to make length # www.BillHowell.ca 18Feb07 (NOT a standard QNial optr) # Usage: str_endStripChrsOrAddSpaces_to_width str1 sw str1 string sw fixed string length str_endStripChrsOrAddSpaces_to_width IS lst_reduceTo_width # 06Sep2021 for deletion : string_wide_z IS z_str_reduceTo_width IF flag_debug THEN write 'loading str_strip_chr' ; ENDIF ; #] str_strip_chr IS OP chr str - remove chr from string, standard QNial library # 16Jan2020 initial - for d_Qndfs 'email - split Thunderbird email folder.ndf' str_strip_chr IS lst_strip_itm # 06Sep2021 for deletion : strip_chrs_z IS z_str_strip_chr IF flag_debug THEN write 'loading str_strip_subStr' ; ENDIF ; #] str_strip_subStr IS OP str subStr - removes subStr from str # 07Sep2017 just use sed??? # see link d_Qtest 'strings/strings- tests.ndf' : str_strip_subStr_test # 10Sep2021 see also subStr_cut_str str_strip_subStr IS lst_remove_subLst # link subStr_posnLLChrAllIn_str # str_strip_subStr 'an apple is of is in is on' 'is' >> OK, that works?!?! IF flag_debug THEN write 'loading chr_in_str' ; ENDIF ; #] chr_in_str IS OP chr str - boolean indication of whether chr is in str # 28Sep2020 initial Because chr_in_str_in does NOT use grep, it easily handles '$.*/[\]^' characters, # 10Oct2021 (chrL str) aren't checked for type chr_in_str IS OP chr str { chr in str } +--+ Moved to array, table.ndf' : IF flag_debug THEN write 'loading chrL_anyIn_str' ; ENDIF ; #] 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, # 09Oct2021 initial # d_Qtest 'strings/strings- tests.ndf' chrL_anyIn_str IS OP chrL str { IF (AND EACH isstring chrL str) THEN OR (chrL EACHLEFT in str) ELSE fault '?chrL_anyIn_str : NOT [chrL, str] inputs' ENDIF } IF flag_debug THEN write 'loading chrLL_anyIn_strL' ; ENDIF ; #] chrLL_anyIn_strL IS OP chrL str - boolean indication of whether any of chrA are in strA # 09Oct2021 initial Because chrLL_anyIn_strL does NOT use grep, it easily handles '$.*/[\]^' characters, # 11Oct2021 (chrL str) aren't checked for type # d_Qtest 'strings/strings- tests.ndf' chrLL_anyIn_strL IS OP chrLL strL { IF (AND EACH EACH isstring chrLL strL) THEN OR (chrLL EACHLEFT EACH in strL) ENDIF } IF flag_debug THEN write 'loading chrA_anyIn_strA' ; ENDIF ; #] 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 # 09Oct2021 initial # d_Qtest 'strings/strings- tests.ndf' # 09Oct2021 because chrA_anyIn_strA does NOT use grep, it easily handles '$.*/[\]^' characters # 11Oct2021 couldn't get [TWIG, EACHLEFT TWIG] to work # 11Oct2021 sortup a big text document - blow up memory, take forever? # 13Oct2021 from test "t22 : 'fails due to non-simple (nested) chrA?? I need to generalize ary_to_atomL' chrA_anyIn_strA IS OP chrA strA { % handles simple arrays, but not all nested arys (fix at some time in the future?) ; chrL := cull sortup ary_to_atomL chrA ; str := cull sortup ary_to_atomL strA ; IF (AND (EACH isstring chrL str)) THEN OR link (chrL EACHLEFT in str) ELSE fault '?chrA_anyIn_strA : NOT [chrA, strA] inputs' ENDIF } +--+ #] subAryN_find1stIn_ary IS OP sub aryN - addr of 1st subArray in array, error if not found # returns error if not found (not the length!), integer otherwise # it will NOT find a string within a string # 03May2020 - doesn't work now!!?? # 06Sep2021 - argument [name, order]ing should be changed? (some day far in the future) subAryN_find1stIn_ary IS OP sub ary { LOCAL key ; key := find sub ary ; IF (< key (gage shape ary)) THEN key ELSE fault '?subAryN_find1stIn_ary : item not found' ENDIF } IF flag_debug THEN write 'loading find_Howell' ; ENDIF ; #] find_Howell IS subAryN_find1stIn_ary - legacy optrName, don't use any more! # 06Sep2021 for deletion : find_Howell IS subAryN_find1stIn_ary # examples qnial> find_Howell (2 3 4) ((1 2 3) (2 3 4) (5 6 7) (8 9 10)) 1 qnial> find_howell 'fish' 'There are many fish in the ocean' ?find_Howell : item not found qnial> find_howell 'fish' ('There are many fish in the ocean' 'plants' 'food' 'fish') 3 IF flag_debug THEN write 'loading subL_in_lst' ; ENDIF ; #] subL_in_lst IS OP subL lst - simple indication of whether a subL is in lst # 04Nov2021 initial from strings.ndf (~identical) subL_in_lst IS OP subL lst { LOCAL flag_in len_subL len_lst i_lst i_subL ; len_subL := gage shape subL ; len_lst := gage shape lst ; flag_in i_lst i_subL := o 0 0 ; WHILE (i_lst < len_lst) DO WHILE (AND ((i_subL + i_lst) < len_lst) (i_subL < len_subL) (= subL@i_subL lst@(i_lst + i_subL)) ) DO i_subL := i_subL + 1 ; ENDWHILE ; IF (= i_subL len_subL) THEN flag_in := l ; EXIT 'done' ; ELSE flag_in := o ENDIF ; i_lst := i_lst + 1 ; i_subL := 0 ; ENDWHILE ; flag_in } IF flag_debug THEN write 'loading subLL_anyIn_lst' ; ENDIF ; #] subLL_anyIn_lst IS OP subLL lst - returns true if ANY of subLL are in lst # 06Sep2021 renamed, new code, old version was a mixup of [code, intent]? # 10Sep2021 see 'strings- tests.ndf' for checks subLL_anyIn_lst IS OP subLL lst { OR (subLL EACHLEFT subL_in_lst lst) } #***************************** #] +-----+ #] Individual test set : IF flag_debug THEN write '+-----+' ; ENDIF ; IF flag_debug THEN write 'Individual test set : ' ; ENDIF ; # loaddefs link d_Qtest 'QNial test optrs.ndf' IF flag_debug THEN write 'loading setStr_dir_test' ; ENDIF ; #] setStr_dir_test IS OP testTyp setStr dir testDataL - run a set of tests, saveDated to dir # 06Nov2021 adapted from 'strings/strings- tests.ndf' setStr_dir_test IS OP testTyp setStr dir testDataL { LOCAL n_cols n_rows opNameL n_correctL n_totalL OKL plog tbl ; NONLOCAL chrMaxPerLine setRslt ; % ; plog := link dir 'z_Archive/' timestamp_YYMMDD_HMS setStr '.txt' ; intro := (link 'set_dir_test of group : ' setStr) (link 'start time : ' timestamp) '' ; EACH write intro ; EACH strL_write_pth_pthTyp (list cart intro [plog] "povr) ; % ; testDataL := null ; FOR test WITH testDataL DO setRslt := link setRslt (apply testTyp ) ; ENDFOR ; % IMPORTANT debugging! : quick output in case tbl fails, as will often happen ; write post setRslt ; setRslt := link setRslt ; n_cols := 3 ; n_rows := floor ((gage shape testDataL) / n_cols) ; opNameL n_correctL n_totalL := cols (n_rows n_cols reshape testDataL) ; OKL := n_correctL EACHBOTH = n_totalL ; tbl := transpose mix OKL opNameL n_correctL n_totalL ; tbl := table_add_colTitles tbl ('OK' 'test (optr)' 'correct' 'total' 'comments') ; tbl := aryL_join_vertical tbl (1 4 reshape ' ' 'totals, all tests' (sum n_correctL) (sum n_totalL)) ; results := (picture tbl) [' '] "povr ; ('' (link 'finish time : ' timestamp_YYMMDD_HMS) tbl '' '') ; EACH write results ; EACH strL_write_pth_pthTyp (list cart results [plog] "povr) ; } # set_dir_test setData (includes (testTyp setStr dir testDataL)) # set_dir_test strings_posnTests # olde code 08********08 #] 01Nov2021 [fault, check]s generic code - create basic system faults.ndf $ diff "$d_Qtest"'Qndfs optr symbol changes - tools, TableOfContents, ToDos.txt' "$d_temp"'Qndfs optr symbol changes - tools, TableOfContents, ToDos.txt' --suppress-common-lines #] check_argL IS OP optrPhr argPhrL argL - special checks for optrPhr, generic checks for args NYET! - best to keep separate!!! 211028 04h17m19s QNial userWkspSymbol header.ndf : contents moved to : QNial setup - header.ndf - now loads during QNial startup file moved to : 211028 04h17m19s QNial userWkspSymbol header.ndf +-----+ 02Nov2021 #] check_pthOrStdout IS OP pthOrStdout - returns EITHER [result, fault] # result - ("outputStr outputStr) for redirecting output, including stdout option # fault - if pth doesn't exist pth_write_strLAposUnbalanced link d_Qndfs 'QNial userWkspSymbol header.ndf' pth_write_strLAposUnbalanced link d_Qndfs 'QNial setup.ndf' $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep --with-filename --line-number "is_variableDefined" LINE /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/QNial setup - header.ndf:159: is_variableDefined IS OP symbolPhr { null } >> this is now useless +-----+ 03Nov2021 #] build_userWkspSymbol IS - create [noun, adjective, verb, adverb, checkArg, etc] lists >> not assigning adjectives properly I removed from build_userWkspSymbol : % convert the following to fit symNameL ; symTypeL := EACH first (symPosnL EACHLEFT choose symTypeL ) ; symAdjtvLL := EACH first (symPosnL EACHLEFT choose symAdjtvLL ) ; symAdverbLL := EACH first (symPosnL EACHLEFT choose symAdverbLL ) ; symCheckL := EACH first (symPosnL EACHLEFT choose symCheckL ) ; Major fix to build_userWkspSymbol - works I'm getting "spurious faults : ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?noexpr ?L ?L ?noexpr ?noexpr ?noexpr ?L ?L nouns : -->[nextv] ?.. % nouns - check consistency - ignore noun[Adjtv, Adverb]LL for now (not as important?) -->[nextv] ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_allvalues 'nounGlobalL' Noungloball ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_allvalues 'nounCheckL' Nouncheckl ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_allvalues 'nounPosnL' Nounposnl ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?noexpr ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_onlyone 'nounGlobalL' Nounposnl ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?noexpr ?L ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_onlyone 'nounPosnL' Nounposnl ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?noexpr ?L ?L ?.. % verbs : -->[nextv] ?.. % verbs - check consistency - ignore verb[AdverbLL, etc] for now (not as important?) -->[nextv] ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_allvalues 'verbGlobalL' Verbgloball ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?noexpr ?L ?L ?noexpr ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_allvalues 'verbCheckL' Verbcheckl ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?noexpr ?L ?L ?noexpr ?noexpr ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_allvalues 'verbPosnL' Verbposnl ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?noexpr ?L ?L ?noexpr ?noexpr ?noexpr ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_onlyone 'verbGlobalL' Verbposnl ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?noexpr ?L ?L ?noexpr ?noexpr ?noexpr ?L ?.. Syminfofaultl := link Syminfofaultl ( resfltstr_resfltl_onlyone 'verbPosnL' Verbposnl ) -->[nextv] ?noexpr ?noexpr ?noexpr ?L ?noexpr ?noexpr ?noexpr ?L ?L ?noexpr ?noexpr ?noexpr ?L ?L 03Nov2021 I'm getting "spurious faults" from build_userWkspSymbol [noun, verb] checks: >> leave it for now back to : #] pinn_strL_options_grepTo_pout IS OP pinn grepSearchL grepOptions pthOrStdout - #] (pthOrStdout = 1) for stdOut, assumes that special grepSearchChrL have been escaped, if needed qnial> loaddefs link d_Qndfs 'QNial usrWkSpc symbol changes.ndf' ... loading pinn_strL_options_grepTo_pout ?undefined identifier: FAULTL := RESULTFAULTL_SEPARATE <***> LINK CHECK_ARGL loading pinn_strL_options_grepTo_pout_output ?undefined identifier: FAULTL ( PINN_STRL_OPTIONS_GREPTO_POUT <***> PINN STRL GREPOPTIONS ... loading pthL_searchReplaceL_options_sedOverwrite ?undefined identifier: ( EACH STR_CHECKISSTR <***> ( LINK STRSEARCHL ... errors found: 3 #] resultFaultL_separate IS OP resultFaultL - res ipsa loquitor resultFaultL_separate IS OP resultFaultL { LOCAL selector ; selector := EACH isfault resultFaultL ; (NOT selector) selector EACHLEFT sublist resultFaultL } +-----+ 04Nov2021 I renamed all strings.ndf symbols in optrs that had been moved to lists.ndf #] lst_splitAtFront_subLstL IS OP lst subLstL - splits lst at each point that an item of subLstL occurs #] 04Nov2021 corrupted? lst_splitAtFront_subLstL change : +.....+ lst_splitAtFront_subLstL IS OP lst subLstL { LOCAL lstL subLst subSubLst ; lstL := [lst] ; FOR subLst WITH subLstL DO FOR lst_remain WITH lstL DO IF (subLst in lst_remain) THEN subSubLst := lst_remain lst_splitAtFront_subLst subLst ; % move all to one level ; lstL := null ; FOR i WITH (tell gage shape subLstL) DO IF (islist subSubLst@i) THEN lstL := link lstL [subSubLst@i] ; ELSE lstL := link lstL (link subSubLst@i) ; ENDIF ; ENDFOR ; ENDIF ; ENDFOR ; ENDFOR ; lstL } +.....+ To : +.....+ +.....+ #] loaddefs link d_Qtest 'strings/strings- tests.ndf' #] 04Nov2021 many more tests converted to current approach Failed string tests : +-----------------------------------------+ |str_to_unicodeL 0 6 | +-----------------------------------------+ |str_isOf_chrSet 8 8 | +-----------------------------------------+ |str_posnLOfChr1st_subStr 0 6 | +-----------------------------------------+ |str_posnLLOfChrAll_subStr 0 6 | +-----------------------------------------+ |str_posnLOfChr1st_subStrL 1 6 | +-----------------------------------------+ |str_posnLLOfChrAll_subStrL 0 6 | +-----------------------------------------+ |str_cutBy_chr 1 8 | +-----------------------------------------+ |str_replace_subStr 7 13 | +-----------------------------------------+ |str_splitAtFront_subStr 3 3 | +-----------------------------------------+ |str_splitAtFront_subStr 6 6 | +-----------------------------------------+ |str_splitLftRgtTo_midIndxs_StrList 5 5 | +-----------------------------------------+ |str_subStrs_getLenMatches_subStrPairs 3 6| +-----------------------------------------+ |?noexpr | +-----------------------------------------+ |?noexpr | +-----------------------------------------+ |str_remove_subStr 0 6 | +-----------------------------------------+ |strL_eachQuoted_strOut 1 6 | +-----------------------------------------+ |strL_to_strExecuteMirror 0 4 | +-----------------------------------------+ |listOfStrL_to_strExecuteMirror 0 5 | +-----------------------------------------+ search escape : \tflog EACHRIGHT str_appendTo_pthOrHandle \n\t\t'' '+-----+' (link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS) ; replace : \t'' '+-----+' (link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS) \n\t\tEACHLEFT str_appendTo_pthOrHandle flog ; Garbage output 'strings/strings- tests.ndf' - cant work : +.....+ (picture test_tbl) EACHLEFT str_appendTo_pthOrHandle flog ; str_appendTo_pthOrHandle '' flog ; +.....+ To : +.....+ EACH write test_tbl '' ; +.....+ optr change : +.....+ '' '+-----+' (link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS) EACHLEFT str_appendTo_pthOrHandle flog ; +.....+ To : +.....+ EACH write '' '+-----+' (link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS) ; +.....+ +-----+ 05Nov2021 pth_write_strLAposUnbalanced link d_Qndfs 'QNial optr symbol changes.ndf' qnial> pth_write_strLAposUnbalanced link d_Qtest 'strings/strings- tests.ndf' '>> Hmm, doesn't work - must be something in QNial??' >> not a problem, as it is in a comment section pth_write_strLAposUnbalanced link d_Qtest 'strings/strings- tests.ndf' change optr to be more general (eg parenthesis) pth_chr_write_strLChrUnbalanced (link d_Qtest 'strings/strings- tests.ndf') `( >> great view! but that wasn't the problem (now I know for sure!) +-----+ olde code IF flag_debug THEN write 'loading check_examples' ; ENDIF ; #] check_examples IS OP strL_name - to facilitate [setup, calc, display, check] of examples # 24Oct2021 probably too archaiic but clean up later check_examples IS OP strL_name { exampler := execute strL_name ; EACH write ' ' ' ' '**************' (link 'check_examples on : ' (string strL_name)) ' ' ; FOR i WITH exampler DO write ' ' ; [write, write execute] i ; ENDFOR ; } # IF flag_debug THEN write 'loading userQndf_extract_checks' ; ENDIF ; #] userQndfs_extract_checks IS OP qndfPthL - gather all qndfPthL check declarations (IS OPs) (concept only) # 21Oct2021 initial # 21Oct2021 userQndfs_extract_checks - starting point for automated checks of checks [static, dynamic, evolving, chaotic], also should include testOptr [status, vintage] # what are [reasons, criteria] to [, not] check? userQndfs_extract_checks IS OP qndfPthL { } # loaddefs link d_Qndfs 'QNial last of [initial, core] loaddefs.ndf' IF flag_debug THEN write 'loading QNial_user_symbol_changes_loaddef_postStartup' ; ENDIF ; #] QNial_user_symbol_changes_loaddef_postStartup IS - loaddef working files post-startup core # 25Oct2021 initial QNial_user_symbol_changes_loaddef_postStartup IS { LOCAL flag_debug_old ; NONLOCAL flag_debug d_Qndfs d_Qtest ; flag_debug_old := flag_debug ; flag_debug := o ; faultL := EACH loaddefs [link d_Qndfs 'QNial usrWkSpc symbol changes.ndf'] ; flag_debug := flag_debug_old ; faultL } # +-----+ # usrWkSpcSymName [nomenclature, grammar] # see link d_Qndfs 'QNial userWkspSymbol header.ndf' # +-----+ # faults of all sources - mostly used for tests : # see link d_Qndfs 'faults - header.ndf' (["sub] ("desc '[part of, ?same type but possibly smaller than?] a [ary, lst, str, etc]' 'in the case of [lst, tbl, ary[simple, nested]], the sub must be across a full dimension (shape)' ) ("type "adjective) ("checkArg null) ("similars "not_done_yet) ) is_variableDefined IS OP symbolPhr { null } % ??symPosnL:= (symNameL EACHLEFT EACHRIGHT in symNameLL) EACHLEFT sublist (tell n_rows) ; # olde code { LOCAL cmd faultL outputStr ptmp_grepOut ptmp_pinn search_expr wordOption ; faultL := null ; faultL := link faultL (pth_typ_checkExists pinn "p_old) ; faultL := link faultL (EACH str_checkIsStr strL) ; % 23Oct2021 str_fixCheck_grepOptions is a dummy optr - returns null ; faultL := link faultL (str_fixCheck_grepOptions grepOptions) ; % 28Oct2021 comment-out? - must hand-craft strL, back to sed code 1-3 years ago to reinstate auto-fix? ; IF (lstL_checkIfAnyFaults (strL := EACH str_fixCheck_grepSearchChrL strL)) THEN faultL := link faultL (fault '?str_fixCheck_grepSearchChrL error : problem with strL') ; ENDIF ; % ; % optional output to stdout ; IF (= 1 pthOrStdout) THEN resultL := "outputStr ' ' ; ELSE resultL := "outputStr (link ' >"' pthOrStdout '" ') ; faultL := link faultL (pth_typ_checkExists pthOrStdout "p_old) ; ENDIF ; # loaddefs link d_Qtest 'strings/strings- tests.ndf' IF flag_debug THEN write 'loading str_head_midl_tail' ; ENDIF ; #] str_head_midl_tail IS OP str - separate str into parts given end substrings #] 20Nov2020 this is defunct, I think # 06May2020 based on 'strings/strings- tests.ndf' # Can probably be added to str_splitLftRgtTo_midIndxs_StrList_test with adaptation str_head_midl_tail_test IS { LOCAL t_name t_input t_standard t_result ; EACH write_testStr '#+-----+' (link 'str_head_midl_tail_test, ' timestamp) ; % ; EACH write '' '****************************' ; t_name := '# str_head_midl_tail_test example 1 - simple HREF' ; t_input := '%20' ' ' '' '/media/bill/SWAPPER/Website - raw/economics, markets/SP500/multi-fractal/1872-2020 SP500 index, ratio of opening price to semi-log detrended price.html:63:
  • 7,500 years of history - This is the same challenge ...' ; t_standard := '/media/bill/SWAPPER/Website - raw/economics, markets/SP500/multi-fractal/1872-2020 SP500 index, ratio of opening price to semi-log detrended price.html:63:
  • 7,500 years of history - This is the same challenge ...' ; t_result := str_head_midl_tail t_input ; write_test_head t_name t_input t_standard t_result ; EACH write t_input t_standard t_result '' ; % ; EACH write '' '****************************' ; t_name := '# str_head_midl_tail_test example 2 - complex SRC with extra tail-ends' ; t_input := '%20' ' ' 'SRC="' '"' ' ' ; t_standard := ' ' ; t_result := str_head_midl_tail t_input ; write_test_head t_name t_input t_standard t_result ; EACH write t_input t_standard t_result '' ; % ; EACH write '' '****************************' ; t_name := '# str_head_midl_tail_test example 3 - multiple HREFs in a line' ; t_input := '%20' ' ' 'HREF="' '">' '
  • QNial program to update "raw" conference guides to "full" format with [menues, sponsors, explanations] that is ready to upload to Conference Guides website.
    ' ; t_standard := '
  • QNial program to update "raw" conference guides to "full" format with [menues, sponsors, explanations] that is ready to upload to Conference Guides website.
    ' ; t_result := str_head_midl_tail t_input ; write_test_head t_name t_input t_standard t_result ; EACH write t_input t_standard t_result '' ; % ; EACH write '' '****************************' ; t_name := '# str_head_midl_tail_test example 4 - HREF (I added %20) & SRC in same line, extra tail_ends ' ; t_input := ' ' ; t_standard := ' ' ; t_result := str_head_midl_tail '%20' ' ' 'SRC="' '"' t_input ; write_test_head t_name t_input t_standard t_result ; EACH write t_input t_standard t_result '' ; } # coad awaiting t_result := str_head_midl_tail '%20' ' ' 'HREF="' '">' (str_head_midl_tail '%20' ' ' 'SRC="' '"' t_input) ; # strL := 'hello' 'Dolly is a big cheese' '% keep printing out vertical slabs until done? should I pad with spaces to have constant width?; ' # pout := link d_Qtest 'strings/' timestamp_YYMMDD_HMS ' alltest strings.txt' # strL_writeAppend_pout strL 110 pout # olde code % are all chrTbl same length? ; strLenL := #! 06Sep2021 for deletion : list_writeTo_pth_z IS z_strL_writeOvr_pout #! 06Sep2021 for deletion : strL_writeOvr_pout_z IS z_strL_writeOvr_pout # legacy # d_Luca := '/media/bill/SWAPPER/Lucas - Universal Force/' # a := pth_read_strL (link d_Luca 'symList good HFLN.txt') # strL_write_pth a (link d_QNial_temp 'symList good HFLN.txt') # host link 'diff "' (link d_Luca 'symList good HFLN.txt') '" "' (link d_QNial_temp 'symList good HFLN.txt') '" ' qnial> host link 'diff "' (link d_Luca 'symList good HFLN.txt') '" "' (link d_QNial_temp 'symList good HFLN.txt') '" ' >> OK, it works # test_simple str_to_unicodeL_test # olde code %select 'stdout' or logfile output ; p_log_test := link d_Qtest 'strings/' timestamp_YYMMDD_HMS ' alltest strings.txt' ; % flog := open p_log_test "w ; flog := 1 ; % (link d_Qtest 'strings/strings- tests.ndf') 'strings_alltest runs all strings-related tests' (link 'start time : ' timestamp) ' ' EACHLEFT str_appendTo_pthOrHandle flog ; % '' (link 'finish time : ' timestamp) '' '' EACHLEFT str_appendTo_pthOrHandle flog ; % (picture post resultsL) EACHLEFT str_appendTo_pthOrHandle flog ; % close flog ; % flog := 1 ; % reset to stdout as default ; % resultsL ; # olde code using filehandles '' '+-----+' (link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS) EACHLEFT str_appendTo_pthOrHandle flog ; ... (picture test_tbl) EACHLEFT str_appendTo_pthOrHandle flog ; str_appendTo_pthOrHandle '' flog ; 08********08 #] 28Oct2021 opl_sed item, userSymbol grammar list created #] "$d_Qtest"'Qndfs optr symbol changes - tools, TableOfContents, ToDos.txt' - #] tools elated to 'Qndfs optr symbol changes - develop tests.txt' #] link d_Qndfs 'QNial userWkspSymbol header.ndf #] userWkSpcSymNameL := standard symbol [name, [pre, post]fix, [adverb, ]] in the user workspace, #] with [grammar, syntax] to build symbol names #] bug hunt : #] pinn_strL_options_grepTo_pout - grep search for each string in strL, for all paths in pthL : #] pinn_strL_options_grepTo_pout IS OP pinn strL grepOptions pout - #] pinn_strL_options_grepTo_pout_output IS OP pinn strL grepOptions - #] pinn_strL_options_grepTo_pout_test IS OP pout 29Oct2021 continued... qnial> QNial_optr_symbol_changes_loaddef_postStartup ?undefined identifier: ; LOADDEFS_START F_LOAD <***> ; ?undefined identifier: LOADDEFS_ENDED F_LOAD <***> ; errors found: 2 >>> loading start : fileops/file_ops- test.ndf ?undefined identifier: P_ZARCHIVE := PZARCHIVE_RESTORE <***> P_LATESTBACKUP ) ) <<< loading ended : fileops/file_ops- test.ndf errors found: 1 >>> loading start : QNial optr symbol changes.ndf <<< loading ended : QNial optr symbol changes.ndf qnial> loaddefs link d_Qndfs 'lists.ndf' >>> loading start : lists.ndf ?tokens left: * * 24 <***> # LIST OF >> very simple glitches for new [creation, edit]s >> pZarchive_restore -> gone missing, restore from backup >> simple OK re-instated qnial> pinn_strL_options_grepTo_pout (link d_Qtest 'fileops/test input files/' 'test- QNial setup.ndf') ['^#] .* IS OP '] ' ' (link d_Qtest 'fileops/pinn_strL_options_grepTo_pout/' 't01 test- QNial setup.ndf') >> works, but includes '#] ' as specified qnial> pinn_strL_options_grepTo_pout (link d_Qtest 'fileops/test input files/' 'test- strings.ndf') ['^\(#] \).* IS OP '] ' ' (link d_Qtest 'fileops/pinn_strL_options_grepTo_pout/' 't02 test- strings.ndf') >> Nuts,still has '#] ' pinn_strL_options_grepTo_pout (link d_Qtest 'fileops/test input files/' 'test- strings.ndf') ['^^\(#\] \).* IS OP '] ' ' (link d_Qtest 'fileops/pinn_strL_options_grepTo_pout/' 't02 test- strings.ndf') >> no output #] str_checkGrepSearchChrs IS OP strSearch - check str for problematic grep search chrs #] str_checkSedSearchChrs IS OP strSearch - check strSearch for problematic grep chrs #] str_checkSedReplaceChrs IS OP strReplace - check strReplace for problematic grep chrs #] >> updated lists of special chrs for all the above #] >> integrated backslash modifications integrated backslash modifications : earlier coding : YIKES!! pth_backupDatedTo_zArchive - doens't qwork (again!) >> for several years, it seems work for only a couple of days, then fails Added fault return, fixed embarassinglyly incomplete code : pth_backupDatedTo_zArchive IS OP pth { LOCAL d_zArchive dir fname noError p_out faultL ; % ; dir fname := pth_extract_dirFname pth ; d_zArchive := link dir 'z_Archive/' ; % ; faultL := null ; faultL := link faultL (pth_typ_exists pth "p_old) ; % ; IF (= null faultL) THEN IF (~= null (pth_typ_exists d_zArchive "d_old)) THEN host link 'mkdir "' d_zArchive '"' ; ENDIF ; p_out := link d_zArchive timestamp_YYMMDD_HMS ' ' fname ; host link 'cp -p "' pth '" "' p_out '" ' ; ENDIF ; % ; link faultL } qnial> QNial_optr_symbol_changes_backup ++++-------------------------------------------------+++ ||||?pth_typ_exists error [dir,path] not found||| ++++-------------------------------------------------+++ >> oops - 'fileops/file_ops- development.txt' - I had temporarily rname file! (idiot) - but confusion does result from duate work in [work, final] ndf files >> AWESOME improvement seeiault returns!!! Adds great confidence Should be modified! : #] pthL_replace_wordL IS OP pthL wordOldNewL flag_word flag_backup - change [str, word]L each pthL #] uses sed, therefore cannot simply handle sed restricted : search $.*/[\]^ replace &\/\n $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep --with-filename --line-number "fault_null_comparisons" LINE | sed 's/^\(.*\):[0-9]\+:.*/\1/' | sort -u /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/lists.ndf /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/QNial last of [initial, core] loaddefs.ndf /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/QNial usrWkSpc symbol changes.ndf >> I moved fault_null_comparisons to lists.ndf +-----+ olde code IF flag_debug THEN write 'loading strSedReplace_escapeProblemChrs' ; ENDIF ; #] strSedReplace_escapeProblemChrs IS OP strSedReplace - do NOT use for pre-composed regexprs!! # 29Oct2021 initial strSedReplace_escapeProblemChrs IS OP strSedReplace { NONLOCAL sedReplaceChrL ; str_escape_regExprChrL strSedReplace sedReplaceChrL } 08********08 #] 27Oct2021 pinn_strL_options_grepTo_pout[, _output, _test] revamp to current approach to [fault, test]s qnial> QNial_optr_symbol_changes_loaddef_postStartup >>> loading start : QNial check user[, WkSpace]Optrs.ndf <<< loading ended : QNial check user[, WkSpace]Optrs.ndf >>> loading start : fileops/file_ops- test.ndf ?undefined identifier: CODEDRESULTL := PTHL_RESULTL_SHORTENTO_CODES <***> DAT1L ?undefined identifier: D_QTEST ; FLOG <***> EACHRIGHT WRITEFILE '........' ?undefined identifier: CODEDRESULTL := PTHL_RESULTL_SHORTENTO_CODES <***> DAT1L RESULTLL ; <<< loading ended : fileops/file_ops- test.ndf errors found: 3 >>> loading start : QNial optr symbol changes.ndf ?expecting end of block: D_QTEST 'fileops/pinn_strL_options_grepTo_pout/' ; <***> ?undefined identifier: "t01 ( D_INN <***> LINK 'test- QNial setup.ndf' ) <<< loading ended : QNial optr symbol changes.ndf errors found: 2 change in ['QNial check user[, WkSpace]Optrs.ndf', 'QNial optr symbol changes.ndf',fileops]: +.....+ pthL_resultL_shortenTo_Codes +.....+ To : +.....+ pthL_faultLL_shortenTo_Codes +.....+ 08********08 #] 24Oct2021 adapt [pth_find_latestZarchive, pZarchive_restore, pth_backupDatedTo_zArchive] # pthL_faultL_resultL_shortenTo_Codes IS OP pthL resultLL faultL - for fairly general use in _tests # pZarchive_restore IS OP pth - restore most recent pth_backupDatedTo_zArchive of a file, retain the backup # 26Oct2021 pth_backupDatedTo_zArchive_test - I've run out of time, The backups work, the test isn't finished with the upgrade. Leave it for the future +-----+ olde code # olde code # pZarchive_restore IS OP pth - restore most recent pth_backupDatedTo_zArchive of a file, retain the backup p_zArchive := fault '?pZarchive_restore error: p_zArchive cannot be found due to other failures' ; % 01Oct2021 this could be wrong - should check dir for non-dated which would cause problems ; % check for [pth, dir] problems ; IF (NOT pth_typ_exists d_zArchive "d_old) THEN noError := o ; EACH write '?pZarchive_restore error, no d_zArchive, so cant restore!' d_zArchive '' ; ENDIF ; fname_list := host_result link 'ls -1 "' d_zArchive '" | grep "' fname '" ' ; IF (= null fname_list) THEN noError := o ; EACH write '?pZarchive_restore error, no fname in d_zArchive, so cant restore!' fname '' ; ENDIF ; % given dating of zArchive files, the most recent fname is the last ; pth_find_latestZarchive pth IF (NOT pth_typ_exists pth "p_old) THEN result := link result (fault '?pZarchive_restore error <1> original file unknown') ; ELSE pth_backupDatedTo_zArchive pth ; ENDIF ; p_zArchive := link d_zArchive fname_backup ; 08********08 #] 24Oct2021 upgrade greatly : pth_typ_exists[, _test], created : #] pthL_faultL_resultL_shortenTo_Codes IS OP pthL resultLL faultL - for fairly general use in _tests also - fault_null_comparisons - learn about [null, fault] lists 26Oct2021 15:43 when done, I moved pth_typ_exists to file_ops.ndf +-----+ 'QNial optr symbol changes.ndf' : 24Oct2021 fault handling : general rule for [test, check] returns : true = `l, otherwise faultL IMPORTANT! - faultL = fault LIST, not a simple fault! fault_null_comparisons IS - looking at how [fault, null][,L] behave 25Oct2021 continued... cleaned up 'Check operator arguments' in 'QNial check user[, WkSpace]Optrs.ndf' renamed [optr, arg]s moved pthL_resultL_faultL_shortenTo_Codes 'QNial check user[, WkSpace]Optrs.ndf' as this optr is fairly general and will help when creating similar optrs pth_backupDatedTo_zArchive_test - modify to use pthL_resultL_faultL_shortenTo_Codes created : str_overWriteTo_pthOrHandle IS OP str pthOrHandle - res ipsa loquitor str_appendTo_pthOrHandle IS OP str pthOrHandle - res ipsa loquitor strL_subStr_insertBetween_strOut IS OP strL subStr - link (insert sbStr between strL items) strPairL_sortCullUniqueL IS OP strPairL - sort, then cull to get a unique list of strPairs pth_typ_exists IS OP pth typ problem with "p_old type when dir is an arg -> generates a list of files in dir # $ find '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/' -type f # pth_write_strLAposUnbalanced link d_Qndfs 'QNial optr symbol changes.ndf' # pth_write_strLAposUnbalanced link d_Qtest 'fileops/file_ops- test.ndf' 26Oct2021 continued ... # pth_typ_exists IS OP pth typer - returns true if a [dir, pth] exists, or can be created change : +.....+ IF (= "d_old typ) THEN typet := '-type d' ; ELSEIF (= "p_old typ) THEN typet := '-type f' ; ELSEIF (= "d_new typ) THEN typet := '-type d' ; paty := ((last last str_posnLOfChr1st_subStr paty '/') + 1) take paty ; ELSEIF (= "p_new typ) THEN typet := '-type d' ; paty := (( last str_posnLOfChr1st_subStr paty '/') + 1) take paty ; ELSEIF (= "p_ovr typ) THEN typet := '-type d' ; paty := (( last str_posnLOfChr1st_subStr paty '/') + 1) take paty ; ELSE result := fault '?pth_typ_exists error : unknown type' ; ENDIF ; % ; firstLine := first host_result (link 'find "' paty '" -maxdepth 0 ' typet) ; IF (': No such file or directory' subStr_in_str firstLine) THEN result := fault '?pth_typ_exists error : path not found' ; % should not overwrite if path already exists and "p_new is used! (use "p_ovr for that) ; ELSEIF (= "p_new typ) THEN IF (pth_typ_exists pth "p_old) THEN result := fault '?pth_typ_exists error : path already exists. To overwite use type "p_ovr' ; ENDIF ; ENDIF ; +.....+ To : +.....+ IF (= "d_old typ) THEN typet := '-type d' ; ELSEIF (= "p_old typ) THEN typet := '-type f' ; ELSEIF (= "p_new typ) THEN typet := '-type f' ; ELSEIF (= "d_new typ) THEN typet := '-type d' ; paty := ((last last str_posnLOfChr1st_subStr paty '/') + 1) take paty ; ELSEIF (= "p_ovr typ) THEN typet := '-type f' ; ELSE result := link result (fault '?pth_typ_exists error : unknown type') ; ENDIF ; % ; firstLine := first host_result (link 'find "' paty '" -maxdepth 0 ' typet) ; IF (': No such file or directory' subStr_in_str firstLine) THEN IF (= "p_new typ) THEN paty := ((last str_posnLOfChr1st_subStr paty '/') + 1) take paty ; firstLine := first host_result (link 'find "' paty '" -maxdepth 0 -type d') ; % but do I want the containing directory created? NO!! ; IF (': No such file or directory' subStr_in_str firstLine) THEN result := link result (fault '?pth_typ_exists error : "p_new containing dir noExist') ; % useless ELSE, but makes double clear ; ELSE result := link result null ; ENDIF ; ELSE result := link result (fault '?pth_typ_exists error : [dir,path] not found') ; ENDIF ; ENDIF ; +.....+ pthL_resultL_faultL_shortenTo_Codes change : +.....+ codedFaultNumberL := '(' EACHRIGHT link (EACH string (tell (gage shape faultL))) EACHLEFT link ')' ; +.....+ To : +.....+ codedFaultNumberL := ('(' EACHRIGHT link (EACH string (tell (gage shape faultL)))) EACHLEFT link ')' ; +.....+ optr change BACK!! : +.....+ codedFaultL := null ; FOR fault WITH faultL DO codedFaultNumberL := ('(' EACHRIGHT link (EACH string (tell (gage shape fault)))) EACHLEFT link ')' ; codedFaultL := codedFaultL link codedFaultNumberL EACHBOTH link (' ' EACHRIGHT link (EACH string fault)) ; ENDFOR ; +.....+ To : +.....+ codedFaultNumberL := ('(' EACHRIGHT link (EACH string (tell (gage shape faultL)))) EACHLEFT link ')' ; codedFaultL := codedFaultNumberL EACHBOTH link ( ' ' EACHRIGHT link (EACH string faultL)) ; +.....+ optr change : +.....+ str_extractBetween_StrtEnd IS OP str strStrt strEndr { LOCAL betweens between_first between_last between_strs flag_continue flag_pairs fronts rears i j shape_strStrt ; % ; % must be able to detect if, for the SAME [strStart, strEndr], this appears in pairs! ; flag_pairs := l ; IF (= strStrt strEndr) THEN flag_pairs := (= 0 (mod (gage shape str_posnLOfChr1st_subStr str strStrt) 2)) ; ENDIF ; % ; IF flag_break THEN BREAK ; ENDIF ; IF flag_pairs THEN shape_strStrt := gage shape strStrt ; fronts rears := str EACHRIGHT str_posnLOfChr1st_subStr strStrt strEndr ; betweens := null ; FOR i WITH fronts DO FOR j WITH rears DO IF j > i THEN betweens := betweens append (i j) ; rears := rest rears ; EXIT null ; ENDIF ; ENDFOR ; ENDFOR ; between_strs := null ; FOR i WITH betweens DO between_first := first i + shape_strStrt ; between_last := second i - between_first ; between_strs := between_strs append ((between_first + tell between_last) choose str) ; ENDFOR ; ELSE between_strs := fault link 'str_extractBetween_StrtEnd unpaired, strStrt= ' strStrt ; ENDIF ; between_strs } +.....+ To : +.....+ str_extractBetween_StrtEnd IS OP str strStrt strEndr { LOCAL betweens between_first between_last between_strs flag_continue flag_pairs fronts rears i j shape_strStrt ; % ; % must be able to detect if, for the SAME [strStart, strEndr], this appears in pairs! ; flag_pairs := l ; IF (= strStrt strEndr) THEN flag_pairs := (= 0 (mod (gage shape str_posnLOfChr1st_subStr str strStrt) 2)) ; ENDIF ; % ; IF flag_break THEN BREAK ; ENDIF ; IF flag_pairs THEN shape_strStrt := gage shape strStrt ; fronts rears := str EACHRIGHT str_posnLOfChr1st_subStr strStrt strEndr ; fronts := fronts + shape_strStrt ; rears := rears - 1 ; betweens := null ; FOR i WITH fronts DO FOR j WITH rears DO IF j > i THEN betweens := betweens append (i j) ; ENDIF ; ENDFOR ; ENDFOR ; between_strs := null ; FOR between WITH betweens DO posnStrt posnEndd := between ; between_strs := between_strs append ((posnStrt + (tell (posnStrt - posnEndd))) choose str) ; ENDFOR ; ELSE between_strs := fault link 'str_extractBetween_StrtEnd unpaired, strStrt= ' strStrt ; ENDIF ; between_strs } +.....+ Finally, after a huge [# logic mistakes, effort], it work: # pth_typ_exists_test IS - res ipsa loquitor, types = [p_ = path, d_ = dir]cart[old, new] +-----+ olde code - still cleaning up 24Oc2021 This is useless! Just use (eg) result := link result (pinnL EACHLEFT pth_typ_checkExists "p_old) ; #] pthL_typ_check IS OP pthL typ - check if all pthL are legitimate paths of the same type typ # as usual, l if true, fault if not # example pthL_typ_check # 21Oct2021 initial pthL_typ_check IS OP pthL typ { LOCAL result ; result := l ; IF (NAND (pthL EACHLEFT pth_typ_exists typ)) THEN result := link result (fault '?pthL_typ_check error: unknown path(s), or pthTyp failure') ; ENDIF ; result } % ; fault_1 := fault '?pth_find_latestZarchive error : d_zArchive doesn"t exist' ; fault_2 := fault '?pth_find_latestZarchive error : pth doesn"t exist, or is dir' ; fault_3 := fault '?pth_find_latestZarchive error : no backup file found' ; fault_4 := fault '?pth_backupDatedTo_zArchive error : backup is not the same as original' ; % ; % Below, the long [pth, fault]s are replaced with short [fname, fault codes] ; % This makes the table of outputs much more readable and compact. ; % ; % calcL here is used for comparison to stdResult for fnames only, % drop date eg '210626 13h24m32s ' ; stdFnameL := stdResultL ; calcL := resultL ; FOR i WITH (tell n_rows) DO IF (isstring resultL@i) THEN stdFnameL@i := pth_extract_fname dat1L@i ; % special case of dir only, no fname : return the last subDir ; IF (= null stdFnameL@i) THEN stdFnameL@i := ((last front (`/ findall dat1L@i)) + 1) drop dat1L@i ; ENDIF ; calcL@i := 17 drop (pth_extract_fname resultL@i) ; ENDIF ; ENDFOR ; % ; OKL := stdFnameL EACHBOTH = calcL ; % ; % calcL here is adapted so that fnames show the backup date-time, eg '210626 13h24m32s ' ; FOR i WITH (tell n_rows) DO IF (isstring resultL@i) THEN calcL@i := pth_extract_fname resultL@i ; ENDIF ; ENDFOR ; write calcL ; % ; % here the dat1L faults are converted to codes for brevity in the output ; tell_n_rows := tell n_rows ; n_indxChgL := gage shape indxChgL ; indxChgL := ((fault_1 fault_2) EACHRIGHT = stdFnameL) sublist tell_n_rows ; stdFnameL#(indxChgL) := n_indxChgL reshape ['(1)(2)'] ; indxChgL := (fault_1 EACHRIGHT = stdFnameL) sublist tell_n_rows ; stdFnameL#(indxChgL) := n_indxChgL reshape ['(1)'] ; indxChgL := (fault_2 EACHRIGHT = stdFnameL) sublist tell_n_rows ; stdFnameL#(indxChgL) := n_indxChgL reshape ['(2)'] ; indxChgL := (fault_3 EACHRIGHT = stdFnameL) sublist tell_n_rows ; stdFnameL#(indxChgL) := n_indxChgL reshape ['(3)'] ; indxChgL := (fault_4 EACHRIGHT = stdFnameL) sublist tell_n_rows ; stdFnameL#(indxChgL) := n_indxChgL reshape ['(4)'] ; % ; % here the calcL are converted to codes for brevity in the output ; tell_n_rows := tell n_rows ; indxChgL := ((fault_1 fault_2) EACHRIGHT = calcL ) sublist tell_n_rows ; calcL#(indxChgL) := n_indxChgL reshape ['(1)(2)'] ; indxChgL := (fault_1 EACHRIGHT = calcL ) sublist tell_n_rows ; calcL#(indxChgL) := n_indxChgL reshape ['(1)'] ; indxChgL := (fault_2 EACHRIGHT = calcL ) sublist tell_n_rows ; calcL#(indxChgL) := n_indxChgL reshape ['(2)'] ; indxChgL := (fault_3 EACHRIGHT = calcL ) sublist tell_n_rows ; calcL#(indxChgL) := n_indxChgL reshape ['(3)'] ; indxChgL := (fault_4 EACHRIGHT = calcL ) sublist tell_n_rows ; calcL#(indxChgL) := n_indxChgL reshape ['(4)'] ; IF (= null result) THEN firstLine := first host_result (link 'find "' paty '" -maxdepth 0 ' typet) ; IF (': No such file or directory' subStr_in_str firstLine) THEN result := link result (fault '?pth_typ_exists error : [dir,path] not found') ; ELSEIF (= "p_new typ) THEN result := link result (fault '?pth_typ_exists error : path already exists. To overwrite use type "p_ovr') ; ENDIF ; ENDIF ; # mailto_text := '"mailto:IEEE%20WCCI%202020%20HELP%20daemon%20?subject=IEEE%20WCCI%202020%20HELP%20:%20paper%20formatting&body=Provide%20a%20description%20of%20your%20problem,%20including%20any%20[output%20from%20the%20system,%20error%20codes]%20">' # str_extractBetween_StrtEnd 'maito:' '">' mailto_text qnial> str_extractBetween_StrtEnd 'maito:"' '">' mailto_text sh: 1: amp: not found sh: 1: cannot open daemon@BillHowell.ca: No such file >> oops, extra quote # screws up! - needs fixing... # olde code % host link 'echo >"/media/bill/ramdisk/str_extractBetween_StrtEnd str.txt" "' str '" ' ; %write link link 'str_extractBetween_StrtEnd: fronts=' (EACH string fronts) ' rears=' (link link ((EACH string rears) EACHLEFT append ' ')) ; %write 'str_extractBetween_StrtEnd - before 1st FOR ' ; %write 'betweens = ' betweens ; %write 'str_extractBetween_StrtEnd - before 2nd FOR ' ; %write 'leaving str_extractBetween_StrtEnd : between_strs' ; %write i between_first between_last ; %write i j ; flag_continue := l ; %flag_continue := o ; 08********08 # 24Oct2021 cleaning up 07:40 First, loaddefs bug hunts! I "dropped" several optrs that I needed yesterday. I am losing it. 'QNial setup.ndf' - It's a pain in the ass loaddefing everything just for a few pathetic sections all material after loaddef : +--+ +-----+ Check userOptrs, for 'QNial setup.ndf' pthL_existsCheck IS OP pthL - check if all pthL are legitimate paths, l if true, fault if not strL_check IS OP strL - check if all strL are legitimate paths, l if true, fault if not strOldNewL_strPairCheck IS OP strOldNewL - check that strOldNewL is a pair of strings, l if true, fault if not options_findGrepSedPhr_regexprCheck IS OP options findGrepSedPhr - (21Oct2021 not started code yet) check for problematic [find, grep, sed] characters, l if true, fault if not searchReplaceL_findGrepSedPhr_regexprCheck IS OP searchReplaceL findGrepSedPhr - check for problematic [find, grep, sed] characters in [[search, replace] terms, l if true, fault if not ??? IS OP strOldNewL - ???, l if true, fault if not +-----+ Check userWkSpaceOptrs, for 'QNial setup' userQndfs_extract_checks IS OP qndfPthL - gather all qndfPthL check declarations (IS OPs) (concept only) +-----+ Handy mathematical stuff : average IS / [sum, tally] - square IS prod [pass, pass] - floor_mod IS OP a b - convenient return of BOTH floor and mod! int_is_oddNum IS OP int - true if int is an odd number int_is_evenNum IS OP int - true if int is an odd number +-----+ Matrix ops - symbolic through semi-symbolic through numeric vector_from_list IS OP c_r lista - creates a vector from a list (legacy - don't use this for new code!) list_convertTo_vector IS OP lista c_r - creates a vector from a list +-----+ Encryption-related, should set up d_Qndfs 'encrypt - code generation.ndf' : full_code IS - randomly generated codes [alpha, numeric, symbol] codes (12 character sequences) numeric_code IS - randomly generated numeric-only codes (12 character sequences) alpha_code IS - randomly generated alpha-only codes (12 character sequences) alphanumeric_code IS - randomly generated codes [alpha, numeric] codes (12 character sequences) save_codes IS - save randomly generated full, alpha, numeric, alpha-numeric] codes (20 codes per class) +--+ moved to new path : 'QNial check user[, WkSpace]Optrs.ndf' >>> loading start : QNial check user[, WkSpace]Optrs.ndf ?expecting then: STR ) ) <***> ) THEN RESULT +-----+ olde code # 24Oct2021 still fixing [pth_typ_exists, pinnL_strL_options_grepTo_pout]_test # fault_null_comparisons - learn about [null, fault] lists # +-----+ # host commands, checks of [file system, workspace, drives] QNial environment settings : IF flag_debug THEN write '+-----+' ; write 'loading host commands, checks of [file system, workspace, drives]' ; ENDIF ; IF flag_debug THEN write 'loading host_result' ; ENDIF ; # host_result IS OP str - returns [str, str_array, null] result of host commands with stdout returns # 17Jan2020 initial for "Anonymous Recipient Email Daemon" (ARED) # dangerous to use if cmd already outputs to a file!!! # readfile cases : # - null : # - [integer, real] - depends if conversion to str is needed? # - string : will want to "extract" from 1st and only item in list # - string_list : depends on application # This is defined earlier in section "Library directory definitions" # tests # host_result 'ls ' 08********08 #] 22Oct2021 pthL_strL_options_grepTo_pout IS OP pthL strL grepOptions pout - search for strL in pthL # this is good practice before getting to the sed version From middle-of-last night : #] "$d_Qndfs"'QNial symbol names - computability.txt' - [typeCheck, consistency, etc] #] www.BillHowell.ca 22Oct2021 initial +-----+ 23Oct2021 continue to [create, edit] checks ... ********************* loaddefs link d_Qndfs 'QNial optr symbol changes.ndf' +-----+ 24Oct2021 fault handling : general rule for [test, check] returns : true = `l, otherwise faultL IMPORTANT! - faultL = fault LIST, not a simple fault! fault_null_comparisons IS - looking athow [flt, null] behave >> created fault_null_comparisons to help understand [test, check]s - returns of [l, null, fault[,L]] pth_typ_exists IS OP pth typer - returns true if a [dir, pth] exists, or can be created +-----+ pinnL_strL_options_grepTo_pout - grep search for each string in strL, for all paths in pthL : pinnL_strL_options_grepTo_pout IS OP pinnL strL grepOptions pout - [multiple, "parallel"]cart[strL, pinnL] grep search, (pout = 1) for stdOut pout is archived, automatically providing an historic comparison across times this is run. Note that [pinnL, strL] must be lists!! This requires [] if only one [pth, str] is provided if problematic sed chrs are in strL, then customized [grep, QNial [slow, limited]!] approaches required This operator makes a VERY limited use of grep capabilities! But this should be [robust, easy] to use. pinnL_strL_options_grepTo_pout_output IS OP pthL strL grepOptions pout - produce outPut file, compare to standard & output diff to log file pinnL_strL_options_grepTo_pout_test IS - >> nasty problems : pinnL_strL_options_grepTo_pout_test tests weren't working - [fault, null, list, etc] returns ********************* loaddefs link d_Qtest 'fileops/file_ops- test.ndf' +-----+ pthL_resultL_faultL_shortenTo_Codes IS OP pthL resultL faultL - [dat1L, resultL] for faults are converted to codes for brevity in the output of course, a resultCode of l (true) is kept the same >> created pthL_resultL_faultL_shortenTo_Codes to clarify changes to output pth_typ_exists_test IS - res ipsa loquitor, types = [p_ = path, d_ = dir]cart[old, new] >> moved optrs back to 'QNial optr symbol changes.ndf' +-----+ olde code # olde code IF (= 'stdout' pout) THEN outputStr := '' ; ELSE outputStr := link ' >>"' pout '" ' ; ENDIF ; % write link 'pout = ' pout ; # 23Oct2021 it is NOT useful to have an opeerator for descriptions - # my normal "Table of Contents" do that very well! # loaddefs link d_Qndfs 'QNial optr symbol changes.ndf' IF flag_debug THEN write 'loading pth_get_optrDescL' ; ENDIF ; #] pth_get_optrDescL IS OP pth - find optrDescL in path, recursive find user [op,expr] #] optrDescL is a list of operator symName descriptions, pth is normally a QNial ndf file #] descriptions are the one-line comments that precede declarations #] pth_typ_checkExists must be done BEFORE calling this optr # 15Oct2021 initial pth_get_optrDescL IS OP pth { host_result link 'grep --line-number " IS OP " "' pth '" ') } # loaddefs link d_Qndfs 'QNial optr symbol changes.ndf' IF flag_debug THEN write 'loading pth_get_exprDescL' ; ENDIF ; #] pth_get_exprDescL IS OP pth - find exprDescL in path, recursive find user [op,expr] #] exprDescL is a list of expression symName descriptions, pth is normally a QNial ndf file #] descriptions are the one-line comments that precede declarations #] pth_typ_checkExists must be done BEFORE calling this optr #] This will "drag in" operators, when there are two or more spaces between "IS" and "OP" # 15Oct2021 initial pth_get_exprDescL IS OP pth { host_result link 'grep --line-number "^#] .* IS " "' pth '" ' } FOR pth WITH pthL DO host link 'echo "" ' outputStr ; host link 'echo "+----+" ' outputStr ; host link 'echo "processing path : ' pth '" ' outputStr ; cmd := link 'grep ' grepOptions ' "' grep_expr '" "' "' pth '" ' outputStr ; host link 'echo "' cmd '" ' outputStr ; host cmd ; ENDFOR ; 08********08 #] 21Oct2021 [new, modified] code for 'QNial setup.ndf' qNial_get_userSymLL - should be OK pth_getOptrExpr_declDescLines - ?status pthL_strL_options_runGrep_pout #] Moved optrs in incomplete state (but ease of reference) #] [qNial_get_userSymLL, userWkSpc_extract_symLL, pthL_existsCheck, strL_check IS OP strL, #] strOldNewL_pairCheck, options_findGrepSedPhr_regexprCheck, #] searchReplaceL_findGrepSedPhr_regexprCheck] +-----+ Check userOptrs, for 'QNial setup.ndf' qNial_get_userSymLL IS - extract lists of user symbols in the QNial workspace, as global data symTypePhr includes ["op, "expr, "var, "ident] userWkSpc_extract_symLL IS - extract lists of user symbols in the QNial workspace, as global data pthL_existsCheck IS OP pthL - check if all pthL are legitimate paths, l if true, fault if not strL_check IS OP strL - check if all strL are legitimate paths, l if true, fault if not strOldNewL_pairCheck IS OP strOldNewL - check that strOldNewL is a pair of strings, l if true, fault if not options_findGrepSedPhr_regexprCheck IS OP options findGrepSedPhr - (21Oct2021 not started code yet) check for problematic [find, grep, sed] characters, l if true, fault if not searchReplaceL_findGrepSedPhr_regexprCheck IS OP searchReplaceL findGrepSedPhr - check for problematic [find, grep, sed] characters in [[search, replace] terms, l if true, fault if not 08********08 #] 21Oct2021 clean up 'QNial setup[, header].ndf', upgrade several Table of Contents" for easier tracking >> Whew, that was a 5.6 hour head-[banger, spinner] #] "$d_Qtest""fileops/file_ops- development.txt" #] 21Oct2021 these old optrs are really NOT the way to go! They were removed from 'file_s.ndf' : +-----+ [NOT, SELDOM] used backup [pth, dir]s : pth_backupDatedTo_dir IS OP pth dirBackup - backup dated version of a file to dirBackup pth_backupTo_dir IS OP pth dirBackup - NOT USED normally, clumsy pth_backupDatedToSameDir IS OP pth - DON'T USE normally, clutters up working dir pth_backupDated_delete IS OP pth - DON'T USE normally!! rename a file with date precursor +-----+ crappy old tools for using [find, grep, sed] : pinn_sedPretreat_poutFixed IS OP pinn - pre-process pinn to handle [apo, quote,'&\/\n']) pinnFixed_sedPostTreat_pout IS OP pout - translate pname_inn for QNial use +-----+ Specialized stuff for 2017 IJCNN Alaska : line_charcodes IS OP pth line_start line_end - convert ASCII file lines to charcodes over interval rename_files IS [later ... OP dname fname_oldPattern fname_newPattern] - rename a bunch of files pthL_moveEach IS - move selected files listed in text file 08********08 #] 20Oct2021 move optr[declaration, test]s t"standard files" +-----+ [new, modified] code for file_ops.ndf pth_typ_exists IS OP pth typer - returns true if a [dir, pth] exists, or can be created pth_typ_exists_test IS - res ipsa loquitor types = [p_ = path, d_ = dir]cart[old, new] pth_isEmpty IS OP pth - returns l if true and o if false, applicable to [dir, pth]s Warning : if a path does not exist, then as per Linux convention, this returns o (non-existent files aren't empty!) pth_isEmpty_test IS - res ipsa loquitor types = [p_ = path, d_ = dir]cart[old, new] pth_backupDatedTo_zArchive[,_output] IS OP pth >> done pth_backupDatedTo_zArchive all core files! Change : +-----+ pth_backupDatedTo_zArchive_output IS OP pth { LOCAL p_latestBackup p_temp result ; NONLOCAL d_temp ; % ; p_temp := link d_temp 'pth_backupDatedTo_zArchive temp.txt' ; pth_backupDatedTo_zArchive pth ; p_latestBackup := pth_find_latestZarchive pth ; % ; noerror := l ; result := p_latestBackup ; IF (isfault first p_latestBackup) THEN noerror := o ; IF ('backup corrupted' subStr_in_str (link EACH string p_latestBackup)) THEN write 'p_latestBackup = ' p_latestBackup ; host link 'rm "' p_latestBackup '" ' ; result := pth_find_latestZarchive pth ; ENDIF ; ENDIF ; % ; IF noerror THEN host (link 'diff --width=85 "' pth '" "' p_latestBackup '" --suppress-common-lines >"' p_temp '" ') ; IF (NOT pth_isEmpty p_temp) THEN result := fault '?pth_backupDatedTo_zArchive error : backup is not the same as original' ; ELSE result := l ; ENDIF ; ENDIF ; result } +-----+ To : +-----+ pth_backupDatedTo_zArchive_output IS OP pth { LOCAL p_latestBackup p_temp result ; NONLOCAL d_temp ; % ; p_temp := link d_temp 'pth_backupDatedTo_zArchive temp.txt' ; pth_backupDatedTo_zArchive pth ; p_latestBackup := pth_find_latestZarchive pth ; % ; noerror := l ; result := p_latestBackup ; IF (isfault first p_latestBackup) THEN noerror := o ; IF ('backup corrupted' subStr_in_str (link EACH string p_latestBackup)) THEN write 'p_latestBackup = ' p_latestBackup ; host link 'rm "' p_latestBackup '" ' ; result := pth_find_latestZarchive pth ; ENDIF ; ENDIF ; % ; IF noerror THEN host (link 'diff --width=85 "' pth '" "' p_latestBackup '" --suppress-common-lines >"' p_temp '" ') ; IF (NOT pth_isEmpty p_temp) THEN result := fault '?pth_backupDatedTo_zArchive error : backup is not the same as original' ; ELSE result := l ; ENDIF ; ENDIF ; result } +-----+ +-----+ olde code # loaddefs link d_Qndfs 'QNial optr symbol changes.ndf' IF flag_debug THEN write 'loading pth_backupDatedTo_zArchive_output' ; ENDIF ; #] pth_backupDatedTo_zArchive_output IS OP i_test pinn - common optr to execute & ouput diff to log file # 19Oct2021 initial using current approach to tests # IF flag_break THEN BREAK ; ENDIF ; pth_backupDatedTo_zArchive_output IS OP pth { LOCAL p_latestBackup p_temp result ; NONLOCAL d_temp ; % ; p_temp := link d_temp 'pth_backupDatedTo_zArchive temp.txt' ; pth_backupDatedTo_zArchive pth ; p_latestBackup := pth_find_latestZarchive pth ; write 'p_latestBackup = ' p_latestBackup ; % ; noerror := l ; result := p_latestBackup ; IF (isfault first p_latestBackup) THEN noerror := o ; IF ('backup corrupted' subStr_in_str (link EACH string p_latestBackup)) THEN host link 'rm "' p_latestBackup '" ' ; result := pth_find_latestZarchive pth ; ENDIF ; ENDIF ; % ; IF noerror THEN host (link 'diff --width=85 "' pth '" "' p_latestBackup '" --suppress-common-lines >"' p_temp '" ') ; IF (NOT pth_isEmpty p_temp) THEN result := fault '?pth_backupDatedTo_zArchive error : backup is not the same as original' ; ELSE result := l ; ENDIF ; ENDIF ; result } # olde code | grep ' chr_apo '^>' chr_apo ' | sed ' chr_apo 's/^>\ //' chr_apo ' # subStr_in_str 'hello' 'hello Dolly' '" --suppress-common-lines >"' p_temp '" 2>&1 ') ; IF flag_debug THEN write 'loading pth_backupDatedTo_zArchive' ; ENDIF ; #] pth_backupDatedTo_zArchive IS OP pth - SAFE WORKING backup file to a z_Archive dated today (create?) # zArchive is [specific, with respect] to each path, it is not an overall zArchive # Notice that there is no error output (write) - that must be handeled by the calling optr! # 24Oct2020 new variant of [pth_backupDated, pth_backupDated_delete] # 13Jun2021 initial adapted from pth_backupDatedTo_dir # For [single, small number of] path backups # PROBLEM - Often, different files in different directories have the same name. At present, this operator overwrites backups of [earlier, same-name but different] files. # some fileNames don't have extensions! # In the future - special naming (eg part of original dirName) to avoid this, with checks. # should force this !!!! - no "update option ; $ man cp - -u, --update, copy only when the SOURCE file is newer than the destination file ; % or when the destination file is missing ; IF flag_break THEN BREAK ; ENDIF ; pth_backupDatedTo_zArchive IS OP pth { LOCAL d_zArchive dir fname noError p_out result ; noError := l ; dir fname := pth_extract_dirFname pth ; d_zArchive := link dir 'z_Archive/' ; IF (NOT pth_typ_exists pth "p_old) THEN noError := o ; ELSEIF (NOT pth_typ_exists d_zArchive "d_old) THEN result := host_result link 'mkdir "' d_zArchive '"' ; ELSE p_out := link d_zArchive timestamp_YYMMDD_HMS ' ' fname ; host link 'cp -p "' pth '" "' p_out '" ' ; ENDIF ; noError } IF flag_debug THEN write 'loading pth_backupDatedTo_zArchive_test' ; ENDIF ; #] pth_backupDatedTo_zArchive_test IS - res ipsa loquitor # 13Jun2021 initial pth_backupDatedTo_zArchive_test IS { LOCAL d_zArchive dir fname p_out ; d_Fauci := link d_webRawe 'Pandemics, health, and the Sun/corona virus/Fauci covid emails/' ; f_emailsClean1 := '210609 Leopold - Anthony Fauci emails, NIH Freedom Of Information Act, 1st clean.txt' ; path := link d_Fauci f_emailsClean1 ; write post pth_extract_dirFname path ; pth_backupDatedTo_zArchive path ; } IF flag_debug THEN write 'loading pth_exists_test' ; ENDIF ; #] pth_exists_test IS - res ipsa loquitor, types = [p_ = path, d_ = dir]cart[old, new] pth_exists_test IS { null } # being revamped in 'QNial optr symbol changes.ndf' ... # loaddefs link d_Qtest 'fileops/file_ops- test.ndf' IF flag_debug THEN write 'loading HDdrive_mountCheck' ; ENDIF ; #] HDdrive_mountCheck IS OP dir_to_test - checks if hard drive is mounted (dumb coding?) HDdrive_mountCheck IS OP dir_to_test { NONLOCAL dir QNial ; fpth_log := link d_Qroot 'z_HDdrive_mountCheck.txt' ; cmd := link 'ls >"' fpth_log '" "' dir_to_test '"' ; write 'HDdrive_mountCheck : ' cmd ; host cmd ; fin := open fpth_log "r ; line1_directory_output := readfile fin ; close fin ; IF isfault line1_directory_output THEN o ELSE l ENDIF } IF flag_debug THEN write 'loading pthL_strL_grepOptions_linesTo_pout_test' ; ENDIF ; #] pthL_strL_grepOptions_linesTo_pout_test IS - search strL in pathL, return lines that hit # [construct, run] a grepExpr, assumes that ALL pathL are valid files! (check before calling!) # the number of strs is limited in [find, grep, sed] or the expressions exceed maxLength= ?? IF flag_break THEN BREAK ; ENDIF ; pthL_strL_grepOptions_linesTo_pout_test IS { LOCAL inputs n_cols n_rows OKL optr optrArgs resultL p_stdRslt stdResultL test_tbl testNumL pathLL strLL grepOptionL poutL commentL ; NONLOCAL d_Qtest ; % ; optr := "pthL_strL_grepOptions_linesTo_pout ; d_testy := link d_Qtest 'fileops/[test, std, result] files/' ; p_stdRslt := link d_testy 'pthL_strL_grepOptions_linesTo_pout std results.txt' ; p_result := link d_testy 'pthL_strL_grepOptions_linesTo_pout calc results.txt' ; % ; write '' ; write '+-----+' ; write link '#] ' (string optr) ' test ' timestamp_DDMMMYYYY_HMS ; write '' ; % ; % input order [testNumL, pathLL, strLL, grepOptionL, poutL, commentL] ; inputs := "t01 [[link d_testy 'test- file_ops.ndf']] [[' IS OP ']] [' '] '?comment?' "t02 [[link d_testy 'test- file_ops.ndf']] [[' IS ']] [' -w '] '?comment?' "t03 [[link d_testy 'test- file_ops.ndf']] [[' for ']] [' -c '] '?comment?' "t04 [[link d_testy 'test- file_ops.ndf']] [[' for ']] [' -cw '] '?comment?' ; n_cols := 5 ; n_rows := floor ((gage shape inputs) / n_cols) ; testNumL pathLL strLL grepOptionL commentL := cols (n_rows n_cols reshape inputs) ; % ; % Note the [[p_result]] to prevent mix from generating a chrL ; optrArgs := EACH link (rows transpose mix (pathLL strLL grepOptionL (n_rows reshape [[p_result]]) ) ) ; % write optrArgs ; % write (n_rows reshape [p_result]) ; applyArgs := (n_rows reshape optr) EACHBOTH append optrArgs ; EACH apply applyArgs ; strLhitL := pth_read_strL p_result ; % ONLY used to setup stdResultL!!, comment out otherwise ; strL_write_pout strLhitL p_stdRslt ; stdRsltL := pth_read_strL p_stdRslt ; IF flag_break THEN BREAK ; ENDIF ; diffRslt := host_result link 'diff "' p_stdRslt '" "' p_result '" --suppress-common-lines ' ; IF (= '' diffRslt) THEN OK := n_rows ; ELSE OK := 0 ; ENDIF ; test_tbl := 1 5 reshape ('test#' 'pathLL' 'strLL' 'grepOptionL' 'comments') ; test_tbl := aryL_join_vertical test_tbl (transpose mix (testNumL pathLL strLL grepOptionL commentL)) ; write test_tbl ; write '' ; write 'IF OK ~= n_rows,then you have to check p_result to see which test # failed' ; write (2 3 reshape 'operator' 'OK' 'total' optr OK n_rows ) ; optr OK n_rows } # tests-in-waiting : "t10 ('file_ops.ndf' 'test- QNial setup.ndf' 'test- strings.ndf') ['hello'] ' -c ' 'stdto' '?comment?' "t11 ('file_ops.ndf' 'test- QNial setup.ndf' 'test- strings.ndf') ['hello'] ' -c ' 'stdto' '?comment?' "t12 ('file_ops.ndf' 'test- QNial setup.ndf' 'test- strings.ndf') ['hello'] ' -c ' 'stdto' '?comment?' "t20 ('file_ops.ndf' 'test- QNial setup.ndf' 'test- strings.ndf') ['hello'] ' --invert-match ' 'stdto' '?comment?' "t21 ('file_ops.ndf' 'test- QNial setup.ndf' 'test- strings.ndf') ['hello'] ' -c ' 'stdto' '?comment?' "t22 ('file_ops.ndf' 'test- QNial setup.ndf' 'test- strings.ndf') ['hello'] ' -c ' 'stdto' 'n/a - will create more tests later' 08********08 #] 19Oct2021 pth_backupDatedTo_zArchive_test - revamp with standard test files! pth_backupDatedTo_zArchive_test IS { LOCAL d_zArchive dir fname p_out ; d_Fauci := link d_webRawe 'Pandemics, health, and the Sun/corona virus/Fauci covid emails/' ; f_emailsClean1 := '210609 Leopold - Anthony Fauci emails, NIH Freedom Of Information Act, 1st clean.txt' ; path := link d_Fauci f_emailsClean1 ; write post pth_extract_dirFname path ; pth_backupDatedTo_zArchive path ; } >> done with 1 wrong calcf 5 - result is OK, just can't get the code inttest_tbl good enough, at least backups work +-----+ olde code IF flag_debug THEN write 'loading pth_backupDatedTo_zArchive' ; ENDIF ; #] pth_backupDatedTo_zArchive IS OP pth - SAFE WORKING backup file to a z_Archive dated today (create?) # zArchive is [specific, with respect] to each path, it is not an overall zArchive # Notice that there is no error output (write) - that must be handeled by the calling optr! # 24Oct2020 new variant of [pth_backupDated, pth_backupDated_delete] # 13Jun2021 initial adapted from pth_backupDatedTo_dir # For [single, small number of] path backups # PROBLEM - Often, different files in different directories have the same name. At present, this operator overwrites backups of [earlier, same-name but different] files. # some fileNames don't have extensions! # In the future - special naming (eg part of original dirName) to avoid this, with checks. # should force this !!!! - no "update option ; $ man cp - -u, --update, copy only when the SOURCE file is newer than the destination file ; % or when the destination file is missing ; IF flag_break THEN BREAK ; ENDIF ; pth_backupDatedTo_zArchive IS OP pth { LOCAL d_zArchive dir fname noError p_out result ; noError := l ; IF flag_break THEN BREAK ; ENDIF ; dir fname := pth_extract_dirFname pth ; d_zArchive := link dir 'z_Archive/' ; IF (NOT pth_typ_exists pth "p_old) THEN noError := o ; ELSEIF (NOT pth_typ_exists d_zArchive "d_old) THEN result := host_result link 'mkdir "' d_zArchive '"' ; ELSE p_out := link d_zArchive timestamp_YYMMDD_HMS ' ' fname ; host link 'cp -p "' pth '" "' p_out '" ' ; ENDIF ; noError } IF flag_debug THEN write 'loading pth_typ_exists' ; ENDIF ; #] pth_typ_exists IS OP pth typer - returns true if a [dir, pth] exists, or can be created # 11Oct2020 initial version, this makes it easier to check code for all cases # 04Jun2021 modified & shortened - tgoing to screw up a lot of legacy coding!!!! pth_typ_exists bash if dir pth dir pth exits already "d_old "p_old '-d' '-f' can create "d_new "p_new '-d' '-f' # while one can test for faults with QNial's "open" operator, this checks BEFORE any opens % for "w, it doesn't matter if a file exists, it is overwritten ; % for "a, it does matter, but I don't include "a below yet 17Oct2020 ; # 26Oct2020 must accomodate (I just added to setup.ndf) - but that's OK, no changes needed! : stdInn := 0 stdOut := 1 stdTmp := link d_temp 'stdTmp.txt' ; # 05Jun2021 NYET? : result should be an error if paty is a problem? # 16Oct2021 modified to simplify expression : # '[ ' typet ' "' paty '" ] && echo l >"' p_hostCmdRslt '" || echo o >"' p_hostCmdRslt '" ' # 16Oct2021 wdoes it mean d_new when dir is provided? add to end (given path is legit), # or is egive IF flag_break THEN BREAK ; ENDIF ; pth_typ_exists IS OP pth typer { LOCAL noError paty typet result ; NONLOCAL p_temp ; % ; } pth_typ_exists IS OP pth typer { null } # being revamped in 'QNial optr symbol changes.ndf' ... #! 06Sep2021 for deletion : file_exists_z IS z_pth_exists IF flag_debug THEN write 'loading pth_size' ; ENDIF ; #] pth_size IS OP pth - returns the filesize pth_size IS OP pth { LOCAL result ; null } #! 06Sep2021 for deletion : file_size_z IS z_pth_size # tests $ ls -l "/home/bill/SWAPPER/Servers/HELP contacts/200122 16h16m00s Inbox" qnial> towords1 '-rw-r--r-- 1 bill bill 114703 Jan 22 23:16 /home/bill/SWAPPER/Servers/HELP contacts/200122 16h16m00s Inbox' qnial> pth_size '/home/bill/SWAPPER/Servers/HELP contacts/200122 16h16m00s Inbox' qnial> pth_size (link d_Qroot 'nial7_LMDE64') IF flag_debug THEN write 'loading pth_size_human' ; ENDIF ; #] pth_size_human IS OP pth - returns the filesize in human-readable [T, GM, k]-bytes pth_size_human IS OP pth { LOCAL result ; null } 08********08 #] 18Oct2021 pth_size_test, pth_backupDatedTo_zArchive - fix!! +-----+ 19Oct2021 pth_size_test - now works properely with dirs I [rearrange, symChange]ed so that '$ qnial' loads cleanly pth_backupDatedTo_zArchive - fix!! file_ops,ndf change : +.....+ pth_exists +.....+ To : +.....+ pth_typ_exists +.....+ >> none in [strings, [array, table], boolean, windows...].ndf $ qnial >> loads cleanly pth_backupDatedTo_zArchive in file_ops.ndf change : +.....+ IF (NOT pth_typ_exists "d_old d_zArchive) THEN ... IF (NOT AND (EACH pth_typ_exists ("d_old d_zArchive) ("p_old pth))) +.....+ To : +.....+ IF (NOT pth_typ_exists d_zArchive "d_old) THEN ... IF (NOT AND (EACH pth_typ_exists (d_zArchive "d_old) (pth "p_old))) +.....+ >> pth_typ_exists will affect MANY optrs!!! mostly in file_ops.ndf?? pth_typ_exists_test works fine... >> as stated above, none in [strings, [array, table], boolean, windows...].ndf So this doesn't affect "first pass" mass symbol [name, arg[order, number]] work This has only 1 test!? - must use standard test files!! #] pth_backupDatedTo_zArchive_test IS - res ipsa loquitor # 13Jun2021 initial pth_backupDatedTo_zArchive_test IS { LOCAL d_zArchive dir fname p_out ; d_Fauci := link d_webRawe 'Pandemics, health, and the Sun/corona virus/Fauci covid emails/' ; f_emailsClean1 := '210609 Leopold - Anthony Fauci emails, NIH Freedom Of Information Act, 1st clean.txt' ; path := link d_Fauci f_emailsClean1 ; write post pth_extract_dirFname path ; pth_backupDatedTo_zArchive path ; } #] pZarchive_restore IS OP pth - restore most recent pth_backupDatedTo_zArchive of a file, #] retain the backup pZarchive_restore in file_ops.ndf change : +.....+ IF (NOT pth_typ_exists "d_old d_zArchive) THEN ... IF (NOT pth_typ_exists "p_old pth) +.....+ To : +.....+ IF (NOT pth_typ_exists d_zArchive "d_old) THEN ... IF (NOT pth_typ_exists pth "p_old) +.....+ >> do the same for other optrs using pZarchive_restore in file_ops.ndf >> none in [strings, [array, table], boolean, windows...].ndf pZarchive_restore still doesn't work : check pth_extract_dirFname # qnial> findall `/ (link d_Qndfs 'strings.ndf') 0 6 11 17 31 37 45 qnial> fin_slash := last findall `/ (link d_Qndfs 'strings.ndf') 45 qnial> (fin_slash + 1) [take, drop] (link d_Qndfs 'strings.ndf') +----------------------------------------------+-----------+ |/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/|strings.ndf| +----------------------------------------------+-----------+ qnial> post (pth_extract_dirFname link d_Qndfs 'strings.ndf') (pth_extract_dirFname 'strings.ndf') (pth_extract_dirFname '') (pth_extract_dirFname null) +------------------------------------------------------------+ |+----------------------------------------------+-----------+| ||/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/|strings.ndf|| |+----------------------------------------------+-----------+| +------------------------------------------------------------+ |?pth_extract_dirFname - no OR[directory, fname]! | +------------------------------------------------------------+ |?pth_extract_dirFname - no OR[directory, fname]! | +------------------------------------------------------------+ |?pth_extract_dirFname - no OR[directory, fname]! | +------------------------------------------------------------+ >> OK NUTS!! I forgot to fix as above : pth_backupDatedTo_zArchive in file_ops.ndf change : IF (NOT AND (EACH pth_typ_exists (d_zArchive "d_old) (pth "p_old))) lq_fileops check qnial> timestamp_YYMMDD_HMS 211019 14h03m09s >> OK -->[nextv] pth_typ_exists pth "p_old -->[nextv] >> why does it return null? result - extraneous variable, delete it and stay with noerror Hah! I forgot : loaddefs link d_Qndfs 'QNial optr symbol changes.ndf' #] pth_typ_exists_test IS - I revamped to provide footnote long form of error, all tests OK pth_backupDatedTo_zArchive (link d_Qndfs 'strings.ndf') >> OK! it works EACH pth_backupDatedTo_zArchive (link d_Qndfs 'strings.ndf') (link d_Qndfs 'file_ops.ndf') (link d_Qtest 'QNial optr symbol changes - header.ndf') (link d_Qndfs 'QNial optr symbol changes.ndf') (link d_Qndfs 'array, table.ndf') (link d_Qndfs 'boolean.ndf') (link d_Qndfs 'windows [open, close, ID, title], [get,set,move] cart [posn,size].ndf' ) >> OK! all backups are good. What a relief! +-----+ # olde code # pth_exists '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' "d_old # pth_exists '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/noExist/' "d_old # pth_exists '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/test- strings.ndf' "p_old # pth_exists '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/test- empty file.txt' "p_old # pth_exists '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/strngs.ndf' "p_new # qnial> pth_isEmpty '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/' ?L qnial> pth_size '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/' ?tonumber arg is not a string holding a number Tbyte # qnial> pth_isEmpty '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' ?L # pth_isEmpty '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/noExist/' # pth_isEmpty '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/test- strings.ndf' # pth_isEmpty '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/test- empty file.txt' # pth_isEmpty '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/strngs.ndf' # apply "pth_isEmpty # tests qnial> pth_size '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' total 0 $ ls -l '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' total 0 qnial> pth_size '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' total 0 qnial> pth_size '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/test- strings.ndf' qnial> pth_size '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/test input files/test- empty file.txt' # pth := link d_Qtest 'fileops/test input files/test- strings.ndf' # a := first str_cutBy_chr (last host_result link 'du --total --human-readable "' pth '" ') ` #qnial> pth_backupDatedTo_zArchive (link d_Qndfs 'strings.ndf') # (link d_Qroot 'PuetzUWS - Universal Waves Series.ndf') (link d_Qndfs 'strings.ndf') (link d_Qndfs 'file_ops.ndf') EACHLEFT pth_backupDatedTo_zArchive (link d_Qndfs 'z_Archive/') EACHLEFT pth_backupDatedTo_zArchive (link d_Qndfs 'z_Archive/') 08********08 #] 18Oct2021 pth_isEmpty[, _test] This needs to be generalized for dirs. geany [regexpr, multi-line] : search "\'.*\'" \n replace "should fail - only applies to filePaths, not dirs (return o)' \n" oops- pth_exists not working now. Why??? qnial> loaddefs link d_Qndfs 'QNial optr symbol changes.ndf' loading pth_isEmpty ?undefined identifier: QNIAL <***> > PTH_ISEMPTY >> stray words - I commented out For some reason,now works!??? (sighhhh...) qnial> pth_size '/media/bill/Dell2/Website - raw/Qnial/code develop_test/fileops/dir empty tests (dont add files)/' total 0 bool[,ean]List -> boolL indexLists -> indexLs (careful, as indexList also used! - later clean up) indexList -> indexL (careful, as indexList also used! - later clean up) Wow! was I mixed up, still am 4/24 tests FAIL!! : +--+------------+-------------------------------------+-----+----+-------------------------------------------- | o|04_d_empty |dir empty tests (dont add files)/ |p_new| o|??should be OK - dir exists even though empt | o|03_p_exists |test input files/strings.ndf |p_old| o|??should be OK - pth exists | o|04_p_exists |test input files/strings.ndf |p_new| o|??should be OK - containing dir exists, so a | o|04_p_noExist|test input files/strngs.ndf |p_new| o|??should be OK - containing dir exists (find +--+------------+-------------------------------------+-----+----+-------------------------------------------- In my opinion : 04_d_empty 03_p_exists 04_p_exists 04_p_noExist definitely should work >> oops - incomplete coding in pth_exists! : pth_exists change : +.....+ ELSEIF (AND (= "p_new typer) (???)) THEN typet := '-type d' ; +.....+ To : +.....+ ELSEIF (= "p_new typer) THEN typet := '-type d' ; +.....+ OK, now only failure is an important one : 03_p_exists why does this fail? >> IDIOT! I forgot to preface fname with 'test- strings.ndf' OK - now works! Check : $ find "$d_Qtest"'fileops/test input files/strings.ndf' -type f $ find "$d_Qtest"'fileops/test input files/strings.ndf' -maxdepth 0 -type f >> -maxdepth 0 works fine +-----+ I should add a conditional to [d, p]_new - if the proposed new [subDir, pth] exists, returns false p_ovr to overwite pth, but safer NOT to so so with dir!! >> but what will the impact be on legacy code? pth_exists change : +.....+ ELSEIF (= "p_new typer) THEN typet := '-type d' ; paty := (( last str_posnLOfChr1st_subStr paty '/') + 1) take paty ; ELSE result := fault (link '?pth_exists error : unrecognized typet' typer) ; noError := o ; ENDIF ; ... IF noError THEN result := first host_result (link 'find "' paty '" -maxdepth 0 ' typet) ; IF (OR (null = result) (': No such file or directory' subStr_in_str result) (isfault result) ) THEN result := o ; ELSE result := l ; ENDIF ; ENDIF ; +.....+ To : +.....+ ELSEIF (= "p_new typer) THEN typet := '-type d' ; paty := (( last str_posnLOfChr1st_subStr paty '/') + 1) take paty ; ELSEIF (= "p_ovr typer) THEN typet := '-type d' ; paty := (( last str_posnLOfChr1st_subStr paty '/') + 1) take paty ; ELSE result := fault (link '?pth_exists error : unrecognized typet' typer) ; noError := o ; ENDIF ; ... IF noError THEN result := first host_result (link 'find "' paty '" -maxdepth 0 ' typet) ; IF (OR (null = result) (': No such file or directory' subStr_in_str result) (isfault result) ) THEN result := o ; ELSE result := l ; ENDIF ; % ; % should not overwrite if path already exists and "p_new is used! (use "p_ovr for that) ; IF (AND (= "p_new typer) (= l result)) THEN IF (pth_exists pth "p_old) THEN EACH write '?pth_exists error: path already exists. to overwite use typer "p_ovr' ; pth result := o ; ENDIF ; ENDIF ; ENDIF ; +.....+ #] "p_ovr typer in pth_exists works -> prevents overwrite unless "p_ovr is specified #] but what will effect on legacy code be? 08********08 #] 17Oct2021 path_[exists, isEmpty] continued...tests #] pth_exists_test IS - res ipsa loquitor # loaddefs link d_Qtest 'fileops/file_ops- test.ndf' loading pZarchive_restore_test_output ?expecting end of block: '"' ) ; <***> ?undefined identifier: LINK 'echo "" >>"' P_LOG <***> '"' ; } loading pthL_strL_grepOptions_linesTo_pout_test ?undefined identifier: % ONLY used to setup stdResultL!!, comment out otherwise ; +-----+ str_replaceIn_pth testing loading str_replaceIn_pth_output ?undefined identifier: % Note that for tests, flag_backup is false ; loading str_replaceIn_pth_test ?undefined identifier: 'test- 1872-2020 SP500 index, ratio of opening price to semi-log detrended price.html' loading pth_replace_wordL_test_output ?undefined identifier: IF ( PTH_ISEMPTY <***> P_LOG ) THEN loading pthL_replace_wordL_test ?undefined identifier: := LINK D_QTESTY <***> 'file_ops- test log.txt' ; FLOG All pth_exists_test have error : type ?op_parameter >> probably due to improper handling of phrases nyet - I didn't use 2-dat input format, although I did "try" to copy it pth_exists IS OP pth typer optr change : +.....+ result := first host_result (link 'find "' paty '" -maxdepth 0 ' typet) ; +.....+ To : +.....+ result := first host_result (link 'find "' paty '" -maxdepth 0 ' typet) ; +.....+ continue tomorrow... 08********08 #] 16Oct2021 further symName cleanups... +-----+ 17Oct2021 continue ... 'file_ops.ndf' #] pth_exists IS OP typer path - returns true if a [directory, path] exists, or can be created 'QNial setup.ndf' : I reversed the argOrder to 'pth typer' as per convention, and changed [path, pathL, pathLL]_ to [pth, pthL, pthLL]_ throughout file_ops[,_test].ndf' entered into optr_names_rawof link d_Qtest 'QNial optr symbol changes - header.ndf' $ find "$d_Qndfs" -type f -name "file_ops.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep --with-filename --line-number "path_" LINE >> many _path - change these too : _[path, IS OP pth] $ find "$d_Qndfs" -type f -name "file_ops.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep --with-filename --line-number "path_" LINE ~ >> OK #] pth_retrieve_subDirFname IS OP pth dirBase - returns (subDir fname) from a path 17Oct2021 pth_backupDatedTo_zArchive is probably broken!! pthList -> pthL Do the same thing in [file_ops- test,strings, QNial setup, 'array, table', boolean].ndf strings - zilch QNial setup - many array, table - zilch boolean - zilch >> perfect example of modularizing libraries, at les for file optrs and their usage bye & loaddef to see damage >>> loading start : file_ops.ndf ?undefined identifier: PTH WITH PTHLIST <***> DO FNAME := ?undefined identifier: STRLIST := STRLIST_READFROM_PTH <***> P_INN ; STRLIST ?undefined identifier: WORDOPTION ; PTHL_STRL_OPTIONS_RUNGREP_POUT <***> PTHL STRL ?undefined identifier: % backup first!! ; ?undefined identifier: LINEL := STRLIST_READFROM_PTH <***> PTH ; STRSINLINESL >>> loading start : windows [open, close, ID, title], [get,set,move] cart [posn,size].ndf ?undefined identifier: TAKE ( PATH_EXTRACT_FNAME <***> POUT ) ) >> not so bad (wait till I get to other files!) strList -> strL file_ops.ndf - perhaps 15+- strings.ndf - perhaps 20+- changed array, table.ndf - a few commines only boolean.ndf - zilch #] 17Oct2021 Too many optrs in many files have been affected - rely on mass opName replacnts! This just has to work with core optrs of first phase also - change pth_backupDatedTo_dir -> pth_backupDatedTo_zArchive file_ops.ndf strings.ndf - none changed (I still retain optr just in case) QNial setup - one redundancy was removed >> I didn't check ['array, table', boolean] bye & loaddef to see damage >>> loading start : file_ops.ndf ?undefined identifier: STRLIST := STRL_READFROM_PTH <***> P_INN ; STRLIST ?undefined identifier: WORDOPTION ; PTHL_STRL_OPTIONS_RUNGREP_POUT <***> PTHL STRL ?undefined identifier: LINEL := STRL_READFROM_PTH <***> PTH ; STRSINLINESL >> oops, missed a few STRL_READFROM_PTH - not defined!? should be changed to pth_read_strL file_ops.ndf - perhaps 10+- changed bye & loaddef to see damage >> I screwed up twice with STRL_READFROM_PTH, now fixed? strL_write_pout -> strL_writeTo_pth bye & loaddef to see damage >>> loading start : file_ops.ndf ?undefined identifier: STRL ; STRL_WRITETO_PTH <***> STRL P_OUT ; ?undefined identifier: WORDOPTION ; PTHL_STRL_OPTIONS_RUNGREP_POUT <***> PTHL STRL >> getting there... winIDorName_copyAllTextTo_pout -> winIDorName_copyAllTextTo_pth >> I can't find [STRL_WRITETO_PTH, PTHL_STRL_OPTIONS_RUNGREP_POUT] >> wow, go it at last, mst have been errors "further along" in optr defns hidden by previous errors All initial wkSpc loads no errors now +-----+ # olde code #] path_isEmpty IS OP path - returns l if true and o if false # doesn't work : path_isEmpty IS OP path { IF (AND (path_exists "p_old path) (= 0 (path_size path))) THEN result := 'l' ; ELSE result := 'o' ; ENDIF ; boolean result } # cmd := link 'cat "' p_optrDeclL '" "' p_optrDescL '" "' p_exprDeclL '" "' p_exprDescL '" >"' pcalc '" ' ; % write cmd ; host link cmd ; # a := transpose mix lll (1 2 3) ('a' 'b' 'c') # b := transpose mix lll ooo lol olo # c := 3 1 reshape ('d' 'b' 'f') # d := aryL_join_horizontal (aryL_join_horizontal (transpose mix lll (1 2 3) ('a' 'b' 'c')) (transpose mix lll ooo lol olo)) (3 1 reshape ('d' 'b' 'f')) # IF (path_isEmpty pdiff) THEN diffL := link diffL l ; ELSE diffL := link diffL o ; ENDIF ; ENDFOR ; diffL # ENDFOR ; o o o o # pstndL pcalcL := cols EACH link cart [link d_testy 'path_getOptrExpr_declDescLines, ' 'blah-blah, '] ('optrDeclL' 'optrDescL' 'exprDeclL' 'exprDescL') (' stnd.txt' ' calc.txt') # cntOptrDecl cntOptrDesc cntExprDecl cntExprDesc cntOptrDecl := first str_cutTo_wordList (first (host_result link 'wc -l "' pcalc_optrDecl '" ')) chrs_QNialSymbols ; cntOptrDesc := first str_cutTo_wordList (first (host_result link 'wc -l "' pcalc_optrDesc '" ')) chrs_QNialSymbols ; cntExprDecl := first str_cutTo_wordList (first (host_result link 'wc -l "' pcalc_exprDecl '" ')) chrs_QNialSymbols ; cntExprDesc := first str_cutTo_wordList (first (host_result link 'wc -l "' pcalc_exprDesc '" ')) chrs_QNialSymbols ; # a := aryL_join_horizontal (transpose mix (OKL testNumL finnL)) ( mix OKLL) # b := aryL_join_horizontal a (n_cols 1 reshape commentL) # c := aryL_join_vertical (1 8 reshape ('OK' 'test#' 'fname' 'optrDeclL' 'optrDescL' 'exprDeclL' 'exprDescL' 'comments') ) b +-----+ #] path_exists IS OP typer path - returns true if a [directory, path] exists, or can be created # path_exists "p_old (link d_Qtest 'fileops/[test, std, result] files/test- empty file.txt') # path_exists "p_new (link d_Qtest 'fileops/[test, std, result] files/test- empty file.txt') # path_exists "p_old (link d_Qtest 'fileops/[test, std, result] files/test2- empty file.txt') # path_exists "p_old (link d_Qtest 'fileops/[test, std, result] files/') # path_exists "d_old (link d_Qtest 'fileops/[test, std, result] files/test2- empty file.txt') # path_exists "d_old (link d_Qtest 'fileops/[test, std, result] files/') # path_exists "d_new (link d_Qtest 'fileops/[test, std, result] files/') # path_exists "d_new (link d_Qtest 'fileops/[test, std, result] files2/') # $ find "$d_Qtest"'fileops/[test, std, result] files/test- empty file.txt' -type f # $ find "$d_Qtest"'fileops/[test, std, result] files/test- empty file.txt' -type d # $ find "$d_Qtest"'fileops/[test, std, result] files/test- empty file2.txt' -type f # $ find "$d_Qtest"'fileops/[test, std, result] files/test- empty file.txt' -type d # $ find "$d_Qtest"'fileops/[test, std, result] files/' -type f # $ find "$d_Qtest"'fileops/[test, std, result] files/' -maxdepth 0 # olde code noError := l ; paty := path ; result := null ; % a new [path, subDir] is truncated to the already-existing directory ; IF (= "d_old typer) THEN typet := '-d' ; ELSEIF (= "p_old typer) THEN typet := '-f' ; ELSEIF (= "d_new typer) THEN typet := '-d' ; paty := ((last last str_posnLOfChr1st_subStr paty `/) + 1) take paty ; ELSEIF (= "p_new typer) THEN typet := '-d' ; paty := (( last str_posnLOfChr1st_subStr paty `/) + 1) take paty ; ELSE result := fault (link '?path_exists error : unrecognized typet' typer) ; noError := o ; ENDIF ; % ; IF noError THEN % write 'paty = ' paty ; result := first host_result link '[ ' typet ' "' paty '" ] && echo l || echo o ' ; ENDIF ; result IF noError THEN % write 'paty = ' paty ; result := path_read_strL path ; IF (gage shape ENDIF ; IF noError THEN write 'typet = ' typet ', paty = ' paty ; result := first host_result (link '[[ ' typet ' "' paty '" ]] && echo l || echo o ') ; ENDIF ; result #] pth_retrieve_subDirFname IS OP pth dirBase - returns (subDir fname) from a path # old code IF (chr_in_str `# path) THEN path ELSEIF (= 'http' ( 4 take path)) THEN path ELSE fname := pth_extract_fname path ; fPath := first ((fname EACHRIGHT str_in_pth webSiteAllPathList) sublist webSiteAllPathList) ; % write 'fPath = ' fPath ; IF (isfault fPath) THEN path ELSE subDirFname := str_takeAfter_subStr fPath dirBase ; link '[#=; backtrack ;=#]' subDirFname ENDIF ENDIF 08********08 #] 15Oct2021 path_getOptrExpr_declDescLines[,_[output, test]] #] path_getOptrExpr_declDescLines IS OP path - find user [op,expr]cart[Decl,Desc]s in path # debug cmd : $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep " IS OP " >> works, but includes Table of Contents (TOC) $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^.* IS OP " >> still includes TOC don't work : $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^\t.* IS OP " ~ $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^\t.* IS OP " ~ $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^\t[.]* IS OP " ~ $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^ .* IS OP " >> only get TOC $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^^\( \).* IS OP " ~ $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^[^ ]\{3\}.* IS OP " >> only gets optr declarations, eg : array_findAll_subArray IS OP subArray array_to_search { null } boolean IS OP chrIntStr { null } booleanL_cut_list IS OP booleanL ary { null } >> I would also like to get optr descriptive lines, eg : #] boolean IS OP BoolChrIntPhrStr - convert [chr, str, int] to boolean $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^[^ ]\{3\}.* IS OP " >> aptures optr description lines in 'QNial setup.ndf" like : array_findAll_subArray IS OP subArray array_to_search { null } boolean IS OP chrIntStr { null } booleanL_cut_list IS OP booleanL ary { null } >> for now just do twice and link??? $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^#] .* IS OP " >> captures optr description lines, looks good? $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep "^[ ]\{3\}.* IS OP " >> captures optr declaration lines, looks good? 08********08 #] 14Oct2021 path_getOptrExpr_declDescLines[,_[output, test]] at the time, called : QndfOps_symbolChange[Identify, Pretest,] Operators transferred to ndf files : 13Oct2021 I forgot to write down many others transferred ... #] boolean.ndf #] boolA_cut_ary IS OP boolA ary - extract an ary (array) of subArys from booleanL #] array, table.ndf #] atomA_restructSameAs_ary IS OP atomA ary - only effective for top-most structure of ary #] strings.ndf #] strL_cutBy_chrL IS OP strL chrL - cut each strL by all chrL, omitting chrL, lists only #] fileops.ndf #] pZarchive_restore IS OP path - restore most recent path_backupDatedTo_zArchive of a file, #] pathL_replace_wordL IS OP pathL wordOldNewL flag_word flag_backup - #] change [str, word]L each pathL #] pathL_replace_strL IS OP pathL wordOldNewL flag_backup - change strL each pathL #] pathL_strL_grepOptions_linesTo_pout IS OP pathL strL grepOptions pout - search strL in pathL #] [first, stupid] approach! #] it became clear a day or two later that the QNial 'see "symbol' is perfect! opPhr_identify_opInL IS OP opPhr { LOCAL cmd opStr p_opIn ; % ; opStr := string opPhr ; % identify the ndf file defining the optr, beware of duplicates! ; cmd := link 'find "$d_Qndfs" -name "*.ndf" | grep --invert-match "z_Old" | grep --invert-match "z_Archive" | tr \\n \\0 | xargs -0 -IFILE grep --with-filename --line-number "^\(#] \)' opStr ' IS " "FILE" | sed "s|/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/||;s/\(.*\):[0-9]*:\(.*\)/\1:\2/" | sort -u ' ; write cmd ; p_opIn := host_result cmd ; IF (= '' p_opIn) THEN write link 'opPhr_identify_opInL : opPhr ' opStr ' not found' ; ELSE EACH write p_opIn ; ENDIF ; % ; % collect the optr definition ; } 08********08 #] 11Oct2021 opPhr_ary_LEAFreplaceWith_aryStatic Still have probelms with : ary_to_atomL_test ary_to_atomL 3 8 why isnt [all] split into chrs? chrA_anyIn_strA_test chrA_anyIn_strA 0 11 fails due to non-simple (nested) chrA?? I need to generalize ary_to_atomL pathL_strL_options_runGrep_pout_test no test works - incomplete coding? Qndfs_optr_symbol_changes_test not working I moved optr that pass (most) tests : from: link d_Qtest '210929 Qndfs optr symbol changes.ndf' to: [strings, array, table] cart [.ndf, - test.ndf] remaining -> only pathL_strL_options_runGrep_pout [optr, test] test "t20 "link '' ' : postWord' ('� : postWord' '� : postWord' '� : postWord') 'obvious' ; qnial> charrep ` -18 qnial> charrep `� -17 qnial> charrep `� -17 qnial> charrep `� -17 from strings.n : qnial> charrep '∫' -30 -120 -85 +-----+ olde code # quick tests # transpose mix ((tell 20) (reverse tell 20)) # OUTER pass ((tell 20) (reverse tell 20)) #olde code % calcL := EACH LEAF_ary1aryStatic (transpose mix optrL dat1L dat2L) ; % calcL := EACH (LEAF_ary1aryStatic aryInn_replaceWith_aryOut) (rows transpose mix dat1L dat2L) ; n_cols := 6 ; n_rows := floor ((gage shape inputs) / n_cols) ; testNumL optrL dat1L dat2L stdL commentL := cols (n_rows n_cols reshape inputs) ; % ; IF flag_break THEN BREAK ; ENDIF ; allRowL := rows (transpose mix testNumL optrL dat1L dat2L stdL commentL) ; optrRowL := ("aryInn_replaceWith_aryOut EACHRIGHT = optrL) sublist allRowL ; calcL := EACH (LEAF_ary1aryStatic aryInn_replaceWith_aryOut) optrRowL ; OKL := stdL EACHBOTH = calcL ; test_tbl := transpose mix (OKL testNumL optrRowL dat1L dat2L stdL calcL commentL) ; test_tbl := table_add_colTitles test_tbl ('OK' 'test#' 'optr' 'dat1' 'dat2' 'std' 'calc' 'comments') ; optrRows := rows (transpose mix testNumL optrL dat1L dat2L stdL commentL) ; # olde code # % if I use `| instead of `/ as sed_separator, will that work (eg directories)? ; # loaddefs link d_Qtest '210929 Qndfs optr symbol changes.ndf' # EACH (gage shape) testNumL pathLL strLL grepOptionL poutL commentL # mix transpose mix ('path1' 'path2' 'path1') strLL grepOptionL poutL # $ d_testy="$d_Qtest"'fileops/[test, std, result] files/' # $ p_stdRslt="$d_testy"'pathL_strL_grepOptions_linesTo_pout std results.txt' # $ p_result="$d_testy"'211013 20h55m57s pathL_strL_grepOptions_linesTo_pout calc results.txt' # $ diff "$p_stdRslt" "$p_result" --suppress-common-lines # $ cat "$d_Qtest""fileops/[test, std, result] files/test- QNial setup.ndf" | grep " IS OP " # olde code IF (~= 'stdOut' (first pout)) THEN host link 'rm "' pout '" ' ; ENDIF ; ptmp_grepOut := link d_temp 'pathL_strL_grepOptions_linesTo_pout grepOut.txt' ; ptmp_pathL := link d_temp 'pathL_strL_grepOptions_linesTo_pout pathL.txt' ; strL_write_pout pathL ptmp_pathL ; host link 'cat "' ptmp_grepOut '" ' outputStr ; 08********08 #] 11Oct2021 continue [test, new, revise old] [strings, fileops, array, boolean] cart [optr, test]s $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep --with-filename --line-number "isEven" LINE Problems with shape of result : optrPhr_LEAF_ary_aryStatic (cart optrPhr ary [aryStatic]) # cols mix (3 EACHRIGHT reshape "hello [1 `t `z ] [lll]) # optrPhr_LEAF_ary_aryStatic "aryInn_replaceWith_aryOut `z l qnial> cart "hello (2 2 reshape tell 4) +-------+-------+ |hello 0|hello 1| +-------+-------+ |hello 2|hello 3| +-------+-------+ qnial> cart "hello (2 2 reshape tell 4) l +---------+---------+ |hello 0 l|hello 1 l| +---------+---------+ |hello 2 l|hello 3 l| +---------+---------+ qnial> cart "hello (2 2 reshape tell 4) (2 2 reshape (10 + tell 4)) +----------+----------+ +----------+----------+ |hello 0 10|hello 0 11| |hello 1 10|hello 1 11| +----------+----------+ +----------+----------+ |hello 0 12|hello 0 13| |hello 1 12|hello 1 13| +----------+----------+ +----------+----------+ ... +----------+----------+ +----------+----------+ |hello 2 10|hello 2 11| |hello 3 10|hello 3 11| +----------+----------+ +----------+----------+ |hello 2 12|hello 2 13| |hello 3 12|hello 3 13| +----------+----------+ +----------+----------+ qnial> cart "hello (2 2 reshape tell 4) [2 2 reshape (10 + tell 4)] +---------------+ +---------------+ |+-----+-+-----+| |+-----+-+-----+| ||hello|0|10 11|| ||hello|2|10 11|| || | |12 13|| || | |12 13|| |+-----+-+-----+| |+-----+-+-----+| +---------------+ +---------------+ |+-----+-+-----+| |+-----+-+-----+| ||hello|1|10 11|| ||hello|3|10 11|| || | |12 13|| || | |12 13|| |+-----+-+-----+| |+-----+-+-----+| +---------------+ +---------------+ qnial> mix cart "hello (2 2 reshape tell 4) [2 2 reshape (10 + tell 4)] +-----+-+-----+ +-----+-+-----+ |hello|0|10 11| |hello|1|10 11| | | |12 13| | | |12 13| +-----+-+-----+ +-----+-+-----+ ... +-----+-+-----+ +-----+-+-----+ |hello|2|10 11| |hello|3|10 11| | | |12 13| | | |12 13| +-----+-+-----+ +-----+-+-----+ qnial> 2 0 blend cart "hello (2 2 reshape tell 4) [2 2 reshape (10 + tell 4)] +-----+-----+ +-----+-----+ |hello|hello| |hello|hello| +-----+-----+ +-----+-----+ +-+-+ +-+-+ |0|1| |2|3| +-+-+ +-+-+ +-----+-----+ +-----+-----+ |10 11|10 11| |10 11|10 11| |12 13|12 13| |12 13|12 13| +-----+-----+ +-----+-----+ qnial> 2 1 blend cart "hello (2 2 reshape tell 4) [2 2 reshape (10 + tell 4)] +-----+-----+ +-+-+ +-----+-----+ |hello|hello| |0|1| |10 11|10 11| +-----+-----+ +-+-+ |12 13|12 13| +-----+-----+ +-----+-----+ +-+-+ +-----+-----+ |hello|hello| |2|3| |10 11|10 11| +-----+-----+ +-+-+ |12 13|12 13| +-----+-----+ qnial> 1 0 blend cart "hello (2 2 reshape tell 4) [2 2 reshape (10 + tell 4)] +-----+-----+ |hello|hello| +-----+-----+ |hello|hello| +-----+-----+ +-+-+ |0|1| +-+-+ |2|3| +-+-+ +-----+-----+ |10 11|10 11| |12 13|12 13| +-----+-----+ |10 11|10 11| |12 13|12 13| +-----+-----+ qnial> 2 2 reshape (mix cart "hello (2 2 reshape tell 4) [2 2 reshape (10 + tell 4)]) +-----+-----+ |hello| 0| +-----+-----+ |10 11|hello| |12 13| | +-----+-----+ qnial> ary := ((2 2 reshape ('hot' ((2 2 reshape (l (ll) (2 2 reshape l) l))) (2 2 reshape (1 `t `z ['all'])) 'small')) ) +---------+-------+ |hot |+--+--+| | || l|ll|| | |+--+--+| | ||ll| l|| | ||ll| || | |+--+--+| +---------+-------+ |+-+-----+|small | ||1|t || | |+-+-----+| | ||z|+---+|| | || ||all||| | || |+---+|| | |+-+-----+| | +---------+-------+ qnial> a := cart "hello ary [aryStatic] +-----------------+ +-------------------+ |+-----+---+-+ | |+-----+---------+-+| ||hello|hot|l| | ||hello|+-+-----+|l|| |+-----+---+-+ | || ||1|t || || +-----------------+ || |+-+-----+| || |+-----+-------+-+| || ||z|+---+|| || ||hello|+--+--+|l|| || || ||all||| || || || l|ll|| || || || |+---+|| || || |+--+--+| || || |+-+-----+| || || ||ll| l|| || |+-----+---------+-+| || ||ll| || || +-------------------+ || |+--+--+| || |+-----+-----+-+ | |+-----+-------+-+| ||hello|small|l| | +-----------------+ |+-----+-----+-+ | +-------------------+ qnial> b := 1 lower (cart "hello ary [aryStatic]) +---------------------+-------------------+ |+-------------+ |+-----------------+| ||+-----+---+-+| ||+-----+-------+-+|| |||hello|hot|l|| |||hello|+--+--+|l||| ||+-----+---+-+| ||| || l|ll|| ||| |+-------------+ ||| |+--+--+| ||| | ||| ||ll| l|| ||| | ||| ||ll| || ||| | ||| |+--+--+| ||| | ||+-----+-------+-+|| | |+-----------------+| +---------------------+-------------------+ |+-------------------+|+---------------+ | ||+-----+---------+-+|||+-----+-----+-+| | |||hello|+-+-----+|l|||||hello|small|l|| | ||| ||1|t || ||||+-----+-----+-+| | ||| |+-+-----+| |||+---------------+ | ||| ||z|+---+|| ||| | ||| || ||all||| ||| | ||| || |+---+|| ||| | ||| |+-+-----+| ||| | ||+-----+---------+-+|| | |+-------------------+| | +---------------------+-------------------+ qnial> c := EACH first (1 lower (cart "hello ary [aryStatic])) +-------------------+-----------------+ |+-----+---+-+ |+-----+-------+-+| ||hello|hot|l| ||hello|+--+--+|l|| |+-----+---+-+ || || l|ll|| || | || |+--+--+| || | || ||ll| l|| || | || ||ll| || || | || |+--+--+| || | |+-----+-------+-+| +-------------------+-----------------+ |+-----+---------+-+|+-----+-----+-+ | ||hello|+-+-----+|l|||hello|small|l| | || ||1|t || ||+-----+-----+-+ | || |+-+-----+| || | || ||z|+---+|| || | || || ||all||| || | || || |+---+|| || | || |+-+-----+| || | |+-----+---------+-+| | +-------------------+-----------------+ 13Oct2021 optrPhr_LEAF_ary_aryStatic -> optrPhr_LEAF_aryStatic_ary This can be simplified by arranging the atomArgs at the start of the cart, then using a single REDUCE transformer : qnial> a := cart "hello [aryStatic] ary +-------------------+-----------------+ |+-----+-+---+ |+-----+-+-------+| ||hello|l|hot| ||hello|l|+--+--+|| |+-----+-+---+ || | || l|ll||| | || | |+--+--+|| | || | ||ll| l||| | || | ||ll| ||| | || | |+--+--+|| | |+-----+-+-------+| +-------------------+-----------------+ |+-----+-+---------+|+-----+-+-----+ | ||hello|l|+-+-----+|||hello|l|small| | || | ||1|t |||+-----+-+-----+ | || | |+-+-----+|| | || | ||z|+---+||| | || | || ||all|||| | || | || |+---+||| | || | |+-+-----+|| | |+-----+-+---------+| | +-------------------+-----------------+ qnial> b := 2 lower (cart "hello [aryStatic] ary) +---------------------------------------+ |+-------------------+-----------------+| ||+-----+-+---+ |+-----+-+-------+|| |||hello|l|hot| ||hello|l|+--+--+||| ||+-----+-+---+ || | || l|ll|||| || || | |+--+--+||| || || | ||ll| l|||| || || | ||ll| |||| || || | |+--+--+||| || |+-----+-+-------+|| |+-------------------+-----------------+| ||+-----+-+---------+|+-----+-+-----+ || |||hello|l|+-+-----+|||hello|l|small| || ||| | ||1|t |||+-----+-+-----+ || ||| | |+-+-----+|| || ||| | ||z|+---+||| || ||| | || ||all|||| || ||| | || |+---+||| || ||| | |+-+-----+|| || ||+-----+-+---------+| || |+-------------------+-----------------+| +---------------------------------------+ qnial> c := first (2 lower (cart "hello [aryStatic] ary)) +-------------------+-----------------+ |+-----+---+-+ |+-----+-------+-+| ||hello|hot|l| ||hello|+--+--+|l|| |+-----+---+-+ || || l|ll|| || | || |+--+--+| || | || ||ll| l|| || | || ||ll| || || | || |+--+--+| || | |+-----+-------+-+| +-------------------+-----------------+ |+-----+---------+-+|+-----+-----+-+ | ||hello|+-+-----+|l|||hello|small|l| | || ||1|t || ||+-----+-----+-+ | || |+-+-----+| || | || ||z|+---+|| || | || || ||all||| || | || || |+---+|| || | || |+-+-----+| || | |+-----+---------+-+| | +-------------------+-----------------+ Nah, not worth it? I can only have one atomIndex for reduce, so doing twice is not much better than EACH first +-----+ olde code # a := (1 `t `z ) # b := ((2 2 reshape ('hot' ((2 2 reshape (l (ll) (2 2 reshape l) l))) (2 2 reshape (1 `t `z ['all'])) 'small')) ) # ary_to_atomL b # olde code (most recent at top of stack): IF (OR EACH isAtom ary) THEN link ary ELSE link link EACH ary_to_atomL (link ary) ENDIF IF (OR EACH isAtom ary) THEN link ary ELSE link link EACH ary_to_atomL ary ENDIF IF (OR EACH isAtom ary) THEN write ary ; link ary ELSE write ary ; link link EACH ary_to_atomL ary ENDIF IF (EACH isAtom ary) THEN write ary ; link ary ELSE write ary ; link EACH ary_to_atomL ary ENDIF IF (EACH isAtom ary) THEN ary ELSE link EACH ary_to_list ary ENDIF IF (EACH isAtom ary) THEN link ary ELSE link EACH ary_to_list ary ENDIF # ELSE listA := EACH ary_to_list ary ; shapeA := gage shape listA ; IF (= null shapeA) THEN shapeA := 1 ; ENDIF ; (* shapeA) reshape listA # stack explosion : IF (isAtom ary) THEN ary ELSE link ary_to_list ary ENDIF ELSE EACH optrPhr_LEAF_ary_aryStatic (mix optrPhr (EACH pass ary) (EACH pass aryStatic)) # ary1 := ((2 2 reshape ('hot' ((2 2 reshape (l (ll) (2 2 reshape l) l))) (2 2 reshape (1 `t `z ['all'])) 'small')) ) # aryStatic := l # LEAF_ary1aryStatic aryInn_replaceWith_aryOut (ary1 aryStatic) 08********08 #] 07Oct2021 NEW test format for all Qndfs_optr_symbol_changes_test # boolA_cut_ary_test IS - extract an ary (array) of subArys from booleanL >> OK, after simple fixes to [optr, test] it works beautifully. This is a much simpler test format to set up, and will help in the future I retain my old test formats - too much work to convert until I need ggregate results (as demands require this). Qndfs_optr_symbol_changes_test : testPhrL := "boolA_cut_ary_test "ary1_transStr_isSameStructAs_ary2_test "atomA_restructSameAs_ary_test "strL_cutBy_chrL_test "pZarchive_restore_test "pathL_replace_wordL_test >> reformat these tests in sequence # ary1_transStr_isSameStructAs_ary2_test IS - use different transformers with the same test data >> OK, beautiful... # atomA_restructSameAs_ary_test IS - use different transformers with the same test data >> OK, beautiful... # pZarchive_restore_test IS OP - restore most recent path_backupDatedTo_zArchive of a file, 09Sep2021 continue upgrade optr pZarchive_restore_test : Problematic ft for last : # strL_cutBy_chrL IS OP strL chrL - cut each strL by all chrL, omitting chrL, ??lists only (not arys)?? +-----+ olde code # use for debugging simple level of test : eachResults twigResults leafResults := cols mix stdResults ; # normal use with ary1_transStr_isSameStructAs_ary2_calcResults : eachResults := ary1_transStr_isSameStructAs_ary2_calcResults dat1 'EACH' dat2 ; twigResults := ary1_transStr_isSameStructAs_ary2_calcResults dat1 'TWIG' dat2 ; leafResults := ary1_transStr_isSameStructAs_ary2_calcResults dat1 'LEAF' dat2 ; IF flag_debug THEN write 'loading ary1_transStr_isSameStructAs_ary2_calcResults' ; ENDIF ; # ary1_transStr_isSameStructAs_ary2_calcResults IS OP dat1L transStr dat2L - # used for a series of tests in ary1_transStr_isSameStructAs_ary2_test # 02Oct2021 initial IF flag_break THEN BREAK ; ENDIF ; ary1_transStr_isSameStructAs_ary2_calcResults IS OP dat1L transStr dat2L { LOCAL ; n_rows := gage shape dat1L ; arg := rows transpose mix (dat1L (n_rows reshape (solitary transStr)) dat2L) ; EACH ary1_transStr_isSameStructAs_ary2 arg } IF flag_debug THEN write 'loading atomA_restructSameAs_ary_calcResults' ; ENDIF ; # atomA_restructSameAs_ary_calcResults IS OP atomAL aryL - # used for a series of tests in atomA_restructSameAs_ary_test # 02Oct2021 initial IF flag_break THEN BREAK ; ENDIF ; atomA_restructSameAs_ary_calcResults IS OP atomAL aryL { LOCAL ; IF flag_break THEN BREAK ; ENDIF ; n_rows := gage shape atomAL ; arg := rows transpose mix (atomAL aryL) ; EACH atomA_restructSameAs_ary arg } IF flag_debug THEN write 'loading pathL_replace_strL' ; ENDIF ; # pathL_replace_strL IS OP pathL strOldNewL flag_backup d_backupRoot - # change strOld to strNew throughout pathL, backup to d_backupRoot 'z_Archive/' # DANGEROUS! safer if one can use words, eg pathL_replace_word # need to upgrade to multi-sed # beware of possible alternate appearances of the f_Pattern!! # use only for filePaths, or other well-constrained strings!! # d_backupRoot MUST have a subDir 'z_Archive/' # example to file html pages in website : # qnial> pathL := host_result (link 'find "$d_webRawe" -type f -name "*.html"') # qnial> pathL_replace_str l d_webRawe '/media/bill/Dell2/Website - raw/' '' pathL # 11Sep2021 INCOMPLETE, untested pathL_replace_strL IS OP pathL strOldNewL flag_backup d_backupRoot { LOCAL d_backup flag_backup pinn ; % ; IF flag_backup THEN d_backup := link d_backupRoot 'z_Archive/' timestamp_YYMMDD_HMS ' backups pathL_replace_str/' ; host link 'mkdir "' d_backup '" ' ; ENDIF ; % ; IF (NOT path_exists "d_old d_backup) THEN EACH write '?pathL_replace_str error : could not create d_backup : ' d_backup ; ELSE FOR pinn WITH pathL DO IF (NOT path_exists ("p_old pinn)) THEN EACH write '' '?pathL_replace_str error, file unknown : ' pinn '' ; ELSE IF flag_backup THEN pinn path_backupDatedTo_dir d_backup ; ENDIF ; path_replace_str pinn strOld strNew flag_backup d_backup ; ENDIF ; ENDFOR ; ENDIF ; } # path_replace_str IS OP path strOld strNew flag_backup - res ipsa loquitor # DANGEROUS! safer if one can use words, eg path_replace_word, need to upgrade to multi-sed # defaults to path_backupDatedTo_zArchive # 13Oct2020 there will be problems with strOld inside of words, escaping critical chars, etc, etc # defaults to path_backupDatedTo_zArchive # 13Oct2020 there will be problems with strOld inside of words, escaping critical chars, etc, etc # use only for filePaths, or other well-constrained strings!! # 25May2020 example from 'webSite maintain [menu, header, footer, body] links, TableOfContents.ndf' : writeDoStep (link 'path_replace_strList l ' chr_apo d_webRawe chr_apo ' ' chr_apo '!!linkError!!' chr_apo ' ' chr_apo '[#=; backtrack ;=#]' chr_apo ' ' 'htmlPathsSortedByPath' ) ; # 25May2021 needed to fix str_replace_subStr - was igoring null replacement, and returning original str # 11Sep2021 should have different version using sed (cannot simply handle sed restricted : $.*/[\]^ &\/\n) # 11Sep2021 INCOMPLETE, untested # 11Sep2021 example setup in link d_Qroot 'Working file.ndf' # not so useful, as only fileops.ndf is affected!! I didn't run it to check optr_updates IS { pathL := d_Qndfs EACHRIGHT link 'file_ops.ndf' '' '' ; strNew := 'path_replace_str' ; pathL_replace_str pathL 'replaceStringIn_path' strNew l (link d_Qndfs 'z_Archive/') ; pathL_replace_str pathL 'str_replaceSubStrIn_path' strNew l (link d_Qndfs 'z_Archive/') ; pathL_replace_str pathL 'str_replaceIn_path' strNew l (link d_Qndfs 'z_Archive/') ; } # normally should use multi-sed, word based : str-based is dangerous 08********08 #] 07Oct2021 further work on optr_names_raw, adapt some optrs remove loaddefs strings.ndf in : video production/video production/strings.ndf video production/video capture/strings.ndf convert resident ndf files to use generic strings.ndf 'word_replaceIn_dir' 'dir_replace_wordL' I created a NEW test frmat : boolA_cut_ary_test IS - extract an ary (array) of subArys from booleanL >> OK, after simple fixes to [optr, test] it works beautifully. This is a much simpler test format to set up, and will help in the future I retain my old test formats - too much work to convert until I need ggregate results (as demands require this). +-----+ olde code IF flag_debug THEN write 'loading pathL_replace_wordL' ; ENDIF ; #] word_replaceIn_path IS OP sOld sNew p_inn cList flag_backup - # change word throughout file using sed # therefore cannot easily handle sed restricted : $.*/[\]^ &\/\n # Howell defines word as string bounded by "whiteSpace", which depends on usage (eg Qnial symbols, filePaths, etc) # ddOct2020 initial - still not completed word_replaceIn_path IS OP sOld sNew p_inn cList flag_backup { LOCAL p_temp pathList ; p_grep := link d_temp 'path_replace_wordL greps.txt' ; p_temp := link d_temp 'path_replace_wordL temp.txt' ; IF (NOT AND (EACH path_exists ("p_old p_inn) ("p_new p_grep) ("p_new p_temp))) THEN write fault link '?path_replace_wordL file unknown error : OR [p_inn, p_temp]' ; ELSE IF flag_backup THEN path_backupDated_retain p_inn ; ENDIF ; finn := open p_inn "r ; ftemp := open p_temp "w ; % for [efficiency, speed] first cull lines that have sOld ; cmd := link 'grep "' sOld '" "' finn '" ' >"' p_grep '" ' ; write cmd ; % host cmd ; IF (NOT path_exists "p_old p_grep) THEN write fault link '?path_replace_wordL file unknown error : p_grep' ; ELSE fgrep := open p_grep "r ; WHILE (NOT isfault (line := readfile fgrep)) DO line := last string_cutBy_char line `: ; writefile ftemp (link str_replaceIn_strList sOld sNew) ; % what else? ; ENDWHILE ; close fgrep ; ENDIF ; EACH close finn ftemp ; ENDIF ; } # word_replaceIn_path IS OP sOld sNew p_inn cList flag_backup - change word throughout file # develop an operator that does a whole list of (sOld sNew) - might be more efficient? # 15Oct2020 - much later... IF flag_debug THEN write 'loading pathL_replace_wordL' ; ENDIF ; #] pathL_replace_wordL IS OP pathL wordOldNewL flag_backup d_backup - # change word throughout file using sed, # therefore cannot easily handle sed restricted : $.*/[\]^ &\/\n # Howell defines word as string bounded by "whiteSpace", which depends on usage (eg Qnial symbols, filePaths, etc) # ddOct2020 initial - still not completed # 10Sep2021 looks dangerous! not finished -> converted to sed, but QNial allows proper backups # but I should reincarnate an [alternate, more general, vastly slower] QNial version pathL_replace_wordL IS OP pathL wordOldNewL flag_backup d_backup { LOCAL ptmp pathList ; NONLOCAL chrs_sed_notSearch chrs_sed_notReplace ; % ; noerror := l ; IF (OR (chrs_sed_notSearch EACHLEFT = (EACH first wordOldNewL)) (chrs_sed_notReplace EACHLEFT = (EACH second wordOldNewL)) ) THEN noerror := o ; write link '?pathL_replace_wordL error : illegal chr for sed' ENDIF ; % ; IF noerror THEN p_grep := link d_temp 'path_replace_wordL greps.txt' ; ptmp := link d_temp 'path_replace_wordL temp.txt' ; % ; % test for illegal characters in wordOldNewL ; % if I use `| instead of `/ as sed_separator, will that work (eg directories)? ; sed_expr1 := 's|\b' EACHRIGHT link (EACH first wordOldNewL) ; sed_expr2 := sed_expr1 EACHLEFT link '\b|' ; % 11Sep2021 will the semi-colon cause a problem within the string? (shouldn't) ; sed_expr3 := sed_expr2 EACHBOTH link ((EACH second wordOldNewL) EACHLEFT link '|;') ; sed_expr4 := front link sed_expr3 ; % ; FOR pinn WITH pathL DO IF (NOT path_exists "p_old pinn) THEN EACH write '?pathL_replace_wordL, file unknown : ' pinn '' ; ELSE IF flag_backup THEN path_backupDatedTo_zArchive pinn ; ENDIF ; % do I have to remove the final trailing '\|' or perhaps put a dummy in? ; cmd := link 'sed "' sed_expr4 '" "' pinn '" >"' ptmp '" ' ; write cmd ; host cmd ; host link 'mv "' ptmp '" "' pinn '"' ; ENDIF ; ENDFOR ; ENDIF ; } #! 06Sep2021 for deletion : replaceWordIn_path _z IS z_path_replace_wordL #! 06Sep2021 for deletion : word_replaceIn_path_z IS z_path_replace_wordL # 11Sep2021 example # pathL := d_Qndfs EACHRIGHT link 'audio notes.txt' 'diff - see also txtFile compare.ndf.txt' 'Scratchpad.txt' # wordOldNewL := ('the' 'theyyy') ('see' 'seexxx') ('mas' 'maszzz') # pathL_replace_wordL pathL wordOldNewL l (link d_Qndfs 'z_Archive/') # wordOldNewL := ('theyyy' 'the') ('seexxx' 'see') ('maszzz' 'mas') >> 11Sep2021 Cool! works like a reversible charm!!! IF flag_debug THEN write 'loading pathL_replace_wordL' ; ENDIF ; #] pathL_replace_wordL IS OP pathL wordOldNewL flag_word flag_backup - # change [str, word]L each pathL # uses sed, therefore cannot simply handle sed restricted : search $.*/[\]^ replace &\/\n # backups to z_Archive under dir of file being backed up. Auto-created if doesn't exist # 10Sep2021 initial based on pathL_replace_strL # pathL_replace_wordL_test # DANGEROUS to not set [flag_backup, flag_word] == l !!! # but there are situations ... (eg pre-backup all pathL) # sed option \b uses sed or regexpr characters for word boundaries (can this be changed?) # Howell defines word as string bounded by "whiteSpace", which depends on usage # eg [Qnial symbols, filePaths, etc] # 10Sep2021 perhaps I should reincarnate an [alternate, more general, vastly slower] QNial-only version? # especially for sed restricted : search $.*/[\]^ replace &\/\n IF flag_break THEN BREAK ; ENDIF ; pathL_replace_wordL IS OP pathL wordOldNewL flag_word flag_backup { LOCAL ptmp pathList wordOption ; % ; noerror := l ; p_grep := link d_temp 'path_replace_wordL greps.txt' ; ptmp := link d_temp 'path_replace_wordL temp.txt' ; % ; % test for illegal characters in wordOldNewL ; % if I use `| instead of `/ as sed_separator, will that work (eg directories)? ; IF (OR ('$.*/[]^' EACHLEFT = (EACH first wordOldNewL)) ('&/' EACHLEFT = (EACH first wordOldNewL)) ) THEN noerror := o ; write '?pathL_replace_wordL error: $.*/[]^ or &/ chrs in strOldNewL' ; ENDIF ; % ; % test that each wordOldNewL is a pair of strings ; IF (= o (AND (AND (2 EACHRIGHT = EACH (gage shape) wordOldNewL)) (AND link (TWIG isstring wordOldNewL)) ) ) THEN noerror := o ; write '?pathL_replace_wordL error: wordOldNewL items must be pairs of strings' ; ENDIF ; % ; % test that each pathL exists ; pathTestStr := "p_old EACHRIGHT pair pathL ; IF (NOT AND (EACH path_exists "p_old EACHRIGHT pair pathL)) THEN noerror := o ; EACH write '?pathL_replace_wordL error: unknown path(s)' ; EACH write pathL ; write '' ; ENDIF ; % ; IF noerror THEN FOR pinn WITH pathL DO IF (NOT path_exists "p_old pinn) THEN EACH write '?pathL_replace_wordL, file unknown : ' pinn '' ; ELSE IF flag_backup THEN EACH path_backupDatedTo_zArchive pathL ; ENDIF ; IF flag_word THEN wordOption := '\b' ; ELSE wordOption := '' ; ENDIF ; sed_expr1 := (link 's|' wordOption) EACHRIGHT link (EACH first wordOldNewL) ; sed_expr2 := sed_expr1 EACHLEFT link (link wordOption '|') ; % 11Sep2021 will the semi-colon cause a problem within the string? (shouldn't) ; sed_expr3 := sed_expr2 EACHBOTH link ((EACH second wordOldNewL) EACHLEFT link '|;') ; % remove the final trailing semi-colon ; sed_expr4 := front link sed_expr3 ; cmd := link 'sed "' sed_expr4 '" "' pinn '" >"' ptmp '" ' ; write cmd ; host cmd ; host link 'mv "' ptmp '" "' pinn '"' ; ENDIF ; ENDFOR ; ENDIF ; } # p_ndfL := host_result link 'find "$d_Qtest" -type f -name "*.ndf" | grep --invert-match "z_Archive" | grep --invert-match "z_Old" | grep --invert-match "code develop_test" | grep --invert-match "Qnial_bag" ' # pathL_replace_wordL IS OP pathL wordOldNewL flag_word flag_backup # pathL_replace_wordL p_ndfL wordOldNewL l l # olde code str_cutBy_subStr IS OP str subStr { LOCAL boolL chrPosns str_length subPosns subStr_length ; subStr_length str_length := EACH tally subStr str ; chrPosns := str_posnLLOfChrAll_subStr str subStr ; boolL := str_length reshape l ; boolL#chrPosns := o ; booleanL_cut_list boolL str } 08********08 #] 05Oct2021 '210929 Qndfs optr symbol changes.ndf' - change optr names for [clarity, consistency] continue with corrections of +-----+ $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep -w -i --with-filename --line-number "chrList_changeChrSet" LINE /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/strings.ndf:88: chrList_changeChrSet IS OP chrList - change chrsAsStrs in chrList from g_chrSet1 to g_chrSet2 /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/strings.ndf:1033:IF flag_debug THEN write 'loading chrList_changeChrSet' ; ENDIF ; /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/strings.ndf:1035:#] chrList_changeChrSet IS OP chrList - change chrsAsStrs in chrList from g_chrSet1 to g_chrSet2 /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/strings.ndf:1037: chrList_changeChrSet IS OP chrList { EACH chrAsStr_changeChrSet chrList } /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/strings.ndf:1039:# chrList_changeChrSet (EACH string 'fUTURE REDUCTION OF ADD PERSONALISATION? fIRST ') /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/strings.ndf:1047:{ link chrList_changeChrSet (EACH string str) /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/strings.ndf:1068: strNew#indxs1 := chrList_changeChrSet strNew#indxs1 ; /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/strings.ndf:1070: strNew#indxs2 := chrList_changeChrSet strNew#indxs2 ; >> Forget it - leave as-is! I would have to work with it to make proper changes : chrList_changeChrSet +-----+ $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep -w -i --with-filename --line-number "ary_to_str" LINE /media/bill/Dell2/Website - raw/Qnial/MY_NDFS/windows [open, close, ID, title], [get,set,move] cart [posn,size].ndf:319: xPosn yPosn xSize ySize := link (EACH ary_to_str winPosn) (EACH ary_to_str winSize) ; 'array, table.ndf' : ary_find1st_subAry find_Howell IS ary_find1st_subAry +-----+ $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep -w -i --with-filename --line-number "ary_convertTo_strA" LINE >> NO instances?!?!? looks wrong? $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep -w -i --with-filename --line-number "array_of_strings" LINE | sed 's|/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/||' video production/video production/strings.ndf: 86:# Array_of_strings A- ensures that every atom is converted to a string, to enable symbolic processing (followed by execute where desired) 330:# array_of_strings A- ensures that every atom is converted to a string, to enable symbolic processing (followed by execute where desired) 332:array_of_strings IS OP A { LEAF string_base A } 86:# Array_of_strings A - ensures that every atom is converted to a string, to enable symbolic processing (followed by execute where desired) 330:# array_of_strings A - ensures that every atom is converted to a string, to enable symbolic processing (followed by execute where desired) 332:array_of_strings IS OP A { LEAF string_base A } QNial setup.ndf:812:# "labelled_arrays" or "array_of_strings" semi-tensor product.ndf: 77:# array_of_strings IS OP A - uses "string_base to convert all LEAFs of A to strings 102:# which are "array_indexLabelleds" or "array_of_strings" 105:# which are "array_indexLabelleds" or "array_of_strings" 137:# or "array_of_strings" to convert numeric to string array 164: I_A_col := array_of_strings Identity_array (alpha / a_col) ; 165: I_B_row := array_of_strings Identity_array (alpha / b_row) ; 213: writescreen picture semi_tensor_prod_symbolic (EACH array_of_strings A B) ; 222:# Semi_tensor_prod_symbolic (EACH array_of_strings A B) symbolic reduction.ndf: 96:# array_of_strings IS OP A - uses "string_base to convert all LEAFs of A to strings semi-tensor product - examples and checks.ndf: 70:A1 B1 := EACH array_of_strings A B ; 58:A1 B1 := EACH array_of_strings A B ; Examples/matrix operations - symbolic & real-valued, examples.ndf: 31: 'C := 1 5 reshape array_of_strings 1 2 3 4 5' 32: 'C2 := 5 1 reshape array_of_strings 20 21 22 23 24' 57: 'As Bs := EACH array_of_strings A B' Kronecker_prod.ndf: 6:# or "array_of_strings" to convert numeric to string array 154:# array_of_strings IS OP A - uses "string_base to convert all LEAFs of A to strings 567:# which are "array_indexLabelleds" or "array_of_strings" 576:# which are "array_indexLabelleds" or "array_of_strings" 603:# which are "array_indexLabelleds" or "array_of_strings" 885:# which are "array_indexLabelleds" or "array_of_strings" 965:# which are "array_indexLabelled" arrays or "array_of_strings" 991:# which are "array_indexLabelleds" or "array_of_strings" 1070:# which are "array_indexLabelleds" or "array_of_strings" >> so array_of_strings produces a strL -> atomStrA_convertTo_strL $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep -w -i --with-filename --line-number "string_base" LINE | sed 's|/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/||' video production/video production/strings.ndf: 321:# string_base IS OP A - ensure every atom is a string, but leaves strings as strings 323:string_base IS OP A 332:array_of_strings IS OP A { LEAF string_base A } semi-tensor product.ndf: 76:# string_base IS OP A - applies "string to an array A, assumes at "lowest level" (atomic or string) 77:# array_of_strings IS OP A - uses "string_base to convert all LEAFs of A to strings symbolic reduction.ndf: 95:# string_base IS OP A - applies "string to an array A, assumes at "lowest level" (atomic or string) 96:# array_of_strings IS OP A - uses "string_base to convert all LEAFs of A to strings matrix operations - symbolic & real-valued.ndf: 153:# string_base IS OP A - applies "string to an array A, assumes at "lowest level" (atomic or string) 154:# array_of_strings IS OP A - uses "string_base to convert all LEAFs of A to strings >> from video production/video production/strings.ndf: 332:array_of_strings IS OP A { LEAF string_base A } >> so string_base -> atomStrA_convertTo_strL $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep -w -i --with-filename --line-number "stripblanks" LINE | sed 's|/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/||' video production/video production/strings.ndf:105:# stripblanks S removes all leading and trailing blanks from a string. video production/video production/strings.ndf:244:Operation: stripblanks Str video production/video production/strings.ndf:249:stripblanks IS OPERATION Str { video production/video production/strings.ndf:258: stripblanks ' This is a string. ' video production/video production/strings.ndf:271: stripblanks ' This is a string. ' video production/video capture/strings.ndf:105:# stripblanks S removes all leading and trailing blanks from a string. video production/video capture/strings.ndf:244:Operation: stripblanks Str video production/video capture/strings.ndf:249:stripblanks IS OPERATION Str { video production/video capture/strings.ndf:258: stripblanks ' This is a string. ' video production/video capture/strings.ndf:271: stripblanks ' This is a string. ' reviews Schmidhuber - references analysis.ndf:44:# stripblanks S removes all leading and trailing blanks from a string. matrix - symbolic reduction.ndf:464: text2 := stripblanks text ; Thunderbird - delete binary attachments.ndf:7: The operation uses the library operations "stripblanks" and "?str_find1stChrOf_subStr?". port_translate_Matlab_to_QNial.ndf:253: res_list := stripblanks func_declare|[ res_start + tell (res_end - res_start + 1) ] ; port_translate_Matlab_to_QNial.ndf:265: fun_name := stripblanks func_declare|[ fun_start + tell (fun_end - fun_start + 1) ] ; matrix - write with parenthesis aligned.ndf:93: nofspace IS OP str { stripblanks str link ' ' } >> so stripblanks -> ???? +-----+ no occurence, no action : $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep -w -i --with-filename --line-number "ary_to_strA" LINE | sed 's|/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/||' >> nothing $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep -w -i --with-filename --line-number "array_to_str" LINE | sed 's|/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/||' >> nothing $ find "$d_Qndfs" -type f -name "*.ndf" | grep --invert-match 'z_Archive' | grep --invert-match 'z_Old' | tr \\n \\0 | xargs -0 -ILINE grep -w -i --with-filename --line-number "array_atomsTo_strs" LINE | sed 's|/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/||' >> nothing +-----+ olde code # 10Dec2021 rename, argOrder OK : str_splitSeparate_subStr IS str_splitSeparate_subStr # Examples str_splitSeparate_subStr 'abcdefghij' 'def' str_splitSeparate_subStr 'abcdefgdefj' 'def' str_splitSeparate_subStr 'abcd /* sdgb' '/*' str_splitSeparate_subStr 'abcd /* sdgb */ /*dkrifggkgfg*/' '/*' str_splitSeparate_subStr 'abcd /* sdgb /*jhkjk *** */ sd/*zfes /*fr' '/*' str := 'Fauci, Anthony (NIH/NlAID) (E] <{-----Subject: Coronavirus on surfaces' str_splitSeparate_subStr str 'Subject: ' #junk for now ... IF flag_debug THEN write 'loading str_splitAtFront_subStr' ; ENDIF ; # listInn_combos_splitAtFront_listOut IS OP listInn combos optrPhr listOut - # splits str at each point that subStr occurs # 16Jun2021 initial lister_subL_matchAndSubLTo_subLOut IS OP lister subL subLOut { LOCAL lister_len ; lister_len := gage shape listInn ; combos := listSeq_findIn_list lo listInn ; combos := (combos EACHLEFT < (lister_len - 1) sublist combos ; comPlus := combos + 1 ; listOut } 08********08 #] ??Sep2021 list of optr name changes planned #+-----+ # from setup.ndf : findAll_Howell findAll_Howell % no change #+-----+ # from fileops.ndf : dir_extract dir_extract_??? replaceStringIn_dir dir_replace_str file_exists path_exists_path file_size path_sizeOf_path file_backupDated_retain path_backupPathDated_retain file_backupDated_delete path_backupPathDated_delete file_changeExtension path_change_extension file_change_lines path_change_linesIn file_exists fileOrDir_exists pname_extract_dirBaseExtn path_extract_dirBaseExtn line_charcodes path_extract_lineChrCodes p_dateTimeStamp path_get_dateTimeStamp insertInPath_fHand path_insertIn_FileHandle insertInPath_fHand path_insertIn_FileHandle replaceStringIn_path path_replace_strIn replaceWordIn_path path_replaceWordIn_path replaceWordIn_dir path_replaceWordIn_dir file_remove_leading_whiteLines path_remove_leadWhiteLines readfile_table path_readTo_table readPath_tabTable path_readTo_tabTable path_read_list path_readTo_list readfile_list path_readTo_list sed_file_pretreat path_sedPretreat sed_file_postreat path_sedPostreat sedPretreat_path path_sedPretreat sedPostreat_path path_sedPostreat file_sortup path_sortupTo_pathOut files_sortCat path_sortupCatTo_pathOut rename_files pathList_rename_paths mv_files_listed pathList_move_paths list_writeTo_path pathList_writeTo_path splitStringTo_words str_splitStringsTo_words findWordIn_string str_find_word replaceWordIn_string str_replace_word writefile_table table_writeTo_path path_write_tabTable tabTable_writeTo_path path_write_wcTable wcTable_writeTo_path URL_download URL_downloadTo_path #+-----+ # from strings.ndf : string_base atomsOfArray_convertTo_strs array_of_strings atomsOfArray_convertTo_strs case_upper str_convertTo_caseUpper case_lower str_convertTo_caseLower cuttext str_cutBy_chr_Q cutStringBy_char str_cutBy_chr cutString str_cutBy_chr string_cut_by_char str_cutBy_chr ???? towords str_cutBy_substr_Q towords1 str_cutBy_substr splitStringWith_string str_cutBy_substr ?multiple versions : check! splitStringBy_subString str_cutBy_substr splitStringByStringWithSub str_cutBy_substr string_split_by_string str_cutBy_substrIn string_splitWith_string str_cutBy_substrOut splitStringTo_strings str_cutBy_strs ??? string_split_by_string_with_sub str_cutBystrWithSub ??? splitStringTo_words str_cutTo_wordList string_wide str_drop_nTailChrs extractFromString_nLeadChrs str_extract_nLeadChrs lead_chrs str_extract_nLeadChrs ??? strings_between str_extractBetween_chrs??? ??? strFull_strFront_extract_strEnd str_extractWith_HeadTail extractStringUseEndsFrom_string str_extractUseEndsFrom ??? strings_between str_extract??? ??? prepadString str_prepad postpadString str_postpad regexp_substitute str_regexp_substitute strOld_sub_strNew_in_strFull str_replace_substr string_sub str_replace_substr replaceStringIn_string str_replace_substr sub_head_midl_tail str_replaceMidlGiven_HeadTail sed_prep_string str_sedPrep sed_unprep_string str_sedUnprep sed str_sed strip_chrs str_stripOff_chrList stripStringOf_chars str_stripOff_chrList stripblanks str_stripOff_tailBlanks ??? spaces only? strip_allBlanks str_stripOff_allBlanks strip_extra_whitespace str_stripOff_extra_whitespace stripStringOf_blanks str_stripOff_blanks stripStringOf_allBlanks str_stripOff_allBlanks stripStringOf_extra_whitespace str_stripOff_extraWhitespace tostring array_create_str ??? tostring_sep str_tostr_sep ??? string_the_numList numList_create_str replaceStringIn_strList strList_replace_str str_replaceIn_strList strList_replace_str temptest webpage_reformatTest 08********08 #] 29Sep2021 change [symbol, arg]s of [strings, fileops, QNial setup].ndf see "$d_Qroot""code develop_test/strings/210910 string ops planning.txt" # enddoc