help-octave
[Top][All Lists]
Advanced

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

Repeating bug (error: subscript indices must be either positive integers


From: ragan2328
Subject: Repeating bug (error: subscript indices must be either positive integers or logicals)
Date: Tue, 26 Apr 2011 04:49:23 -0700 (PDT)

I've been working on this program for the past few hours. It's simply a
password generator. I had the program fully functioning, but upon restarting
Octave, I keep on getting the message:

error: subscript indices must be either positive integers or logicals.

Here is the code for the main program:


%P1: Pseudocode for Passgen (main)
NumberofPass = input(['How many passwords do you require?: ']);

if(isempty(NumberofPass));
   NumberofPass = 1;
endif;

NumberofChar = input(['How many characters (6-12) do you require in each
password?: ']);

if(isempty(NumberofChar));
   NumberofChar = 8;
   elseif(NumberofChar < 6);
      NumberofChar = 8;
      disp(['Number of characters is too low, defaulted to 8 characters'])
   elseif(NumberofChar > 12);
      NumberofChar = 8;
      disp(['Number of characters is too great, defaulted to 8 characters'])
endif;

lowercase = (['a':'z']);

uppercase = (['A':'Z' ]);

digits = [ '0':'9' ];

PasswordsList = zeros(NumberofPass,NumberofChar);

for(passcount = 1:NumberofPass);
   ValidPassword = false;
   while(not(ValidPassword));
      run OnePassword;
      run PassCheck;
   endwhile
   PasswordsList(passcount,:) = Password;
endfor;

Passwords = char(PasswordsList);

disp(Passwords)




...And the code for the program OnePassword that seems to contain the issue:



%P2: Pseudocode for OnePassword (function)

letters = [uppercase lowercase];
randomletter = round(rand(1)*52);
Password(1) = letters(randomletter);

for(n = 2:NumberofChar);
   randomchar = round(rand(1)*62);
   allchar = [uppercase lowercase digits];
   Password(n) = allchar(randomchar);
endfor;
return;



The error points to the code in the OnePassword program, although when run
separately, no issue exists:
Password(n) = allchar(randomchar);

Although all was normal up until restart. I'm not sure why it's registering
this error. Help would be appreciated.

--
View this message in context: 
http://octave.1599824.n4.nabble.com/Repeating-bug-error-subscript-indices-must-be-either-positive-integers-or-logicals-tp3475251p3475251.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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