gusano79 247 Posting Shark

"How to connect" is going to depend on what kind of database you are using. Is there a specific database you must connect to, or are you able to choose your own?

gusano79 247 Posting Shark

Here's a hint: Compare the binary representations of the ASCII codes for A-Z and a-z. Do you see a pattern?

gusano79 247 Posting Shark

P.S. Do you know any coding in AS3?

I haven't worked much with ActionScript 3. The last time I worked with Flash it was AS2, which has more than a few weird warts and non-compliant "features"... but I gather that AS3 is a complete overhaul that among other things is supposed to be 100% compliant with ECMAScript 4th edition.

gusano79 247 Posting Shark

Oh my. That's one ridiculous infomercial website.

What do you think it was coded in?

If you take the time to read the page, it's right there in the middle of his sales pitch: "...all the software I develop is created using Adobe Flash."

And how long do you think it would take to make something similar to it?

IMO, it wouldn't take very long. The application is neither large nor complex. Mr. Ken Reno is claiming 5 days from concept to version 1.0, and another 19 to get from there to 2.0, and I don't get the impression that he's any kind of lightning-fast software genius. A couple of weeks should be plenty of time, even for a lone developer. I would also expect most of that time would be spent on design and requirements-like activities--actual coding would be very quick.

PythonNewbie2 commented: Great answer! Everything I asked was answered! +1
gusano79 247 Posting Shark

Provider=Microsoft.Jet.OLEDB.4.0

A quick (flame retardant =) distinction--Jet is the database system, and Access is an application front end that is often used with it. A lot of people conflate the two. We're really talking about Jet here.

I was considering mysql but I can't budle mysql together with my program to deliver to users as it's illegal. It's also kind of shame if I ask users to download mysql separately in order to use my program.

For a file-system database, I prefer SQLite; it resembles its server-based counterparts more closely than an Access database does. If you're doing .NET development, there's System.Data.SQLite.

Can you please share with us what kind of trouble you encountered with access?

This was a while ago and I don't remember specifics; sorry. In general, I had problems with more complex queries. There was usually a way to do what I wanted, but it ended up being ugly (== hard to maintain) sometimes. For example, deleting based on an inner join requires a keyword specific to Jet SQL.

We also had an Access database in a production environment for the longest time... it wasn't in something I'd call a high-volume application--maybe 30 concurrent users as an absolute maximum spike, but we had problems with database corruption.

gusano79 247 Posting Shark

Is Access something you have to use, or are you able to consider alternatives? Access is great for prototyping and rapid development, but IMO it's more trouble than it's worth if you're delivering an application to other people.

gusano79 247 Posting Shark
String hexString = "0x5C";
Byte myNewByte;

myNewByte = Byte.Parse(hexString);

Error: "The input string was not in a correct format"

Byte.Parse() with just a string parameter doesn't know that "0x" means hexadecimal. What you need is the overload of Byte.Parse() that lets you tell it to look for hex. You'll need to give it NumberStyles.AllowHexSpecifier or NumberStyles.HexNumber, and you can't use the "0x" at the front either... you'll need to strip that out first.

Something like this:

String hexString = "0x5C";
Byte myNewByte;

myNewByte = Byte.Parse(hexString.Replace("0x", ""), NumberStyles.HexNumber);
gusano79 247 Posting Shark

What is the specific query you were trying to run? Access isn't able to handle some kinds of deletes that other database systems can.

gusano79 247 Posting Shark

The only method that I can think of to improve my licensing to make it more secure, is to encrypt the license file contents with a key that I hold secret on my side. Then I want to have a different key hard coded in the system which will be able to decrypt this text file. But this hard coded key should not be able to encrypt the file again. This would mean that my software will expect an encrypted file and if using the user's key to decrypt the file, but the file was hacked and encrypted by the user's key - it won't work.

The theory makes sense - at least to me, but I just can't find any encryption methodology that can do this. I've tried RSA, DES, AES and a few others. Could anyone maybe send me in a direction and let me know if this is at all possible.

AES and DES are both symmetric-key systems, which is basically what you were using before--one key both encrypts and decrypts--so they are not what you want.

What you want--and you've summarized it pretty well--is a public-key system. RSA is an excellent example; what made you decide it wasn't going to work for you?

gusano79 247 Posting Shark

But "make" command in unknown in my command prompt.I have MinGW installed which comes with codeblocks.

My Code::Blocks distribution came with "mingw32-make.exe"; check your C::B installation folder to see what came with it, e.g., C:\Program Files\CodeBlocks\MinGW\bin .

gusano79 247 Posting Shark

SP is just a pointer to somewhere in memory; nothing enforces stack discipline.

If there's more code in the example than the one line you provided here, the rest of it might prove enlightening. Could you post anything else that came with the MOV instruction?

gusano79 247 Posting Shark

I've read lots of definitions of it, but I don't quite understand it.

I'm assuming you're talking about this one:

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

Let's say that I create new software that uses my own code and modified code from open source code that is licensed under the MIT License.

When I sell my software, do I need to provide all of my source code? Or simply put the MIT License text inside a text file and add it to the package?

Based on my understanding of the license, which is most certainly not legal advice:

  • You are not required to provide source code for anything, but you can if you want to.
  • You must include a copy of the license with the MIT-licensed part.

If I read you right, you sound most concerned about the licensing of your own software. The MIT license clearly gives you the rights to modify and sublicense the third-party code, so you can license your product that uses …

gusano79 247 Posting Shark

Lol, apology accepted and no hard feelings :p
Your podt agreed with everything mine said then told me off for spreading missinformation...i was trying to figure out what part was wrong :)

And I swear I read it twice to make sure it said what I thought it said... ackthbbbpt.

gusano79 247 Posting Shark

I'm sorry...they ARE reference types, and they ARE immutable but i was wrong to say they are an immutable reference type?

Oh holy crap. I totally misread that the first time--now that I look at it again, you had it right all along. SORRY! :,(

gusano79 247 Posting Shark

Whilst a string may often behave like a value type it is in fact an Immutable Reference type. Some extra behaviours (such as value comparisons and value reassignments) have been added for convenience but they are still a reference type at the core...thats why string.Replace() doesnt affect the string but returns a new value to be stored (optionally in the same varaible).
See the msdn page for more in depth info.

You mean the MSDN page that clearly says "Although string is a reference type..."?

Yes, strings are immutable and have special behavior that anyone that uses them should know about, but please don't spread misinformation. It is important, for example, to understand that when using strings as method parameters, they are passed by reference, not by value.

gusano79 247 Posting Shark

Strings in C# are reference types, as indicated by the C# Reference on MSDN.

Maximum string length will depend on your machine's architecture and memory allocation situation, but the String.Length property is a 32-bit integer, so there's an effective upper bound of Int32.MaxValue.

Running (and developing) .NET applications on Linux can be done with Mono.

I'm not sure what you mean by "which web server we had to use", but if you want an ASP.NET equivalent, see Mono's ASP.NET page.

Ketsuekiame commented: Good answer +1
gusano79 247 Posting Shark

There are a variety of ways to create content this way... which one you choose will depend on what kind of game you're creating and your personal tastes. Suggesting reading to get you started: Maze generation, cellular automata. For roguelike caves, here's an example cellular automaton. There's a also an entire wiki dedicated to procedural content generation.

gusano79 247 Posting Shark

I am unzipping a folder into a new folder and then wants to read all the files from the folder .My code is as follows.I dont want to create a folder but i cnt figure out a way to read all the files froma compressed folder and now when i create another folder i cnt read the files and i get error saying i do not have persmission to access teh folder.I have unchecked the read only preperty of the folder too.Can anyone help me with this.

If I read you right, you want to get at the contents of a ZIP file (compressed folder) without extracting them first. Yes? If so, you might look into using SharpZipLib.

gusano79 247 Posting Shark

Yes, and yes.

My $0.02: A real stock management application would most likely need a proper server-based database system. For a class project, however, may I suggest SQLite? It runs as part of your application, so there's no overhead of installing, configuring, and maintaining a server, but it's still a fairly complete RDBMS, so you should be able to move to a server-based database without too much hassle if you ever need to.

gusano79 247 Posting Shark

Would it also work to change the max FPS of the game? Or should I not do that, and just stick with the timer?

All else being equal, I'd recommend keeping game time independent of framerate. Limiting the maximum frames/second can keep it from running too fast, but slower machines that can't achieve that limit will appear to be running in slow motion (the inverse of your current issue). If you track time separately, the framerate may drop on some systems, but the action will remain consistent.

gusano79 247 Posting Shark

Is there any other way of visualizing the play field without document.write?

Just as an example, here's a JavaScript snake game that doesn't use document.write ; it looks like it uses YUI.

You could probably use JavaScript to update the DOM directly; different playing field states (empty, snake, food) could just be CSS classes you change on the <TD> s for display.

gusano79 247 Posting Shark

This week, I've changed my development to a newer computer with a brand new graphics card. When I ran my game, everything was moving WAY too fast. I think I know what caused this. Since my current computer is so much faster, the game loop runs more quickly which in turn causes the units to move more often (faster).

That's the most likely reason--you'll see this happen with a lot of older games as well.

What can I do to prevent this? How do I make a game run at the same speed on a low-end computer as a high-end computer?

You need some sort of timer to let you know how long it's been since the last time through your game loop. In this case, you'll want to wait until a certain amount of time has passed (exactly how much is up to you--how fast do you want it to go?) before you update your game objects.

gusano79 247 Posting Shark

in this program i have to enter numbers in the tree
maketree() function is a recursive function
but it does not work properly.

Again, more detail would be helpful. What does "not work properly" mean to you here? What is it not doing that you expect it to? What is it doing right, if anything?

You'll get better results in this forum (and with software engineering in general) if you start asking yourself these questions--and answering them.

Just looking at the code, a few things stand out:

void maketree(struct node **root)

Why the double indirection? I don't think it's necessary, and it only confuses your code.

if(*root==NULL){
  //printf("Enter number");
  scanf("%d",&num);
  temp=(struct node*)malloc(sizeof(struct node));
  temp->data=num;
  temp->left=temp->right=NULL;
}

You create a new node here, but never assign anything to root , so it will always be NULL .

temp=(struct node*)malloc(sizeof(struct node));

You're allocating storage for all these nodes, but the memory is never freed. You should do that before the program exits. Here's an introduction to common malloc -related errors.

gusano79 247 Posting Shark

If you want help, please post a specific question. What about this code is troubling you?

gusano79 247 Posting Shark

Umm, does the trick work at basic C? I'm not sure since we've only been taught of Basic C at the moment. so far, with loops.

Oh, and at <stdio.h>.

You can do this in C. Don't focus too much on the technology; the question is about a mathematical algorithm, and the answer will be the same no matter what language you use to implement it.

gusano79 247 Posting Shark

I am working with g++. I always remove warning before running it. I don't know what happened. Thanks anyways.

Turn on warnings; they are useful. If you actually bother to read and understand compiler warnings, it will help you understand what you're doing when you write code.

gusano79 247 Posting Shark

What compiler can I use to build/run an flex scanner? I tried mircle and visual studio 2010 neither one would run the program.

I think you can use gcc for the purpose along with flex...

Most C compilers should readily compile the code that flex generates. By "run the program" did you mean "scan some input and run it through the generated lexer"? Or something else?

gusano79 247 Posting Shark

Hi, i have tried this, but can not get it to work.
From what im reading, doesn't clock() and timerStart have the same value? so it will not start?

Read about clock() . It's not really a "timer"--all it does is tell you what the time is when you call it. In order to find out how much time has passed, you have to call clock() again, and compare the two values.

From my (admittedly not super-clear) example:

clock_t timerStart = clock();

This happens right before the main loop. It tells us what time it was when the loop started.

Then, in the loop:

// Track only the number of seconds since timerStart
seconds = (clock() - timerStart) / CLOCKS_PER_SEC;

...figures out how many seconds since the loop started.

The call to clock() here happens every time through the loop, so it's possible that for the first time--or more, depending on how fast the loop is--it might return the same as the initial call to clock() . Eventually, though, enough time will pass and we're looking at the time elapsed since we assigned timerStart originally.

Then, when it's time to start counting again:

// Reset clock() here--actually, just track a new start time
timerStart = clock();

..reassigns timerStart , so we're measuring from the moment clock() gets called for the assignment--this effectively resets the timer.

So we've built a simple timer from a "what time is it?" library function. …

gusano79 247 Posting Shark

why dosen’t it allow me to use
2.
using Admin_Application.PresentationLayer.*;
can’t I use it the second way??

That's just the way the C# language is designed; there is no ' * ' like with Java's import directive.

What you can do, though, is this:

using Admin_Application.PresentationLayer;

Then you can refer to Proposal_in_Progress and Proposals_Submitted directly in your code. If those are classes, then I think this gets you what you want.

Also note: In C#, you're importing a "namespace", not a "package"--nitpicky details, perhaps, but the perspective shift might help: Namespaces have nothing to do with folder structure. The IDEs I use usually create a namespace block that matches folder structure when code files are created, but it's this declaration in the file contents, not its location in the file system, that determine the namespace.

Of possible interest: Comparison of Java and C#

gusano79 247 Posting Shark

Here's a timer class of mine that's put together a little differently. On Win32 platforms, it uses the Windows high-resolution timer if it's available, or clock() if it's not. On non-Win32 platforms, it compiles to use gettimeofday() .

Also of possible interest: clock vs gettimeofday

gusano79 247 Posting Shark

Make a simple timer class to simplify stuff. For example :

Beat me to it! =)

This is better; the timer details don't distract from your main loop.

gusano79 247 Posting Shark

the clock starts when the program is run and after 8 secs, FIVE moves position.
When i press F, i want FIVE to reset its position [which it does], and to reset the clock(), so that after 8 secs, FIVE will move again.
Anyway to do this?
Using Windows 7, visual studio.

Short answer is you can't reset clock() . It always returns the ticks elapsed since the program started.

What you can do is keep around some sort of "seconds since last time FIVE moved" variable, and reset it to the current number of ticks when you want to reset the clock. It might look like this:

int seconds;
clock_t clock();

// This keeps track of the start time for your 8-second timer
clock_t timerStart = clock();

// I added this to keep track of whether or not we're using the 8-second timer.
// This way, we can stop the timer when it triggers
bool timerOn = true;

while(true) // I'm assuming your code has this in a loop somewhere...
{
  // Only check the timer if it's "on"
  if(timerOn)
  {
    // Track only the number of seconds since timerStart
    seconds = (clock() - timerStart) / CLOCKS_PER_SEC;
		
    // Changed "==" to ">=" here; this catches instances where one check ends up
    // at 7 seconds, but the loop takes so long that the next one reads 9 seconds
    if (seconds >= 8)
    {
      FIVE.SetPositionX(-1);

      // Turning off the timer here; we …
gusano79 247 Posting Shark

I am trying to loop until length is meet but it only creates one char and I am trying to when it gets to certain char to skip and do nothing but loop until length is meet.

char symbol,symbols; 
string password;
for(int d=0; d < numericUpDown1->Value;++d) 
{
    symbol = rand() % 92 + 33; 
    /* ... */
    symbols = symbols + symbol ;
}
password = password + symbols;

Shouldn't symbols be a string ?

It looks like you want to concatentate stuff to it, but as written, the + operator changes its value instead, leaving it as a single character.

gusano79 247 Posting Shark

hey i know it is string

Ah. Wasn't sure if you knew the type; that's why I started where I did.

gusano79 247 Posting Shark

when i try to validate it it gives an invalidCastException.(the line is bolded, this is tha place where the error occurs)

...

how can i solve this.

Rephrasing your question: "Why isn't e.FormattedValue a DateTime ?"

A good next step is to figure out what type of object it really is. Try something like this:

private void dgvActions_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
  if (e.ColumnIndex == 2)
  {
    if (e.FormattedValue != null)
    {
      MessageBox.Show(e.FormattedValue.GetType().FullName);
    }
  }
}

Once you know what type e.FormattedValue really is, your new question can be: "Why is e.FormattedValue this type?" With luck, knowing what type it is will give you some idea of where it came from.

ddanbe commented: Good thinking! +6
gusano79 247 Posting Shark

Usually the results I get are like this: 16,16,19,25,25,21,18,15,15,23,23... so it's more or less random although you get to see that sometimes it doesn't have enough time to generate and there are some couples that are the same number.

"Doesn't have enough time" isn't correct here... that concept applies only when you're creating new Random objects. As Nick pointed out, you're not getting a wide range of random numbers, so it's normal that it would occasionally come up with the same one twice in a row. There's nothing wrong here.

I added a recursive function in one of the places that calls for this generation to occur so now it calls more often and i get things like: 25,25,25,25,25,25,25,25,19,19,19,19,19,19,19...

This is unusual. Could you post code for the recursive method?

gusano79 247 Posting Shark

This seems to complicate it more as I have to use this external engine to run my code.

You're right. Adding a scripting engine does complicate things for you, the developer, but it makes things less complicated for rule writers. This may not be important for your project; I'm just offering an alternative.

gusano79 247 Posting Shark

When i run it, ALL objects have the same dying age, so weird. So I added a breakpoint in the function that generates the dying age and guess what, it works perfectly when debugging but not in a normal run. So it's like the function doesn't have enough time to generate different values everytime the constructor calls it (10 times in a row) but it does have the time to generate different values if i'm debugging the program (going instruction by instruction).

How can i fix this? Why does it seems to not work properly when working without stopping everytime i call this function?

I think your problem is in here:

private int CalcularEdadFinal(int eF)
{
  Random randNum = new Random();
  diferencia = randNum.Next(0, 10);
  if (diferencia % 2 == 0) return eF - diferencia;
  else return eF + diferencia;
}

Every time you're getting a new final age, you're creating a new Random object. You're on the right track; the Random classes are getting created fast enough that each Random object gets the same seed, and therefore generates the same random numbers.

The MSDN documentation for Random says: "The default seed value is derived from the system clock and has finite resolution. As a result, different Random objects that are created in close succession by a call to the default constructor will have identical default seed values and, therefore, will produce identical sets of random numbers."

The solution to your problem …

gusano79 247 Posting Shark

Good idea gusano79, but I was thinking that he had to check many conditions (rows, columns, and boxes), so generating a permutation of a whole row at a time and then checking all 9 elements for those conditions may be just as slow as doing it one number at a time.

If you mean using rejection sampling with respect to the entire 9x9 grid, absolutely! I was just addressing the permutation issue.

An alternative would be as you generate the rows, modify each one if it doesn't fit the constraints. For example, if randomly-permuted row 2 has a number that doesn't fit, swap it with the next one after it in the row that does match all constraints. By the time you finish with the last row, you'll have a working Sudoku grid.

gusano79 247 Posting Shark

A friend of mine told me to use function pointers and then use a shared object or DLL to specify the external functions. Then the config file could tell the code where the DLL is and what the corresponding function names are.

That's one way to do it, but it isn't as flexible as it could be. It requires anyone creating rules for your expert system to write them in C and compile them before they can be used, which limits your rule-writing audience. As a suggestion, it would be easier to use if rules were specified as code in a text file that people wouldn't have to compile on their own. This means more work for you, but if you go with a well-known scripting language like Lua, it wouldn't be too difficult.

gusano79 247 Posting Shark

What you have described is called "rejection sampling". That sounds like a reasonable way to go about this to me. If you use std::vector to to store the elements you can then use find() from the stl to do the search. It shouldn't be that bad for something as small as a sudoku game.

I'd use rejection sampling if the sample space were much larger than the number of samples I needed, but for this, it seems like overkill.

So far we've been approaching this as a "generate some random numbers" problem, when it really isn't. You already know which numbers you want, i.e., 1-9 inclusive. What you want to be random is the order of these numbers; you're looking for a random permutation.

One way to do this is to start with a list of the numbers, and then walk through the list, exchanging each element with a random other element, which mixes them up nicely. This is called the Fisher-Yates shuffle.

Also, remember that the diagonals and each of the 3x3 square regions can't have the same number twice. Simply generating random permutations for each row doesn't guarantee these constraints will be met.

gusano79 247 Posting Shark

I have a treeview, in wich the user adds/removes dynamicaly nodes and a button wich should save the treeview structure in a database table when clicked. The thing is, that the depth is not known, so i need a way that i can get all-depth nodes and save the whole Treeview structure.

The Wikipedia article on tree traversal has some good explanations of the task you're describing, including some examples.

Exactly how you write the function will depend on your data model. If it uses a recursive relationship, you'll probably want to use a preorder traversal so that you have the parent row's key available when you're creating the child records.

I was always a bit confused about how to create a recursive function, so thats where i need you help. :)

... I thought that i need a recursive function, but if you have any better solution, be my guest.

I think recursion is appropriate here. You can traverse a tree without recursion, but I wouldn't sacrifice its expressive power unless you have constraints, e.g., limited stack space.


P.S. For a laugh, search for "recursion" on Google. =)

gusano79 247 Posting Shark

no one uses C these days

Says who? C is alive and well. For example, here's a list of free software written in C.

gusano79 247 Posting Shark

Well, this is bizarre.

Maybe call SoundPlayer.Load (see here) before you play the sound. It really shouldn't be necessary, but I think it's worth a try.

Other than that, I'm stumped. I found a post on MSDN that seems to be describing something very similar to what you're experiencing... unfortunately, the detailed article that it refers to appears to be missing. :(

gusano79 247 Posting Shark

That sounds like a good idea to me.

One thing to keep in mind is what search algorithm is being used. Sorting by access probability should work fine if it's "start at the beginning of the array and run through it until you find what you're looking for." You might have to adjust for different search algorithms--in general, you've got the right idea: put high-probability elements in places where the search looks first.

gusano79 247 Posting Shark

int a; counts as a tentative declaration in C. If you don't write in a default value, you can declare the variable again later. Try providing a value both times you declare it and you should get an error:

#include <stdio.h>

int a = 42;
int a = 42;

int main()
{
  a = 100;

  printf("fdfsa");
  scanf(&a);
}

You get the error in C++ because C++ doesn't have tentative declarations.

Also: Best practice in C is to only declare variables once. Otherwise, things can get funky really fast, especially if you have multiple declarations in different files... yuck.

gusano79 247 Posting Shark

How would you benefit from such information so that you minimize the search time?

I'm trying to think of a way to point you in the right direction without just giving you an answer... what have you come up with so far?

gusano79 247 Posting Shark

This might be a garbage collection issue... could you post a ZIP file with the form that uses the SoundPlayer and the Resources class?

gusano79 247 Posting Shark

@gusano79
Thanks for u r reply..
Correct me if I am wrong.. but are'nt SqlLite and MySQL Relational databases and not Object oriented databases ?

Yes, sorry! I'll read more carefully next time. :S

gusano79 247 Posting Shark