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

So I am trying to create a program that takes a list of integers typed in by the user, puts them into order and prints them to the screen. However, my compiler just shows nothing after I type in the list. No output whatsoever.
I get the following hint: Variable "RefListe" does not seem to be initialized. But I cannot make sense of that right now.

Can anyone tell me why this doesn't work?

program TesteSortiereListe(input, output);

  type
  tNatZahl = 0..maxint;
  tRefListe = ^tListe;
  tListe = record
             info : tNatZahl;
             next : tRefListe;
           end;

  var
  RefListe : tRefListe;


procedure SortiereListe (var ioRefListe:tRefListe);
{ Sorts a linked list in ascending order }

  var
  RefAnfang,
  Vorgaenger,
  aktuell:tRefListe;

begin
  RefAnfang := ioRefListe;
  while ioRefListe <> nil do
  {Go through the entire list}
  begin
  vorgaenger := ioRefListe;
  ioRefListe := ioRefListe^.next;
  aktuell := ioRefListe;
    if aktuell^.info < RefAnfang^.info then
    {Element is the smallest element found so far}
      begin
      Vorgaenger^.next := aktuell^.next;
      aktuell^.next := RefAnfang;
      RefAnfang := aktuell;
      end
    else if ioRefListe^.info > aktuell^.info then
    { Element is the biggest element in the list so far, we don't have to change its position}
      begin
      aktuell:=ioRefListe;
      end
    else
        if aktuell^.info < vorgaenger^.info then
        {The number is smaller than the previous one, they

Open in new window

0
Cloud Class® Course: Microsoft Azure 2017
LVL 12
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

And the image url f remote location is given in json response...how do i parse and display that in list view...parsing is done andvi cud display the text and details which s so fast over the network...but how do i retrieve the images and display it in list view imagelist appearence
0
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!