[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Send data to a buffer of a dynamicly created component

Hello Experts,

I need your help badly. Thats why I give 500 points.

I am still busy with my to terminal-emulation component. Now
I use this code to test my component dynamicly:

procedure TForm1.FormCreate(Sender: TObject);
begin
  with DSP3270.Create(self) do
  begin
    Parent := self;
    Align := alClient;
    Caption := '...';
    Left := 0;
    Top := 0;
    {...}
  end;
end;

I have even a server and a connection to that server, but I use
temporarly a TMemo to display the output, but I want the
output send to a buffer that is created in de component-unit.
Is dat possible?

This is the buffer in the 3270-component unit:

 TScrBuf = array [1..MAXROWS,1..MAXCOLS] of TScrCell ;
  PScrBuf = ^TScrBuf ;

  TScrCell = record
    Data:    char ;   { presentation character (a,b,c,d,..) }
    Attrib:  char ;   { extended character attribute (Input,Prot,..) }
    Hilite:  char ;   { extended character hilight (Blink,Reverse,..) }
    CharSet: char ;   { character set to use (Default,APL,..) }
    Color:   char ;   { character color (Red,Pink,..) }
  end ;

Private
  FScrBuf: TScrBuf ;

This is the code in de MainForm that sends the output
to the TMemo:

procedure TForm1.Display;
var
    I : Integer;
begin
    DisplayMemo.Lines.BeginUpdate;
    try
        if DisplayMemo.Lines.Count > 200 then begin
            for I := 1 to 50 do
                DisplayMemo.Lines.Delete(0);
        end;
        DisplayMemo.Lines.Add(Msg);
    finally
        DisplayMemo.Lines.EndUpdate;

        SendMessage(DisplayMemo.Handle, EM_SCROLLCARET, 0, 0);
        Timer1.Enabled := False;
    end;
 end;

I hope anyone can help me with this problem!

Greetings,

Peter Kiers
0
peterkiers
Asked:
peterkiers
  • 3
  • 2
1 Solution
 
2266180Commented:
I suggest you write a smal lprocedure that will output a text string on the terminal buffer, something similar to this:

procedure  TDSP3270.putText(text:string);// maybe put some other things here, like attribute, charset etc
var i,cx,cy:integer; c: TScrCel;
begin
  cx:=current carret possition on the terminal window for x;
  cy:=smae as above but for y;
  for i:=1 to length(text)  do
  begin
    if xc>terminal window width then
    begin
      inc(cy);
      cx:=1;
    end;// note that there is no check for cy which must result in a scroll (little bit more complicated, but not impossible)
    c.data:=text[i];
    c.rest of thing must be initialized;
    FScrBuf[cy,cx]:=c;
    inc(cx);
  end;
  // if you want a writeln like output, then increment cy here and make cx=1
end;

that is the basic idea. this procedure will be public of course.
so your memo display will look like:

procedure TForm1.Display;
begin
    try
        DSP3270.putText(Msg);
    finally
        Timer1.Enabled := False;// dunno why this is here ...
    end;
 end;
0
 
peterkiersAuthor Commented:
AH, thank you for your response, only the code did not work
maybe I did something wrong:

In the component-unit is a procedure that reads the buffer:

procedure Tscreenf.ReadBuffer(var os: string) ;
{
  This routine reads the entire buffer, and builds a data stream containing
  all data on the screen. Field attributes are represemnted by embeded
  SF orders. Nulls are not inserted into the generated data stream.

  ** This is the field version only
}
var
  i, j: integer ;
begin
  for i := 1 to SCRROWS do
    for j := 1 to SCRCOLS do
      begin
        if ScrBuf[i,j].data = Char(cdFieldAttr) then
          os := os + Char(IO_SF) + ScrBuf[i,j].Attrib
        else
          os := os + Char(as2eb(Byte(ScrBuf[i,j].data))) ;
      end ;
end ;

Now how can I put something in it?

Peter
0
 
2266180Commented:
as I see, there are some transofrmations needed to be done to the character before beeing put in the buffer. so
 c.data:=text[i];
should be something like:
 c.data:=Char(eb2as(Byte(text[i]))); // here is the revers function of as2eb

this is how I see it :) and of course that there is something for that cdFieldAttr but I don't know what that represents and how and what it is used for. but only that conversion should do the trick.
0
 
peterkiersAuthor Commented:
aH, your example did work, Thank you.the 500 point are for you

I have one little question to you:

I have found the source code of a telnet programm
only it is made in Visual Basic, is there a way to
convert the source code to Delphi, i have found
a few programms but the are all shareware.
Is there a way to covert it without paying for it?

Peter
0
 
2266180Commented:
of course. you learn a little VB and do it manually. or ask a friend :)
I don't know of any free vb to delphi converters. but VB is pretty simple, so I suggest going through the vb syntax and you should be able to at least understand teh concepts.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now