|
How do you want the conversion to work? Do you want the result rounded? What should happen if the double is negative?
Steve
|
|
|
|
|
You can not convert. The only thing that you can do is to separate the four Bytes of the double into unsigned chars, and afterwards mount them another time.
This is what I have to do to get the "real" variables of a PLC. But its a shi...
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
|
This is what I have to do to get the real value of an analog input on a PLC.
The communication and reading function is BYTEwise, but reals in Step7 are 4 bytes. So I have to read indepentant bytes, separate some bits, and make the conversion to real using the formule of the IEEE.
BTW, thanks you a lot for the link. There is much better explained as in the help files of siemens
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hey Friends
Do we have a way to fill in values in the active window?
eg i have a html page & i want that an exe should fill values in edit boxes sort of
text then tab & then fill data ?
Regards
|
|
|
|
|
Can anybody help me to write a code to enhance an image.
I have a webcam captured image in BMP format(24bit or 16 bit RGB).Can the noises and distortions in the image can be cleared
|
|
|
|
|
Deepu Antony wrote: Can the noises and distortions in the image can be cleared
doubtful, we can't clear the noise and distortions in this forum.
|
|
|
|
|
|
Franz Klein wrote: the cause of the error.
It would appear you don't have required header files included properly.
|
|
|
|
|
Franz Klein wrote: name_extractor variable(name);
This looks like a declaration of a member function variable that takes one parameter of unknown type. If you really mean to declare a function, all parameters must have their types declared, i.e.
<br />
name_extractor variable (std::string& name);<br />
|
|
|
|
|
Franz Klein wrote: name_extractor variable(name);
name is not a type.
Steve
|
|
|
|
|
Having downloaded the 60 day trial version of Borlands Visibroker, I did get the first simple example working, but that was using the DOS Command windows.
I could not find a way to call the IDL complier and produce a solution in VS 2005.
I used the nmake to build the application on a DOS window launched from VS2005, otherwise the nmake was not known in the Borland DOS window.
Anyone have been here before?
Andy.
|
|
|
|
|
Dear Experts,
I am stuck up with a piece of code, which I am not able to break. Could you kindly help me out.
Situation:
I am trying to perform a string comparison between 2 variables, one defined as const TCHAR * and other defined as CS_CHAR, inside an Embedded SQL program in C++. My relevant code snippet is as below:
=====
short CSQLBox::fnTest(const TCHAR *varInput)<br />
{<br />
CS_CHAR szExtract;<br />
<br />
....<br />
<br />
if(strcmp(szExtract, varInput)==0)<br />
{<br />
...<br />
}<br />
}
=====
When I try to compile this code, the strcmp step is throwing an error "cannot convert parameter 1 from 'char' to 'const char *'".
I have tried typecasting parameter 1 as:
if(strcmp((const char*)szExtract, varInput)==0)
This way, the code compiles, but fails in runtime with unhandled exception error. I am unable to understand how to solve this issue.
Could anyone kindly offer me some suggestions.
cheers,
sanK
|
|
|
|
|
It looks like CS_CHAR is a single character not a string. If so then sending it to strcmp is not going to work.
|
|
|
|
|
sntnknd wrote: if(strcmp(szExtract, varInput)==0)
Try:
if (szExtract == varInput[0])
...
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello Everybody,
Thank you for your responses. I must say I had tried to be too specific and had missed out to mention that szExtract is an array. I am very sorry for this mistake. The actual piece of code goes like this:
<br />
short CSQLBox::fnTest(const TCHAR *varInput)<br />
{<br />
exec sql begin declare section;<br />
CS_CHAR szExtract[10];<br />
exec sql end declare section;<br />
<br />
szExtract[0] = _T('\0');<br />
<br />
....<br />
<br />
for( int j=0; j<5; j++)<br />
if(strcmp(szExtract[j], varInput)==0)<br />
{<br />
...<br />
}<br />
}<br />
I am sure I am making some serious mistake, for which this piece couldn't be compiled, but I am not sure what. Could you kindly suggest.
cheers,
sanK
|
|
|
|
|
Now you should be able to use strncmp() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Good day. I am urgent to find a method to make my static library using (or calling) functions from other static library using Visual C++ 6.0.
I was given a header file and a static library file, for most of the time during application development, I just need to #include the header file and make my project setings link to static library.
But when developing a static library, I found that my project settings cannot link to the static library as Visual C++ 6.0 project settings does't show the link tab.
Is there anyway for me to call the function inside a static library from a static library?
|
|
|
|
|
Hirakawa wrote: I just need to #include the header file and make my project setings link to static library.
Exactly.
Alternatively, you could add
#pragma comment( lib, "libname") to your headerfile.
This is a Microsoft specific way of forcing the linker to include the lib given.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Hi George,
Thank you for your reply. If I included #pragma comment(lib, "libname") into my static library file, will the compiler compile everything into one static library?
Update:
I have two static libraries right now (LibraryA.lib and LibraryB.lib). I tried to put #pragma comment(lib, "LibraryA.lib") into LibraryB.h and compile.
The result is the size of LibraryB.lib does not increase...
-- modified at 14:22 Thursday 11th October, 2007
|
|
|
|
|
This will be resolved when you use this library in your final project. In that case, you will need to link against both libraries (otherwise you'll get linking errors).
|
|
|
|
|
Hi Cedric,
Thank you for your reply. Do I need to put #pragma comment(lib, "libname") into both header of static library in order to make the static library link against each other?
|
|
|
|
|
In the project that will use the libraries (which in turn uses the second library), you will need to specify in the project options that the project uses both A.lib and B.lib even if it only uses A.lib directly.
|
|
|
|
|
Thank you. I found the solution already.
For LibraryA.lib and LibraryB.lib,
just #include LibraryA.h in LibraryB.cpp and LibraryB.lib can access to LibraryA.lib provided LibraryA.lib and LibraryB.lib both must include into the project settings of application.
|
|
|
|
|
I need to print a bitmap image (about 2inch X 2inch) at a specific location on a paper but the following code always prints it at the upper left corner. How can I specify the x and y coordinated of the paper? What am I doing wrong? Even if I specify the first 2 parameters of StretchBlt function to my desired location(like 7,7), it prints at the upper left corner of the paper.
Please help!!!
void PrintBitmap(LPCTSTR filename)
{
CPrintDialog printDlg(FALSE);
printDlg.GetDefaults();
CDC dc;
if (!dc.Attach(printDlg.GetPrinterDC()))
{
AfxMessageBox(_T("No printer found!")); return;
}
dc.m_bPrinting = TRUE;
DOCINFO di;
// Initialise print document details
::ZeroMemory (&di, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
//di.lpszDocName = filename;
BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job
// Get the printing extents
// and store in the m_rectDraw field of a
// CPrintInfo object
CPrintInfo Info;
Info.SetMaxPage(1); // just one page
int maxw = dc.GetDeviceCaps(HORZRES);
int maxh = dc.GetDeviceCaps(VERTRES);
Info.m_rectDraw.SetRect(0, 0, maxw, maxh);
dc.StartPage(); // begin new page
//Info.m_nCurPage = page;
CBitmap bitmap;
// LoadImage does the trick here, it creates a DIB section
// You can also use a resource here
// by using MAKEINTRESOURCE() ... etc.
if(!bitmap.Attach(::LoadImage(::GetModuleHandle(NULL), filename, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE)))
{
AfxMessageBox(_T("Error loading bitmap!")); return;
}
BITMAP bm;
bitmap.GetBitmap(&bm);
int w = bm.bmWidth;
int h = bm.bmHeight;
// create memory device context
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap *pBmp = memDC.SelectObject(&bitmap);
memDC.SetMapMode(dc.GetMapMode());
//dc.SetStretchBltMode(FULLTONE);
dc.StretchBlt(7, 7, 2*w, 2*h, &memDC, 0, 0, w, h, SRCCOPY);
// clean up
memDC.SelectObject(pBmp);
bPrintingOK = (dc.EndPage() > 0); // end page
//}
if (bPrintingOK)
dc.EndDoc(); // end a print job
else dc.AbortDoc(); // abort job.
}
|
|
|
|