Solved

Help me understand some delphi code

Posted on 2008-06-13
8
192 Views
Last Modified: 2010-04-05
I purchased some delphi code off a freelancer and he left me high and dry as far as comments. I'm not too familiar with delphi so I'm looking for some help to understand it. Can someone that is familiar with delphi comment on some of the lines of code so I can get an idea of what everything is? Did he purposely condense the code to make it hard to understand?
function Find(fname:PChar):PChar; stdcall;
type region=record x,y,cx,cy,x2,y2,dx,dy,count,e:integer; aws:double; pts:array of byte; end;
     pair=record a,b:integer; w:double; end;
var img:TImage; bitmap:TBitMap; rgb:longint; r,g,b:byte; loaded:boolean;
    text:^string; dx,dy:integer; t,tb:integer;
    bw,gs,nt,ms,fd,of1,of2,im,p,q,pth,pts:array of byte; w:array of longint;
    xf,yf:array of longint;
    ws,qws:array of double;
    x,y,x0,y0,z,dz,n,m,i,j,k,ls,s1,s2:integer; td,td2,ay,mdf,ma,aws:double; f,rf:boolean;
    minx,miny,maxx,maxy,rdx,rdy:integer; mx,my,xb,yb,xe,ye:integer;
    nrg,nregions:integer; rg,regions:array[0..99] of region;
    ids:array[0..99] of integer;
    npairs:integer; pairs:array[0..9999] of pair;
    xi,yi,xj,yj,xij,yij,s:double; tp:pair;
    sxa,sxb,sya,syb:integer; vi,vj,gix,gix2,gjx,gjx2:integer;
    trg:region;

Open in new window

0
Comment
Question by:JPERKS1985
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 21778554
pffff. those are only declarations.
the actual code will be after a begin and before an end; and you will have more than one such pair. at least one for each function/procedure and if there are more blocks inside them then even more.

but just as a side note, I have never in my live seen a procedure with so many variables and I've been coding for over 10 years now.
0
 
LVL 1

Author Comment

by:JPERKS1985
ID: 21778572
Its for a neural network. The guy sent me the code to read it and not the code to train it and create the array data for it.
0
 
LVL 28

Expert Comment

by:2266180
ID: 21779202
those 16 lines are everything he sent? :o
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:rfwoolf
ID: 21783416
It looks absolutely juicy... but it does absolutely nothing. We need to see a begin and end.
0
 
LVL 2

Accepted Solution

by:
dMa earned 500 total points
ID: 21788859
the definitions after formating....
function Find( fname :PChar ) :PChar ; stdcall ; // function with the result as pchar, prepared to work indied a dll
 
type
     // types definitions
     region = record                                        // region is an record
            x,y,cx,cy,x2,y2,dx,dy,count,e : integer       ; // all the variables represents an integer = 123456...
            aws                           : double        ; // all the variables represents an double  = 12.12
            pts                           : array of byte ; // undefined array of bytes
     end;
 
     pair=record
          a,b   :integer;
          w     :double;
     end;
 
var
    // Variables
 
    img                                   : TImage;          // holder for an image used on a form
    bitmap                                : TBitMap;         // graphic object
    rgb                                   : longint;         // long integer
    r,g,b                                 : byte;            // byte
    loaded                                : boolean;         // boolean value (true or false)
    text                                  : ^string;         // pointer to an string
    dx,dy                                 : integer;
    t,tb                                  : integer;
    bw,gs,nt,ms,fd,of1,of2,im,p,q,pth,pts : array of byte;   // undefined array of bytes
    w                                     : array of longint;// undefined array of long integer
    xf,yf                                 : array of longint;
    ws,qws                                : array of double; // undefined array of doubles
    x,y,x0,y0,z,dz,n,m,i,j,k,ls,s1,s2     : integer;
    td,td2,ay,mdf,ma,aws                  : double;
    f,rf                                  : boolean;
    minx,miny,maxx,maxy,rdx,rdy           : integer;
    mx,my,xb,yb,xe,ye                     : integer;
    nrg,nregions                          : integer;
    rg,regions                            : array[0..99] of region;  // assigned array of the record "region" with max 99 entries
    ids                                   : array[0..99] of integer; // assigned array of integer with max 99 entries
    npairs                                : integer;
    pairs                                 : array[0..9999] of pair; // assigned array of the record "pair" with max 99 entries
    xi,yi,xj,yj,xij,yij,s                 : double;
    tp                                    : pair;                   // one record "pair"
    sxa,sxb,sya,syb                       : integer;
    vi,vj,gix,gix2,gjx,gjx2               : integer;
    trg                                   : region;                 // one record "region"

Open in new window

0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 21800164
it's like he sent a box of chocolates,
but without the chocolates
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 21800179
there's talk of a dll now.
A dll is compiled machine code - and is useful because multiple programming languages can just make a call to the desired part of the specified dll. But, without knowing the code inside the dll - or at least some documentation of what's inside the dll, or without even knowing what's being called in the dll ...
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 21810461
i don't think it's a dll
just prepared to work in a dll with stdcall directive

>>JPERKS1985
any more code that actually does something
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dev Express grid collapse 2 55
Dev express lookupcombo 3 64
Microsoft Access 97 and Delphi XE2 9 85
How to add columns to a RAD Studio FMX grid at design time 1 61
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question