Changeset 939
- Timestamp:
- 06/14/07 14:21:29 (1 year ago)
- Files:
-
- 1.8.3/branches/devel/game/txt/hlp/pennfunc.hlp (modified) (1 diff)
- 1.8.3/branches/devel/src/function.c (modified) (2 diffs)
- 1.8.3/branches/devel/src/funmisc.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/devel/game/txt/hlp/pennfunc.hlp
r934 r939 755 755 756 756 See also: lcon(), next() 757 & COND() 758 & CONDALL() 759 & NCOND() 760 & NCONDALL() 761 cond(<cond1>, <expr1>, [<condN>, <exprN>], ...[<default>]) 762 condall(<cond1>, <expr1>, [<condN>, <exprN>], ...[<default>]) 763 ncond(<cond1>, <expr1>, [<condN>, <exprN>], ...[<default>]) 764 ncondall(<cond1>, <expr1>, [<condN>, <exprN>], ...[<default>]) 765 766 cond() evaluates <cond>s until one returns a boolean true value. Should 767 none return true, <default> is returned. 768 769 condall() returns all <expr>s for those <cond>s that evaluate to true. 770 771 ncond() and ncondall() are identical to cond(), except it returns <expr>s 772 for which <cond>s evaluate to false. 773 774 Examples: 775 > say cond(0,This is false,#-1,This is also false,#123,This is true) 776 You say, "This is true" 777 778 > say ncond(0,This is false,#-1,This is also false,#123,This is true) 779 You say, "This is false" 780 781 > say ncondall(0,This is false,#-1,This is also false,#123,This is true) 782 You say, "This is falseThis is also false" 757 783 & CONFIG() 758 784 config() 1.8.3/branches/devel/src/function.c
r909 r939 351 351 {"COMP", fun_comp, 2, 3, FN_REG}, 352 352 {"CON", fun_con, 1, 1, FN_REG}, 353 {"COND", fun_if, 2, INT_MAX, FN_NOPARSE}, 354 {"CONDALL", fun_if, 2, INT_MAX, FN_NOPARSE}, 353 355 {"CONFIG", fun_config, 1, 1, FN_REG}, 354 356 {"CONN", fun_conn, 1, 1, FN_REG}, … … 529 531 {"NCHILDREN", fun_lsearch, 1, 1, FN_REG}, 530 532 {"NCON", fun_dbwalker, 1, 1, FN_REG}, 533 {"NCOND", fun_if, 2, INT_MAX, FN_NOPARSE}, 534 {"NCONDALL", fun_if, 2, INT_MAX, FN_NOPARSE}, 531 535 {"NEXITS", fun_dbwalker, 1, 1, FN_REG}, 532 536 {"NPLAYERS", fun_dbwalker, 1, 1, FN_REG}, 1.8.3/branches/devel/src/funmisc.c
r937 r939 508 508 char tbuf[BUFFER_LEN], *tp; 509 509 char const *sp; 510 511 tp = tbuf; 512 sp = args[0]; 513 process_expression(tbuf, &tp, &sp, executor, caller, enactor, 514 PE_DEFAULT, PT_DEFAULT, pe_info); 515 *tp = '\0'; 516 if (parse_boolean(tbuf)) { 517 sp = args[1]; 518 process_expression(buff, bp, &sp, executor, caller, enactor, 510 /* Since this may be used as COND(), NCOND(), CONDALL() or NCONDALL, 511 * we check for that. */ 512 int findtrue = 1; 513 int findall = 0; 514 int found = 0; 515 int i; 516 517 if (called_as[0] == 'N') 518 findtrue = 0; 519 520 if (strstr(called_as,"ALL")) 521 findall = 1; 522 523 for (i = 0 ; i < nargs-1 ; i += 2) { 524 tp = tbuf; 525 sp = args[i]; 526 process_expression(tbuf, &tp, &sp, executor, caller, enactor, 519 527 PE_DEFAULT, PT_DEFAULT, pe_info); 520 } else if (nargs > 2) { 521 sp = args[2]; 528 *tp = '\0'; 529 if (parse_boolean(tbuf) == findtrue) { 530 sp = args[i+1]; 531 process_expression(buff, bp, &sp, executor, caller, enactor, 532 PE_DEFAULT, PT_DEFAULT, pe_info); 533 if (!findall) return; 534 found = 1; 535 } 536 } 537 /* If we've found no true case, run the default if it exists. */ 538 if (!found && (nargs & 1)) { 539 sp = args[nargs - 1]; 522 540 process_expression(buff, bp, &sp, executor, caller, enactor, 523 541 PE_DEFAULT, PT_DEFAULT, pe_info);
