Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8321377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:59:35+00:00 2026-06-08T22:59:35+00:00

function classes(o:integer): String; var allclasses : array[1..7] of String; begin allclasses[1]:= ‘class1’; allclasses[2]:= ‘class2’;

  • 0
function classes(o:integer): String;
var allclasses : array[1..7] of String;
begin
    allclasses[1]:= 'class1';
    allclasses[2]:= 'class2';
    allclasses[3]:= 'class3';
    allclasses[4]:= 'class4';
    allclasses[5]:= 'class5';
    allclasses[6]:= 'class6';
    allclasses[7]:= 'class7';
    classes := allclasses[o];
end;

Above you can see a function, which should receive an integer and give a result of string that was stored in array.

procedure loadthis(chosen : string);
var f: text;
    i : integer;
begin
    Assign(f, 'files\'+chosen+'.txt');
    Reset(f);
    ReadLn(f, i);
    MyChar.clas := classes[i];
end;

When this procedure is called, it calls a “classes” function. Pleae note that Mychar ir a global variable.

begin
    loadthis(FileName);
    ReadLn;
    Readln
end.

Ant this is the main program, which calls “loadthis” procedure.

I Have no idea whats wrong, but I am getting these errors:

  • Wrong amount of parameters specified
  • Illegal qualifier

Both errors come from this line:
MyChar.clas := classes[i];. I have really no idea what is wrong, maybe I can not call a function from a procedure ? Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:59:37+00:00Added an answer on June 8, 2026 at 10:59 pm

    You’re trying to access it as an array index, but it needs to be a function call:

    MyChar.clas := classes(i);  { note () instead of [] }
    

    You should probably add some range checking, too. What happens if someone puts 20 in the text file? Your array only has items at indexes 1 through 7, so you’ll get a runtime error when you call classes(20) with the out of range value.

    (You could probably use a constant array for allclasses to lessen your code as well, but your instructor probably haven’t gotten that far yet.)

    Given your comment about not having an instructor, here’s a suggestion about a better way to handle the function:

    function classes(o:integer): String;
    const
      allclasses: array[1..7] of string = ('class1', 
                                           'class2',
                                           'class3',
                                           'class4',
                                           'class5',
                                           'class6',
                                           'class7');
    begin
      {
        Low() returns the lowest index of the array, and
        High() returns the highest. The if statement makes sure
        that o is between them. It is the range check I mentioned.
      }
      if (o >= Low(allclasses)) and (o <= High(allclasses)) then
        classes := allclasses[o]
      else
        classes := '';
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function sc_HTMLParser(aHTMLString){ var parseDOM = content.document.createElement('div'); parseDOM.appendChild(Components.classes['@mozilla.org/feed-unescapehtml;1'] .getService(Components.interfaces.nsIScriptableUnescapeHTML) .parseFragment(aHTMLString, false, null, parseDOM)); return parseDOM;
I am trying to make a function that creates classes, and append these classes
Basically from C++ FAQ I learned that: A virtual function allows derived classes to
In some classes I see a call to a function is like: $this->ClearError(); When
Classes that implement IEnumerable and provide a public void Add(/* args */) function can
I am having a classes which have function to make random text and captcha
I have three classes that all have a static function called 'create'. I would
I have in my javascript these 2 functions classes: // product class function Product()
I'm having trouble creating a global function accessible from within all classes. I receive
I have this class that have a function to load other classes and create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.