Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

As a bit of speculation, was the assignment by any chance to raise the value to any power, not just squaring? That would explain the multi-threading, as the solution could involve spawning threads to break the problem down by halves. If this is the case, the general solution would involve something like this:

main thread:
    get n to square as an int
    get expt as an int
    Integer result = 0
    spawn a pow thread with (n, expt, result) as its arguments


pow thread (n, expt, rsult):
    synchronized (result):
        if expt is 0:
            result += 1
        else if expt is 1:
            result += n
        else if expt is even:
            spawn two pow threads (n, (expt / 2))
            result = result * result
        else:
            spawn a pow thread (n, (expt - 1))
            result = n * result

This is just a quick sketch; I haven't tried it out. But it should at least give you a place to start.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I realize that we seem to be dragging our feet, but the thing is, we are trying to avoid the many people who are trying to get free homework solutions. We get such things all too often, and as a result, we generally don't geive direct solutions, only advice.

In this case, there are a few things that stand out. First, it is hard to see where synchronized would come up in this, since there aren't any shared values anywhere. I realize you are trying to understand thread synchronization better, but this example doesn't seem to need it.

Second, the way you currently have things, the first thread is completing before the second thread is begun (indeed, given that it is just a single assignment, it probably completes before you .join it), which, as I understand it, has the effect that the instance variable is no longer in scope even if you access it from the thread object. Any corrections on this would be appreciated, BTW.

Third, as JamesCherill pointed out, you want to use e.printStackTrace() rather than e.getStackTrace() on line 29, in order to see the results of the exception, if one is raised. As it is, it fetches the stack trace but does nothing with it.

If this is an assignment, could you please post the exact wording of the project? That will help us get an idea of what you need. Ordinarily, we wouldn't ask for that, but the program requirements aren't very clear as to why, …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I am afraid you will wait indefinitely if you expect us to do the work for you. While we are here to help you learn, doing your work for you doesn't actually accomplish that. As a matter of policy for both Daniweb in general and most members in particular, we do not provide homework solutions whole cloth. We will help you solve problems, and explain why things may not be working as you want them to, but we won't write your code for you.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The difference is that when you were creating ob in Checking, were were creating an object in each thread, which meant that they weren't shared between the different threads - each thread was synchronizing a different object. You need to have a shared object to synchronize on if you are trying to provide mutual exclusion.

By constructing the single object in main(), and more importantly, passing that single object to all three threads, all three threads share the object. That is what the synchronized block is for - for controlling access to a shared resource. If you aren't sharing the resource, then synchronized will have no effect.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I am no expert at Java threading, but I believe the main issue is that you aren't synchronizing on a single object, but rather you have three separate objects of the same type, which happen to be synchronized, but not with each other. You would need a single object which is synchronized in all three threads in order to control the order in which the threads interleave.

import java.lang.Runnable;

class Race1{

    public void show(String s){ 

        try{

            System.out.print("["+s);
            Thread.sleep(1000);
        }catch(InterruptedException e){

            e.printStackTrace();
        }
        System.out.println("]");

    }
}
class Checking implements Runnable{

    Race1 ob;
    String s;
    public Checking(String s, Race1 ob){
        this.s = s;
        this.ob = ob;
    }
    public void run(){

        synchronized(ob){
            ob.show(s);
        }
    }
}

public class RaceCondition1{

    public static void main(String args[]){
        Race1 ob = new Race1();

        Thread t1=new Thread(new Checking("Hello", ob));
        Thread t2=new Thread(new Checking("World", ob));
        Thread t3=new Thread(new Checking("Complete", ob));
        t1.start();
        t2.start();
        t3.start();
        try{

            t1.join();
            t2.join();
            t3.join();
        }catch(InterruptedException e){

            e.printStackTrace();
        }
    }
}
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

While Deceptikon's answer is excellent, I would want to ask if you understood what an array really is, in the assembly language you are using. The algorithm won't help you if you don't know how to declare an array in the first place.

Which processor are you targeting, and what assembler are you using? Those are always the place to start in this forum, because every assembler is different in how it does some things, and ones for different processors can be very different from each other.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The first thing I would recommend in starting out with Python is finding a good Integrated Development Environment, oe IDE; while IDLE, the one that comes with Python, is passable, it is not really new-user friendly and takes a bit of getting used to. Unfortunately, 'good' is very subjective when it comes to IDEs, so you might find yourself trying a few before you come across the best fit. This thread and this one discuss the matter at length, without really giving a solid answer, for example. My personal choices are PyCharm (if you are willing to shell out for it) and Eric (which is free), but they might be a bit overwhelming to a novice. If you are planning to stick with Python 2 - not recommended, but many do - then Dr Python is excellent for novices. Still, you need to try a few out to get the one you are comfortbale with.

So why is the IDE so important, when all you really need is Notepad and an open shell window? Convenience, primarily. A good Python IDE will have both an editing window and an interpreter window in plain sight, making it easy to use the Python listener (the interactive interpreter) to test things in, while still having access to the program you are writing. Also, a good IDE makes it easier to work with more than one source module, when you get to that point in …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I am currently making out the plans for the milestones for the rest of this year in my long-term projects (Thelema, Assiah, and Alfheim). I was hoping that someone would be able to review these plans and help me determine which are feasible in the next four months.

The overall goal, which I project to take at least until the end of next year, is to develop a rudimentary compiler and REPL for my language project, Thelema. I am currently focusing on the lower-level toolchain which will support the language, which will consist of an assembler, Assiah, and a library for manipulating and linking ELF format object files, Alfheim. All the preliminary code is to be in R6RS Scheme; later iterations will be self-hosting in a combination of Assiah and Thelema, but that is probably at least two years away.

At this time, my milestone plans are as follows, the notes in italics are partially started already:

Development Milestones for Thelema Project for Sept-Dec 2014
Assiah - develop a simple data table format for representing x86 instructions
Assiah - Begin data entry of x86 instructions
Assiah - design basic data structures needed to represent x86 instruction as a stream of opcodes
Assiah - design pattern-matching macros and functions for transforming a line code into an opcode stream representation
Assiah - review instruction data format for completeness and match it to the opcode format
Assiah - complete data entry of x86 instructions

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What have you tried so far, and what problems are you having with it? Please include at least enough of your source code to explain any difficulties you are experiencing.

Keep in mind the following DaniWeb community rule:

Do provide evidence of having done some work yourself if posting questions from school or work assignments

And be aware that we will not do your homework for you.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

First off, which version of Dev-C++ do you have? The original Bloodshed Dev-C++ has not been maintained for nearly ten years, and is badly out of date. We recommend the Orwell fork as the most up to date version available.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

That, plus you may want to have a little patience. Fora like this aren't IM or Twitter; they are more like email, where you might have to wait hours or even days before a response. OTOH, it also means that you aren't limited to 140 characters, so posts can be a good deal longer than on more rapid forms of communication. You should learn to take advantage of this, and stop posting one-line messages here.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Hmmn, I gather from the downvote that I went a bit too far in helping this particular person. Either that, or the fact that I did a favor for a help vampire like the OP offended someone. In either case, I do apologize, and will be more circumspect in the future.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

My optimism in others' good intentions is battling with my pessimism about help vampires (which the OP is quickly proving herself to be). Still, in the hope of giving her at least a leg up, I'll try to give what advice I may.

a) Explain how the computer passes control to a subroutine (or procedure) and returns it to the main routine once the task has been completed.

The basic mechanism, inside the compiled code, consists of saving the address of the location in memory just past where the function call is made, and jumping to the function. When the function ends, it retrieves the address and jumps back to the location it was called from. There are a few different ways this can be done, such as linkage registers and function windows, but the usual method is to save the return address on the hardware stack. There! That's enough information to get you started, but not by any means a full explanation.

b) Explain, giving a relevant example, how a subroutine (or procedure) can be used several times in the same program, each time accepting different data values and passing back different results.

Hint: All of the standard C and C++ I/O stream operations are actually library functions. Have you ever used printf() or cout << more than once in a program?

c) ABS and INT are two numeric data handling functions found in many languages. Explain what EACH of the following …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

tapananand: Actually, that isn't true. Lists can be unpacked automatically just as tuples can. For example:

a, b, c = ['1', '2', '3']

will populate the three variables correctly. The real issue at hand is passing the command-line arguments in the first place.

VKG147: I get the impression you are unfamiliar with working in the shell, which isn't uncommon for new programmers. If you have only worked in Windows or MacOS, and haven't done any programming before, you probably have never used or even seen a shell window (also called a command line or -in the Windows world - a DOS prompt) before. I recommend closing the IDLE window and trying the following just to familiarize yourself with what is actually going on here.

I am going to assume you are using Windows 7 here; if you are using Windows 8, or an older version of Windows such as XP, you may have to adjust this accordingly.

To start the Power Shell (the modern Windows equivalent of a DOS prompt), go to the Start menu and in the programs bar enter 'PowerShell'. This should bring up at least one option for running the powershell in the Programs dialog. If that doesn't work, go to Accessories and you should find it.

Once you start Powershell, you should get a window with white text on a blue background. It will have a prompt saying the directory you are in, something like,

C:\Users\VKG147\Documents>

The flashing cursor at the end …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

sigh Yes, that is true. Looking back on the thread, I have to say I let my enthusiasm for the subject get the better of me. I should have laid out more clearly how impractical the idea was, especially when the OP was considering implementing more than one source language.

In the end, JWenting ans Stultuske are right: the OP is way over his head with this. Even a scaled down toy language would be hard if not impossible to complete in the time given, especially if you don't have a clear idea already of how to do it. As I said earlier, even a two-semester course sequence rarely gets past the most basic compiler techniques, and trying to write a full compiler - by which I mean one that implement more than 80% of a language's definition, never mind a commercial-grade implementation - without the necessary background is setting yourself up for failure.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Good to meet you, though I should point out that such introductions really ought to be posted to the 'Community Introductions' forum, rather than one of the language fora. Since you are new, I don't think anyone will fault you for it, but it is something to be aware of if you are going to any other message boards in the future.

For now, please read the forum rules and get to know what's going on. If you haven't any specific questions right now, you might want to lurk for a bit, and try the social fora as well. Again, good to have you on board.

ddanbe commented: Very friendly! +15
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

How are you running the script, and what command line arguments are you invoking the script with? If you are running the script from the command line, you would have arguments as part of the invocation, like so:

 python test_argv.py arg1 arg2 arg3

OTOH, if you are using an IDE such as IDLE, Eric, PyCharm, Dr Python, etc., you should have a menu option for entering the script arguments somewhere. Just where it is and what it is called will depend on the editor in question.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

jwenting: I agree that it certainly looks like that, and for all I know you may be right (the part suggesting it compile more than one language is particularly damning), but I prefer to give the benefit of the doubt for cases like this. I'd rather hear from the OP to see what they have to say for themselves before jumping to that conclusion.

Even if you are right, I'd rather treat it as an opportunity to teach something useful to someone rather than simply smack them down for their ignorance. Seeing how the OP hasn't replied to anything said so far, it is likely a moot point anyway; I am well aware, just as you are, that the majority of first-time posters never return. That doesn't mean we shouldn't make an effort to help those who eventually do.

(I'll also admit a bit of personal interest in this anyway, as language design and translation is one of my main interests in the field. I have a very ambitious ongoing project of my own in this area, though I have deliberately kept the core language minimal precisely to make it feasible to complete in a few years' time. That, plus the choice of Lisp dialects for both the implementation language (R6RS Scheme) and the source language (Thelema) - and even the target language (my Assiah x86 assembler) - mean I have some real shot at finishing it in a reasonable time frame. Even so, a 'reasonable …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Could you please give more details about what you need? First off, I expect most of the people here are unfamiliar with the game you refer to, and we'd need to know what operating system you are running on (Windows, Linux, MacOS, etc.) and what compiler you are using.

I've done searches on the terms 'raccoon dog game' and 'neoguri game' but came up with nothing definitive, so I don't know what game you are referring to.

(For those unfamiliar with the term 'raccoon dog', it is a species of early canids which can be found throughout central and north eastern Asia (and has been transplanted to Eastern Europe as well), which vaguely resembles a North American raccoon. In the US it is better known by the Japanese name, 'tanuki', though that strictly speaking only refers to the sub-species found on the islands of Honshu and Hokkaido. In Korean, if I understand correctly, the name is 'neoguri', while the Chinese and Russian names are 'háozi' and 'magnut', respectively.)

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

That's an excellent point; we may have been reading more into the OP's words than was intended.

m4mukulgarg: Is your plan to make an existing compiler accessible through a web page (a la IDEOne), or is developing a new compiler from scratch your main goal? While neither is a small project, they are orders of magnitude apart in difficulty.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I hate to say it, but Taywin is right. Your typical Compiler Development course runs a full semester and only gets as far as implementing the most basic language functionality (assignment, simple expressions, conditionals, and maybe definite loops), while targetting a simplified hardware emulator (that's about where the course I took left off, in fact; you can see the final version of my 'baby' Algol compiler in my GitHub repo). A graduate followup course would be usually be needed just have time to implement indefinite loops and function calls, with POD data structures as an extra credit option most won't get to. I don't want to discourage you, but even a toy compiler is a major undertaking.

I might add that if you really intend to press on with this, you'll want to know at least two things first: the basics of Finite State Automata, as they are used in the lexical analysis phase of compiling, and how to use a version control system such as Subversion, Mercurial, Git, or Bazaar, as you will code yourself into a corner at least once during the project.

Let me be as blunt as I can about this last point: if you don't have any account on a repository such as Sourceforge, Heroku, or GitHub, get one right away and use it. Writing any non-trivial software without off-site revision control is just plain …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

First off, as JamesCherrill states, there is a vast amount of tutorials and other resources covering the subject of compiler development around, and while much of it is of questionable value, it should be possible to find something you can use to begin your work. This forum reference, while dated, is a good place to start. Also, the OS-Dev Wiki group is currently getting ready to fork off a compiler dev wiki, and while it is only in the nascent stages, the pages they do have up may prove helpful (if perhaps a bit discouraging). Two (very different) resources I recommend are Crenshaw's "Let's Build a Compiler" series (which never did get completed, but still gives a good starting point), and Ghuloum's "An Incremental Approach to Compiler Construction", which gives a very detailed explanation of how to write a Scheme compiler (in Scheme, but it can be applied to any implementation language, as demonstrated here).

That having been said, you are probably not really aware of the scope of the project you are preparing to undertake. Compiler design is demanding of both programming skill and theoretical knowledge, and if you haven't taken a formal course on the subject (or at least an online course, you are likely to miss important factors on how to do it most effectively. At the very least, you should read at least one textbook on the subject, preferably cover to cover. …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Actually, if the OP is using 5.7.1, then presumably their talking about the Orwell fork, which is maintained and up to date (with gcc 4.8.1).

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I'm not sure what to suggest, then, other than to try executing the ALTER TABLE command again. Sorry.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What I mean is, it is possible you reversed the two tables, with the result that it related Branch_and_Branch_Code to the field in Animal_Cruelty rather than the way you wanted it, like so:

ALTER TABLE APP.Branch_and_Branch_Code
ADD CONSTRAINT animal_cruelty_branch_fk
FOREIGN KEY branch_codes
REFERENCES Animal_Cruelty (branch_codes)

It would be an easy mistake to make, if you weren't clear on the syntax. I seem to recall doing something like that once when I was first learning SQL, in fact.

If you look under the Foreign Keys section for Branch_and_Branch_Code, does anything show up?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

If you need one other suggestion which would cover both computer science and software engineering, and involves an actual open research problem, you might look into the question of compiling and linking generics (such as C++ templates) in an object format. It is a difficult issue because instantiating a generic involves generating new code based on the generic function or class at compile time - the compiler would have to be able to extract the generic from the object file without necessarily having the source code available in its original form. The advantages would be significant, however, as it would allow library writers to remove the template implementations from the headers and keep them in the source files, where they belong.

I would recommend looking at the ELF format to begin with, as it is a completely open standard and would be easier to extend, IMAO. If you succeed in this, consider doing the same with the PE format (convincing Microsoft to adopt your extensions is left as an exercise for the reader).

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, I am official puzzled. Have you looked to make sure it wasn't attached to Branch_and_Branch_Code instead of Animal_Cruelty?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You probably won't be surprised to find out that this has been discussed here at length before, nor that no real conclusions were ever reached. The appeal and value of a development environment is a highly ideosyncratic thing, and what works for one programmer often doesn't suit another.

For what it is worth, I usually just stick to GNU Emacs, though Eric is also quite good in my opinion, if a bit tricky to get installed.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

If you have a question like this, please start a new thread rather than resurrecting a long-dead one like this.

As for why printf() and scanf() aren't used in Java very often, well, to begin with, ther is no scanf() method in the standard Java library. Rather, the Scanner class is used for the same purpose, which not only has fewer issues than the C style scanf(), but gives better control of the input.

As for printf(), it was introduced into the language fairly late on, and is usually only used for fairly complex string formatting; most of the things which you would use printf() for in C are handled better by the overloaded forms of print() and println(). Even with complex formatting, it is more common to use the String.format() mathod to do the string interpolation, then display the generated string with print().

I should add that even in C, scanf() has fallen into disuse for most modern programming, as it has a number of pitfalls to it. Today, most experienced programmers use fgets() to get the input and then parse the string using sscanf(), which is more secure and less prone to buffer overruns and newline issues.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The purpose of the d'tor is not to free the object itself; that is done by delete, which should only be applied to dynamically allocated memory (that is, values allocated using new) in any case. Also, freeing the object does not overwrite the object; the memory itself is is still unchanged, at least for the time being, and in order to ensure that a pointer variable no longer points at that now-invalid memory location, you need to assign a new value (such as 0) to it.

The purpose of the destructor is to clean up the elements of the objects that are not automatically released when the object itself is freed: deleteing any dynamically allocated instance values, closing files, releasing semaphores, and the like.

As sepp2k said, the d'tor should almost never be called directly. However, if a class has a d'tor, it is called automatically when an object of the class is freed, whether by means of delete or when a local goes out of scope.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

And did the constraint show up under Foreign Keys? It won't be listed with the field itself.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

fdis: Help you with what, learning not to hijack three-month-old threads without even asking a question? Gladly. If, on the other hand, you want help with a programming problem, you will need to start a new thread of your own, explain what you need help with in clear and standard English without using unnecessary abbreviations or textspeak, and demonstrate that you have made a good-faith effort to solve the problem on your own. Can you do that much?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I would prompt you to consider a shorter if somewhat more complex solution, one which works by sorting the three values. While a full sorting function is a bit heavyweight for this purpose, consider using three temporary values, min, mid, and max, and then testing the three input values in such a way as to put the results into the three temporary values as appropriate:

sort (a, b, c):
    if a <= b
        min = a
        mid = b
    else
        min = b
        mid = a

    if mid <= c
        max = c
    else
        max = mid
        if ...
// I'll leave the rest to you...

you would then simply print out min, mid, and max.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

It would be impossible to say without more information, as the term Mealy Machine refers to a class of Finite State Automata, not a specific FSA. You would have to know the state transitions for the specific machine in order to determine what the output would be.

iqra aslam commented: can u please draw a mealy machine and pass the input from it +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Just to make it clear that it is in fact appearing in Netbeans 8.0, this screenshot shows it as it should appear on your screen.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

This is where you will find the information about the foreign key constraint after it is created.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Just to make sure we're on the same page: you went to the 'Foreign Keys' section for the 'Animal_Cruelty' table, selected 'Execute Command', and entered the following code (or something like it):

ALTER TABLE APP.Animal_Cruelty
ADD CONSTRAINT animal_cruelty_branch_fk
FOREIGN KEY branch_codes
REFERENCES Branch_and_Branch_Code (branch_codes)

and executed it?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

That's very strange. What version of Netbeans are you using? I just installed the newest version (8.0), which does indeed have Boolean, but if you have an older version it may not support it yet. I'd be surprised if that were the case, but it could be the source of the problem.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Simple:

func();

If you have ever used printf() or any other standard library calls, you have made a function call. These functions are not part of the language; they are part of the library, which is something completely different. Just because they are standard does not mean they are part of the core language.

Similarly, if you have written a C program at all, you know how to write a new function. The main() function may be a special case, but the syntax is the same as it is for any other function:

return_type func()
{
    /* function body */
    return return_value;
}

If there is no return value, the type would be void, and you would omit the return statement. If you need to pass parameters to the function, you would declare them in the parameter list:

double foo(int bar, double baz)
{
    return bar / baz;
}

Many new programmers get confused by this, which is natural, but the answers are quite simple, really.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

There was a time when mad skillz was sufficient. In the 1970s, just claiming to be an assembly programmer would get you a high-paying job; in the mid-1980s, a C programmer with any experience might as well own the Philosopher's Stone; in 1995, you could walk into a company with an HTML book under one arm and get hired. But for the past fifteen years, most employers are looking for a good deal more than just the ability to copy code out of a book or off of the web.

C++ is an excellent starting place for a career, but it is not in and of itself enough, unless you are prepared to slog through ten years of small contracts from freelancer.com to earn enough experience to qualify for a entry-level corporate position - and even that is unlikely to work, as almost all companies today require a college degree for any position higher than janitor. At minimum, you'll need some sort of certification, and there are none specifically for C++ that are universally accepted.

Knowing anough about basic data structures and algorithms is just the tip of the iceberg. You need to know about the common tools (version control, various IDEs - you'll often be different environments in different jobs - the command-line toolchains, wikis, build tools such as Make, Ant, or Maven, and so on), common methodologies, common libraries, and common operating system APIs. You'll need to know how to work with programs written in other …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Well, I don't think going from a long to a short will help.

BTW, I suggest you look at where the comment is in relation to the modulo expression.

    b=a/2;                /*Formula for Decimal
    c=a%2;                  to Binary*/

As you have it here, the second line is getting commented out entirely.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, now that I can see what you are talking about, I can tell you that there is in fact a BOOLEAN option in the type pulldown, it just is off the lower edge of the menu. If you scroll down in the pulldown menu itself, you'll find it at the bottom. It is remarkably easy to miss, so don't fault yourself for it.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, I've finally got Netbeans running and connecting to a local (embedded) database that I created manually with IJ, so I've got a handle on what you are talking about. As it happens, there is a way to add a foreign key to a table in Netbeans, but it isn't quite intuitive.

What you need to do is create the attribute (that is, the field) you are going to use as a foreign key in the table you are relating, making sure it is the same type as the key of the table it relates to. Then, after you have saved the table, you go to the table's etry under the database, and open the tree node so that it shows the indexes and foreign keys. Right click on foreign keys and select Execute Command. You then would code an ALTER TABLE statement in the Command window to add the FK constraint.

For example, in the database I created, I have a table State with a NUMERIC primary key id, and a twoCHAR field state for the abbreviations of the US states. In another table, Address, I have a NUMERIC key state which I will set a foreign key constraint on:

ALTER TABLE APP.Address
ADD CONSTRAINT address_state_fk
FOREIGN KEY (state) 
REFERENCES State (id)

I then hit 'SQL Execute' to add the constraint.

There may be any easier way to do this, but this way does work.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Nicolae_1: First off, this is an English language forum, and giving an answer in another language (especially one poorly known outside of its home country such as Romanian) is extremely rude and unlikely to be helpful. Even if the OP were a native speaker - which is not the case in this instance - it is a problem for anyone else who isn't and is trying to read the response. Please write in English as best you can; we are patient with non-English speakers, up to a point at least, so long as you use actual full English words and sentences rather than text-speak.

Second, in the future, pelase do not simply hand over completed code to the querents; it amounts to helping them cheat, and is unhelpful to either them or yourself. The forum is here to give advice and assistance, not solve homework problems for free. I know you meant well, and you aren't the first to make this mistake (I did a number of times myself, when I got frustrated with the process of helping), but it really isn't a good policy to answer other posters' questions so directly.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

It shouldn't be too much for a lambda expression, so long as you recall a) that you can use a boolean expression such as in in a regular statement, and b) the string library includes a handy set of constant strings with the sets of letters, digits, and whitespace. All you should need to do is import string and apply in to your string's first character, and string.digits, and you should be able to use that as the lambda expression.

(OK, I'm sandbagging on this, as I've tested it and it works fine in Python 3.4, but I feel it is better to lead you to the code than simply give it to you. In this case, the explanation should be more than adequate for you to get the appropriate code worked out.)

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Also, which compiler are you using? If it is Turbo C, then you are limited to a long of 16 bits, which gives an unsigned maximum value of 65535.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I the absence of other information, I would recommend trying the -I option with the path to the header files in question.

g++ -Ipath\to\include main.cpp program1.cpp -o program1.exe

However, if they are in the path already that shouldn't be necessary, so there may be more to this than that.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

That doesn't make sense - it should be there, and called BIT. I'll look into it myself and find out what is going on.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Well, technically, every data type is bit data, though not in any useful sense; I think you are confusing the terms 'bit' and 'byte'. No, what I mean is, BIT is the name of the data type in the tables.

How are you building the tables? Are you writing SQL CREATE commands directly, or using a tool for table generation? I'll show you how to create tables in SQL, but if you are generating them automatically, it may not be quite the same. I would recommend generating the tables programmatically anyway, as it gives you better control of the database, but I know it is a lot of work as well.

Clif40RD commented: Helloooo anybody there??????!!!!!! +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Ah, yes, in SQL (not just Derby), there is a type BIT which is usually used for Boolean values.