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 4539432
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:56:45+00:00 2026-05-21T14:56:45+00:00

I have an application that when run at home works fine, however when ran

  • 0

I have an application that when run at home works fine, however when ran on school computers(Windows XP) i get the following message. (This is recompiling it, not just running the .exe)- In Delphi 2005

First chance exception at $7C81EB33. Exception class EAccessViolation with message ‘Access violation at address 0045E5E2 in module ‘Project2.exe’. Read of address 00000198′. Process Project2.exe (440)

Code: Ignoring unneeded stuff.

        Image1: TImage; // Image(all the way to 72) 
        Timer1: TTimer; Timer2: TTimer;   
        procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure SomeOtherProcedure(Sender: TImage);
        procedure Timer1Timer(Sender: TObject);
        procedure Timer2Timer(Sender: TObject);
          private
        { private declarations }
      public
        { public declarations }
      end;
    var
      Form1: TForm1;
      left : integer;
      top  : integer;
      gap  : integer;
      type
        coordinates = record
          row : integer ;
          col : integer;
        end;

      var
      picarray : array[0..5,0..5] of timage;
      thiscover, midcover, lastcover : timage;
      imageindex : array[0..5,0..5] of integer;
      picloc: array[0..3] of coordinates;
      clickcount, pairsfound, attemptcount : integer;
implementation
{$R *.lfm}
procedure initialise();
var
i, j, whichcol, whichrow : integer;
begin
        for i := 0 to 5 do
        for j := 0 to 5 do
        imageindex[i,j] := -1; // not used
        randomize;
        for i := 0 to 11 do
        for j := 1 to 3 do
        begin
        repeat
          begin
          whichcol := random(6) ;
          whichrow := random(6)  ;
          end;
        until imageindex[whichcol, whichrow] = -1;
        picarray[whichcol, whichrow].Picture.LoadFromFile('C:\Users\Hayden\Pictures\'+ inttostr(I+1) +'.jpg');
        imageindex[whichcol, whichrow] := I  ;
        end;
        clickcount := 0  ;            //
        pairsfound := 0    ;
        attemptcount := 0  ;
        end;

    procedure TForm1.FormCreate(Sender: TObject);
var
cpic : tcomponent;
whichcol: integer;
whichrow : integer;
begin
gap := image2.left - image1.left;
top := image1.Top;
left := image1.left;
for cpic in form1 do
begin
     if (cpic.ClassType = timage) and (cpic.Tag = 10) then
     begin
     whichcol := (timage(cpic).left - left) div gap;
     whichrow := (timage(cpic).Top - top) div gap;
     picarray[whichcol, whichrow] := timage(cpic)   ;
end;
end;
initialise;
end;

Line >>> picarray[whichcol, whichrow].Picture.LoadFromFile(‘C:\Users\Hayden\Pictures\’+ inttostr(I+1) +’.jpg’);
seems to cause the error. And if it is a coding error, what is the correct way to do this?

  • 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-05-21T14:56:46+00:00Added an answer on May 21, 2026 at 2:56 pm

    First, I’m going to clean up your code a little, because as it stands, it’s very difficult to figure what’s going on. I highly recommend you get into the habit of taking a few minutes to keep your code clearly formatted – it will save you hours of debugging.

    I’ve applied only the following simple changes: Indentation, Blank lines, and liberal use of begin .. end;

    var
      picarray : array[0..5,0..5] of timage;
      thiscover, midcover, lastcover : timage;
      imageindex : array[0..5,0..5] of integer;
      picloc: array[0..3] of coordinates;
      clickcount, pairsfound, attemptcount : integer;
    
    implementation
    
    {$R *.lfm}
    procedure initialise();
    var
      i, j, whichcol, whichrow : integer;
    begin
      for i := 0 to 5 do
      begin
        for j := 0 to 5 do
        begin
          //It's clear you're initialising the 36 entries of imageindex to -1
          imageindex[i,j] := -1; // not used
        end;
      end;
    
      randomize;
      for i := 0 to 11 do
      begin
        for j := 1 to 3 do
        begin
          //This loop also runs 36 times, so it fills the whole of imageindex with new values
          //It also loads all 36 entries of picarray with an image specfied by the current value of i
          //The approach is dangerous because it depends on the 'loop sizes' matching,
          //there are much safer ways of doing this, but it works
          repeat
            begin //This being one of the only 2 begin..end's you provided inside this is routine is pointless because repeat..until implies it.
              whichcol := random(6) ;
              whichrow := random(6)  ;
            end;
          until imageindex[whichcol, whichrow] = -1;
    
          //This line itself will throw an access violation if picarray[whichcol, whichrow] doesn't 
          //contain a valid TImage instance... we have to check other code to confirm that possibility
          picarray[whichcol, whichrow].Picture.LoadFromFile('C:\Users\Hayden\Pictures\' + inttostr(I+1) + '.jpg');
          imageindex[whichcol, whichrow] := I  ;
        end;
      end;
    
      clickcount := 0  ;            //
      pairsfound := 0    ;
      attemptcount := 0  ;
    end;
    

    Moving on to the next piece of code:

    procedure TForm1.FormCreate(Sender: TObject);
    var
      cpic : tcomponent;
      whichcol: integer;
      whichrow : integer;
    begin
      gap := image2.left - image1.left;
      top := image1.Top;
      left := image1.left;
      for cpic in form1 do
      begin
        //This loop attempts to assign existing TImage instances to picarray
        //However, the way you're going about it is extremely dangerous and unreliable.
        //You're trying to use the position of a component on the form to determine its
        //position in the array.
        //There are many things that could go wrong here, but since this seems to be a
        //homework excercise, I'll just point you in the right direction - you need
        //to debug this code.
        if (cpic.ClassType = timage) and (cpic.Tag = 10) then
        begin
          whichcol := (timage(cpic).left - left) div gap;
          whichrow := (timage(cpic).Top - top) div gap;
          picarray[whichcol, whichrow] := timage(cpic)   ;
        end;
      end;
    
      //Here you call initialise, which as I said before, will
      //cause an Access Violation if picarray is not correctly 'set up'
      //The previous code in this method certainly has a bug which is 
      //preventing one or more picarray entries from being assigned a 
      //valid TImage instance.
      //You could write a simple for I := 0 to 5, for J := 0 to 5 loop
      //here to check each of picarray entries and pinpoint which is 
      //incorrect to aid your debugging of the pevious loop.
      initialise;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 32-bit application that must run on a Windows x64 server using
I have a WPF application that will always run on windows 7, it opens
I am getting the following error on a Windows Forms application that I have
If you have a web application that will run inside a network, it makes
I have an application that I have to run as Administrator. One small part
I have an application (winform exe) that I run several times. Does this mean
I have VB application that requires visual service pack 6 to run , now
I have an application that when it first starts i need it to run
I have an application that takes a couple of seconds to run. Is it
I have a delphi (Win32) web application that can run either as a CGI

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.