~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

^
A CEO of the company he would someday establish. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

^
A well behaved kid, avoids l337 speak.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There is something that doesn't work here:

The lengthy processing function requires values to be passed to it from the error display process. It does nothing to the values displayed, but it does need them to know what to calculate default values for.

I can't pass the values to the processing function if they haven't been set yet.

Also, site policy says I should not modify the html code with scripts. I need to set styles and values instead.

Also, you put in an alert. That alone will cause the display to complete. But I don't want to distract the user from what he is doing with an alert.

I guess I still don't get the big picture. As far as the processing function requiring the data is concerned, you can always make the function which is called before the processing function to make changes to the global variable(map or associative array). This way you don't need to pass anything. Plus you get to decide when to call the processing.

And the 'alert()' in my code was just an example.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Why not keep the function which just does only processing in background for while i.e. make use of setInterval and setTimeout functions which would give the code which displays names enough time to do its job.

Something like this:

<html>
<head>
    <script>
    var counter = 0;
    var hnd = null;
   
    function doSomething()
    {   
        //your lengthy processing function
        hnd = setInterval("calculate()", 3000);

        //your display function
        var d = document.getElementById('d');
        d.innerHTML = "<b>Hello to all</b>";
    }
   
    function calculate()
    {
        alert("Sum of 3  and 5 is 8");
        clearInterval(hnd);
    }
    </script>
</head>
<body onload="doSomething();">
    <div id="d"></div>
</body>
</html>

This way you can keep the function which consumes the most of CPU cycles to run at a later moment.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

How about posting some code so that we have something to chew on?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It seems that you have never interacted with clients who insist on having a 'popup' window or some clean up routines to be performed when the user attempts on closing or unloading the window. Though this may seem like a nonsense requirement for public domain sites, it becomes a nifty feature for intranet sites.

Even Google makes use of this confirmation thingy (try composing a mail and going back to inbox without sending it) by either using the 'onunload' event or some other trick for rich and interactive user experience. Come to think of it, when you think of web revolution in terms of applications which behave more and more like the desktop applications, the onunload suddenly seems to be a required feature.

Think out of the box and you would see of the different ways in which you can use such events for the betterment of applications as well as UI.

My personal experience has been that Opera scales the worst when it comes to handling events displaying the most random behavior.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Firefox, I don't know. Do they remember JS state through navigation history?
Yes, only when the user doesn't provide an 'onunload' event handler. Read more about caching in Firefox.

Plus as far as I know, there is a bug in Opera related to the 'onunload' event.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Methinks, PHP + MySQL, with a _lot_ of servers. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Why do you want to return a 2D array which is a member of the class when all you are doing in the 'population()' method is make changes to the same array? You can just call the 'population()' function in your constructor and your 2D array would have the updated/required values.

Your class design looks weird, but I will leave that up to you to figure out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> no i disagree, it doesn't take long to edit each post.
I disagree. I absolutely refuse to add code tags to posts of those members who have been already warned a number of times. Maybe you have a lot of time firing up your favorite IDE, indenting it and reposting it -- many don't.

> Newbies should not be blamed for their stupidity.
Stupidity yes, casualness and carelessness no. And come to think of it, this thread has been started keeping exactly these kind of people in mind who never bother using code tags.

> We don't want to ignore them, we want to help them.
Help begets help. If someone ignores me repeatedly, I would probably do the same.

And last but not the least, I completely am in favor of a script which reminds the newbies to use code tags along with the link to the page which shows how to use code tags. Considering that they won't be able to make their post, they would definitely consider reading the announcements more carefully. But considering most people block scripts from sites, a client side script won't do the job...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You can either pass the array considering as a sparse array i.e. by doing void someFunc(int** myArray) or you can pass it as a normal array by leaving off at the max the first dimension i.e. void someFunc(int myArray[][COLS]) . Also read this.

Consider constructing your 2D array using vectors since it is more flexible that way.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It can be done in two ways. The difference between the two methods is obvious: one of them(visibility) doesn't change the page layout while the other(display) does.

<html>
<head>
    <script>
    function hide()
    {
        var elem = document.getElementById('myP');
        elem.style.display = 'none';
    }
    function show()
    {    
        var elem = document.getElementById('myP');
        elem.style.display = '';
    }
    
    function hide2()
    {
        var elem = document.getElementById('myP2');
        elem.style.visibility = 'hidden';
    }
    function show2()
    {    
        var elem = document.getElementById('myP2');
        elem.style.visibility = 'visible';
    }
    </script>
</head>
<body>
    <form>
        <h2 align="center">Using the display property of CSS</h2>
        <p id="myP">Here is some text which I want to hide</p>
        <br />
        <input type="button" onclick="hide();" value="Hide" />
        <input type="button" onclick="show();" value="Show" />        
        
        <h2 align="center">Using the visibility property of CSS</h2>
        <p id="myP2">Here is some text which I want to hide</p>
        <br />
        <input type="button" onclick="hide2();" value="Hide" />
        <input type="button" onclick="show2();" value="Show" />
    </form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Come on Dani, even you know very well that people who don't use code tags after they have been warned 2-3 times are not the ones who would like to stick around.

> Besides, I point you back to Stymiee (our super mod) who initially
> came here just to make one spam post to advertise his services and then leave.
No wonder he is so good at detecting spam. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> we might have lost a potential tech saavy member who otherwise could have had a lot to offer
I disagree. A 'tech savvy' member who has a 'lot to offer' would definitely try to learn how to use code tags and understand the forum rules. Its the kids who don't give a damn to anything as long as their problem gets solved, we are dealing with. :)

> Of course, if AD and the other mods are happy with correcting the missing code tags
Its not happiness, its call of duty. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I guess this suggestion was put up before, but the problem being we can't add a 5 point infraction for not using code tags and it also doesn't make any sense. A warning or two or a two point infraction at the max. Plus the ones who come here asking for help don't plan on sticking for long so they obviously don't care. Come to think of it, most of them don't even know what infractions or warnings are !!!

One way we can make them learn is by letting them know that without code tags there is no hope for getting any help...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

^ A kid who is good at managing things, never giving up plus an ideal replacement for Eminem. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

^ The super-unknown :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you will look at the list of the things allowed in signatures...

Allow Basic BBCode [B]Yes[/B]
Allow Color BBCode [B]No[/B]
Allow Size BBCode [B]No[/B]
Allow Font BBCode [B]No[/B]
Allow Alignment BBCode [B]No[/B]
Allow List BBCode [B]No[/B]
Allow Code BBCode [B]No[/B]
Allow PHP BBCode [B]No[/B]
Allow HTML BBCode [B]No[/B]
Allow Quote BBCode [B]No[/B]
Allow HTML [B]No[/B][U][I][B]
Allow Smilies [B]No
[/B][/B][/I][/U]Allow [IMG] Code [B]No[/B]
Can Upload Images for Signature [B]No[/B]
Can Upload Animated GIF for Signature [B]No[/B]

I hope this clears up the matter... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> did anyone ask you bench?
Bad attitude. First in another thread and now this one. If you keep up this, I don't think you would be getting any help.

Always learn with an open mind and smile on your face otherwise getting help would become an herculian task.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Bench has given a good suggestion. But if you are not allowed to use maps, try using two parallel string arrays in which the location of the name of the animal and its description resides in the same location in their respective arrays.

const int SIZE = 3;
string animal[SIZE] = {"dog", "cat", "pig"};
string desc[SIZE] = {"bark", "meow", "oink"};

bool found = false;
for(int i = 0; i < SIZE; ++i)
{
    if(animal[i] == input)
    {
        cout << animal[i] << " -> " << desc[i];
        found = true;
        break;
    }
}
if(!found)
    cout << "No such animal exists";

I know this looks like a lot of work for a single user input, but is just another way of doing things, plus this is much more flexible approach instead of the hard-coded 'if...else' or 'switch' constructs. Since you are under going a programming course, I guess the focus would be more on logic and uniqueness than efficiency.

Killer_Typo commented: great idea! +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAIK, you can't do that since before the document is being unloaded, submitting the form is an illegal action.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I would request all of you to enclose your code in code tags so that it looks like code and not some vedic mantra. Please read this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Right shifting 1 by 8, 16 or 24 times isn't going to get you anywhere. After a single right shift, the number will become 0 and 'AND'ing it with any number would make no difference. Oh and BTW, 0XF is the same as 0XFF or 0XFFFFFFFF.

Try something like:

int main()
{
    int x,y,z, i = 16;

    x = (unsigned char) (i >> 2 & 0xff );
    y = (unsigned char) (i >> 3 & 0xF );
    z = (unsigned char) (i >> 4 & 0xFFFFFFFF );

    cout << "Original number: " << i << '\n';
    cout << "x=" << x << endl;
    cout << "y=" << y << endl;
    cout << "z=" << z << endl;
    getchar();
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A function with a base case(the terminating condition) and a recursive case, calling itself is known as Recursion. So whats basically happening in the above case is that to tackle the problem of the generation of result set which grow exponentially, and to simplify the solution, I decided to call the same function within itself seeing that each run of the function would generate a permutation for me.

Maybe you should wait a bit longer before submitting this solution or start reading your text book or the ample resources on the internet. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe this should be a good starting point:

// Untested

import java.net.*;
import java.io.*;

public class A
{
    public static void main(String args[])
    {
        try
        {
            ServerSocket ss = new ServerSocket();
            ss.bind(new InetSocketAddress(100));
            System.out.println("Application started");
            Thread.sleep(1000000000);
        }
        catch (SocketException e)
        {
            System.out.println("Application already running");
            System.exit(1);
        }
        catch(Exception e)
        {
            System.out.println("Application encountered some problem.");
            System.exit(1);
        }
    }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Dump the loops, what you need is a recursive algorithm which would work for arbitrary lengths of arrays. One of the way is using 'Heap Permute'. Here is a sample program which you can easily adapt to use with C style strings:

// Untested

const int SIZE = 4;
static int counter = 1;

void swap(int arr[], int one, int two)
{
    int tmp = arr[one];
    arr[one] = arr[two];
    arr[two] = tmp;
}

void print(int arr[])
{
    for(int i = 0; i < SIZE; ++i)
    {
        cout << arr[i] << "  ";
    }
    cout << " ------->  " << counter++;
    putchar('\n');
}

void permute(int arr[], int size)
{
    if(size == 1)
    {
        print(arr);
    }
    else
    {
        for(int i = 0; i < size; ++i)
        {
            permute(arr, size - 1);
            if(size % 2 == 1)
                swap(arr, 0, size - 1);
            else
                swap(arr, i, size - 1);
        }
    }
}

int main()
{
    int myArr[SIZE] = {1, 2, 3, 4};
    permute(myArr, SIZE);
    cin.get();
}
Killer_Typo commented: a very smart man indeed +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

libsdl is a better choice than BGI since it has a host of functions and has better tutorials and support on the internet than BGI. Considering that you have one entire month for making the game, you can easily switch to libsdl and finish off the project.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Though I personally haven't used it, this seems promising.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Even if you could do that, Firefox closes so quickly that nobody could read it.
The 'onunload' event fires before the browser is closed and if an alert is fired, stops the window from closing so 'closes so quickly' is not an issue as such. The problem here is that the OP wants a function which would be fired _if and only if_ the browser is closed which I don't think is possible using any standard way.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes, the visibility property works cross browser. But the catch here is that when the visibility is set to 'hidden', the element is still present there and still contributes to the layout of the page, it just isn't visible.

On the other hand, setting the display property to nothing('') will remove the element and effect the layout of the page since the element is physically not there (though I guess it exists in the DOM since we can always make it come back).

Choose the method which suits you the most in the given scenario keeping the above things in mind. Here is an interesting read.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I go into the irc... so why ain't i been rep spammed?
I am almost always there and I have never see you even once. :-)

> Why will it be reversed?
Too late, it already has been reversed.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This thread with its controversial title has stopped being of any use to anyone. Closed.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> there is a function in c++ called strlen() which tells you the length of an array
That would only be for char arrays, not any array.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> He didn't rep me at all!! Let's ban him!
*hint* He repped only those who hang out with him in the IRC.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Every object you create can have a draw method, which will know how to render itself on the screen. So you just need to call the draw method of each object in a loop for all objects in the game. The object will have its own information like color, position etc. so you don't need to worry about the location of drawing.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No, that won't work. Destruction of a class object has got nothing to do with the display. You would anyways need to actually 'erase' the thing which is on the screen. Thus your logic would consist of two parts: Game logic and graphics.

When the pawn is moved, you need to call the move() function on the object as well as repaint the screen instead of just destroying the object.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Like I said before, you need to read the function reference which is inbuilt in Turbo C to find it out since I have never worked with such things. Read something related to view ports concepts in Turbo C.

You have two choices:
- Use clrscr() and redraw the entire board with the updates
- Clear a specific portion of the screen using some functions in BGI.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I am sorry I highlighted the wrong part.

The statement you ought to change is: string[25] = '/0'; . It should be string[25] = '\0'; , which is a null terminator.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You should try to copy and paste the exact code provided to you, at least till you get the concepts right.

I pasted:

for(int i=0;i<24-1;i++)
{
    string[i] = getch();
}

You wrote:

for(int i=0;i < 24,i++)
  string[i] = getch();

Don't you think these two are different?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Why a null terminator after each character input? I guess it was a typo.

char string[100];
for(int i=0;i<100-1;i++)
{
    string[i] = getch();
}
string[i+1] = '\0';
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Damn, someone bad rep Rash for me as I have to spread some around first..
I have given him enough good points to last for 2-3 rounds... ;-)

joshSCH commented: Damn your rep power. I would bad rep you, but I'm afraid of the consequences :) +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> It's not often that I get to play with someone as uptight as christina.
Shoo, go away and mess with Betov and his henchmen. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I am afraid I don't know a lot about Turbo C graphics library and its specific functions. But for erasing the previous figure and redrawing it at a new location, consider erasing the particular part of the screen where s1 is present or clear the whole screen and draw a new s1 at the specified location.

You can find the function reference here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Read this. Simple and short answer: As far as the standards are concerned, main() always has returned an int as its exit status.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This is happening because you are setting the fill color as well as the border color of the fill to the same color i.e. RED.

This is confusing the floodfill algorithm which checks the color of the neighboring pixels to determine when to stop. By making the border RED, the check is never unsuccessful and it fills up the entire screen. This seems to be a bug with the function since this is not expected but you have got to live with it. :-)

Choose different colors for floodfilling and its border and you should be fine. Oh and BTW, main returns an int and not void.

#include<stdio.h>
#include<graphics.h>
//you don't need conio

int main(void)
{
  int driver,mode;
  driver = DETECT;
  initgraph(&driver,&mode,"\\tc\\bgi");  
  rectangle(105,90,125,110);
  setfillstyle(SOLID_FILL, RED);
  floodfill(115, 100, WHITE);
  getchar();
  closegraph();
  return(0);
}

}

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This can't be done in Javascript since its a client side technology. The only thing a Javascript code can store on client's machine is cookies which can't exceed 4KB, so I guess its out of question.

You would require some sort of server side language with a database to store the comments.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Satish, store the client information / state in client session i.e. session variables. Since the servlet class is loaded in memory on its first invocation and the client reqests just result in the creation of thread, storing state in servlet instance variables would make them kind of global, i.e. accessible by each and every client.

To store common information related to the entire web application, look into the <context-param> element of deployment descriptor. To store common information related to a particular servlet, look into <init-param> element of deployment descriptor.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe posting the entire code in code tags would help your cause.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

JAR files are normal zip files. Use any zipping software like Winrar or Winzip to open them.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Any point inside any closed figure.