help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Bizarre Error


From: Julian DeMarchi
Subject: RE: Bizarre Error
Date: Tue, 11 Feb 2003 23:36:35 -0500

Sorry Peter,
 
I don't mean to be a pain, but, if you commented your code it would be a lot 
easier to help you with.
 
- Julian / MatLinks

        -----Original Message----- 
        From: address@hidden [mailto:address@hidden 
        Sent: Tue 2/11/2003 11:30 PM 
        To: address@hidden 
        Cc: 
        Subject: Bizarre Error
        
        


        Heres an interesting one:
        I created a menu system to read in all the files in a directory and 
then list
        them 10 at a time allowing users to change pages or to select a file. 
As part
        of my error checking i use the input string option to make the user 
input as a
        string. To turn the users string input into a numerical input i used 
num2str.
        If the input is not numeric this returns an empty matrix which i can 
then act
        on, in this case returning to the top of the program. Now if i entered 
in
        say "hfdlas" (any erroneous string) in the user input i get the correct
        response. Also with "as576gf" (an erroneous alphanumeric string). 
However if i
        enter in "23dsjk" then i get parse errors when the code returns to the 
top.
        From everything i can tell this should happen since from the top of the 
file
        nothing is affected by the user input.
        I check the outputs of all lines and enterering "4sdjhg" is identical to
        entering "kjdhsf4" ie str2num on both produces an empty matrix and thus 
results
        in identical program flow and in no variables being redefined. So how 
is it
        that one produces an error while the other does not?
        Cheers,
        Peter Anderson
        
        
        This is the error:
        
        -------------------------------------------------------------
        parse error:
        
        >>> load -force materials/B45505.mtl
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 35
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 36
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 37
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 38
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 39
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 40
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 41
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 42
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 43
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 44
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: invalid character `' (ASCII 0) near line 49, column 45
        parse error:
        
        >>> load -force materials/B45505.mtl
        error: evaluating for command near line 23, column 3
        error: evaluating if command near line 11, column 2
        error: evaluating while command near line 10, column 1
        error: called from `getmatv2' in file `/composite/getmatv2.m'
        error: called from `viewmat' in file `/composite/viewmat.m'
        error: called from `opt' in file `/composite/opt.m'
        -------------------------------------------------------------
        
        This is the code that produces the error:
        -------------------------------------------------------------
        
        function [Cmat]=getmat
        global Ex
        Cpage=1;
        
        filelist=readdir('Materials');
        mtlfiles=fnmatch('*.mtl',filelist);
        mtlfiles=find(mtlfiles==1);
        filelist=filelist(mtlfiles,:);
        
        while Ex==0;
                if isempty(filelist)==1
                        disp('No saved files')
                        return
                        else
                        Cpage_start= ((Cpage-1)*10+Cpage);
                        if (Cpage*10)>length(mtlfiles)
                                Cpage_finish=length(mtlfiles);
                                else Cpage_finish=(Cpage*10);
                        end
                       
                        disp('\n* Available Files *\n')
                        matlist='';
                        for i=Cpage_start:Cpage_finish
                        loadline=['load -force materials/',filelist(i,:),' 
matname'];
                        eval(loadline);
                        matlist=[matlist;[num2str(i),'. ',matname]];
                        end
                        disp(matlist)
                        disp(sprintf('\n%.0f of %.0f 
Page(s)\n',Cpage,ceil(length
        (mtlfiles)/10)))
                        disp('Enter material number or (<>)to change page:\n\n 
                (b)ack\n                (e)xit\n')
        
                        userin=input('>>','s');
                        [h,w]=size(userin);
                        if userin=='b'
                                return
                        elseif userin=='e'
                                Ex=1;
                                return
                        elseif userin=='>' 
                                Cpageok=Cpage+1;
                                if (Cpageok*10-10)>(length(mtlfiles)) | 
Cpageok<=0
                                        disp('\nInvalid page number\n')
                                        else Cpage=Cpageok;
                                        continue
                                end                    
                        elseif userin=='<' 
                                Cpageok=Cpage-1;
                                if (Cpageok*10-10)>(length(mtlfiles)) | 
Cpageok<=0
                                        disp('\nInvalid page number\n')
                                        else Cpage=Cpageok;
                                        continue
                                end
                        elseif userin==''
                        continue
                       
                        else userin=str2num(userin)
                        if userin==[]
                                disp('Invalid Input')
                                continue
                        end
        
                        if userin>length(mtlfiles)
                                disp('No such Material')
                                continue
                        else
                                Cmat=[filelist(userin,:)];             
                        return
                        end
                        end
        
                end
        end
        
        
        -------------------------------------------------
        This mail sent through IMP: www-mail.usyd.edu.au
        
        
        
        -------------------------------------------------------------
        Octave is freely available under the terms of the GNU GPL.
        
        Octave's home on the web:  http://www.octave.org
        How to fund new projects:  http://www.octave.org/funding.html
        Subscription information:  http://www.octave.org/archive.html
        -------------------------------------------------------------
        
        




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]