|
So, I have this snippet of code that formats an html table data cell:
if(aSensor[i].sensorSwitchState == lowState) {
client->print("<td style='width:30px; background-color:lawngreen'>");
} else {
client->print("<td style='width:30px; background-color:red'>");
}
I have each background-color:<colorname> hardcoded and the subsequent printing output is as I was expecting. However, I would like to replace the <colorname> entry - lawngreen and/or red - with a const (or #define) so that the <colorname> entry is replaced with the color name.
I've tried
#define GREEN lawngreen
...
client->print("<td style='width:30px; background-color:GREEN'>")
and that doesn't work.
I've tried
const char acolor[]="lawngreen";
client->print("<td style='width:30px; background-color:acolor'>")
and that doesn't work.
I know there has to be a way to do this, but I can't seem to figure it out. Any ideas how I go about making a declaration that will let me insert the <color name=""> in the appropriate place would be greatly appreciated.
TNX
|
|
|
|
|
Try
#define GREEN "lawngreen"
client->print("<td style='width:30px; background-color:" GREEN "'>");
|
|
|
|
|
This
#define GREEN "lawngreen"
client->print("<td style='width:30px; background-color:" GREEN "'>") should work.
There might be more elegant ways, depending on print function definition.
|
|
|
|
|
To both K5054 and Cpallini:
Thanks, that gets the job done!!
It turns out I had tried
#define GREEN "lawngreen"
but then wrote the code escaping the quotes:
client->print("<td style='width:30px; background-color:\" GREEN \"'>");
I had also tried
client->print("<td style='width:30px; background-color:"GREEN"'>");
but that didn't work. Its the space after the leading quote that does the trick.
client->print("<td style='width:30px; background-color:" GREEN"'>");
The trailing quote doesnt need a space before it.
Gotta think on that one a bit (why the quotes and their spacing is important but escaping the quotes is not) ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
In C/C++ consecutive string literals are catenated together
cout << "hello " "world" << endl;
cout << "hello world" << endl; both produce the same thing. I don't know why the C++11 standard requires a space between a literal and a string macro, but it probably has something to do with ambiguous parsing when no space is present.
As for the escaped quotes, if you mean
client->print("<td style='width:30px; background-color:\" GREEN \"'>"); recall that \" embeds a double quote in a string, much like \n or \t embeds a new-line or a tab. If that's not what you were referring to, then maybe you could explain it better?
|
|
|
|
|
Frankly, I had forgotten the concatenation example you show.
As for your escaped quotes, yes, I was referring to the use of the \ to allow the explicit use of the the following ". I thought that since the contents of the print statement were already delineated by leading and trailing quotes, that I had to use the \ to permit the use of additional quotes between those two "bookend" quotes. Thanks for setting me straight.
Its been a good day - I learned something. Thank you!!
|
|
|
|
|
I Searched on internet for any library done by c++ for scan image but cannot found
any library for c++ as open source free
can any one help me to give me any source code or links by c++ for scan image by scanner
then get direct to computer
|
|
|
|
|
|
I am trying to make a app that will record the exact duration, and the sequence of keystrokes. it need to be able to record with very precise timing because I am planing on using it to create a way to record a game follow path. For example a driving game that earns you money for just diving around in free roam and if you follow a specific path you maximize the amount of money you earn. but i don't know what i need for the coding. Is there a way to code something like that?
|
|
|
|
|
Recording keystrokes is frowned upon, and illegal without the users' consent. That being said, you could use a keyboard-hook. That does record keyboard-strokes, not characters.
Not one of the easiest things to do, and not something I'm inclined to help with for cheating-purposes.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
well it is going to be an app so they will give the consent and i will not see the key strokes
|
|
|
|
|
And they will use it to cheat the game company out of money.
|
|
|
|
|
Most serious online games have counter measures to stop this sort of thing and it directly violates there User agreement and gets you banned. If you are dealing with real money it also comes under the fraud act of most countries and selling or distributing the app itself will fall under the same laws.
I would think very carefully about what you are doing it will generally be illegal.
In vino veritas
|
|
|
|
|
Who is 'they'? If it's the company that made the game, it would be trivial for them to do this from within the game itself. If not, it's difficult and illegal.
Note that most EULAs specifically prohibit that kind of thing. At the very least, this is true for all multiplayer games, simply because it would create an unfair advantage over other players.
P.S.:
Just to be clear: any program that is capable of recording user input for other applications has the potential to record login credentials. For that reason alone it is most likely illegal in most countries, and that's on top of EULA and other rights that the game company may claim.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
modified 25-Mar-19 5:27am.
|
|
|
|
|
Member 14190981 wrote: Is there a way to code something like that?
Yes.
Not that difficult if you have experience programming.
The app would need admin access and you would need to do a deep dive into OS API calls.
|
|
|
|
|
well OK it is illegal i wont try it., i mean i only wanted it so i can make an app that will allow you to make a type of AI afk non competitive grinder bot follow path so people can do long distince routs without having to be the PC for long time. i guess i should just start on a auto clicker and do even more research
|
|
|
|
|
I need to check weather Dot net 4.6 in installed on machine or not. So I checked registry entry (
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full ) for windows 10.
But I need to check for Win7 and Win8 as well. Is the registry entry same for all win7, win8 and window10.
|
|
|
|
|
It's present on my Win 7 machine.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Why not just trying running a test API? Or are you going to install it if it isn't there?
|
|
|
|
|
|
This question is for anyone using the CADODatabase classes in codeproject.com:
I'm trying to pass a currency amount to a SQL command and keep getting an exception about not declaring scalar variable @Amount. Any ideas about what is wrong?
CADORecordset *pRecSet=new CADORecordset(pDB);
// search for amount $28050.65
CADOCommand *pCmd=new CADOCommand(pDB, "select itemid from item where amount=@Amount", CADOCommand::typeCmdText);
COleCurrency currency;
currency.m_cur.int64=280506500;
_variant_t vtValue;
vtValue.vt=VT_CY;
vtValue.cyVal=currency.m_cur;
pCmd->AddParameter("@Amount", CADORecordset::typeCurrency, CADOParameter::paramInput, 8, vtValue, 0, 0);
if(pRecSet->Execute(pCmd)) {
// exception gets thrown by Execute(pCmd)
}
pRecSet->Close();
delete pCmd;
delete pRecSet;
|
|
|
|
|
I presume you are referring to A set of ADO classes - version 2.20[^]. In which case you should post your question to the article forum. Although it appears the author is no longer active here.
|
|
|
|
|
That's why I asked here, sorry if it wasn't the appropriate place. I was hoping someone was actually using the code and could point me in the right direction.
|
|
|
|
|
You may be lucky, but it still requires someone who really understands the code. From my quick look at the article it would take some considerable time to reach that stage. Do you really need this code, or is there an alternative way of solving your problem?
|
|
|
|
|
The code should work, every example I've seen on the internet with ADO is making identical COM calls. I was hoping there was a trick (it's Microsoft after all) to making it work.
|
|
|
|