def atodbref ( s -- d ) "" "#" subst atoi dbref def control? ( d -- i ) ME @ swap .controls def controls ( d d -- i ) over ok? over ok? and if controls else pop pop 0 then def confirm ( s -- i ) ( displays query string and waits for user input-- returns 1 if user said "y" ) me @ swap notify read 1 .yes? def envprop ( d s -- s ) envpropstr swap pop def envsearch ( d s -- d ) envpropstr pop def getenvprotect ( d s -- s ) over over "_" swap strcat .envprop dup if swap pop swap pop else pop .envprop then def getprotect ( d s -- s ) over over "_" swap strcat getpropstr dup if swap pop swap pop else pop getpropstr then def hasflag? ( d s -- i ) ( like flag?, but can be multiple single char flags; returns true if has any of them set ) 0 swap begin dup while 1 strcut swap 4 pick swap flag? rot or swap repeat pop swap pop def max ( i i -- i ) over over < if swap then pop def max_pennies ( -- i ) "max_pennies" sysparm atoi def mdisplay ( s -- ) ( like .tell, but calls a program if starts with an @-sign ) .sqfuncs "mdisplay" call def me_wiz? ( -- i ) ME @ .wizard? def min ( i i -- i ) over over > if swap then pop def nl ( -- s ) ( returns a single MPI newline character ) .sqfuncs "nl" call def nl-repl ( s1 s2 -- s ) ( replaces all hard-coded newline characters in s1 with s2 ) .sqfuncs "nl-repl" call def null? ( s -- i ) not def omdisplay ( s -- ) .omsg-sub .otell ( displays an o-message to the room [q.v. omsg-sub] ) def omsg-sub ( s -- s ) ( formats a standard o-message; see @listing ) .sqfuncs "omsg-sub" call def otell ( s -- ) LOC @ ME @ 1 4 rotate notify_exclude def pmatch+ ( s -- d ) ( pmatch+; pmatch with partial name matching ) .sqfuncs "pmatchplus" call def pmatch-f ( s -- d ) ( pmatch-free; pmatch with a penny rebate ) .pmatch .MAX_PENNIES ME @ owner pennies - "lookup_cost" sysparm atoi .min dup 0 > if ME @ owner swap addpennies else pop then def popn ( xn ... x2 x1 n -- ) begin dup 0 > while swap pop 1 - repeat pop def quote ( s -- s ) "\"" swap strcat "\"" strcat def quote_string ( s -- s ) "\"" swap strcat "\"" strcat def rstrfmt ( s i -- s ) swap .spc80 swap strcat swap over strlen swap - strcut swap pop def safecall ( xi ... x2 x1 d i -- ) ( a "stack safe" call ) .sqfuncs "safecall" call def seeflags? ( d -- i ) dup .control? swap "ACL" .hasflag? or def spc80 ( -- s ) " " def split ( s s1 -- s2 s3 ) over over instr dup 1 < if pop pop "" else rot swap 1 - strcut rot strlen strcut swap pop then def split2 ( s s1 -- s2 s3 ) ( just like .split except that s2 and not s3 will be null if s1 is not found in s ) over over instr dup 1 < if pop pop "" swap else rot swap 1 - strcut rot strlen strcut swap pop then def sqfuncs #???? def strfmt ( s i -- s ) swap .spc80 strcat swap strcut pop def tell ( s -- ) ME @ swap notify def unparseobj ( d -- s ) dup .seeflags? if unparseobj else name then def wizard? ( d -- i ) "Wizard" flag? def wizmatch ( s -- d ) .sqfuncs "wizmatch" call def yes? ( s -- i ) ( checks that string starts with y ) 1 strcut pop "y" stringcmp not