473,805 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

basic language chr$

simple...what does basic chr$ used in visual c++ ????
i need to send chr$(5) to serial port/comm port but using visual c++
language...

thanks in advanced....
Jun 2 '06 #1
3 3471
joshua siew wrote:
simple...what does basic chr$ used in visual c++ ????
i need to send chr$(5) to serial port/comm port but using visual c++
language...

thanks in advanced....


In C and C++ char is an integer type so...

char ch = 5;

is legal, and is the same value as chr$(5) in Basic.

Note that this is different from

char ch = '5';

which is also legal, but is a different character value: the value 53 in
ASCII or Unicode, where the other example is, of course, the value 5.

-cd
Jun 2 '06 #2
dear cd,
so how does I send this string to the comm port....

"<ENQ>02FFTT1AB CDE07"

and since this string is a PLC command there will be repond from the PLC if
this is send successfull. The PLC device Receive Data indicator stated it's
received but no respond??!???!! definately need help....below is my code.

//this is where I pass the data....
m_CommPort->Write( Encoding::ASCII->GetBytes(ch) );
m_CommPort->Write( Encoding::ASCII->GetBytes ("02FFTT1ABCDE0 7" ) );
Below is my class funciton....

// This function writes the passed array of bytes to the
// Comm Port to be written.
System::Void Write(Byte Buffer[])
{
DWORD iBytesWritten, iRc;

if (mhRS == (HANDLE)-1)
{
throw new ApplicationExce ption(S"Please initialize and open port before
using this method");
}
else
{
// Transmit data to COM Port
if (meMode == Mode::Overlappe d)
{
// Overlapped write
if (pHandleOverlap pedWrite(Buffer ))
throw new ApplicationExce ption(S"Error in overlapped write");
}
else
{
// Clears IO buffers
PurgeComm(mhRS, PURGE_RXCLEAR | PURGE_TXCLEAR);

// Convert name from String to Ansi char string
System::Text::A SCIIEncoding* encoder = new System::Text::A SCIIEncoding();
Byte __pin* abytes = &Buffer[0];
iRc = WriteFile(mhRS, (char*)abytes, Buffer->Length, &iBytesWritt en, 0);
if (iRc == 0)
{
String* strErr = String::Format( S"Write Error - Bytes Written {0} of
{1}", iBytesWritten.T oString(), Buffer->Length.ToStrin g());
throw new ApplicationExce ption(strErr);
}
}
}
}

// This function writes the passed string to the
// Comm Port to be written.
System::Void Write(String* Buffer)
{
System::Text::A SCIIEncoding* oEncoder = new System::Text::A SCIIEncoding();
Byte aByte[] = oEncoder->GetBytes(Buffe r);
this->Write(aByte) ;
}

"Carl Daniel [VC++ MVP]" wrote:
joshua siew wrote:
simple...what does basic chr$ used in visual c++ ????
i need to send chr$(5) to serial port/comm port but using visual c++
language...

thanks in advanced....


In C and C++ char is an integer type so...

char ch = 5;

is legal, and is the same value as chr$(5) in Basic.

Note that this is different from

char ch = '5';

which is also legal, but is a different character value: the value 53 in
ASCII or Unicode, where the other example is, of course, the value 5.

-cd

Jun 2 '06 #3
safe_cast<Syste m::Char>(5)
(via our Instant C++ VB to C++/CLI converter)
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

"joshua siew" wrote:
simple...what does basic chr$ used in visual c++ ????
i need to send chr$(5) to serial port/comm port but using visual c++
language...

thanks in advanced....

Jun 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2591
by: Danny | last post by:
Hi all, I would like to write C++ code and call it from VBDOS, or even QB 4.5 or PDS 7.1, including plain-type parameter passing. My C/C++ compiler is MS-C/C++ v8.00c, and I have VBDOS v1.00, PDS v7.1, and QuickBASIC v4.5.
28
1689
by: Intermouse | last post by:
I have recently purchased an aspi wrapper control for vb. I haven't had much experience with hex and memory addresses and that's my problem. The piece of code that baffles me is: With ASPI1 .HostAdapter = 0 .SCSIID = 4
2
7971
by: paddy_nyr | last post by:
I converted an Access 97 db to Access 2002 db and I now get the following error message when I try and run a query. Thanks Here's my query. SELECT DISTINCTROW tblCo_Info.Co_id, & Chr(13) & Chr(10) & & IIf(Trim()<>"",Chr(13) & Chr(10) & ,"") & Chr(13) & Chr(10) & IIf(Trim()<>"",Trim() & ", ","") & & " " & AS
5
149118
by: Christian Blackburn | last post by:
Hi Gang, I would like to use a caesar cipher on the mailto: links in my website to prevent crawlers from farming the e-mails off my site. Can someone tell me the equivalents to Chr() and Asc() from Visual Basic, but for JavaScript? Chr(n) returns the character based on the numeric ASCII code. For example Chr(34) --> " Asc(") --> 34
9
12553
by: me | last post by:
I am working as an intern at a place using Access 2003 code builder. Looking at the cold of the old project t(hat we are redoing), I see Chr(39) Chr(91) Chr(45) Chr(93)
97
5560
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in the first place. Anyone else heard about this development? The Master
28
3610
by: Randy Reimers | last post by:
(Hope I'm posting this correctly, otherwise - sorry!, don't know what else to do) I wrote a set of programs "many" years ago, running in a type of basic, called "Thoroughbred Basic", a type of business basic. I need to re-write it, bring it kicking and screaming to run on Windows XP. This is for a video rental place, tracks movie and game rentals, customers, employee transactions, reservations, does reports,..... and on. I know some of...
10
3127
by: Esmael | last post by:
Hi to all, /*****************************/ OS-WIn XP SP2 VB6 SP6 /*****************************/ Is their anyone who can help me with this: Source code written on VB6.
2
2366
by: ozipos | last post by:
I am trying to print text to a docket printer with the following command printer.print "trying to print" but I keep getting an error. Actually I want to print special keys so that the cah draw opens. I first need to know that the print commands work. If I can specify the printer as well it would be great. I have tried pinter.print Chr$(27);Chr$(0);Char$(80);Chr$(80) but this doesnt work in opening the draw. The printer doesn't respond at...
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.