[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Pascal

Pascal is an influential imperative and procedural programming language, largely (but not exclusively) intended to teach students structured programming and data structuring. Pasca was implemented on a wide range of architectures, from early PCs to mainframes. Pascal derivatives include OOP-based Object Pascal (used in Delphi and Lazarus/Free Pascal). Pascal is a purely procedural language and includes control statements with reserved words, but has many data structuring facilities and other abstractions like type definitions, records, pointers, enumerations, and sets.

Share tech news, updates, or what's on your mind.

Sign up to Post

I am going to be doing some simple text processing with Free Pascal.  I would like to use a debugger of some kind that allows me to see the values of variable, step through execution, etc.  I would like something easy to set up and use.  Lightweight, too.
0
Python 3 Fundamentals
LVL 12
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Hello programming experts! I am having a memory problem that cannot explain root cause, please help me! The problem is as follows: My program throws exception when i exit. I investigated and thought that the cause of the error was the use Copymemory function to copy the record containing the variable have string data type.

Below is my demo program by delphi 2009: In my project,  I added 2 file project dpr then add sharedmemory for use BorlndMM.dll instead of using FastMM memory management. I define a struct containing a String variable. Allocate 1 array of 2048 PByte elements. Use Memory Copy function to copy 2 struct. finally, Free array 2048. when i exit program, my program threw exception.
type   
 TMyStructure = record
 F1: TMyStructure;

Open in new window

unit 1
procedure TForm9.FormCreate(Sender: TObject);
var
    i: Integer;
begin
    F1.str1 := 'This is a string to demo for copying the String data type 
                                            using the Copymemory method';
end;

Open in new window

unit 2
procedure TForm8.btn1Click(Sender: TObject);

var
Form9: TForm9;
i: Integer;
s1: array[0..2048-1] of PByte;
begin
    //  Alloc 1st 2048 segments, each segment gain 1KB
    for i := 0 to Length(s1) - 1 do
    begin

    s1[i] := AllocMem(1024);
end;

//  Create Form9
Form9 := TForm9.Create(Owner);

//  -> ERROR
CopyMemory(@Self.F1, @Form9.F1, SizeOf(TMyStructure));

//  -> OK
//  Self.F1 := Form9.F1;

// Free memory s1 array
for i := 0 to Length(s1) - 1 do
begin
    FreeMem(s1[i]);
end;
end;

Open in new window

0
I have big problem with StringList. I have text file with text like this:

     
51,179 km=Powiat Ostrzeszowski
    51,179 - 61,402 km=Powiat Wieruszowski
    61,402 - 64,559 km (d. DW450)=Powiat Wieruszowski
    64,559 km (d. DW450)=Powiat Kępiński 

Open in new window


I want to import this file and show first values, before "=" in RadioGroup. Second values after "=" i want to show on Label in moment when user clicks proper value on RadioGroup.

I would like to operate on Names and Values of StrongList.

Something like this: https://i.stack.imgur.com/dkLih.png

In *.pas file I have:

     
var
      Form1: TForm1;
      list: TStringList;
      i: Integer; 

Open in new window


On FormCreate:

   
 list := TStringList.Create;    
    list.LoadFromFile('dat\a1pik.dat');
    RadioGroup1.Visible := true;
    RadioGroup1.Items.Clear;

    for i := 0 to list.Count-1 do
        begin
            RadioGroup1.Items.Add(list.Names[i]);
        end;

And first values I have on RadioGroup. 

Open in new window


I try with RadioGroup like this:

     
procedure TForm1.RadioGroup1Click(Sender: TObject);
        begin
        Label.Caption := list.Values[list.Names[RadioGroup1.ItemIndex]];
        end; 

Open in new window


But doesn't work. What I do wrong?

P.S. Sorry for my English :)
0

Pascal

Pascal is an influential imperative and procedural programming language, largely (but not exclusively) intended to teach students structured programming and data structuring. Pasca was implemented on a wide range of architectures, from early PCs to mainframes. Pascal derivatives include OOP-based Object Pascal (used in Delphi and Lazarus/Free Pascal). Pascal is a purely procedural language and includes control statements with reserved words, but has many data structuring facilities and other abstractions like type definitions, records, pointers, enumerations, and sets.

Top Experts In
Pascal
<
Monthly
>

No Top Experts for this time period. Answer questions to earn the title!