Re: [DUG] HEX to decimal

2011-08-04 Thread Todd Martin
edit2.text := IntToStr(StrToInt('$' + sRaw));

On Thu, Aug 4, 2011 at 5:50 PM, Marshland Engineering 
marshl...@marshland.co.nz wrote:

 **
 I cannot get the decimal equivalent of the number sent from my micro in
 Delphi !!!

 I am running and ATmega (micro) and it sends out a hex number corresponding
 to an A to D conversion. It is 8 bit.

 I'm using SerialNG to read the data with

 procedure TfDyno.SerialPortNGRxClusterEvent(Sender: TObject);
 Var
 sRaw:String;
 begin
 if SerialPortNG.NextClusterSize = 0 then begin
sRaw:=SerialPortNG.ReadNextClusterAsString;
edit2.text:=sRaw;
 end;
 end;

 In the text box I get the ASCII character displayed eg [  {  9   *   {
 }  % etc.

 How do I get the Decimal equivalent to display. Should be in the range
 0-65534.

 I've spent many hours trying so far !!!


 Cheers Wallace

 ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@delphi.org.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
 unsubscribe

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] HEX to decimal

2011-08-04 Thread Marshland Engineering

Been there done that 

edit2.text := IntToStr(StrToInt('$' + sRaw));

Result  '[' is not a valid integer. 



___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] HEX to decimal

2011-08-04 Thread Steven Knight
You might need to use the ORD function byte by byte

Steven

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of Marshland Engineering
Sent: Thursday, 4 August 2011 7:47 p.m.
To: delphi@delphi.org.nz
Subject: Re: [DUG] HEX to decimal


Been there done that

edit2.text := IntToStr(StrToInt('$' + sRaw));
Result  '[' is not a valid integer.





**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.clearswift.com
**
___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] HEX to decimal

2011-08-04 Thread Jeremy Coulter
The data returned in SerialPortNG.ReadNextClusterAsString, is it a buch of
chars at a time, or just one at a time?
If its a bunch of them at a time, you will need to do a conversion one char
at at time in a loop.

i.e. for x:=0 to length(sRaw) do
   begin
  ivalue:= ORD(sRaw[x])) ;
   end;

something along those linesI didnt write that in Delphi, I just did it
from memory but it should help a bitI hope.

Jeremy

On Fri, Aug 5, 2011 at 8:43 AM, Steven Knight steven.kni...@ecan.govt.nzwrote:

  You might need to use the ORD function byte by byte

 ** **

 Steven

 ** **

 *From:* delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz]
 *On Behalf Of *Marshland Engineering
 *Sent:* Thursday, 4 August 2011 7:47 p.m.
 *To:* delphi@delphi.org.nz
 *Subject:* Re: [DUG] HEX to decimal

 ** **

  

 Been there done that 

  

 edit2.text := IntToStr(StrToInt('$' + sRaw));

 Result  '[' is not a valid integer. 

  

  

  

  

 **
 This email and any files transmitted with it are confidential and
 intended solely for the use of the individual or entity to whom they
 are addressed. If you have received this email in error please notify
 the sender of the message.

 This footnote also confirms that this email message has been swept by
 MIMEsweeper for the presence of computer viruses.

 www.ecan.govt.nz
 **

 ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@delphi.org.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
 unsubscribe

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] HEX to decimal

2011-08-04 Thread Jeremy Coulter
just noticed I missed a -1 in the for loop. Should be

for x:=0 to length(sRaw) -1 do


Jeremy


On Fri, Aug 5, 2011 at 9:32 AM, Jeremy Coulter jscoul...@gmail.com wrote:

 The data returned in SerialPortNG.ReadNextClusterAsString, is it a buch of
 chars at a time, or just one at a time?
 If its a bunch of them at a time, you will need to do a conversion one char
 at at time in a loop.

 i.e. for x:=0 to length(sRaw) do
begin
   ivalue:= ORD(sRaw[x])) ;
end;

 something along those linesI didnt write that in Delphi, I just did it
 from memory but it should help a bitI hope.

 Jeremy

 On Fri, Aug 5, 2011 at 8:43 AM, Steven Knight 
 steven.kni...@ecan.govt.nzwrote:

  You might need to use the ORD function byte by byte

 ** **

 Steven

 ** **

 *From:* delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz]
 *On Behalf Of *Marshland Engineering
 *Sent:* Thursday, 4 August 2011 7:47 p.m.
 *To:* delphi@delphi.org.nz
 *Subject:* Re: [DUG] HEX to decimal

 ** **

  

 Been there done that 

  

 edit2.text := IntToStr(StrToInt('$' + sRaw));

 Result  '[' is not a valid integer. 

  

  

  

  

 **
 This email and any files transmitted with it are confidential and
 intended solely for the use of the individual or entity to whom they
 are addressed. If you have received this email in error please notify
 the sender of the message.

 This footnote also confirms that this email message has been swept by
 MIMEsweeper for the presence of computer viruses.

 www.ecan.govt.nz
 **

 ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@delphi.org.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
 unsubscribe



___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] Email/SMTP code

2011-08-04 Thread David O'Brien
From memory it fails if you try. I think the SMTP component frees them...

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of Ross Levis
Sent: Thursday, 4 August 2011 4:02 p.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: Re: [DUG] Email/SMTP code

 

I’m basically implementing the code below.  I was wondering why the 
TIdText.Create and TIdAttachmentFile.Create’s don’t need to be freed.  Does 
this occur automatically when the mail is sent?

 

Ross.

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of David O'Brien
Sent: Thursday, 14 July 2011 7:12 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Email/SMTP code

 

Put the code in another project that doesn’t require admin access?

What server are you pointing at, and are you going through a proxy server?

 

Username  password are both blank in my implementation.

 

Here is a bit more up to date version from another project, this returns any 
error message.

function SendEmail(msgFrom, msgTo, msgCC, msgBCC, msgSubject: String; msgBody: 
TStringList; Attachments: TStringList): String ;

var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  Result := '' ;

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

MsgTo := Trim(MsgTo) ;

if Length(MsgTo)  0 then

  if MsgTo[Length(MsgTo)] = ';' then

Delete(MsgTo, Length(MsgTo), 1) ;

MsgCC := Trim(MsgCC) ;

if Length(MsgCC)  0 then

  if MsgCC[Length(MsgCC)] = ';' then

Delete(MsgCC, Length(MsgCC), 1) ;

MsgBCC := Trim(MsgBCC) ;

if Length(MsgBCC)  0 then

  if MsgBCC[Length(MsgBCC)] = ';' then

Delete(MsgBCC, Length(MsgBCC), 1) ;

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

if MsgTo  '' then

  idMessage.Recipients.Add.Address := msgTo ;

if MsgCC  '' then

  idMessage.CCList.Add.Address := msgCC ;

if MsgBCC  '' then

  idMessage.BccList.Add.Address := msgBCC ;

idMessage.Subject := msgSubject ;

with TIdText.Create(IdMessage.MessageParts, nil) do

begin

  Body.Assign(msgBody) ;

  ContentType := 'text/html';

end;

if Assigned(Attachments) then

  for i := 0 to pred(Attachments.Count) do

with TIdAttachmentFile.Create(idMessage.MessageParts, 
Attachments[i]) do

begin

  ContentID := inttoStr(1000+i) ;

  ContentType := 'image/jpeg' ;

  Filename := ExtractFileName(Attachments[i]) ;

end;

t := now ;

while (SMTP.Connected) and

  (now  t + 10 * (1/86400)) do // 10 Seconds

  sleep(10) ;

SMTP.Host := ASettings.SMTPServer ;

SMTP.Port := ASettings.SMTPPort ;

SMTP.Username := ASettings.Username ;

SMTP.Password := ASettings.Password ;

SMTP.Connect ;

try

  SMTP.Send(idMessage) ;

finally

  SMTP.Disconnect ;

end ;

  finally

SMTP.Free ;

  end;

end;

  except

on e: Exception do

begin

  Result := msgTo+': '+e.Message ;

  EmailFailed := True ;

end;

  end ;

end ;

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of John Bird
Sent: Thursday, 14 July 2011 6:06 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Email/SMTP code

 

Trying to debug this SMTP program, having tweaked the code a little – I am 
getting “Connection timed out” 

 

However I cannot debug, as on Windows 7 this program requires admin access.

 

I restarted the IDE (BDS.EXE) running as administrator but still get the error 
message

 

“Cannot create process”   (Debug)

 

or

 

“Access denied”  (Run without debugger).

 

Can run the program outside of the IDE by right clicking and selecting “Run as 
administrator” but there is no debugging then!

 

What have I missed?

 

John

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] Delphi Digest, Vol 94, Issue 7

2011-08-04 Thread Marshland Engineering
I still have something wrong

I sending
serial_send('B');
serial_send('C');
and a terminal program reads BC correctly

My Delphi code is as below but something is wrong with the second character.

if SerialPortNG.NextClusterSize = 0 then begin
   sRaw:=SerialPortNG.ReadNextClusterAsString;
   memo1.Lines.Add(sRaw);
   sData:='';
   for i:=1 to length(sRaw) do begin
   iValue:= ORD(sRaw[i]);
   sData:=sData+IntToStr(iValue)+'  ';
end;
   memo1.Lines.Add(sData);

Result
Bè
66  232
Bè
66  232
Bè
66  232

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe


Re: [DUG] HEX to decimal

2011-08-04 Thread Marshland Engineering
Adding more characters

serial_send('B');
serial_send('C');
serial_send('D');
serial_send('E');

I get

B(Tú
66  40  84  250
B(Tú
66  40  84  250 

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe


Re: [DUG] Delphi Digest, Vol 94, Issue 7

2011-08-04 Thread Colin Johnsun
What version of Delphi are you using? Could the string be returned as a
Unicode string? or is it an AnsiString?

Secondly, shouldn't the for loop be: for i := 0 to Length(sRaw) do

Regards,
Colin

On 5 August 2011 10:34, Marshland Engineering marshl...@marshland.co.nzwrote:

 I still have something wrong

 I sending
serial_send('B');
serial_send('C');
 and a terminal program reads BC correctly

 My Delphi code is as below but something is wrong with the second
 character.

if SerialPortNG.NextClusterSize = 0 then begin
   sRaw:=SerialPortNG.ReadNextClusterAsString;
   memo1.Lines.Add(sRaw);
   sData:='';
   for i:=1 to length(sRaw) do begin
   iValue:= ORD(sRaw[i]);
   sData:=sData+IntToStr(iValue)+'  ';
end;
   memo1.Lines.Add(sData);

 Result
 Bè
 66  232
 Bè
 66  232
 Bè
 66  232

 ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@delphi.org.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
 unsubscribe

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] HEX to decimal

2011-08-04 Thread Marshland Engineering
What version of Delphi are you using? Could the string be returned as a
Unicode string? or is it an AnsiString?I'm using Ver 6

Apparently ORD works with 1 for the first character and not 0 just to be 
confusing !!!

PS Using 0 returns a blank.



___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe


Re: [DUG] Strange behavour - WebBrowser and ADO

2011-08-04 Thread Dennis Chuah

Folks,

Hi.  You guys may want to know the solution to this issue.  If you call 
TWebBrowser.ExecWB, after it returns, you will find that the EmptyParam 
global variable is no longer the same value.  It gets set to Unassigned. 
There is a bug logged on Quality Central:

http://qc.embarcadero.com/wc/qcmain.aspx?d=61255

This is perhaps not a VCL bug per se, but more of how Delphi calls dual 
interface methods and perhaps a bug in IE itself.  The workaround is simple, 
bypass TWebBrowser.ExecWB and call the browser's ExecWB method directly, 
passing in dummy OLEVariant variables initialised to the same value as 
EmptyParam.

Regards,
Dennis.

--
From: Edward Huang edwa...@slingshot.co.nz
Sent: Wednesday, August 03, 2011 7:39 PM
To: 'NZ Borland Developers Group - Delphi List' delphi@delphi.org.nz
Subject: [DUG] Strange behavour - WebBrowser and ADO

 Hi,

 We have just noticed a strange behaviour recently, which I couldn't figure
 out how to resolve.  The issue could have been there all the time, just we
 didn't used the sequence before.

 We have an application, uses ADO to connect to SQL Server database.
 Components used include TADOQuery, TADOStoreProcedure etc.  It all works
 fine.

 Then we have a form which contains among other things, a TWebBrowser and a
 'Print' button.  On click event of the Print button, we call:

  WebBrowser_Help.ExecWB(OLECMDID_PRINT, 1);

 Which will bring up printing dialog and print the contents of the
 TWebBrowser component.

 The strange thing is that after the Print button clicked, subsequent 
 access
 to database via ADO components all failed with Exception.  The following 
 is
 a sample exception message:

 Arguments are of the wrong type, are out of acceptable range, or are in
 conflict with one another

 I have tried to close ADOConnection, reopen etc, the database access still
 doesn't success.

 Anyone knows how to fix this issue?

 Edward




 ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@delphi.org.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
 unsubscribe 

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe