hello,

how about this hack since working across apps can be a real pain
I like KISS, next release of Windoze and MI will end up trashing any high
level
stuff you write anyway

FYI -- some of D-guys are on [EMAIL PROTECTED] -- saves the *basic*
folks
being confused about *real* programming.

speaking of that it sure is fun switching back and forth, I'm forever having
; stuck
on the end of MB lines or doing :=

I have written UltraMsg that does everthing from email with attachments,
html formatting and output,
RTF message boxes, INI/Registry read/write, API printers/windows/video,
Soundex compares, file copy/move and more...........
plus all the functions of D5 that MB/MI doesnt have like true boolean
or/and/xor,
hyperbolic trig, string replace [one liner from delphi],
and this how I pass everthing back and forth.

========================================
in MB

declare function MyD5Func Lib DelphiStuff (s as string) as String
dim sName as String
dim LName as String
dim FName as String

FName="TREY"
LName="PATTILLO"

sName=FName+chr$(9)+LName

sName=Myd5Func(sName)

FName=left$(sName,instr(1,sName,chr$(9))-1)

LName=mid$(sName,instr(1,sName,chr$(9))+1,len(sName))

print FName+Chr$(13)+chr$(10)+LName

============================

in D5

Library DelphiStuff;

  uses
  Forms,
  Windows,
  Dialogs,
  SysUtils;

{
unit global variables here
}

function MyD5Func(var s: pChar): pChar; stdcall;
var
  LName: string;
  FName: String;
  sName: String;
begin
  sName:=StrPas(s)
  FName:=copy(s,1,pos(#9,s)-1);
  LName:=copy(s,pos(#9,s)+1,length(s));
  FName:=ansilowercase(FName);
  FName[1]:=chr(ord(fname[1]) xor 32);  // A=64 a=96 ---- XOR will flip case
  LName:=ansilowercase(LName);
  LName[1]:=chr(ord(fname[1]) xor 32);
  Result:=FName+#9+LName;
end;

exports
  MyD5Func;

end.

=================

Trey Pattillo
[EMAIL PROTECTED]
http://www.wap3.com

------------------------------------------------

To ME or not to ME, that is the question.
For some it will be to Whistle
and indure the thorns and thistle.
For me it is not to ME, but to NT,
The OS for ME !

  ----- Original Message -----
  From: Peter Zyczynski
  To: 'Marc Pelletier' ; [EMAIL PROTECTED]
  Sent: Wednesday, May 23, 2001 19:28
  Subject: RE: MI-L MB/Delphi - Passing strings from MB to Delphi DLL
(revisited)


  Marc,

  I tried your solution but still get the error message:

  ""This program has performed an illegal operation and will be shut down...
  yada.. yada. yada..."

  Here's my sample MB code...
  Is there anything obviously wrong?


  -----------------------------------------------------------------
  Include "MAPBASIC.DEF"

  Declare Sub ChangeValue Lib "Project_PCharAlternative.DLL"
            Alias "ChangeValue"
            (FName as String, LName as String)

  Declare Sub Main


  '**********************************************************

  Sub Main
  Dim
    FName as String,
    LName as String

  FName = Space$(100)
  LName = Space$(100)
  FName = "Mapinfo First Name"
  LName = "Mapinfo Last Name"

  Note FName + chr$(13) + LName
  call ChangeValue(FName, LName)
  Note FName + chr$(13) + LName

  End Sub
  -----------------------------------------------------------------


  -----Original Message-----
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED]]On Behalf Of Marc
Pelletier
  Sent: Wednesday, 17 January 2001 2:06 AM
  To: [EMAIL PROTECTED]
  Subject: Re: MI-L MB/Delphi - Passing strings from MB to Delphi DLL
  (revisited)

  Peter,

  There's nothing obviously wrong with the function below, and I've done the
  same thing numerous times. It's good practice, though, to pass the lengths
  of the pchars as well so that you can ensure you're not overwriting
  something. That's probably what's happening here.

  I'm really not sure how your record type works, given that the pchars
could
  be any length, in that case I would use an array of char with fixed
length.

  One way to modify the function so you can be sure you're not overwriting
  anything is as follows:

  procedure ChangeValue(var FName:PChar; var LName:PChar);
  begin
      StrLcopy( FName, 'Delphi First Name', sizeof( FName ) - 1 );
      StrLcopy( LName, 'Delphi Last Name',  sizeof( LName ) - 1 );
  end;

  Knocking 1 off of the length ensures that if FName is null terminated to
  begin with it will remain so.

  Hope this helps.

  Marc Pelletier
  Traxis Inc.


  At 12:51 PM 5/23/01 +1000, you wrote:
  >procedure ChangeValue(var FName:PChar; var LName:PChar); Stdcall;
  >
  >implementation
  >
  >//******************************************************
  >procedure ChangeValue(var FName:PChar; var LName:PChar);
  >begin
  >     StrPcopy(FName,'Delphi First Name');  file://<--Everything crashes
in a
  great
  >heap!
  >     StrPcopy(LName,'Delphi Last Name');
  >end;
  >//******************************************************
  >end.



  _______________________________________________________________________
  List hosting provided by Directions Magazine | www.directionsmag.com |
  To unsubscribe, send e-mail to [EMAIL PROTECTED] and
  put "unsubscribe MapInfo-L" in the message body.



  _______________________________________________________________________
  List hosting provided by Directions Magazine | www.directionsmag.com |
  To unsubscribe, send e-mail to [EMAIL PROTECTED] and
  put "unsubscribe MapInfo-L" in the message body.



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.

Reply via email to