gusano79 247 Posting Shark

I wanna create a new Prog language .

I give input as a abstract sentence.

Eg Input : Let A be 10 , B be 10 . C be Sum of A & B.

SO the output to the compiler must be

int a=10, b=20 , c;
c = a+b;

Even though this is possible by simple character search, I wanna a well defined algorithm for this type of language.

The standard well-defined approach is to create a parser for your input language and use it as part of a compiler that generates equivalent code in the output language.

Writing your own is certainly educational, but there are also parser generator applications out there that can take a grammar that describes your input language and generate code or other output for you--ANTLR is a good one.

gusano79 247 Posting Shark

Whenever I create a new database from a C# program and create tables for that database, the tables always show up under the creator's default database instead of being listed under the newly created database.

Hi again!

If you're using the same connection string that created the database to send the create table commands, remember there's no database specified on that connection. Once you've created the database, you'll have to create a new connection that specifies the new database's name. Use that connection to create the tables.

If that doesn't apply to what you're doing (i.e., you're already creating a new connection) or it doesn't solve the problem, please post the relevant code so we can help.

gusano79 247 Posting Shark

I am still unable to Open. I went into SQL Server Management Studio Express and granted all privileges to the root user but still no luck.

A more detailed description of the problem than "still no luck" would help... is it the same exception or a different one? Exception message and stack trace are both useful. Also, what version MySQL are you connecting to, and with what .NET data library?

gusano79 247 Posting Shark

More food for thought... this probably goes beyond your current question, but I think it helps to demonstrate the modelling process:

The unmentioned "Class" object could be the true parent here... a Class would have (among other things) a Teacher who teaches the class, and a Classroom where the class is taught. This seems more natural to me than the Teacher or the Classroom "owning" or "using" the other.

If the class moves from room to room, then instead of having a Classroom, a Class could have a "Schedule" object. A Schedule would be a list of "Session" (there's probably a better name for this I can't think of right now) objects, each of which has a Time and a Place--Classroom could be a type (subclass) of Place, but there could be others, for example a Cafe (for informal classes) or Website (for e-learning courses).

gusano79 247 Posting Shark

My code structure to create a new Access database is in this order:

1. Create the database
2. Open the database
3. Create a database table

Is this the same order that I should apply for creating a mySQL database?

It's not quite the same; Access is a file-based database system, where MySQL is server-based, so you'll need some sort of open connection to the server to do anything useful.

When the program attempts to run the ExecuteNonQuery command for CREATE DATABASE, it fails because it requires an open database connection (ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.)

I don't have a server handy to test this on, and I'm not sure what MySQL library you're using (ODBC, Connector/Net?)... but I think it would look something like this:

MySqlConnection connection = new MySqlConnection("Data Source=serverName;UserId=rootOrOtherAdminAccount;PWD=topSecretPassword;");
MySqlCommand command = new MySqlCommand("CREATE DATABASE FancyDatabase;", connection);
connection.Open();
command.ExecuteNonQuery();
connection.Close();

Is that different than what your code is doing?

gusano79 247 Posting Shark

Can anyone tell me what the assembly type for bottom assembly program?

#DEFINE PAGE0 BCF $03,5
#DEFINE PAGE1 BSF $03,5

INDF: .EQU $00 ;page 0, 1, 2, 3
TMR0: .EQU $01 ;page 0, 2
OPTION: .EQU $01 ;page 1, 3
PCL: .EQU $02 ;page 0, 1, 2, 3
STATUS: .EQU $03 ;page 0, 1, 2, 3
FSR: .EQU $04 ;page 0, 1, 2, 3

PORTA: .EQU $05 ;page 0
TRISA: .EQU $05 ;page 1

...

Looks like code for a PIC microcontroller.

gusano79 247 Posting Shark

AFAIK Normal Windows development (e.g. what you get with normal Visual Studio installations) does not handle multiple key presses, not including modifier keys (ctrl, alt, and shift.)

To clarify, the .NET Framework doesn't provide automatic handling of multiple key presses. You can still handle them yourself.

The problem is Windows supports two types of key press events: KeyDown/Up and Repeat. Key up and down is great, but if you hold a key down, it fires Repeat until that key is let go. Not handy if you are trying to hold 2 keys down at once.

This is what's keeping your code from working right--when you hold one key down and press another at the same time, you stop getting repeats from the first key, and start getting them from the second.

As long as your game logic is coupled to keyboard event handling, you'll always need a new key event to do something in game logic. Because you never get repeats for more than one key at a time, you won't be able to do two actions at once.

The solution? Decouple keyboard event handling from game logic.

First, you need a place to keep track of which keys are currently down. If you only have a few keys you're interested in, you might have a couple of lines like this:

private bool spaceKeyDown = false;

Then, handle the "key down" event:

private void MainFormKeyDown(object sender, KeyEventArgs e)
{
    if(e.KeyCode == Keys.Space)
    {
        spaceKeyDown …
gusano79 247 Posting Shark

Simple, yes... but not something I'd allow into production code. See these links for some discussion.

Here's an alternative... first, a method to try to create a mutex unique to the application:

private Mutex GetSingleInstanceMutex()
{
    bool createdNewMutex;

    Mutex mutex = new Mutex(false, @"Global\" + SomethingUnique, out createdNewMutex);

    if (!createdNewMutex)
    {
        mutex = null;
    }

    return mutex;
}

SomethingUnique should be something unique to the application, for example, the assembly GUID.

Here's how you'd use the method:

using (Mutex mutex = GetSingleInstanceMutex())
{
    if (mutex != null)
    {
        // This is the only running instance; go ahead and run the application.
    }
    else
    {
        // Another instance is running; notify user and quit.
    }
}
ddanbe commented: Very informative for a learner like me! +5
gusano79 247 Posting Shark

I am looking for a DFA that accepts the language that consist of an even number of 0's and an even number of 1's. Any ideas?

Since you can't track a count of zeros and ones in a DFA, try looking at having a state for each possible outcome as you run through the input string--so your states would represent combinations of even/odd zeros and even/odd ones.

gusano79 247 Posting Shark

I am writing a number guessing game, but it request to give hints to player when he guess wrong. And I need to narrow the range to be the hints, what should I write to do this function?

The simplest hint that actually narrows the range is to tell the user "too high" or "too low" for wrong guesses.

gusano79 247 Posting Shark

hi...i'm making a game that uses the direction arrows and fires with space...the problem is that when i keep holding 2 keys it makes only the behavior of one....can any1 tell me what i shall do

Could you post the code you're using to track key up/down status? That would help us find what's going wrong.

gusano79 247 Posting Shark

Already handed it in

yes Gusano, it had something to do with component based software engineering which I learnt doing the essay

Ah, sorry I came in too late... good that you found it, though.

gusano79 247 Posting Shark

Do I need to complete a program in order to know my test results?

No; you're creating a set of simple test data for the conversion program. A program that generates test data would essentially be the same as the conversion program, which defeats the purpose of generating test data.

I'm really not sure what I need to do next, can anyone help?

Whatever the inputs are, just make some up--then figure out what the program should output if you feed it those inputs. Repeat until you think you have enough.

gusano79 247 Posting Shark

...I found that a word (dw) will only hold the last thing passed to it. You can type "abcdefg", but the word will only hold the value "g"...

Right. store will always refer to the same memory location, so every time you write to it, whatever value was there is overwritten by the new value.

...What I'm trying to ask is, would there be a way to make it store everything typed, like.. create a string out of a series of characters?

As long as store only points at a single location, no.

What you want is a series of storage locations, with store pointing at the start... instead of dw 0 , do something like times 100 dw 0 . Then all you need is another variable to hold the address in which to store the next input character. Start it out pointing at store , and every time you read a character, load it into the location at the address of store plus the value of the variable, then increment the variable. That way all of the input characters are saved at different locations, and you have all of them.

Additional thoughts:

You don't have infinite space to keep recording characters, so you'll have to decide how much space to reserve and what happens if someone types more characters before they hit the carriage return.

Instead of defining store as a series of 0 bytes, try filling it with '$' --that way, no …

gusano79 247 Posting Shark

Does anyone know what is ment by fabricated products & softwares?

The phrase "fabricated software" doesn't ring any bells for me, but it might refer to component-based software engineering.

It's a place to start, anyway... I'd clarify with your teacher exactly what was intended.

gusano79 247 Posting Shark

couldnt I just enter dynamic data direct through the datagrid and then just update the table(In other words actually click on the datagrid and then type data in the list and then click on update). The added data will be movie titles, director etc so that I could just add to the list when I want to update.

Short answer is no. How will your application know what SQL to send to your database to insert, update, or delete records?

I wish I had a better answer for you, but this is how it works. There are other ways to do what you want within ADO.NET, but they require more code and more manual management of the database. I believe that what I'm describing here is one of the simpler methods, and I think the most decoupled from the database itself.

Longer answer: DataGrid is there to provide a user interface. It can display and manage data based on a variety of underlying data-holding classes. We're looking at a DataSet or DataTable as the backing object for your DataGrid . Both of these are in-memory representations, i.e., they are a copy of your data, and they don't represent a direct connection to the database. SqlDataAdapter is probably the easiest way manage the link between these data objects and your database. At a minimum, you need to write the SELECT statement, and if you aren't able to use SqlCommandBuilder you'll also need to write appropriate INSERT , UPDATE , …

gusano79 247 Posting Shark

An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll

Additional information: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.

Ah, yes. The command builder also requires that your SELECT statement return a primary key or unique index.

If your table has either of those, you may be able to get away with simply adding the appropriate column(s) to the SELECT statement.

If not, you'll have to write the update command yourself. Here's what it might look like:

using(SqlConnection connection = new SqlConnection("<connection string>"))
{
  SqlDataAdapter adapter = new SqlDataAdapter(
    "SELECT SomeField, SomeOtherField FROM Table"
  );

  adapter.UpdateCommand = new SqlCommand(
    "UPDATE Table SET SomeField = @SomeField WHERE TheKey = @TheKey"
  );

  adapter.UpdateCommand.Parameters.Add(
    "@TheKey", SqlDbType.Int).SourceColumn = "TheKey";

  adapter.UpdateCommand.Parameters.Add(
    "@SomeField", SqlDbType.Binary).SourceColumn = "SomeField";

  DataTable table = new DataTable();

  connection.Open();

  adapter.Fill(table);

  foreach(DataRow row in table.Rows)
  {
    row["SomeField"] = (int)row["SomeOtherField"] == 42;
  }

  adapter.Update(table);
}
gusano79 247 Posting Shark

would you know anywhere I can see what functions it has, and some basics on how to use them?

The library is documented decently from a "what functions are there" perspective.

Good network programming techniques are another topic altogether; an Internet search should uncover some decent guides. There are also some samples that come with the library, if code helps.

I don't really need it to be cross-platform, windows only works fine for me.

Then you're covered; the author provides Win32 binaries on the page I originally linked to.

I would rather not double post, but I want at least somewhere I can go to find help for myself.

This post was "where do I find a networking library"--I would consider a post about "how do I do <something specific> with TCP/UDP" an entirely different post, if that's what you mean.

gusano79 247 Posting Shark

You might try SDL_net. It is free and cross-platform, and should cover both of your requirements:

  • Server detection using UDP to broadcast to the local network (though which side does the broadcasting is a different conversation)
  • Communication between server and client using TCP (if you care about sequencing and guaranteed transmission, and don't mind the wait) or UDP (if you don't care about those things and just want it to be fast)
gusano79 247 Posting Shark

You can't update the database using OleDbDataReader or any other DbDataReader subclass. They provide forward-only, read-only access to data. You need something else.

There's more than one way to do this. Here's one:

This approach only requires you to write the SELECT statement; follow the links for more information on how to use these classes.

See also the System.Data.OleDb and System.Data namespace documentation.

gusano79 247 Posting Shark

Looks like you're not generating the update command. It isn't actually created until you call SqlCommandBuilder.GetUpdateCommand(). You'll need something like this:

MovAdapt.UpdateCommand = cb.GetUpdateCommand

This article has a good explanation of how it works.

gusano79 247 Posting Shark

You can't link directly to a COM library; you have to link to a .NET interop library. The VS IDE secretly generates this library for you when you add a COM project reference. Since you're using the command line, you'll have to generate it yourself. Use tlbimp.exe; it comes with the SDK.

bondo commented: Exactly what I needed +2
gusano79 247 Posting Shark

If "Poisson RNG" means "pseudorandom number generator that generates Poisson-distributed numbers," you can generate your own from a uniform distribution; there's no need to locate a special Poisson generator if you already have a uniform PRNG that meets your requirements.

It sounds the real issue, though, is finding a generator that you can synchronize across multiple parallel processes--requests from different processes will still consume the number stream from a single generator. Suggestions:

  • Use single instance of any PRNG you want, and write a wrapper for it that buffers generated numbers and tracks requests for numbers, delivering the same sequence in the same order to each parallel process.
  • Use separate instances of the same seeded PRNG in each parallel process, but generate the seed globally so each process will generate the same numbers.
  • If you have a seedless generator that you can duplicate or which provides access to its initial state, use copies of the same seedless PRNG in each parallel process.
gusano79 247 Posting Shark

Since you already have the textbook's answers...

"Every dog owner is an animal lover"

Mine:
Ax Ey dog(y) AND onws(x,y) => animallover(x)

Book:
Ax (Ey Dog(y) AND Owns(x,y))=>AnimalLover(x)

- This is almost equal... are the () significant?

They're significant for readability. The book's solution makes it much clearer that both a dog existing and X owning that dog are necessary to X being an animal lover.

Your solution can be read that way, but if you group things differently, i.e., (Ax Ey dog(y)) AND (Owns(x,y) => AnimalLover(x)) , it comes out saying that for every X there exists a dog Y, and if X owns Y then X is an animal lover. The statement still establishes that owning a dog makes you a dog lover, but it also implies the existence of at least one dog if any X-es exist, which isn't something the original statement claims.

Maybe precedence rules take care of this ambiguity, but I recommend using parentheses wherever someone could get confused. It can't hurt.

"No animal lover kills an animal."

Mine:
Not Ex Ay animal_lover(x) AND animal(y) AND kills(x, animal)

Books:
Ax animal_lover(x) => Ay animal(y) => not kills(x,y)

- This differs that I just use ANDs and no => (implication)

Translating back to English...

Book's: "For all X, if X is an animal lover, then for all Y, if Y is an animal, then Y is something that X does not kill."

Yours: "There is no X …

gusano79 247 Posting Shark

I don't have any code samples handy, but if you'd like to create your files the Cowboy Way, try this introduction to the Microsoft PCM WAVE file format. Most wave-file-creating software that I'm aware of doesn't go beyond this subset of the RIFF specification, but there are some gory specification details available if you want to see, and some additional gory details as well.

gusano79 247 Posting Shark

You can do this by capturing keybord interrupt.(09h?yes)
I remember I have seen an article solving this problem.Actually,it is not
an easy stuff,but Im not sure I can check it out.:~)
...

Correct; hardware interrupt 9h is the keyboard interrupt, and it's possible to use that to get keyboard states. But if you're compiling for Win32, then by all means use the API like bdiamond suggests--it's tougher to write your own int 9 handler, and what you get is something that works just like GetAsyncKeyState anyway.

...
I think I have the same problem with you.Im thinking about reading data
from I/O directly,but I havnt done it yet.

Dealing with the keyboard controller directly like that is a couple of orders of magnitude more insane than writing your own handler, trust me.

If you really want to play with hardware, the old, 16-bit DOS edition of the The Art of Assembly Language Programming has a chapter on the IBM PC keyboard and int 9 handling which I think is quite useful, if you don't mind x86 assembly.

--sg

Asif_NSU commented: useful info, I appreciate--- Asif_NSU +1
gusano79 247 Posting Shark

The second parameter to strcmp up there is actually a pointer--that's half of what an array is, just a location in memory (the other half is the field size, in this case char, to use when making offsets into the array).

...
if ( strcmp( words,words) == 0 )
...
error message says:
error c2664: 'strcmp' : cannot convert parameter 1 from 'char' to 'const char*'

..but then, i didn't use pointers

A few additional comments:

The value of count doesn't change, so it doesn't have to be in the loop--if that line assigning to z is really what you want to do.

...
for (int i=0; i<strlen(words); i++)
{
words= tolower(words);
z = count + 5;

}
...

Similar idea here. The loop will always end with i equal to count - 1, so making that last assignment to z doesn't have to be inside the loop--again, if that's what you want it to do.

...
for (i=0; i < count; i++)
{
if ( strcmp( words,words) == 0 )
z = i;
}
...

Continuing the same line of thought, z<count will always be true, so the if statement isn't necessary.

...
if (z<count)
{
ofstream file;
file.open("WORDS.txt", ios::app);
...

This last bit is a little strange--renaming a file that no longer exists?

...
system("del words.txt");
system("ren words.txt words.txt");
}
...

--sg

gusano79 247 Posting Shark

I am doing some very nasty computation using java but it always gives me a java.lang.OutOfMemory Error,after this nothing on the GUI works.i think its ok to have that error but atleast things should work afterwards.

Please Advise

It's not okay to have that exception. My "Please Advise" is that you post code so we can at least see what you're trying to do.

Unless you're loading large amounts of data into memory (i.e. more than will fit in the memory allocated to the VM), this shouldn't happen. A common cause of this problem is some sort of out-of-control recursion. Try running your code with some sort of stack trace enabled so you can find at what point in your code the exception is being raised.

--sg

gusano79 247 Posting Shark

Well, here's an easy one--you've spelled a method two different ways (the first is correct):

...
Temp Celsius( ); //needed to work on
...
<<theTemp.Celcius()
...

Also, it won't compile until you actually define a body for that method like you did for Temp::Fahrenheit.

Hm, also noticed you have both myDegree and myDegrees in your code; I bet you don't want that either.

Unless you've snipped out lots of code, it looks like you haven't actually implemented half of the class members... including the constructor that actually accepts an argument and (one would imagine) initializes myDegree. Without that, it'll always be zero.

And... this looks suspicious:

...
cin>>theTemp; //input
...

There's no way for the compiler to know that you want a double-precision value to be read... you need a double somewhere to hold the value.

That should get you started.
--sg

gusano79 247 Posting Shark

Have a look at SDL--it's pretty nifty.

gusano79 247 Posting Shark

...
I think Communication is essential for a programmer.

Definitely. Programming is basically an engineering discipline, but a programmer is closer to an interpreter or translator than any other kind of engineer. Sure, you can get the job done sitting in a cube and coding, your only companions a stale beer and a cold slice of last night's pizza (and many do), but there's no substitute for proper communication. This goes for any business, really.

--sg

gusano79 247 Posting Shark

Another way to approach your switch statement is to convert the string to a number first, then use the number in the switch. The Integer class can do this.

--sg

gusano79 247 Posting Shark

...
And, about the "&&" operator, yeah, it's true.
If the left hand side is false, it will never evaluate the right hand side
...
this differs in some programming languages.

With some languages, it may depend on the compiler as well. Shortcutting an operation like that can be considered an optimization; I've heard of compilers (can't think of any off the top of my head though) that stop evaluating the expression if the LHS is false when optimizations are turned on, but will evaluate everything when they're turned off... this is especially frustrating when the debug build (optimization off) works fine, but the release build (optimization on) doesn't.

You're save with Java, though; the shortcut is written into the language specification.

--sg

red_evolve commented: Good point. I agree with you. +2
gusano79 247 Posting Shark

... the target in the switch statement works for Integers only. ...

An expression in a switch statement can be any of these: int, short, byte, or char. red_evolve is basically correct, though, since they're all integer types under the hood.

--sg

gusano79 247 Posting Shark

From what I've heard, programs are considered AI when they can fool a human being into thinking they are human (ie. over IRC chat or similar). ...

It's called the Turing test, after Alan Turing.

Here's an article that may be of interest... I'll throw in a quote from the article (italics mine): Turing intended his test specifically as a measure of human intelligence. An entity passing the Turing test may be said to be intelligent, and moreover, to possess a human-form of intelligence. Turing specifically states that the converse statement does not hold, that failure to pass the test does not indicate a lack of intelligence.

Much depends on how you decide to define "intelligence" and how exactly you go about measuring it.

Further reading:
http://tekhnema.free.fr/3Lasseguearticle.htm
http://www.pcmag.com/article2/0,4149,1200185,00.asp
http://www.google.com/search?hl=en&ie=UTF-8&q=Turing+test :)

... Several programs have been able to do this sucessfully.

Such as? Who wrote them? When? That's a pretty bold statement, and these "several programs" would have received quite a lot of attention, which I haven't noticed at all. And don't say ELIZA.

I'm of the opinion that if the person asking the questions is clever enough, he/she will be able to trip any program written to date into revealing itself as not a human being. I won't say that it'll never happen, but we're far from creating anything that will really pass that particular test.

--sg

gusano79 247 Posting Shark

I've been wondering about this for awhile now: does random data compress?
...
Does this or does this not prove that only 1/255 of random data files can be compressed, and is my math correct?

That sum is a lot more complicated than it has to be. It turns out to be equivalent to sum[k=1..31](256^k). Also, it looks like you've transposed the numerator and denominator in the last step, though your result is correct.

You have the ratio for a sequence of 32 bytes; the general solution for the ratio of shorter to full-length sequences is (1/255) - (1/((256^(n-1))*255)). For sequences of very short length, this ratio varies quite a bit, but the second term quickly approaches zero, so for any practical sequence of data (who would want to compress three bytes?), the ratio is 1/255 minus a very small constant.

What has actually been shown is that there are, in general, approximately only 1/255 as many possible shorter sequences, which is more of an upper bound--a given compression algorithm will be able to compress randomly-generated sequences of bytes at most 1/255 of the time, but realistically this will happen even less often.

If you derive the ratio for bits instead of bytes, it is 1-(1/(2^(n-1))), which is much more agreeable. However, on a machine with 8-bit bytes, any 32-byte sequence (for example) that compresses to 31 bytes plus a few bits would have to be padded to 32 bits anyway, effectively losing the compression--so …

gusano79 247 Posting Shark

...
This function converts a string to a numeric value.
...

Are you interested in writing the conversion yourself, or do you just need the conversion to happen? These can help:Double.valueOf(String)Long.valueOf(String)

One approach would be to first try to convert the string to a long. If it works, then you have an integer. If it fails (i.e. throws an exception), then try to convert it to a double--maybe it was only a decimal point that caused the long conversion to fail. Success means it's a double, failure indicates a non-number string. After that, you'll have a long, a double or something that is neither, and you can do what you want with it.

...
please how to write the overload functions same parameter(passing only string) and returtype either double and long.
...

You're asking for something that doesn't exist. Parameters for overloaded methods must always be different (number or type of params), and the return type must always be the same. You'll have to come up with some other way to handle the multiple types.

gusano79 247 Posting Shark

There certainly is... Using the library functions as much as possible is good (code reuse, more sleep)--but it can be quite educational to write your own as well. It builds character, puts hair on your eyeballs, that sort of thing.

gusano79 247 Posting Shark

java.awt.GraphicsEnvironment has what you need:

GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(<your_application_frame_here>);

Setting an application full-screen can be extremely annoying; make sure you're doing it for the right reasons.

gusano79 247 Posting Shark

...
For the void set how would i set the char mer[] to am or pm.
...

The sprintf function should work for that:

#include <stdio.h>

void Set(char string_time[])
{
    sprintf(meridian, string_time);
}

If you do this with string_time larger than meridian, it will crash and burn horribly.

I recommend that you don't store and manipulate that value as a char array. If it's only going to ever have two distinct values, it's a lot easier to handle if you use a simpler type, like an int, for example. Just decide on a meaning for the simpler variable, e.g. a zero int value means "AM" and nonzero means "PM". If you're writing C++, then a bool is even better--it only has two possible values. The only time you need text is when you're displaying the time for a human being, which can be done in a separate function that interprets the numeric values and prints out the textual meaning. This will make your code simpler and easier to work with.

gusano79 247 Posting Shark

...
Great idea on the Pascal! It is what I learned first. I do not see a lot of environments out there for it though.

Have to see if gcc will compile it.
...

Straight GCC doesn't do Pascal as far as I know, but Free Pascal and GNU Pascal might do it for you.

Not all Windows compilers have an inflated price tag and IDE... Borland released a free command-line version of their compiler a while back.

gusano79 247 Posting Shark

sir actually i wana check that the barcode i have generated are valid or not... i dont have barcode reader and i just want a simulation of that.

Simplest way to check actual barcodes without a reader is to find a barcode generation service--like the one Killer_Typo suggested--for the barcode symbology you're implementing (e.g. UPC, EAN). Then put the same numbers into both your program and the generator service and see if they come out the same. Of course, this only works if you trust the third-party barcode generator.

If all you're checking is that the numbers fit the barcode scheme (e.g. checksums are correct), you're really just checking that you've actually implemented the algorithm correctly. Try working through the algorithm by hand for a few sets of numbers to see if your program comes up with the same thing. Even better, find a few real barcodes and check those against what your program does with them.

gusano79 247 Posting Shark

I need to create a date updated field for ms sql 2000. The current trigger I have only works for the insertion of data and it is "(getdate())" is there one that I can use for insertion and update of fields?

You can write a trigger that fires on both insert and update:

CREATE TRIGGER <trigger_name>
ON <table_name>
FOR INSERT, UPDATE
AS
<trigger_body>

Here's the T-SQL reference page:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_create2_7eeq.asp

Slade commented: Thanks, here's your reward :P +36
gusano79 247 Posting Shark

String str = JOptionpane.showInputDialog(null,"Enter String");

Ah, but then you miss all of the stream stuff, which is quite handy for any sort of input/output situation (and it makes you tough, too). Never mind that (warning: opinion ahead) throwing up a dialog box just to get an input string is annoying and should be punished.

gusano79 247 Posting Shark

Looks like Java code that dumps the contents of a URL-referenced file to a text box. No idea what it might be part of.

gusano79 247 Posting Shark

Hi guys, im workin on a little text based RPG using c++. It is a win32 comsole application and i am wondering what i could do to improve it!
...

It's always great to see someone working on text-based games!

It looks like you have a decent start on a room-based game engine. You may want to take the time to use something besides fixed-size arrays for your room locations and inventory; those aren't very flexible. This kind of game is an excellent match for an object-oriented language, so it would make sense to use classes for just about anything you could describe as an "object" in your system. Inheritance is also good--for example, shields, breastplates, and (say) tight leather pants could all be considered armor, or maybe you'd like to make a distinction between objects that are carryable by the player and those that are not.

How familiar are you with text adventures in general? The genre is alive and well, and much wisdom is to be gained from exploring what's already out there. I'm not saying you should scrap your own engine and use a development system somebody else wrote--certainly not--but I think it would be very useful to familiarize yourself with at least one existing system to get an idea of some of the challenges involved.

http://www.wurb.com/if/ is a good place to find other games to play for inspiration
http://www.tads.org/ gets you my authoring system of choice

gusano79 247 Posting Shark

can anyone give me a example of a radix sort

Here's an explanation to complement Abu's code example:

A radix sort works with the digits of a number, working from the least significant digit to the most. Here's a sample set of numbers:
423 586 403 171 92 536 234 243

First, sort the numbers by the least siginificant digit (ones). For this algorithm to work, your buckets have to be order-preserving.
171 92 423 403 243 234 586 536

Then, sort them by the next most significant digit (tens):
403 423 234 536 243 171 586 92

Now hundreds:
92 171 234 243 403 423 536 586

...and they're sorted. Each step doesn't have to be a bucket sort; any order-preserving sort will work.

gusano79 247 Posting Shark

The for loop without any body will execute (n - 2) times, but the first line in your loop above is j = n; which, as written, alters the value of j and thus jacks around with the loop's normal execution. It's clear now that it was mistyped and should have been k = n; though that doesn't quite fix the while loop. As long as you don't specify the loop and just put <body> instead, there's no way to tell what happens to k. As you wrote it, that while loop will never terminate (assuming k > 2) because the value of k never changes. A line like k = k - 1; in the loop would get it to run (n - 2) times.

If you want responses that are helpful, take the time to make sure what you've posted is what you're really asking about.

gusano79 247 Posting Shark

Hello
Why you are using a c-style struct why you are not using a c++ class
here you are a good example

There is nothing wrong with using a struct for the queue nodes here. If all you're storing are a few pieces of information, there's no need for an overgrown class to handle the same data.

The queue template class posted, while it is an example (I'm assuming it works as advertised), I wouldn't call it a good example--it's a bloated gob of code handed down from on high. It looks like Abu here is more interested in saying "ooh, look at all the features i'm using! classes! enumerations! pointers! const methods! templates!" ...all of which are useful things, but not really necessary for the problem at hand.

If you haven't run across templates yet, have a look at http://babbage.cs.qc.edu/STL_Docs/templates.htm for a start.

Now, on to your question--the solution provided by 'infamous' will work, as will doubly-linking the list and running through the display backward. Another approach is to alter the display method:

void queueL::display()
{
    display_recursive(last);
}

void queueL::display_recursive(queue *n)
{
    if(n == NULL) return;
    display_recursive(n->next);
    cout << endl << n->data;
}

Recursion can be a handy tool when dealing with linked lists. If it's not clear, display_recursive will continue to call itself, passing each successive queue node until it hits the end of the list, i.e. it hits a null next pointer. Then it will display them in reverse …

gusano79 247 Posting Shark

...
i don't now why poeple here don't use a c++ feature the are using a c-style

I think people don't often realize there's more than one kind of cast in C++. If that's news to anyone, go look up casting in a good C++ reference and find out what they are and how they work.

Here's a quick article on why to use C++ casting:
http://www.sjbrown.co.uk/static_cast.html

For this problem, though, a C-style cast isn't very dangerous since we're only dealing with numeric types--the really bad stuff happens when you're casting pointers to classes.

--sg