comparison src/variables.cc @ 3361:4f40efa995c1

[project @ 1999-11-19 21:19:37 by jwe]
author jwe
date Fri, 19 Nov 1999 21:19:44 +0000
parents c4983fc7318f
children 86873384cd10
comparison
equal deleted inserted replaced
3360:48bd8127e19b 3361:4f40efa995c1
365 365
366 return retval; 366 return retval;
367 } 367 }
368 368
369 DEFUN (is_global, args, , 369 DEFUN (is_global, args, ,
370 "is_global (X): return 1 if the string X names a global variable\n\ 370 "-*- texinfo -*-\n\
371 otherwise, return 0.") 371 @deftypefn {Built-in Function} {} is_global (@var{name})\n\
372 Return 1 if @var{name} is globally visible. Otherwise, return 0. For\n\
373 example,\n\
374 \n\
375 @example\n\
376 @group\n\
377 global x\n\
378 is_global (\"x\")\n\
379 @result{} 1\n\
380 @end group\n\
381 @end example\n\
382 @end deftypefn")
372 { 383 {
373 octave_value_list retval = 0.0; 384 octave_value_list retval = 0.0;
374 385
375 int nargin = args.length (); 386 int nargin = args.length ();
376 387
394 405
395 return retval; 406 return retval;
396 } 407 }
397 408
398 DEFUN (exist, args, , 409 DEFUN (exist, args, ,
399 "exist (NAME): check if variable or file exists\n\ 410 "-*- texinfo -*-\n\
400 \n\ 411 @deftypefn {Built-in Function} {} exist (@var{name})\n\
401 returns:\n\ 412 Return 1 if the name exists as a variable, 2 if the name (after\n\
402 \n\ 413 appending @samp{.m}) is a function file in the path, 3 if the name is a\n\
403 0 : NAME is undefined\n\ 414 @samp{.oct} file in the path, or 5 if the name is a built-in function.\n\
404 1 : NAME is a variable\n\ 415 Otherwise, return 0.\n\
405 2 : NAME is a function\n\ 416 \n\
406 3 : NAME is a .oct file in the current LOADPATH\n\ 417 This function also returns 2 if a regular file called @var{name}\n\
407 5 : NAME is a built-in function\n\ 418 exists in Octave's @code{LOADPATH}. If you want information about\n\
408 \n\ 419 other types of files, you should use some combination of the functions\n\
409 This function also returns 2 if a regular file called NAME exists in\n\ 420 @code{file_in_path} and @code{stat} instead.\n\
410 Octave's LOADPATH. If you want information about other types of\n\ 421 @end deftypefn")
411 files, you should use some combination of the functions file_in_path\n\
412 and stat instead.")
413 { 422 {
414 octave_value_list retval; 423 octave_value_list retval;
415 424
416 int nargin = args.length (); 425 int nargin = args.length ();
417 426
755 csr->alias (gsr); 764 csr->alias (gsr);
756 } 765 }
757 } 766 }
758 767
759 DEFUN (document, args, , 768 DEFUN (document, args, ,
760 "document (NAME, STRING)\n\ 769 "-*- texinfo -*-\n\
761 \n\ 770 @deftypefn {Built-in Function} {} document (@var{symbol}, @var{text})\n\
762 Associate a cryptic message with a variable name.") 771 Set the documentation string for @var{symbol} to @var{text}.\n\
772 @end deftypefn")
763 { 773 {
764 octave_value retval; 774 octave_value retval;
765 775
766 int nargin = args.length (); 776 int nargin = args.length ();
767 777
899 909
900 return retval; 910 return retval;
901 } 911 }
902 912
903 DEFUN_TEXT (who, args, , 913 DEFUN_TEXT (who, args, ,
904 "who [-all] [-builtins] [-functions] [-long] [-variables]\n\ 914 "-*- texinfo -*-\n\
905 \n\ 915 @deffn {Command} who options pattern @dots{}\n\
906 List currently defined symbol(s). Options may be shortened to one\n\ 916 @deffnx {Command} whos options pattern @dots{}\n\
907 character, but may not be combined.") 917 List currently defined symbols matching the given patterns. The\n\
918 following are valid options. They may be shortened to one character but\n\
919 may not be combined.\n\
920 \n\
921 @table @code\n\
922 @item -all\n\
923 List all currently defined symbols.\n\
924 \n\
925 @item -builtins\n\
926 List built-in variables and functions. This includes all currently\n\
927 compiled function files, but does not include all function files that\n\
928 are in the @code{LOADPATH}.\n\
929 \n\
930 @item -functions\n\
931 List user-defined functions.\n\
932 \n\
933 @item -long\n\
934 Print a long listing including the type and dimensions of any symbols.\n\
935 The symbols in the first column of output indicate whether it is\n\
936 possible to redefine the symbol, and whether it is possible for it to be\n\
937 cleared.\n\
938 \n\
939 @item -variables\n\
940 List user-defined variables.\n\
941 @end table\n\
942 \n\
943 Valid patterns are the same as described for the @code{clear} command\n\
944 above. If no patterns are supplied, all symbols from the given category\n\
945 are listed. By default, only user defined functions and variables\n\
946 visible in the local scope are displayed.\n\
947 \n\
948 The command @kbd{whos} is equivalent to @kbd{who -long}.\n\
949 @end deffn")
908 { 950 {
909 octave_value_list retval; 951 octave_value_list retval;
910 952
911 int argc = args.length () + 1; 953 int argc = args.length () + 1;
912 954
1029 } 1071 }
1030 1072
1031 // Deleting names from the symbol tables. 1073 // Deleting names from the symbol tables.
1032 1074
1033 DEFUN_TEXT (clear, args, , 1075 DEFUN_TEXT (clear, args, ,
1034 "clear [-x] [name ...]\n\ 1076 "-*- texinfo -*-\n\
1035 \n\ 1077 @deffn {Command} clear [-x] pattern @dots{}\n\
1036 Clear symbol(s) matching a list of globbing patterns.\n\ 1078 Delete the names matching the given patterns from the symbol table. The\n\
1037 \n\ 1079 pattern may contain the following special characters:\n\
1038 If no arguments are given, clear all user-defined variables and\n\ 1080 @table @code\n\
1039 functions.\n\ 1081 @item ?\n\
1040 \n\ 1082 Match any single character.\n\
1041 With -x, exclude the named variables") 1083 \n\
1084 @item *\n\
1085 Match zero or more characters.\n\
1086 \n\
1087 @item [ @var{list} ]\n\
1088 Match the list of characters specified by @var{list}. If the first\n\
1089 character is @code{!} or @code{^}, match all characters except those\n\
1090 specified by @var{list}. For example, the pattern @samp{[a-zA-Z]} will\n\
1091 match all lower and upper case alphabetic characters.\n\
1092 @end table\n\
1093 \n\
1094 For example, the command\n\
1095 \n\
1096 @example\n\
1097 clear foo b*r\n\
1098 @end example\n\
1099 \n\
1100 @noindent\n\
1101 clears the name @code{foo} and all names that begin with the letter\n\
1102 @code{b} and end with the letter @code{r}.\n\
1103 \n\
1104 If @code{clear} is called without any arguments, all user-defined\n\
1105 variables (local and global) are cleared from the symbol table. If\n\
1106 @code{clear} is called with at least one argument, only the visible\n\
1107 names matching the arguments are cleared. For example, suppose you have\n\
1108 defined a function @code{foo}, and then hidden it by performing the\n\
1109 assignment @code{foo = 2}. Executing the command @kbd{clear foo} once\n\
1110 will clear the variable definition and restore the definition of\n\
1111 @code{foo} as a function. Executing @kbd{clear foo} a second time will\n\
1112 clear the function definition.\n\
1113 \n\
1114 With -x, clear the variables that don't match the patterns.\n\
1115 \n\
1116 This command may not be used within a function body.\n\
1117 @end deffn")
1042 { 1118 {
1043 octave_value_list retval; 1119 octave_value_list retval;
1044 1120
1045 int argc = args.length () + 1; 1121 int argc = args.length () + 1;
1046 1122