Consider I have an enum, which I have coded today. What are the possible ways to extend its functionality, or perhaps add more variables to it, on a later date?
Will partial enums do the trick?
I need to display text along with values of variables in a CEdit controlled Edit Control Box. How do I do it ? Currently I'm using SetWindowText(), but that only takes a string...how do I get a formatted string to display in the edit control?
Example: printf("The answer is %d\n",ans) - how do i print the same message in a Edit Control?
I'm struggling my way through Artificial Intelligence: A Modern Approach in order to alleviate my natural stupidity. In trying to solve some of the exercises, I've come up against the "Who Owns the Zebra" problem, Exercise 5.13 in Chapter 5. This has been a topic here on SO but the responses mostly addressed the question "how would you solve this if you had a free choice of problem solving software available?"
I accept that Prolog is a very appropriate programming language for this kind of problem, and there are some fine packages available, e.g. in Python as shown by the top-ranked answer and also standalone. Alas, none of this is helping me "tough it out" in a way as outlined by the book.
The book appears to suggest building a set of dual or perhaps global constraints, and then implementing some of the algorithms mentioned to find a solution. I'm having a lot of trouble coming up with a set of constraints suitable for modelling the problem. I'm studying this on my own so I don't have access to a professor or TA to get me over the hump - this is where I'm asking for your help.
I see little similarity to the examples in the chapter.
I was eager to build dual constraints and started out by creating (the logical equivalent of) 25 variables: nationality1, nationality2, nationality3, ... nationality5, pet1, pet2, pet3, ... pet5, drink1 ... drink5 and so on, where the number was indicative of the house's position.
This is fine for building the unary constraints, e.g.
The Norwegian lives in the first house:
nationality1 = { :norway }.
But most of the constraints are a combination of two such variables through a common house number, e.g.
The Swede has a dog:
nationality[n] = { :sweden } AND pet[n] = { :dog }
where n can range from 1 to 5, obviously. Or stated another way:
nationality1 = { :sweden } AND pet1 = { :dog }
XOR nationality2 = { :sweden } AND pet2 = { :dog }
XOR nationality3 = { :sweden } AND pet3 = { :dog }
XOR nationality4 = { :sweden } AND pet4 = { :dog }
XOR nationality5 = { :sweden } AND pet5 = { :dog }
...which has a decidedly different feel to it than the "list of tuples" advocated by the book:
( X1, X2, X3 = { val1, val2, val3 }, { val4, val5, val6 }, ... )
I'm not looking for a solution per se; I'm looking for a start on how to model this problem in a way that's compatible with the book's approach. Any help appreciated.
Why cant we have static method in an inner class but can have static final members?
Can we access static final member variables of inner class outside the outer class without instantiating inner class ?
Hi, I am supplying a Javascript function strings with commands (SVG path commands):
eg. "move 10 10 line 50 50"
move and line are commands
numbers are x, y coordinates
I would like to add special strings to these commands, that would instruct the function to use specific variables
eg. "move %mouseX%+1 %mouseY%+1"
where %mouseX% and %mouseY% would be the mouse x,y coordinates
How can I parse and replace these?
I'm using PayPal Website Payments Standard. Whenever the user lands on PayPal with the variables I sent, it shows a PayPal Login form and at the bottom it shows "Don't have a PayPal account? Use your credit card or bank account (where available)."
I want it to default to always ask for credit card and maybe say "Have PayPal? Use that!". Any ideas?
When implementing a microsoft.build.utilities.task how to i get access to the various environmental variables of the build?
For example "TargetPath"
I know i can pass it in as part of the task XML
<MyTask TargetPath="$(TargetPath)" />
But i don't want to force the consumer of the task to have to do that if I can access the variable in code.
http://msdn.microsoft.com/en-us/library/microsoft.build.utilities.task.aspx
In Visual Studio debug mode it's possible to hover over variables to show their value and then right-click to "Copy", "Copy Expression" or "Copy Value".
In case the variable is an object and not just a basic type, there's a + sign to expand and explore the object. It there a way to copy all that into the clipboard?
Hi,
I'm looking for a way to keep the equivalent of persistent global variables in app engine (python). What I'm doing is creating a global kind that I initialize once (i.e. when I reset all my database objects when I'm testing). I have things in there like global counters, or the next id to assign certain kinds I create.
Is this a decent way to do this sort of thing or is there generally another approach that is used?
When using the cgi module in Python, I can't seem to figure out how to extract CGI variables in the URL. For example if the url servercgi.py?name=user , how do I get 'name' after import cgi? For some reason, form.getvalue and form['user'] do not work but if I print the object, I see something like FieldStorage(None, None, [MiniFieldStoreage('name', 'user')]).
I have a link, which links to domain.com , when a person clicks, I want it to do an ajax call to counter.php and post 2 variables to it, so it can add 1 to the views for that link.
I have a link:
Link Title
How would I do this with jquery?
With reference to the following link: http://docs.python.org/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe
I wanted to know if the following:
(x, y) = (y, x)
will be guaranteed atomic in cPython. (x and y are both python variables)
The questions are in bold, for those that cannot be bothered reading a question in depth.
This is a followup to this question. It is to do with the initialization semantics of static variables in functions. Static variables should be initialized once, and their internal state might be altered later - as I (currently) do in the linked question. However, the code in question does not require the feature to change the state of the variable later.
Let me clarrify my position, since I don't require the string object's internal state to change. The code is for a trait class for meta programming, and as such would would benifit from a const char * const ptr -- thus Ideally a local cost static const variable is needed. My educated guess is that in this case the string in question will be optimally placed in memory by the link-loader, and that the code is more secure and maps to the intended semantics.
This leads to the semantics of such a variable "The C++ Programming language Third Edition -- Stroustrup" does not have anything (that I could find) to say about this matter. All that is said is that the variable is initialized once when the flow of control of the thread first reaches the code. This leads me to ponder if the following code would be sensible, and if not what are the intended semantics ?.
#include <iostream>
const char * const GetString(const char * x_in)
{
static const char * const x = x_in;
return x;
}
int main()
{
const char * const temp = GetString("yahoo");
std::cout << temp << std::endl;
const char * const temp2 = GetString("yahoo2");
std::cout << temp2 << std::endl;
}
The following compiles on GCC and prints "yahoo" twice. Which is what I want -- However it might not be standards compliant (which is why I post this question). It might be more elegant to have two functions, "SetString" and "String" where the latter forwards to the first. If it is standards compliant does someone know of a templates implementation in boost (or elsewhere) ?
Hello All,
I have a long string arrays, which looks like that
var callinfo_data=new Array(
"1300 135 604#<b>Monday - Friday: 9:00 a.m. to 5:30 p.m. AEST</b>", //Australia
..
"0844000040#<b>lunedì-venerdì ore 10:00 - 17:00 CET</b>", //Switzerland (it)
"212 356 9707#<b>Hafta içi her gün: 10:00 - 18:00</b>", //Turkey
"08451610009#<b>Monday - Friday: 9:00 a.m. to 6:30 p.m. GMT</b>", //UK
"866 486 6866#<b>Monday - Friday: 7:00 a.m. to 11:00 p.m. EST</b><br />Saturday: 9:00 a.m. to 8:00 p.m. EST", //USA
"+31208501004#<b>Monday - Friday: 9:00 a.m. to 7:30 p.m. GMT+1</b>", //other countries
" # ");
As you see, it contact Phone number and open time. I can use split to separet them into
info=callinfo_data[n].split("#");
two sections,
And then i can represent them in HTML like
"<div id ='phoneNumber'>"+info[0]+"</div><div id='openTime'>"+info[1]+"</div>"
But my display phone number function will read the cookie variables, and then select the right contact info to display.
Like,
phone=callinfo_data[2].split("#");
if (locale == 'UK') details = phone[0]+ build_dropdown(locale);
else if (locale == 'fr') details = 'French Contact Details<br>'+build_dropdown(locale);
else if (locale == 'be') details = 'Belgian Contact Details<br>'+ build_dropdown(locale);
else details = 'Unknown Contact Detail';
writeContactInfo(details);
My questions are how I can build a function to load phone number and time based on my cookie variables, UK in a smart way.
I can hard code everything, but i think it is too silly.
I have to write a long code like:
phone1= allinfo_data[0].split("#");
phone1= allinfo_data[1].split("#");
...
etc
Second questions, how can I load this long arrays into easy access multi arrays?
Thank you
Regards,
Qing
I need to get access to some server variables like APPL_PHYSICAL_PATH from the the Global.asa file. I can do this on any page of my site using the Request object as follows...
Request.ServerVariables("APPL_PHYSICAL_PATH")
But I don't seem to have access to the Request object within the Global.asa file. Is there an equivalent call I can do here with the Server object?
If host my WCF services in IIS7 or WPAS, is it possible to load up two or more services into the same AppDomain so that they can share static variables?
1) Refcounted pointers need stack variables to have constructors / destructors called at predictable places.
2) Objective-C, afaik, does not support the above.
3) The cocoa libraries are bound in Objective-C, not C++.
Thus, my question: is there a easy way to use the Cocoa libraries, yet still have most of my app in C++ (and thus use my refcounted pointers)?
Thanks!
(iPhone in the title since this is mainly targeted at the iPhone)
I have a piece of code where I can call destructor multiple times and access member functions even the destructor was called with member variables' values preserved. I was still able to access member functions after I called delete but the member variables were nullified (all to 0). And I can't double delete. Please kindly explain this. Thanks.
#include <iostream>
using namespace std;
template <typename T>
void destroy(T* ptr)
{
ptr->~T();
}
class Testing
{
public:
Testing() : test(20)
{
}
~Testing()
{
printf("Testing is being killed!\n");
}
int getTest() const
{
return test;
}
private:
int test;
};
int main()
{
Testing *t = new Testing();
cout << "t->getTest() = " << t->getTest() << endl;
destroy(t);
cout << "t->getTest() = " << t->getTest() << endl;
t->~Testing();
cout << "t->getTest() = " << t->getTest() << endl;
delete t;
cout << "t->getTest() = " << t->getTest() << endl;
destroy(t);
cout << "t->getTest() = " << t->getTest() << endl;
t->~Testing();
cout << "t->getTest() = " << t->getTest() << endl;
//delete t; // <======== Don't do it! Double free/delete!
cout << "t->getTest() = " << t->getTest() << endl;
return 0;
}
I just figured out that all code completion for Eclipse is stored in plain files located here (example):
.\eclipse\plugins\org.eclipse.php.core_2.1.1.v20090921-1100\Resources\language
I tried adding global variables like $_POST, $_GET, $_SERVER to the end of basic.php but without any luck (did try to restart Eclipse).
Is there a way to create compatible files for the needs of "smooth integration" of (ie.)CodeIgniter framework by adding or changing files located here and how would it be done?
I am writing a module and I need to retrieve values set in a form_submit function from a page handler function. The reason is that I am rendering results of a form submit on the same page as the page handler.
I have this working, but I am using global variables, which I don't like. I'd like to be able to use the $form_state['storage'] for this, but can't since I don't have access to the $form_state variable from the page handler.
Any suggestions?
Hi,
I would select multiple DOM elements using a typical code such as this:
$('#ele1, #ele2, #ele3').click(function () {});
If I have variables of each DOM element, e.g.
var domEle1 = $('#ele1');
var domEle2 = $('#ele2');
var domEle3 = $('#ele3');
How can I select them all at once? Instead of individually...
domEle1.click(function () {});
Thanks!
I have a function named Msg that's imported from a dll named tier0.dll. I can DllImport this just fine, but the command only works when the dll is attached to another process which can complete the Msg command. Using CreateRemoteThread, it is possible that I could call Msg using C# while still letting it have access to the variables of the attached process it needs to complete the command? Thanks!
I am trying to use the load method of FileReference object to load the data and use it to display a thumbnail of the selected image.
However, after calling fr.load(), fr.data remains null.
I'm using Flex Builder 3.0.2 on Windows 7 with Flex SDK 3.4 and Flash Player 10 Debug. If I evaluate fr.load() in Eclipse's watch variables list, I get an error reading "No such variable: load."
Anyone know why this is happening?
I have to build a string like this
{ name: "john", url: "www.dkd.com", email: "[email protected]" }
where john, www.dkd.com and [email protected] are to be supplied by variables
I tried to do the following
s1 = "{'name:' {0},'url:' {1},'emailid:' {2}}"
s1.format("john","www.dkd.com","[email protected]")
I am getting the following error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: "'name"
Dont able to understand what I am doing wrong
I have a VS.NET 2008 project. Is it possible to check for classes that are not used anywere in the project? With FXcop I can find unused variables and unused code, but not unused classes.