Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DDE in Delphi1.0

Posted on 1997-06-09
12
Medium Priority
?
366 Views
Last Modified: 2010-04-06
I have a DDE app that works fine in D2 & D3. I am trying to run pretty much the same app in D1 for my WFW clients but the DDE client only get 255 characters back from the DDE server even though I am using DdeClientItem.Lines instead of DdeClientItem.Text. It is as if the ".Lines" property has a bug that makes it act just like the ".Text" property.
Of course, the identical code works fine in NT with D2 or D3 !
0
Comment
Question by:kupiec
  • 7
  • 5
12 Comments
 
LVL 1

Accepted Solution

by:
slp earned 300 total points
ID: 1336887
The Lines property should behave more or less like an array of 255 character strings, and you generally have to treat it as such if you want to get at all of the text:

for i := 0 to DDEClientItem1.Lines.Count - 1 do
begin
  DoSomethingTo( DDEClientItem1.Lines[i] ) ;
end ;

Now, depending on what you want to do, you might be better served by accessing the whole block using the Lines.GetText property and treating it as a PChar.


0
 

Author Comment

by:kupiec
ID: 1336888
This is exactly what I am doing. That is the point ! The Lines property is not behaving like Lines, but like Text ( 255 character limit ).

Here is some of the code: (keep in mind that in Delphi2 under NT this works exactly as written!)

    ParseEdit: TEdit;
    workArea: TMemo;
    String3270: TStringGrid;
    getSOfar,charPTR,getLIMIT: Integer;

  workArea.Lines := DdeClientItem.Lines;
  workArea.SelectAll;
  workArea.CopyToClipBoard;
  ParseEdit.PasteFromClipBoard;
  SyncStr := Copy(ParseEdit.Text, 1, 80);
  while (getSOfar <= getLIMIT) do
    begin
       SyncStr := Copy(ParseEdit.Text, charPTR, 80);
        begin
         with String3270 do
            for L := 0 to 0 do
               for M:= getSOfar to getSOfar do
                  Cells[L,M] := SyncStr;
         Inc(getSOfar);
         charPTR := charPTR + 80;
        end;
    end;

0
 
LVL 1

Expert Comment

by:slp
ID: 1336889
> This is exactly what I am doing. That is the point ! The Lines
> property is not behaving like Lines, but like Text ( 255
> character limit ).

> Here is some of the code: (keep in mind that in Delphi2 under
> NT this works exactly as written!

Forgive me for presuming to reformat your code, but I was having trouble seeing what was going on:

> ParseEdit: TEdit;
> workArea: TMemo;
> String3270: TStringGrid;
> getSOfar,charPTR,getLIMIT: Integer;

> workArea.Lines := DdeClientItem.Lines;
> workArea.SelectAll;
> workArea.CopyToClipBoard;
> ParseEdit.PasteFromClipBoard;

I think THIS may be your problem right here; under D1 the .Text
property of a TEdit is limited to 255 characters (uses a short string, there is no "long" string in D1).  What is the purpose of the clipboard copy?  Why not work with workArea.Lines (or DDEClientItem.Lines for that matter) directly?

> SyncStr := Copy(ParseEdit.Text, 1, 80);
> while (getSOfar <= getLIMIT) do
>   begin
>     SyncStr := Copy(ParseEdit.Text, charPTR, 80);
>     begin
>       with String3270 do

This won't get you very far, is this a typographical error? :

>         for L := 0 to 0 do
>           for M:= getSOfar to getSOfar do
>             Cells[L,M] := SyncStr;
>       Inc(getSOfar);
>       charPTR := charPTR + 80;
>     end;
>   end;

Okay, so if I'm reading this right, what you're trying to do is populate the stringgrid with 80 character blocks from the DDEClientItem?  You probably won't be able to do that in D1 by treating the Lines property as an array of strings, because you won't be able to take a solely character by character view of it; I'd recommend copying the contents of DDEClientItem into a PChar buffer and working with it like that; something like:

var
  DDEBuffer, ShortBuff, charPtr : PChar ;
  SyncStr : string[80] ;
  Len, chars : word ;
begin
  Len := StrLen( DDEClientItem.GetText ) ;
  GetMem( DDEBuffer, Len ) ;
  GetMem( ShortBuff, 80 ) ;
  StrCopy( DDEBuffer, DDEClientItem.GetText ) ;
  charPtr := Buffer ;  
  chars := 0 ;
  while ( getSoFar <= getLimit ) and ( chars <= Len ) do
  begin
    StrLCopy( ShortBuff, charPtr, 80 ) ;
    chars := chars + StrLen( ShortBuff ) ;
    SyncStr:= StrPas( ShortBuff ) ;
   
  {work out for yourself which cell you want to copy SyncStr to}
       
    Inc( charPtr, 80 ) ;
  end ;
  FreeMem( DDEBuffer, Len ) ;
  FreeMem( ShortBuff, 80 ) ;


0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Expert Comment

by:slp
ID: 1336890
Oooops, the line that reads:

charPtr := Buffer ;

in my code snippet should read:

charPtr := DDEBuffer ;
0
 

Author Comment

by:kupiec
ID: 1336891
Thanks for the quick response !
I'll try this today.
FYI:
This won't get you very far, is this a typographical error? :
                  > for L := 0 to 0 do
                  > for M:= getSOfar to getSOfar do  

No, there is a larger loop:
   while (getSOfar <= getLIMIT) do begin...
which moves me down my grid. I always want column to be zero because there is only one column (lot's of rows, but only one column.
0
 

Author Comment

by:kupiec
ID: 1336892
Here is a problem with your solution:

-->> DDEClientItem.GetText

DDEClientItem has NO GetText Property !
This is one of the reasons I do all the finagling with TMemo and TEdit and ClipBoard.
0
 

Author Comment

by:kupiec
ID: 1336893
Here is the problem with your solution:

-->> DDEClientItem.GetText

DDEClientItem has NO GetText Property !
This is one of the reasons I do all the finagling with TMemo and TEdit and ClipBoard.

Looks like I'm back to SQUARE.ONE.
0
 

Author Comment

by:kupiec
ID: 1336894
-->> DDEClientItem.GetText

DDEClientItem.Lines.GetText compiles cleanly, but now I get garbage instead of merely 255 characters ! I keep pressing on...
seems just around the corner.
0
 

Author Comment

by:kupiec
ID: 1336895
Found my "garbage" problem. But, I'm still afflicted. Guess what the following returns:

  Len := StrLen( DDEClientItem.Lines.GetText ) ;
  ShowStr := IntToStr(Len);
  ShowMessage(ShowStr);

If you guessed 257, you win !
Problem is, it should be around 1920 ( the DDE server is a 3270 terminal emulator ).

I just compiled this UNCHANGED in D2, and it returns 1922 ! (as well as filling my grid with ALL the lines !!!!

Hey, you can have the 100 points ! I don't think this one is going to go away. Smells like something funky in the D1 DdeClientItem to me.
b.
0
 
LVL 1

Expert Comment

by:slp
ID: 1336896
> DDEClientItem.Lines.GetText compiles cleanly, but now I get
> garbage instead of merely 255 characters ! I keep pressing
> on... seems just around the corner.

Ooops, my error again, definitely need the "Lines" property specifier.  

> Found my "garbage" problem. But, I'm still afflicted. Guess
> what the following returns:
>
>  Len := StrLen( DDEClientItem.Lines.GetText ) ;
>  ShowStr := IntToStr(Len);
>  ShowMessage(ShowStr);
>
> If you guessed 257, you win ! Problem is, it should be around
> 1920 ( the DDE server is a 3270 terminal emulator ).

This is weird, the only other thing that occurrs to me is to wonder if there are embedded nulls (#0) in the text which makes the PChar terminate; but then it shouldn't work in D2 either.  Are you running the D1 version under Win95 or Win3.1?  

Thanks for the points, I don't feel like I've really earned them yet, do you want to continue this investigation (via Email perhaps?).
0
 

Author Comment

by:kupiec
ID: 1336897
->Are you running the D1 version under Win95 or Win3.1?

Have tested on two different machines, one is NT4 and the other is WFW3.1. There are no embedded nulls that I can detect. Moreover, the D2 version "pages" through multiple 3270 screens and concatenates them into the client's string grid (one of the reasons for the nested loop). It never barks at any of the data.

I will keep pecking at this because I need to resolve it for my WFW clients, and would be quite willing to exchange email.
0
 
LVL 1

Expert Comment

by:slp
ID: 1336898
Okay, you can contact me at slposey@concentric.net.  If you like send me the exact offending code so I can see everything in context.  I will gladly submit to any non-disclosure agreements you may require.  In the meantime I will have a look at the implementation of the TDDEClientItem.Lines property and see if there's anything glaringly wrong.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

963 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