From octave-sources-request at bevo dot che dot wisc dot edu Mon Sep 6 05:18:30 1999 Subject: "Dumper" and struct tools From: etienne grossmann To: octave-sources at bevo dot che dot wisc dot edu CC: etienne at isr dot ist dot utl dot pt Date: Mon, 6 Sep 1999 11:18:02 +0100 (WEST) Hello, this is just to say that I will be sending two tar.gz files on this list. Cheers, Etienne dumper : ====================================================================== cmpany(x,y) # returns one if x and y are the same object. Should # work for matrices, strings, structs and # lists. Should work with 2.0.14. s = any2str( x ) # Writes the object x as a string y = eval(s) cmpany(x,y) # Should be 1 # Write to myfilename.m the variables x,y,... # This REQUIRES 2.1.14 (uses the "argn" function) any2m('myfilename',x,y,...) clear x y ... # x,y ... should be as before they were cleared eval('myfilename') test_dumper # Perform a series of tests # This should be the output : > Number of errors : 0 out of 39 tests structs: ====================================================================== ## f = fields(s) ## ## if version >= 2.1.14 ## Returns the list of fieldnames in structure s. ## Returns an empty list if s is not a struct. ## else ## Returns a string array of fieldnames in structure s. ## Returns '' if s is not a struct. ## ## Force the string behavior with : ## ## f = fields(s,'string') ## Returns a string array of fieldnames in structure s. ## Returns '' if s is not a struct. ## ## For m****b compatibility and flexibility. ## c = cmpstruct(s1,s2) ## ## Compares two structs, returning 1 if they are equal, 0 otherwise. ## ## Will work only if fields of s1 and s2 can be compared through the ## '==' operator. ## ## y = isfield(x,k) ## ## Returns 1 if x is a struct and k a string, and x.k exists. ## Returns 0 otherwise. ## ## For m****b compat and flexibility. And the previous functions : s = struct('key1',val1,...) isstruct(s) = is_struct(s) s = setfield(s,'key1',value1,...) v = getfield(s,key) = s.key t = rmfield(s,key1,...) test_struct # Run Tests > Number of errors : 0 out of 27 tests