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

Sorry about that... anyway, it isn't entirely clear what you are asking, here:

what should I pass while executing C program...below is my code

Could you elaborate on this, and maybe give us a bit more detail on what the program is meant to do?

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

Before trying to understand what you need help with, I want to make a comment about the code itself. I will try to address your question - to the extent that you asked one at all - in a follow-up post, but I wanted to get this out of the way. Feel free to skip this if you don't care about writing good code.

This line shouldn't compile on any compiler that isn't older than I am guessing you are:

main() {

While the original K&R C allowed for default function return values, since the late 1980s the C standard has required a return type declaration. In the case of main() that type should always - always, regardless of what certain older compilers allowed - be int.

Some older compilers allowed default return types up to the late 1990s (usually with some sort of warning), in order to ease the updating of older code, but most newer compilers will reject this code. I am guessing that you are using Turbo C, however, in which case my advice is DON'T.

Aside from the fact that Turbo C is 30 years old, and does not support any of the changes to the language made since 1989, it also has the glaring fault in that it allows main() to be declared as type void. This was based on a misunderstanding of the proposed standard which was still being debated at the time Turbo C 1.0 came out, and later versions of the …

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

Fair enough. I've been in a similar situation more than once myself (both for VB6, and for other old languages and systems), so I understand how that goes. Maintaining legacy apps is its own weird little world.

rproffitt commented: Stay weird, get paid. +15
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You're missing the important point: no one on this forum is going to do it for you.

This forum is for people who want help with a problem when writing a program. The forum for people who want someone else to do some programming for them is the Hiring forum, but that generally will cost you money.

So, if you aren't actually doing the programming yourself, you can go over to the Hiring forum and offer to pay someone to do it, but that's not what the Programming forums are for.

I will also add that if this is a homework problem, then you shouldn't even bother going there - the forum rules specifically forbid asking or paying someone to do an assignment for you (you can ask for help, but not for a hand-out). I don't think that this is the case given what you are asking for, but it is better to add that now to make the point clear.

I realize that you are probably new to fora like Daniweb, so you probably deserve some leeway on all this; besides, I am not a moderator myself, so I can't do anything except give advice. But now that I've explained that you are going about things the wrong way, I hope you will be willing to listen to what I have said.

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

That modification would be a a good deal more than 'a little bit'.

You seem to have misunderstood what this forum is for: it's for people who are trying to solve a programming problem themselves, and need a bit of help. In other words, it is about programmer helping each other.

This doesn't include giving free work to someone who has no interest in doing any programming on their own, or who are simply being too lazy to do their own work. If you aren't doing any programming yourself, or expect someone else to do your programming for you out of the goodness of their hearts, you are in the wrong place.

If you want to hire someone, we have a separate message board under the Community Center for that, but don't expect anyone to do this for free just because you ask them to.

You might be able to find someone who is playing this game themselves, and would do it out of their own interest in the project, but the odds of that are pretty low. You might find someone who will take it on just for the challenge of it, or for cred among other FOSS developers, but that's even less likely. I doubt anyone else would work on it without some kind of motivation, and for someone with no stake in something, that motivation usually involves money.

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

As DDanbe said, we'd need to know what 'error 106' meant here. However, I think we can elaborate on that to make something of a teachable moment.

First, before I address that, I will point out to you that when you post code samples here, you need to indent every line of the code by at least four spaces, or the formatting won't be preserved. I suggest reading the docs for the Daniweb version of Markdown for a more detailed explanation.

With that out of the way, let's get on with the show.

While it isn't entirely clear without more context, it is safe to guess that the '106 error' is a compiler error message, that is, a report of a problem in the code that indicates a fatal error - something that prevents the compiler from finishing the compilation.

It also could be a compiler warning, which indicates something that could be a mistake, but isn't serious enough to be a showstopper - something which the compiler isn't sure is a problem, but thinks you should look into. Or, since you didn't say when it comes up, it could even be an error message that you get after it is compiled, when the program is running.

But the safe bet is that it is a compiler error message.

This means we'd need to know which compiler you are using. Different compilers - even for the same language - will have different error and warning messages and codes, …

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

This problem is most often given under the name "Fizzbuzz", being based on an old children's math game of that name, but as Rev Jim said, it is a problem that a lot of professors use as a check on how well students understand the material, as well as being a favorite of lazy interviewers who don't realize that anyone who has been programming for a few years will have seen it before (to be fair, it wasn't a bad choice fifteen years ago, but today it has been done to death).

A quick web search on the first line of the problem statement should have found literally thousands of relevant hits, even without the usual name attached, so the fact that the are asking this at all indicates a lack of effort. Note that the name 'Fizzbuzz' comes up in one the first

Presumably, changing the words from "fizz" => "FOO", "buzz" => "BAR", and "fizzbuzz" => "BAZ" was to throw off a simple search (as 'foo', 'bar', and 'baz' are standard metasyntactic variables, and searches on them would get a lot of other things instead of the Fizzbuzz problem), as well as keep you from using one of the more common approaches to the problem (one which works for the usual problem, but doesn't scale).

Now, Fizzbuzz is indeed a deceptively tricky problem; that's the whole point. It is not one that really demands much in the way of design …

rproffitt commented: Bizarre implementations? How else to avoid being called out for plagiarism but to make the most bizarre solution? +15
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Has your course covered either while loops, or for loops, yet? It would be very unusual for a class to cover repeat...until without covering those first.

For a quick thumbnail sketch: while is pre-conditional indefinite loop, that is to say, is repeats based on a conditional test that is first tested at the start of the loop.

     a := 0;

     while a < 1 do
     begin
         readln(a);
     end;

It is basically the same as repeat...until, except that repeat...until always runs the body of the loop at least once.

By contrast, the for loop is a definite loop, meaning it repeats a fixed number of times - either counting up, or counting down.

For example, counting from 0 to 10 would be:

     for i := 0 to 10 do
     begin
         { do something here }
     end;

while counting down is

    for j := 10 downto 0 do
    begin
        { do something else here }
    end;

Note also that you can have nested loops, that is, a loop with another loop inside of it:

    For j := a DownTo 1 Do
    Begin
        For i : = 1 To j Do
        Begin
            {  do something here }
        End;
    End;

You will also notice that Pascal is case-insensitive, meaning that for, For, FOR, fOr, etc... are all the same keyword. You can use the style you want, or at least the one your professor requires, but you want to know that it can vary like this.

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

You say,

I have been programming C# for some time,

and

i recently learned about constructors and objects

Unless 'some time' is 'under an hour', these two statements are contradictory.

If you are new to C# programming, either learning it on your own or as a student in a course on the topic, we will understand, and be happy to help. However, if you try to present yourself as experienced in something when you aren't, that sets up expectations which will make it harder for us to help - we won't be able to judge what kind of explanation to give.

And if you try to pass off homework problems as something else, well, that's a Problem, as it is a direct violation of the Daniweb Forum Posting Rules, specifically this one:

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

We can forgive it once, as you are a new member who isn't clear on the rules, but please don't try it again.

rproffitt commented: +1 for putting it nicely. +15
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

@raj_30: Permit me to point you toward the Daniweb Forum Posting Rules before proceeding, as you just broke some of them. As a new member, you will be forgiven - mostly - for these mistakes, but you really don't want to make one of the regulars remind of these again.

  • Do not hijack old forum threads by posting a new question as a reply to an old one
  • Do not post the same question multiple times
  • Do provide evidence of having done some work yourself if posting questions from school or work assignments
  • Do post in full-sentence English
  • Do not write in all uppercase or use "leet", "txt" or "chatroom" speak

This last two are generally considered to also cover the practice of posting a series of fragmentary posts in the manner of a chat room or Twitter feed. As my own post demonstrates, you are not limited to 144 (or even 288) bytes of plain text, and posting sentences separately which could be part of a single post is irritating and inappropriate. Note also that you can edit posts up to 30 minutes after they have been submitted, so typos can be corrected after the fact as well (up to a point; we will forgive it if you simply didn't notice it until after that 30 minute window).

This forum is also unlike a chat room in that it can take hours or even days before someone gets around to reading and replying to …

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

Before proceeding, it should be mentioned that the header file "stdafx.h" is specific to the Windows Visual C++ compiler. Given that the professor has stated that the submitted code will be compiled using GCC under Linux, the inclusion of that header will be a showstopper for you - and one which is entirely unnecessary, as you don't use anything referenced in the header.

Now, to be fair to you, I need to note that the Visual Studio IDE will insert that into certain kinds of C++ projects automatically, on the assumption that the code is for Windows and only Windows. This is the sort of thing a novice cannot be expected to know, so it isn't your fault that you missed it.

Still, I recommend you remove it for now, and be on the lookout for it in the future.

I would recommend removing <cstdio> from the header and type implementation file as well, as it isn't actually used in either of those (yet). You probably will need it in the implementations of the functions pointed to by ItemPrinter() and PriorityPrinter(), but right now, it doesn't need to be there until you have something that actually uses the C Standard I/O library.

On a similarly pedantic and administrative note, I would recommend getting the unfilled information sections in the comments of the provided code before you go any further. It is a picayune and annoying thing, I know, but the sort of professors who give these kinds of pre-built …

Zack_9 commented: Thank you this helps alot! alot of good tips! +0
ryantroop commented: Good catch on system header. That would have been awkward :-/ +9
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

While I can't say much without more detail about the rest of your code, I am pretty sure that, as you seem to suspect, you have either missed or misunderstood part of the assignment. I may be wrong, but based on the description of the problem, it appears that the function signature should be closer to (but not quite; see further down for the full explanation):

void insertEdge(int u, int v, int w, Graph& g);

Where Graph is the second of the two struct types described in section 4 of the assignment:

An object of type Graph represents a weighted graph. It has four fields:

  1. the number of vertices in the graph,
  2. the number of edges in the graph,
  3. an array of Edge structures that holds the edges,
  4. the physical size of that array of edges.

Include a constructor Graph(nv) that yields a graph with nv vertices and no edges. The constructor must create the array of edges.

Note that the Graph type requires the Edge type to already be defined, as each Graph object is has an array of Edges as a component.

So before you do anything else, if you haven't done so already, you need to define the Edge and Graph structures. I assume you've covered structure types already, but the assignment does give a link to the previous lecture notes on struct types, as well as the expected naming and documentation conventions.

Note as well that the …

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

@Kes166 Correct me if I am wrong, but I am pretty sure that in Standard C++, array declarations must use a compile-time constant for the array size. I know that the g++ compiler will allow C99 style dynamic arrays by default, but it isn't standard C++ (unless it was added since I last checked, which could well be the case).

In any case, I seem to recall that even in C, a dynamic array size has to be a constant known at the entry point of the stack frame, meaning that you can't use something from user input unless it is passed as a function parameter. I would need to check to see if I am right however.

This means that if the OP needs to size the arrays based on user input, they need to either:

  • Allocate an over-sized array and hope that it is enough - this terrible idea was a common practice in general in the past, and remains one of the largest sources of bugs and security holes (in the form of buffer overruns). I would avoid this if you have any choice about it.
  • Use explicit dynamic memory allocation using the new and delete keywords.

    bool* occupied = new bool[rooms];    // why would you use double for marking occupied rooms?
                                                             // also, note that 'occupied' is a pointer
    
    // then later...
    delete[] occupied;

This is a lot better, but does mean that you have to watch how you use …

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

@Jose_17: You might want to consider whether your professor really wants you to do that or not, in something that is clearly meant as a lesson on how to write assembly code. You might also want to consider whether they are going to be watching fora like this one to see if someone posts their assignment in order to get someone to do it (ProTip: they are).

I recommend reading the forum Posting Rules, Terms of Service and Asking Questions Advice before proceeding here. Specifically those pertaining to asking for help on homework. This one in particular seems relevant:

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

rproffitt commented: OP didn't write this was school work. Why not learn how this is done IRL? +15
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

My first question is, how does this improve over the mail merge functionality that nearly every SMTP mail reader has had since the 1980s? Outlook has been able to do this out of the box since it came out - heck, Outlook Express could do it, for that matter, back when that was a thing.

Now, it is possible you do have a better mousetrap in mind, but if so, you have not explained how it is better. Conversely, if you are climbing this mountain because it is there, that is fine too, but the way you are speaking of it gives the impression that this is part of a larger project.

Having said that, allow me to address the question itself. I recommend forgetting about using ShellExecute(), and looking into the Office API to work with Outlook directly. You will probably want the Add-Ins API rather than the web-focused Graph REST API, though you will need to look over both to be certain.

Keep in mind that the current Office 365 version is a Software-as-a-Service package; the Office application executable is just a launcher for the cloud application, comparable to an Electron wrapper on a webapp, meaning that Outlook (and Word, Excel, and the rest) is no longer a stand-alone program at all. Older versions of Outlook worked rather differently, though the ordinary user wouldn't be able to tell the difference.

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

And the reason you are using VB 6.0 and MS Access is?

I am not saying it is wrong to do so, but it is a bit unusual, which makes me think there's more information we'd need in order to help you. The reasons for using those - and some facts about the application domain and the purpose of the project - is perhaps the main thing we need to know right now, in fact.

I will say that I suspect you are going to find the goal a difficult one, as I don't know how well VB 6.0 works with Access 2010 (I am surprised they interop at all, really, as MS had dropped support for all pre-.NET versions of Visual BASIC in 2008) and just as importantly, I am not certain that the solution you are trying to implement is the best one.

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

OK... first off, if you don't mind me asking, why did you settle on VB 6.0 and MS Access? Is there a specific need for that particular (20 year old, no longer supported) version of Visual Basic, or any reason why you couldn't use either the built-in Access VBA (depending on the version of Access - more on that in a moment), or conversely, a version - any version - of Visual Basic NET?

I ask because the reasons may have some bearing on the answers we give, and the options at your disposal.

The next question is, what version of Access are you using, and on a related note, what version of Windows is this running on? I ask this mainly because both VB 6.0 and editions of Access older than, uhm, I am not sure off hand but I think it would be 2003, might not run correctly (or at all) on version of Windows more recent than Vista, at least not directly (though you could be using an emulator or virtualizer I suppose).

The last question is, is there existing data already in the Access database, and do you have it properly backed up? I ask this because, aside from the usual concerns of disk failures and power surges and so forth, Access (especially 97 and earlier) is notoriously unstable when you are doing a lot of changes, as is typical of testing during development. I recall the problems this can cause all too keenly, …

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

@rproffitt and @rubberman: I am assuming the OP is writing this for an assembly language course, in which case the C code is simply given as a guide for hand-coding the assembly program.

@Kunyepa: How is the code misbehaving? Can you post the errors you are getting?

It would help if you could tell us the platform (presumably a MIPS simulator such as SPIM or MARS, though I guess it could be an actual MIPS processor), and what constraints your instructor has given you (e.g., the dreaded "no pseudo-instructions", which can be a serious impediment if you need to use any labels for data addressing). Are you expected to match the algorithm exactly, or is it just a guide which you can discard as long as the result is correct?

On a related note, has you instructor mentioned either a) reversing the loop conditional (e.g., using a decrementing count from x to zero rather than counting up) or b) using a jump table to index a test? Also, has the option of pre-sorting the test (i.e., writing a sorting routine to get the grade values in order, which can simplify the test at the cost of greater overhead overall - it's the kind of thing that can be slower when the data set is small, but speeds things up with a large data set) been brought up? Just a few hints.

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

I agree with JOSheaIV that this seems somewhat hinky. However, if you are in fact sincere, you would find a better forum for this matter at the OS-Dev forum, which covers issues related to this in greater detail.

However, you do not - I repeat, DO NOT - want to post this sort of help request there, especially in the "OS Development" or "OS Design and Theory" fora (that's what the "Announcements, Test Requests, & Job openings" board is for), as the posters there do not suffer fools lightly. You want to read the OS Dev Wiki before posting anything there, especially the Introduction, How to Ask Questions, Beginner Mistakes, Required Knowledge, and Getting Started pages. In particular, the section on Teamwork is relevant here:

Teamwork
The number one beginner mistake seen in the Announcements forum. They usually come in one of two forms, although they have quite a bit of overlap:

Community Projects
Don't overestimate your chances of getting people interested in your project. Even the more successful projects usually consist of one, perhaps two people actually working on the code. And that is not due to a lack of need.

Brooks' Law states that the more people on a project, the longer it takes. The only way around this is to split the project into parts that you get people working on and only on that part. …

rproffitt commented: True, a post like that could be like dipping toe in lava pool. +7
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Actually, in India and Pakistan, it is even worse that that: last I heard (as recently as last summer), the national university systems continue to mandate the use of Turbo C++ 1.5 as the standard C/C++ compiler, and professors are forbidden to use anything else for introductory C++ courses (whether they can use other languages in introductory courses wasn't clear, but aparently the scholastic exams are all based on C++, and the tests haven't been changed significantly since around 1995). All efforts to change this have been furiously resisted for decades, apparently.

At least, that is my understanding of the situation, but the issue has been discussed here and elsewhere on numerous occasions, and the consensus is that the national exam system governors see change as a bad thing, and refuse to acknowledge that anything is wrong with the curriculum.

https://www.quora.com/Why-is-Turbo-C++-still-being-used-in-Indian-Schools-and-Colleges

http://stackoverflow.com/questions/1961828/why-not-to-use-turbo-c

https://www.quora.com/Why-should-we-not-use-Turbo-C++

http://www.roseindia.net/programming/tutorials/C++Tutorials.shtml

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

What Labdabeta said is correct, but a bit skimpy, so I'll give you a bit more detail.

For the first five to ten years of programmable electronic computers, programming was done in machine code, though even that can be a bit of an overstatement - several of the first generation computers had no I/O such as we would understand it today, so entering a program would require the opcodes to be entered by means of wiring up a patch panel (think of an old-time phone operator's switchboard and you have the idea). While this was quickly supplanted by punch-card and paper-tape readers, this still didn't change the process of writing a program much.

Initially, the machine codes were written down for entry in a purely numeric format - sometimes decimal, but more often either octal or hexadecimal - but very soon it was realized that this wasn't practical, so a notation was developed for writing the opcodes as word abbreviations. This was called various names but the one that ended up sticking was 'assembly' code, from the fact that the programmer would 'assembly' the program with it. It was used for keeping track of the code while writing it; however, at the time, it was still converted to the machine opcodes by hand, then entered to a punched deck or tape for reading into the machine. Because the computers of the time were based on very unreliable technologies - vaccuum tubes, mercury delay lines, and the like - running a …

StuXYZ commented: Great summary +9
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

A better place to start might be the OSDev wiki, especially the Introduction page (particularly the section 'What Is An Operating System?'), Beginner's Mistakes, and Required Knowledge. The textbook can come after you decide whether or not you really want to tackle such a major project; chances are, after you see just how big a task it really is, you won't. Operating system development is perhaps the hardest area of programming, a task even seasoned pros would hesitate to take on. The only things that come close are language and compiler design, DBMS engine design, and window manager design (which is a completely different thing from OS design).

On second thought, I suspect that the part you actually want to read is What Is A GUI?, since I am pretty sure that what you are looking at writing is a desktop manager, not an operating system. While it is possible to focus on the UX of an OS design early on, you still would need to have a working kernel and other more basic facilities first before even contemplating that.

I'd still recommend reading the other sections, as they will clear up some of the confusion you seem to have, and will probably save you a lot of headaches. I'd also recommend lurking on the OSDev forum afterwards, but you really don't want to post there until you have covered the basic material in the wiki …

Reverend Jim commented: Great answer. +13
ddanbe commented: Better answer than mine!Top! +15
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

natanhailu: I realize that you are a newcomer here, but there are some pieces of netiquette you should be made aware of. First off, you should not post a new question in another poster's existing thread unless the question has some bearing on what is already being discussed. Doing that is called 'thread hijacking' and is considered rude, as it derails the thread from its original purpose. If you have a new question, please start a new thread.

Second, there are separate fora for different languages. The forum you have posted to is the one for the C++ programming language. If you have a question about Visual Basic .NET, you should post it in the appropriate forum on the message board.

Third, clarity is paramount when posting in any technical forum, mailing list or newsgroup. You need to be as specific as possible about the problem you are having and the help you are looking for.

I hope that these comments are taken in the spirit they are intended, and that they help you with future posts on Daniweb and elsewhere. I would recommend going over the forum rules and reading 'How to Ask Questions th Smart Way' by Eric S. Raymond for further advice.

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

Do a search on the Travelling Salesman Problem, for details as to the algorithmic complexity of the problem and various solutions available for it, but keep in mind that your professor will - not might, but definitely will - do the same search as well. Copying the code from any of these sources will only get you the failing grade you deserve.

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

Desipte their names, Java and JavaScript are completely unrelated languages; in fact, when Netscape originally created JavaScript, they were going to call it LiveScript, but changed the name after Sun announced the release of Java in order to jump on the hype train. While some of the changes to JavaScript in versions 2.0 and later on were inspired by Java, the two of them are not connected in any way aside from the names.

Ahmed91za commented: thanks much appreciated +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, let's start off by clearing up a misconception you seem to have. HTML and CSS are not programming languages at all; HTML is a markup language (that is to say, it is used to define the structure of a document), while CSS is a styling language (it is used to define the visual appearance of an HTML document). Together, they define the content, structure, and presentation of a web page. In the absence of some other form of scripting or code generation, they are mostly limited to static layouts, and are more closely related to the Postscript, PDF or RTF document definition markup than to a Turing-complete programming language.

Also, C# itself isn't a web language at all, though it can be used for server-side Web programming, through ASP.Net, the .NET Framework's server-side scripting system (which can use either VB.Net or C#).

Finally, ASP.Net is not an alternative to HTML; rather, it is an enhancement to HTML, in the form of an XML-based extension language that is embedded in the HTML markup and generates HTML code before serving it to the client browser. All the browser sees of an ASP.Net program is the final HTML code it produces.

Even comparing a client-side scripting system such as JavaScript or the (now largely abandoned) Java applet system, is apples to oranges. Those run in the browser itself, on the client system. There are advantages and disadvantages to both, and many ASP.Net web pages also use Javascript and its subsidiary technologies (JQuery, …

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

As NathanOliver said, the Borland graphics.h header, and the library it declares, are not standard C++; indeed, there is no standard graphics package for C++. The Turbo C++ package, furthermore, was specific to MS-DOS, and while programs written for it would work under Windows in the command shell prior to Windows Vista, the removal of 16-bit support in Vista and subsequent Windows versions means that it won't even run in current versions of Windows without using a DOS emulator.

There are a few ports of the graphics.h to Windows, for the sake of backwards compatibility, but none of them are complete, and they all reimplement the library in different ways. I don't know of any that work with Visual Studio 2013, and in any case, they were never the preferred means for writing Windows console programs, never mind GUI programs.

But this is all secondary, as the question itself assumes the answer - you've presented us a Shoe Or Bottle Problem for which the best answer is, 'stop what you are doing and reconsider'. In order to help you in a meaningful way, you would need to tell us what you are trying to accomplish, not the tools which you want to use.

So: what is it you are trying to write? Until we know that, we cannot help you.

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

You might have some more luck if you try searching the OSDev forums, or read their wiki. There aren't many os-devers on Daniweb AFAICT, and I expect that this question (or ones like it) has been addressed there in the past. You absolutely should read the Introduction, Required Knowledge, Beginner's Mistakes and How To Ask Questions entries, if you haven't already.

I should add that the BT tutorial - and pretty much every supposed 'tutorial' on OS dev - has a number of flaws in it, even setting aside the atrocious spelling errors. It is better than most others, but you should still take what it says with a grain of salt. Also, most hobby OS devs agree that the bootloader isn't really a good place to start an OS project - especially one which uses anything resembling a conventional filesystem and executable format (e.g., one that GRUB or a similar existing boot manager can work with). While understanding the boot sequence is of considerable importance, actually writing one yourself is more of a distraction than a necessity. That's not to say you shouldn't read through the tutorial and follow through its code examples, but basing your OS work on it is not going to lead you very far.

Now, regarding the question itself, I am not entirely certain what it is you are asking. The answer depends on if …

ddanbe commented: deep knowledge +15
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Crazy for wanting to write an operating system? No, I wouldn't say so. Overly ambitious perhaps, but not crazy. There are dozens if not hundreds of OS developers (or would-be OS developers) around, even if you discount those on established projects like Linux and FreeBSD. I've been puttering around with OS design ideas for over two decades, and while I have never made any noticable progress, I still keep at it.

The crazy part comes in when you expect others to join your project with only a minimal idea of what you intend to do with it. Most people, even those who are interested in OS development, aren't going to join a project sight unseen without a good reason. Indeed, seeking out partners too early in a project's lifetime is one of the classic mistakes in OS dev, and in open-source development in general.

I would recommend going to the OS Dev wiki and read up on the subject extensively before going any further, especially the "Introduction", "Required Knowledge" and "Beginners' Mistakes" sections. Lurk on their message board for a while, get a feeling for the community, and maybe post a few questions. Don't post a request for help on your project until you've got something to show prospective partners, but still, keep at it, and get a feel for the scope of what you're looking to do. Keep in mind that the overwhelming majority of OS projects …

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

Given that you never actually call create_widgets(), I would expect that it wouldn't display the button in question at all. Similarly, as it is now, it is set up to read from the serial port without regard to the button state (if the button were created in the first place). If you make the following changes, you should get it to do what you want.

import tkinter as tk
import serial
import threading
import queue

class SerialThread(threading.Thread):
    def __init__(self, queue):
        threading.Thread.__init__(self)
        self.queue = queue.Queue()

    def run(self):
        s = serial.Serial('COM15',4800)
        while True:
            if s.inWaiting():
                text = s.readline(s.inWaiting())
                self.queue.put(text) 


class Application(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.geometry("1360x750")
        self.label = None
        self.ckbutton = None
        self.text = None
        frameLabel = tk.Frame(self, padx=40, pady = 40)
        frameLabel.pack()
        self.text.pack()
        self.create_widgets()
        self.queue = Queue.Queue()
        thread = SerialThread(self.queue)
        thread.start()
        self.process_serial() 


    def create_widgets(self):
        self.label = Label(self, text = "Choose COM port:").grid(row=0, column = 0, sticky = W)
        #COM 15 check button:
        print("reached check button")
        self.com15 = BooleanVar()
        self.ckbutton = tk.Checkbutton(self, text = "COM15", variable = self.com15, command = self.process_serial).grid(row=2, column = 0, sticky = W)

        self.text = tk.Text(self, width = 40, height = 40, wrap = WORD)
        self.text.grid(row = 5, column = 0, columnspan = 3) 

    def process_serial(self):
        while self.queue.qsize():
            try:
                self.text.insert('end', self.queue.get())
            except Queue.Empty:
                pass
        self.after(100, self.process_serial)

app = Application()
app.mainloop()
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Again, I would need to see both the function you have written, and the error message you are getting, before I could have any hope of answering that question. Sorry to harp on this again and again, but you need to give us all the information needed to understand what is going on with your program.

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

<rant>
Why do we even bother answering these idiots when all it does is encourage more idiots to post in their threads with the same garbage?
</rant>

Sorry, lost my head for a moment.

kiran_8: Please read the Daniweb forum rules. It is clear that you didn't already, as you just violated three of them:

  • Do provide evidence of having done some work yourself if posting questions from school or work assignments
  • Do not hijack old forum threads by posting a new question as a reply to an old one
  • Do post in full-sentence English

If you have a question, start a new thread. If you have something to say, say it fully and completely, without using unnecssary abbreviations, and write it in full sentences. And most of all, if you have a homework assignment, do it yourself, and only come here to ask for advice - not a handout - after you have made a good-faith effort to solve the problem.

ddanbe commented: Nail on the head! +15
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

decorators only work on function call, not on definition

Actually, they can be either one, sort of; the decorator syntax is just syntactic sugar for calling the decorator function with the defined function as its first argument. That decorator function can be any higher-order function that takes a function as its first positional parameter, and returns a function as its only return value.

Defining a decorator operation that is invoked at function call requires wrapping the defined function in a closure, and returning the closure as the value of the decorator, but the decorator itself runs at define time.

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

basically, what I want to do is add a function name to an outside reference in a safe sys.modules reference without copying the name...

Have you considered writing a decorator? Perhaps something like so:

@register
def myfunc(args):
    x = None
    return x

You could even set it up to allow multiple registries:

@register(myFunctionRegistry)
def myfunc(args):
    x = None
    return x

I'm not quite sure how you would implement it, but that seems like the most reasonable approach to take, given the semantics you want.

Gribouillis commented: Of course +14
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

@JamesCherrill: I am fairly certain the OP as referring to the version numbers for the Substance LAF framework, not Java itself.

That having been said, I doubt anyone here knows anything of Substance (pun intended). You might want to, I dunno, read the documentation? RTFM is always the first thing to try doing in these cases, really.

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

I keep getting an error for "password was not declared in this scope" in main.

As tinstaafl pointed out already, that is because password isn't declared in main(), and in any case you are using a C-string (a zero-delimited character array, as used in the C language, the predecessor of C++) instead of a string object (a class that is specific to C++, which is recommended when working with new code in C++, and what the assignment actually asks for). C-strings aren't so much a type as they are a convention for how to use a char array to hold strings; I'll explain what I mean by that a little bit later.

So, what you want to have is a declaration for a string in main(), which you would read in from the console in main() and then pass as the argument for IsValidPassword().

One of the principles of code design is the separation of concerns; that is, you want to have the code for communicating with the data source (e.g., a text shell, a windowed user interface, a database) separate from the code which processes the data (e.g., computations based on the data, validation tests, etc.). This makes the logic of both sections easier to understand, makes the sections more modular, makes the interfaces between the sections clearer, and makes it so the computation isn't bound tightly to the I/O. For example, if you write your validation function so that it only gets the data from its …

Slavi commented: wow .. +6
TObannion commented: Very explanatory and in depth. Thanks +1
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I think you'll find that it was AH, and that you wanted to set that to 4Ch; however, since AH is the high byte of AX, using MOV AX, 4C00h is the same as assigning MOV AH, 4Ch followed by MOV AL, 00h. The effect is (almost) the same, since you were returning a zero to the shell anyway (zero is used by the shell to indicate a successful completion of the program), but this is misleading; for other interrupt calls, you will sometimes need to pass an argument through AL, and if you had set AX instead of AH, you'd have a serious problem. In this case, it works out (and even saves an instruction, technically speaking), but you should be aware of why it works, and what is really happening, in order to see the potential problems in that approach.

hefaz commented: Yeah +1
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

i have to make a game for window pc .simplest 2D game

Yes, but why? Is this for a homework assignment, or simply for your own interest in the subject? What are the requirements? What kind of game - a Pac-Man style maze game, a Tetris clone, a side-scroller, an Invader game, a Breakout style wall-smasher, or something else entirely? What kind of deadline do you have? Are there requirements for the tools you can use (a specific platform - you said Windows PC, but that could mean a lot of things, including an MS-DOS program running in DosBox - a specific library, a specific compiler)? Are you writing it in Standard C++ with a suitable graphics library, or a dialect such as C++/CLR whic has a default library included? There are still a lot of details missing for us.

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

You'll have to give us a good deal more detail about the problem, I'm afraid. What kind of constant are you trying to use? I assume it is an integer, in which case you probably don't have many options - Turbo Assembler (which is the TASM I assume you mean - there were at least two others which went by that acronym) was a 16-bit real mode assembler for MS-DOS, and did not work directly with values greater than FFFF hex (65536 decimal). There are ways to work around this, but they aren't particularly easy.

Which leads to the next question: why TASM? is this for coursework (in which case you probably don't have any choice), and is there a reason why it is in an archaic 16-bit assembly dialect for MS-DOS? Current versions of Windows (Vista and later) won't even run 16-bit real mode programs except through an emulator such as DosBox; if you have any choice at all in the matter, I recommend that you ditch TASM for a modern assembler that actually still runs, such as NASM or FASM.

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

If you use the Search function of the forums, you ought to find several threads on this subject. I recommend this one, but then I am biased. :-)

That just leaves you with the loop and the exit condition test. I expect you can figure that part out yourself, though I do have a long history of having my hopes dashed in this regard...

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

Ah, now I see the issue: the problem is not with the sorting functions, but with the count variable. You are incrementing it once too many times. If you pass count - 1 to the functions instead it ought to work.

Also, the min variable is redundant, as it will always equal i. I expect that you're aware of this, but that you had added it while trying to debug the functions.

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

Interesting. There are no break statements in the code you posted, which leads me to think that this is from theevaluar module which you are importing, or else some other file that it in turn imports.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster
def puntofijo(po,TOL, N): 
 vectorx = zeros (N, Float64)
 vectory = zeros (N, Float64)

i = 1 
while i<=N :
 vectorx[i-1] = po 
Evaluar.dicc_seguro['x']=po 
fp = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro) 
vectory[i-1]=fp                                                                      
if fabs(po-fp):
 print "La raiz buscada es: ",po, "con", i-1, "iteraciones" 
 sys.exit()
i = i+1 
po = fp 
quit() [vectorx,vectory]

I assume that this is all supposed to be a single function, correct? If so, then the indentation is off, starting at line 9 (the i = 1 line). Try:

import evaluar 
from pylab import * 
from numpy import *

def puntofijo(po,TOL, N): 
    vectorx = zeros (N, Float64)
    vectory = zeros (N, Float64)

    i = 1 
    while i<=N :
        vectorx[i-1] = po 
    Evaluar.dicc_seguro['x']=po 
    fp = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro)
    vectory[i-1]=fp     
    if fabs(po-fp):
        print "La raiz buscada es: ",po, "con", i-1, "iteraciones" 
        sys.exit()
    i = i+1 
    po = fp 
    quit() [vectorx,vectory]

def dibujar(po,TOL, ): 
    x = arange(po-2,po+2,0.1) 
    vectores=puntofijo(po, TOL, Y)

    subplot(211) 
    plot(x, eval(Evaluar.funcion), linewidth=1.0) 
    xlabel('Abcisa') 
    ylabel('Ordenada')
    title('Metodo Punto Fijo con f(x)= x - ' + Evaluar.funcion) 
    grid(True) 
    axhline(linewidth=1, color='r') 
    axvline(linewidth=1, color='r')
    subplot(212) 
    plot(vectores[0], vectores[1], 'k.') 
    xlabel('Abcisa')
    ylabel('Ordenada') 
    grid(True) 
    axhline(linewidth=1, color='r') 
    axvline(linewidth=1, color='r')
    show() 

Note that the convention in Python is to use four spaces for indentation, not two. Also, what is the line quit() [vectorx,vectory] meant to do? I am pretty sure that the list following the quit() call is likely to give you a syntax error. For that matter, where is the function quit() coming from? If you are intending to return the pair [vectorx, vectory] as the …

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

Well, I explained this already in the earlier posts, but once again: the standard C++ stream I/O library has no support for console handling. The conio.h header and library are specific to Turbo C++ (and a few libraries that copied it) and MS-DOS (or Windows console), and while that system specificity will be the case for any console handling library to some extent (there are some portable ones such as ncurses, but they aren't universally applicable), it is something that you need to at least be aware of.

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

sigh basit_3, did you read the other replies in this thread? This is essentially the same as the code posted by mridul.ahuja, and has the same problem of using getch() that his code did.

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

Deceptikon is correct; text echo is a function of the shell itself, not of the stream I/O (which is the same basic model for both the C I/O functions and the C++ iostream classes). The standard C/C++ I/O operations don't know or care where the text comes from, as it always reads it from the input buffer regardless of whether it is from a console, a file, or a pipe. By the time the C/C++ operations even know that there is data to process, the shell operations have already been completed.

It is true that there are functions to communicate with the shell and turn echo on or off, but those functions are always system-specific (and in some cases, shell-specific), and not a part of the standard library.

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

Given that this thread dates from a month ago, and that there seemed to be a definite time limit approaching when that post was written, I doubt that the OP is still having that particular issue at this point.

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

mridul.ahuja: You, and the OP, need to be made aware that getch() (and the rest of conio.h) is not a standard C++ function, but rather is one specific to Turbo C++; some later compilers and IDEs have equivalents, but that doesn't change the basic fact that it will only work for DOS-based systems or their derivatives, and only with the specific libraries that support it.

That having been said, I should also add that Standard C++ has no support for raw console input; all standard C++ I/O is by means of buffered streams, and there are no ways to enter characters without displaying them, move the cursor around the screen or alter characters displayed on previous lines. All such operations are system-specifc; there are portable libraries to do this, such as ncurses. but not even those are universally available. If you know that you are going to be writing the program for a specific platform (e.g., Windows, Linux, MacOS), then the preferred approach is to use that system's native library.

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

I am at a loss to understand what you are trying to say. If you are 'not interested' in following the rules of the forum, I think you will find yourself banned by the moderators rather quickly. I'm not at all clear as to what the second sentence is meant to refer to; it simply makes no sense in this context.

As for not being American, most of the posters here are not, either, yet the rules apply to everybody. It has nothing to do with nationality, and everything to do with Daniweb's policies.

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

dbfud1988: I know you meant well, but please do not just hand out code like this. Doing so goes against the 'no cheating' policy here at DaniWeb. We can assist and give advice, but we try to avoid simply answering homework assignments for students, as it interferes with the learning process. Tru,e there are borderline instances, and nearly everyone here has overstepped that line at some point or another, but this is a pretty clear-cut instance where providing code gratis is a Bad Thing.