• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1200
  • Last Modified:

ActiveX: E2129 Cannot assign to a read-only property

I import an ActiveX to my DELPHI XE. During this process, i checked the option of generating a component wrapper. Then delphi generat wrapper called SMSLibX_TLB (attached her).

My problem is:

When I try to make this simple statment:

var
xx: WideString;
Begin

xx:=edit1.text;

SMSSubmit1.Destination.Address := xx;

Open in new window


It's give me this error!!
E2129 Cannot assign to a read-only property


Any Help please
SMSLibX-TLB.pas
0
MissManal
Asked:
MissManal
  • 16
  • 6
  • 3
  • +1
1 Solution
 
BdLmCommented:
if a object property is defined like


_SMSDeliver = interface(IDispatch)

    property SimIndex: Smallint read Get_SimIndex;
    property Unread: WordBool read Get_Unread;
  end;


you are only able to read and not able to write a value to that object. What kind of class/object  is SMSSubmit1 ???
0
 
jimyXCommented:
This property is for reading only the value of the destination address but not for setting it.
0
 
MissManalAuthor Commented:
SMSSubmit is a class for sending a PDU file.


Attached an MS-Access Example.



SMSLibX-with-Access.zip
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
MissManalAuthor Commented:
Attached the link of the ActiveX component:

ActiveX Component


Help files
HELP Files
0
 
MissManalAuthor Commented:
I'm just trying to send unicode SMS message using this component via Delphi XE.
0
 
jimyXCommented:
I am going to read what you have just sent, but before that I just got some notes from the first attachment that you sent.
You can see that at this line:
    property Destination: _GSMAddress read Get_Destination;

Destination is read property.

Most likely there is a property or function that allow you to do that by doing write:
procedure _Set_Destination(var Param1: _GSMAddress); safecall;
0
 
MissManalAuthor Commented:
HI sage,
I search for this seting function or property but i haven't find any!

I start to think that the problem is from the generated wrapper
0
 
BdLmCommented:
yue have the *.pas source code of your AX control ?
0
 
MissManalAuthor Commented:
No all i got are the attached SMSLibX-TLB.pas and this component
http://www.2shared.com/file/-50cA9Dw/SMSLibX_Install.html
0
 
MissManalAuthor Commented:
Here are some notes explaining how to import SMSLibX in your Delphi project.
After that, it should be easy to call SMSLibX methods from your code - and not so different from the other languages. Please refer to the SMSLibX Help (SMSLibX.chm) for objects and methods documentation.


How to import SMSLibX in your Delphi project

1- Run the SMSLibX installation program.
This will register SMSLibX.dll and related dependencies on your system.


2- Convert the SMSLibX type library to a Delphi stub.
Open your Delphi project.
From the project menu, select Import Type Library.
A dialog will show up containing a list of all registered ActiveX libraries on your system.
Select SMSLibX in that list, then click install (make sure Generate component wrapper is checked).


3- You should find a new "SMSLibX" component installed on your component palette.
You must use it in your application, as described in the SMSLibX documentation
(please refer to the SMSLibX Quick Start guide).

Please see also this generic link:
http://www.delphifaq.com/faq/delphi/delphi_ide/f155.shtml
0
 
BdLmCommented:
looks to me that you can not change that object/class as the code is compiled and stored inside a *.dll

0
 
MissManalAuthor Commented:
if you see the VB example or the MS-Access, you will notice that they don't have  read-only problem. We all use the same *.dll files!
0
 
MissManalAuthor Commented:
Any Help please
0
 
BdLmCommented:
is VB using that DLL, different version  ???
0
 
MissManalAuthor Commented:
no the same!!
0
 
BdLmCommented:
is it worth installing that comp. on my PC ---  can I expect any other type def.pas   with an option for setting /writting that property ????
0
 
MissManalAuthor Commented:
you might find something useful.
0
 
BdLmCommented:
BTW:  do you have working VB code - is it really possible to get your stuff running in VB ??
0
 
MissManalAuthor Commented:
yes, i do. but i need to do it in delphi.
0
 
MissManalAuthor Commented:
do ==> know ;)
0
 
developmentguruCommented:
According to the SMSLibX documentation the address property is what you are supposed to assign to, not it's sub property Address (which is read only).  


SMSSubmit1.Destination =: SMSLibX.GetGSMAddress("+393481234567", gsmTONInternational);


Calling the GetGSMAddress function will combine the two parameters into a formal address which could then be read from the address property.


I got the code (Which I paraphrased) from the documentation found here:

http://www.smslibx.com/tomcat/en/sms/smslibx_datasheet.jsp

look for "User manual & reference" in red text.  Clicking the link will download the compiled help file.
0
 
MissManalAuthor Commented:
if you run this code

SMSSubmit1.Destination =: SMSLibX.GetGSMAddress("+393481234567", gsmTONInternational);

Open in new window


You will get the following error:
E2003 Undeclared identifier: 'SMSLibx'

and if i change SMSLibx to SMSLibX_TLB so the code will look like this:

SMSSubmit1.Destination := SMSLibX_TLB.GetGSMAddress("+393481234567", gsmTONInternational);

Open in new window


you also get this error:
E2003 Undeclared identifier: 'GetGSMAddress'

and if i change it to the following:

SMSSubmit1.Destination := SMSLibX_TLB._GSMLib.getGSMAddress("+393481234567", gsmTONInternational);

Open in new window


OR

SMSSubmit1.Destination := SMSLibX_TLB._GSMLibDisp.getGSMAddress("+393481234567", gsmTONInternational);

Open in new window


i get this error: E2018 Record, object or class type required


Any suggestions?
0
 
MissManalAuthor Commented:
I download the help files and the commands works in VB but not in Delphi!! might the ActiveX wrapper cause the problem!
0
 
developmentguruCommented:
I do not have these components installed and would prefer not to muddy my system with software I have no use for.  I paraphrased the VB code in my earlier attempt to help you.

The following snippet from their help file seems to indicate that the GetGSMAddress method is callable from GSMLib or SMSLibX DLL.

GetGSMAddress Method (GSMLib, SMSLibX)

This was found by going to the index tab in the window that came up when I double clicked on the compiled help file, and choosing "GSMAddress object".  Double clicking on it brought up a choice of two topics.  I chose "GetGSMAddress Method (GSMLib)".


If you want to try to upload the imported wrapper so we can see it I may be able to help.  If you want to call the GetGSMAddress directly from the DLL that should allow you to do the assignment.

I am attempting to help you dig through this and get what you need.  If you want me to take it on as a personal project to get you working code then I would need some hardware to work with (for testing) and some form of payment agreement.
0
 
MissManalAuthor Commented:
Find attached the imported wrapper. Thank you for your time.
SMSLibX-TLB.pas
SPortLib-TLB.pas
VBA-TLB.pas
0
 
developmentguruCommented:
You will need to call the function:

class function CoGSMLib.Create: _GSMLib;

defined on line 2334 of SMSLibX-TLB.pas

Once you have created the automation object and assigned it to a variable you can access it's methods, in this case GetGSMAddress.

The following is mocked up code (pseudo-code).  It should point you in the right direction.
{pseudocode}

procedure TForm1.Button1Click(Sender : TObject);
var
  GSMLib : _GSMLib;

begin
  GSMLib := CoGSMLib.Create;
  try
    GSMLib.GetGSMAddress('+393481234567', gsmTONInternational);
    //the rest of your code here...

  finally
    GSMLib := nil;
  end;
end;

Open in new window

0
 
MissManalAuthor Commented:
Thank you, it works now.
0

Featured Post

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.

  • 16
  • 6
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now