Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

2451.

Solve : programming issue in excel?

Answer»

Hi!

I am trying to find a macro to use in excel VBA

I have two worksheets in excel. One contains a masterdatabase of all the information I have, and the other contains a subset of that information, with some columns having been updated. I need to find a way to search through my masterdatabase, and WHENEVER a cell in a certain COLUMN (C) matches a Cell value in Column B of the second worksheet, I want to use the values/formulas from that second worksheet. If they do not match, than I want to leave it as is..

I TRIED a do while loop that set my rows and columns as integers, but I had ERRORS with that.. any options with this?

Thanks!Without using vba, can you use the vlookup function? I know it sounds simplistic and thus probably isn't what you need but I thought I would put it out there just in case.

2452.

Solve : What's the best way for a newb to learn Java??

Answer»

And I mean a total Newb. I have no coding EXPERIENCE what so ever. I want to learn to write android apps and I want to learn the right way. By learning the language not using some GUI that does it for me but gives me no code.

ThanksYou can start with this.
http://www.freejavaguide.com/corejava.htmYou could try www.java2s.com it provides many code samples.

Thanks for those links. Good stuff. A free tip :
Each computer language, including Java, has the possibility of adding "comments/remarks" to the source code of the program. Each time you write a new program add comments where necessary.
These comments are very useful when you have to change a program THREE years later or so. After three years you don't remember this program very well and then these comments will help you to remember things more quickly.
A good PROGRAMMER always adds comments to his programs and they are never a WASTE of time.
Thanks Eric,

I'm sure it will TAKE me some time to even figure out what the right notes are, let alone the right code.I marked this solved because I'm sure anyone with the same question will find this thread useful, but please don't hesitate to add more advice.

Another related question would be are there any threads in these forums that I might find useful in this learning process. If anyone knows of any I'd love to see them.Thanks for the free java guide link - very helpful for the beginner I have used that before myself and I can vouch for the ease of use and you should be able to pick up Java. Just be patient and don't go too fast.For a total new beginner, I suggest to go through the APRESS beginners java books. Those books are written in simple manner and it’s easy to understand.

2453.

Solve : Help with Space Shooter in C++ and SDL!!!?

Answer»

Hi. I'm currently in the process of writing a space shooter type-of-game in C++ using the SDL API. I have everything working great, but I'm having some trouble getting my spaceship to fire a laser. I know how to do this, but I'm using three different CLASSES that all inherit from each other, and I can't get anything to work from my Laser class. This is the error message I get:

In file included from space.cpp:11:
classDefinitions.h: In member function 'void SpaceShip::handle_ship(bool&, SDL_Surface*, SDL_Surface*)':
classDefinitions.h:85: error: 'handle_laser' was not declared in this scope

I have all three files as attachments in TXT format so I could send them. Thanks all for all of the help

[recovering disk space - old attachment deleted by admin]Generally, inheritance implies an is-a relationship between class types.

Code: [Select]class SpaceShip : public Alien
A SpaceShip is-a Alien seems a bit weird;Same with the Laser... that doesn't help much though, heh.



I'm guessing that this is where you are getting the error:

Code: [Select] if (event.type == SDL_KEYDOWN) {
if (event.key.keysym.sym == SDLK_SPACE) {
handle_laser(scr, bGround)

Consider the message. "Not declared in scope". "But it's right above it!" you say; true, but look at the signatures:

SpaceShip::HandleShip and Laser::HandleLaser; HandleShip is within the SpaceShip class; HandleLaser is within the Laser Class.

Within the SpaceShip class, there is no "laser" instance; I think what may be confusing things here is that you are mixing up the implementations of the various classes. (that is, you write the implementations for the various routines in the same file) This of course isn't illegal, it's just not very common. Generally, the approach is to have a separate header file and a separate cpp file for each class definition; then in each other class header that uses them, you add a #include "classname.h".

I don't know if I explained that very well. In any case, within the implementations of a class, there is an UNSEEN argument- the "this" pointer, which points to the instance of the object the method "BELONGS" to; this allows methods to modify the class-instance data (for example, if you were to have two lasers on the game field, they would still use the same code for handling their actions, but the "this" pointer for each would point to something else. Of course, you aren't using any instance fields (such as positional data) which is a tad curious IMO but hey, WHATEVER works.

Long story short: you haven't created any instances of the Laser class; so you cannot call the instance methods of the Laser class directly from the Ship.

2454.

Solve : php deleting file?

Answer»

hi, in my application i would upload a file to a certain directory then after i would be able to DELETE it but then a got a warning


Warning: unlink(mydirectry/file.csv) [function.unlink]: Permission denied in C:\xampp\htdocs\dum\fac\submit_successfullyg.php on line 84

heres my code

Code: [Select] $myfile = 'mydirectry/file.csv';

if(!file_exists($myfile)) {
echo "File not found. Make sure you specified the correct path.\n";
exit;
}
else
unlink($myfile);The web server must have set the read/write permissions for that file or folder.

On a linux server you would use 0777 chmod. Something like (not tested) ...
Code: [Select]chmod($myfile, 0777);
unlink($myfile);
Also note if there's more folders/files under a folder your using 'unlink' on, ensure you create a recursive delete method. Since it's only one file you shouldn't need to worry about this. well i'm using windows 7 and XAMPP, and i try 0777 and 777 but it didn't work.I've never used XAMPP before, chmod is a linux command probably won't work in your case.
Have you setup a webserver on Windows 7 to host or is this just a temporary testing thing?oh i see, i just using windows 7 as a testing thing but probably it would be host in linux i think!!Yep, you'd probably be hosting on Linux so it shouldn't be an issue.

As an FYI, I searched on the PHP.net site and saw the following comment:

Quote

Under Windows System and Apache, denied access to file is an usual error to unlink file.
To delete file you must to change file's owern.
An example:

<?php
chown($TempDirectory."/".$FileName,666); //Insert an Invalid UserId to set to Nobody Owern; 666 is my standard for "Nobody"
unlink($TempDirectory."/".$FileName);
?>

Not sure if that works. Anywhoo, is just an FYI.Quote from: http://www.php.net/manual/en/function.unlink.php#85938
To ANYONE who's had a problem with the permissions denied error, it's sometimes caused when you try to delete a file that's in a folder higher in the hierarchy to your working directory (i.e. when trying to delete a path that starts with "../").

So to work around this problem, you can use chdir() to change the working directory to the folder where the file you want to unlink is located.

Code: [Select]<?php
$old=getcwd();//Savethecurrentdirectory
chdir($path_to_file);
unlink($filename);
chdir($old);//Restoretheoldworkingdirectory
?>
HY. I runned into that *CENSORED* problem too. And after days of searching I finally found this software: *SPAM*.

It's GREAT. You can find it here: http://www.deletelongfile.com
2455.

Solve : I'm trying to build my own RPG-style game?

Answer»

I have some experience with a couple different programming languages, but very little with creating anything resembling a sophisticated, or even friendly, interface. I've heard that Flash is a reasonable approach, but I know ZERO about programming in/with flash. I am also only self taught...

What would be a good way to create an RPG-style game? Prefer open/free type options. Willing to learn a new language.It depends on if you want to learn in the process or just have a good game you can say you made.

Here are some options:

If you want a really fast and easy way to make an RPG without learning much, then you should use GameMaker.
If you want to learn a new programming language and build your game from scratch, then use C with Allegro.
If you want to make a 3D RPG game and don't want to learn much, then use Unity (not free).
If you want to learn and want a 3D game, then use Irrlicht engine with C.
If you want to create a game with a 'classic' feel, then use QBasic.

If you are interested in one of these options, I can give you more in-depth information.Quote from: Linux711 on November 08, 2010, 08:18:41 AM

If you want to create a game with a 'classic' feel, then use QBasic.

That doesn't make a whole lot of sense... what is a "classic" feel and how does QBASIC provide it?Quote
That doesn't make a whole lot of sense... what is a "classic" feel and how does QBASIC provide it?

The games that you develop using qbasic run under DOS. The PC speaker and 320x200 VGA/CGA graphics make it seem like a classic DOS game that was made in the early 90s.Quote from: Linux711 on November 08, 2010, 10:54:55 AM
The games that you develop using qbasic run under DOS. The PC speaker and 320x200 VGA/CGA graphics make it seem like a classic DOS game that was made in the early 90s.
Doom was made in the early 90's and certainly can be called a classic DOS game. However I fail to understand how QBASIC even comes close to approximating that experience. Additionally, it would seem that you are not describing "classic" DOS games from that era as much as you are describing the crap of the crop of the time.

Just because something creates "DOS games" doesn't instantly give those games a classic feel. That has to be added intentionally. The only games using the PC speaker after around 1993 were not "classics" as much as they were shareware cruft. Additionally, it sounds more like you are using "classic" to refer to text-based RPG games, which is a rather large generalization, and in no way requires a console interface.

Either way, suggesting anybody use QBASIC for any purpose is stupid. The assumption here is that if they produce a game, they want to get other people to try it as well. QBASIC cannot compile so they will have to distribute it as source, and hope anybody who wants to try it is not running a 64-bit OS and KNOWS how to get QBASIC and knows how to use it to start the game. This directly flies in the face of the fact that they implicitly want to create "anything resembling a sophisticated, or even friendly, interface." Which undebatably QBASIC doesn't even begin to provide.



Quote from: icedragon668 on November 07, 2010, 07:54:48 PM
I have some experience with a couple different programming languages, but very little with creating anything resembling a sophisticated, or even friendly, interface. I've heard that Flash is a reasonable approach, but I know ZERO about programming in/with flash. I am also only self taught...

What would be a good way to create an RPG-style game? Prefer open/free type options. Willing to learn a new language.

Flash would be a good option, of course you would need to have Flash in order to work with it. I won't lie and say it's "simple" to make a game, but I've made a few simple games, such as a frogger game, pretty easily, so it can't be that bad. The language is called "ActionScript" and seems pretty powerful, if it is a bit confusing syntax-wise at times.

Barring that, I'd go with one of the .NET languages. I'd stay as far away from C and C++ unless you are planning to write an Operating System, since they will unnecessarily complicate things. Arguments about "being more portable" are also baseless, as in many ways C# and .NET are more portable to Linux then C or C++ are. (C & C++ are "source compatible", which means you would have to recompile it for each platform; and even then it's only theoretical, since you will almost certainly have to make changes to account for the different systems. With .NET, as long as you avoid using the various Windows-only framework components (which sort of necessitates creating a Console game) you can run it on Linux using Mono.

Of course, you could also get a similar and even better effect with Java, which is quite similar in many ways. The advantage here is that you can both use graphics as well as create an Applet that you could plop on a WEB page.

Quote
QBASIC cannot compile so they will have to distribute it as source

False

Quote
suggesting anybody use QBASIC for any purpose is stupid

It's the best way to make a DOS game. The only other option is to use some ancient C compiler like borland and that would suck.

Quote
Flash would be a good option
Quote
I'd go with one of the .NET languages.

The problem with these is that your not going to get that kind of classic RPG ambiance; your going to have to emulate it and because of that, these option would not be MY first choice. But if you want it to reach the most people, then yes, you should use flash.

The good thing about qbasic though, is it's free and flash is not. Visit this site:
http://www.petesqbsite.com/Quote from: Linux711 on November 08, 2010, 12:58:34 PM
False
True. Prove otherwise.

QBASIC != QuickBasic, QBASIC is free in some older Operating Systems. QuickBasic is not. QBASIC cannot compile the programs you create in it. QuickBasic can.

Quote
It's the best way to make a DOS game. The only other option is to use some ancient C compiler like borland and that would suck.
First, wether QBASIC is the best to make a DOS game is irrelevant. Nowhere in their original post do they make even an implication that they want their game to run or work with DOS. Those implications can only be found in your replies. Even so, AGAIN: QBASIC does NOT COMPILE executables. QuickBASIC does, however it's no newer or more capable then any number of competing products, such as the aforementioned Borland C (or even better, Microsoft C Compiler), which was still being updated long after QB 4.5 (and even QBX) were essentially abandoned by MS.

Quote
The problem with these is that your not going to get that kind of classic RPG ambiance; your going to have to emulate it and because of that, these option would not be MY first choice. But if you want it to reach the most people, then yes, you should use flash.
What the *censored* are you talking about? "classic RPG ambience?" DOS doesn't even HAVE any "classic RPGs" in fact even finding a game that can fit today's definition of an "RPG" is difficult, and those you do find both barely fit that definition and aren't very good in comparison to RPGs that everybody generally associated with the genre, such as those created by Square. In fact, the only thing those DOS RPGs that do exist have in common is terrible control mechanisms, buggy implementations and generally bad execution of the concept. These HARDLY constitute "ambience" you would want to emulate, nor are they intrinsic to the operating platform.

Quote
The good thing about qbasic though, is it's free and flash is not.
FreeBASIC is free too, shares a lot of syntax with QBASIC and QuickBASIC, and actually allows you to compile, which despite any claims to the contrary QBASIC does NOT. FreeBASIC also compiles to both DOS and windows and (I think) Linux, as well.

www.freebasic.net


Quote
Visit this site:
http://www.petesqbsite.com/

www.site.com websites are all terrible in concept and especially in the case of something as antiquated as QBASIC only proves how self-deluded people can get.

Personally for 3d games i'd recommend Unity http://unity3d.com.

I've only had a play with it myself but if you can get your head around it it is great. There is a free version and a pro version.

I've also heard that Dark Basic is good although I have yet to try it. It is commercial software but they seem to have an ad-supported free version for home users. http://www.thegamecreators.com/?m=view_product&id=2000&page=index. The manufacturer also seems to offer other game development software.If you don't want a graphics game and instead prefer a MUD (text based game) then I'd go with building a PHP program on a free webserver like www.justfree.com. I've done this twice, and for the last one GOT funding and now a real server (check out the link in my signature).

It's a lot of fun and not too hard, working with PHP/html/css is simple, there's a lot of tutorials, and once it's up it's up and can be played worldwide.

That's my two cents anyway ^^
2456.

Solve : How to add a multiply & division buttons in the program code????

Answer»

Sir I runned this program already but without the multiply & division buttons in the program code.And please help me sir!!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace calculator2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void txtDisplay_TextChanged(object sender, EventArgs e)
{
}
double total1 = 0;
double total2 = 0;
double answer;

private void btnOne_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnOne.Text;
}
private void btnTwo_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnTwo.Text;
}
private void btnThree_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnThree.Text;
}
private void btnFour_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnFour.Text;
}
private void btnFive_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnFive.Text;
}
private void btnSix_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnSix.Text;
}
private void btnSeven_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnSeven.Text;
}
private void btnEight_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnEight.Text;
}
private void btnNine_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnNine.Text;
}
private void btnZero_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnZero.Text;
}
private void btnClear_Click(object sender, EventArgs e)
{
txtDisplay.Clear();
}
private void btnPlus_Click(object sender, EventArgs e)
{
total1 = total1 + double.Parse(txtDisplay.Text);
txtDisplay.Clear();

plusButtonClicked = true;
minusButtonClicked = false;
divideButtonClicked = false;
multiplyButtonClicked = false;
}
private void btnEquals_Click(object sender, EventArgs e)
{
if (plusButtonClicked == true)

{
total2 = total1 + double.Parse(txtDisplay.Text);

}
if (multiplyButtonClicked == true)
{
total2 = total1 * double.Parse(txtDisplay.Text);
}
else if (minusButtonClicked == true)
{
total2 = total1 - double.Parse(txtDisplay.Text);

}
else if (divideButtonClicked == true)
{
total2 = total1 / double.Parse(txtDisplay.Text);
}
txtDisplay.Text = total2.ToString();
total1 = 0;
}
private void btnPoint_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnPoint.Text;
}
bool plusButtonClicked = false;
bool minusButtonClicked = false;
bool divideButtonClicked = false;
bool multiplyButtonClicked = false;
private void btnMinus_Click(object sender, EventArgs e)
{
total1 = total1 + double.Parse(txtDisplay.Text);
txtDisplay.Clear();

minusButtonClicked = true;
plusButtonClicked = false;
divideButtonClicked = false;
multiplyButtonClicked = false;
}

private void btnMultiply_Click(object sender, EventArgs e)
{
total1 = total1 / double.Parse(txtDisplay.Text);
multiplyButtonClicked = true;
divideButtonClicked = true;
minusButtonClicked = false;
plusButtonClicked = false;
txtDisplay.Clear();
}

private void btnDivide_Click(object sender, EventArgs e)
{
total1 = total1 / double.Parse(txtDisplay.Text);
multiplyButtonClicked = true;
divideButtonClicked = true;
minusButtonClicked = false;
plusButtonClicked = false;
txtDisplay.Clear();

}
}
}Sir please reply me now if my posts here is correct.And please post me a message or example of correct format of code that can be post here.
Because I can`t move on in my program code in C sharp because of some errors I did recently here.Okay, If you are the one by deleting my duplicated posts here.That`s good.And I`m very thankful for that sir!! And how it is sir that until now I don`t have RECEIVED a answer for the question I posted here?? Quote from: dave_trodeau2000 on November 12, 2010, 12:19:47 AM
And how it is sir that until now I don`t have received a answer for the question I posted here??

You asked this question before, and received a very pertinent answer.
Because I`m really don`t know how to delete my duplicated posts here!! I meant, you asked, before, "How is it that until now I haven't received an answer?". You asked this

Quote
Sir I am waiting from then that my asked question in the date of Oct.04,2010, 4:26A.M.About my C# questions.And hoping to be answered.So now it is no replied messages in my inbox.So how it is Sir like that??and hoping to you sir more power!!

The answer is "because nobody posted an answer". There is no guarantee that every question will be answered, and it is foolish to complain if you do not get one. In fact, doing this may make people who know how to help you DECIDE not to post.

Sir I`m very thankful for that answer.It`s because I`m really don`t know who is answering my questions here and I think there are working in this site and paid it to assigned for answering a questions here about software programming.
And sir can you help me to delete my question here that is my program code in c sharp and a question in above of that code.Because that questions I asked there is very unclear and lack of grammar to be understand by the members here. Quote from: dave_trodeau2000 on November 13, 2010, 08:16:32 AM
Sir thank you for this answer.It`s because I`m really don`t know who is answering my questions here and I think there are working in this site and paid it to assigned for answering a questions here about software programming.

Nobody is paid here, any answers you might get are from other members like yourself, who may or may not know the answers you need, and are free to answer or not. If people were paid, where did you think the money comes from? Did you pay any money to join or ask questions?
Because I`m really new or I am a beginner to asked a questions in forum like this and I have no other forums like this that are the answer is right away or in the same day..And I feel comfortable for this site.. Quote from: dave_trodeau2000 on November 13, 2010, 08:16:32 AM
Because that questions I asked there is very unclear and lack of grammar to be understand by the members here.

That's somewhat true, but I understood enough to know exactly what the problem was, I believe. Your code contains both of the routines that you SAY you don't have. So I think it follows from that that you have both the button and the code but you cannot "link" them together; that is, you've messed about with them enough that the event has gotten decoupled from the UI element. (this usually happens when you change the name of the procedure).

I also know that if you had read the Programmers guide at all, especially regarding the help for the Visual Studio UI, you would know exactly what do do. You can either use the PROPERTIES window to quickly re-link the events back together with their functions or you could even do something really crazy like double-click on the relevant buttons, at which point new Click Event procedures are generated, and use Copy-Paste to move the code from the old decoupled procedure to the new one.

The former is quite a lot easier.

This is one thing that I personally find rather annoying. nowadays, having a firm grasp of a programming language isn't enough to develop applications in the long-term, since nowadays we have to work with designers. One should make an effort to learn the User-interface and conventions of said environment for the creation of your UI elements, and "connecting" those UI elements with the appropriate code. To be clear, it's not annoying that people that are first learning it have trouble with problems that require UI elements tof the environment that are right in front of their face, it's when people post a question on the forum about it and seemingly stop trying to solve the problem themselves. It's been almost a week since you posted this. You would expect maybe a glance or two at the Visual Studio Programmers guide; specifically, the information on the Properties window.

That was why I didn't answer. Both the solution as well as how to find it are neither obscure nor difficult to discover. It's a lack of initiative to blame here, a tendency to "oh, I hit a roadblock- I give up" and then post on a forum, wait a week, and essentially complain that nobody responded.

But sir there are no definite answer if there are really experienced to solve any problems about programs in c sharp in this forum,am I right???And maybe myself only or my friend programmer could answer my questions someday about my calcultator program?? Quote from: dave_trodeau2000 on November 13, 2010, 10:54:01 PM
And maybe myself only or my friend programmer could answer my questions someday about my calcultator program??
I just gave you two answers to your problem.And sir I have a duplicated posts again here.So can I please you sir to delete that again.Please!!! Please!
thank you3x sir!!!
2457.

Solve : Help my C++ doesn't work?

Answer»

Hi i've started learning to program C++ some weeks ago. I have this pdf book that i learn from but i have run into some troubble with a program. The program is as stated here:

#include
using namespace std;

void cube(int *n, num);

int main()
{
int i, nums[10];

for(i = 0; i < 10; i++) nums = i + 1;

cout << "Original contents: ";
for(i = 0; i < 10; i++) cout << nums << ' ';
cout << '\n';

cube(nums, 10);

cout << "Altered contents: ";
for(i = 0; i < 10; i++) cout << nums << ' ';

return 0;
}

My book tells me to write that. It should show something about array passing from one function to another but i simply cant get it to do as its supposed to. I use borland c++ compiler 5.5 to compile with.

please help me.
Sincerly
Vikken
hi..vikken.!
i'm just wondering if that code is correct or n0t..
the 'nums[10]' variable was DECLARED as an array right? now, in your code inside the for loop, you assign a value to the variable 'nums' which is n0t an array, coz' it does n0t have []..why n0t try to make it nums[ i ]=i+1;

..hope it helps.!actually, it does include the indexing square brackets, but since it was directly in the post, the forum interpreted the [ i ] (without spaces) as an italics TAG.

here is the full code, in a helpful code tag

Code: [Select]#include <iostream>
using namespace std;

void cube(int *n, num);

int main()
{
int i, nums[10];

for(i = 0; i < 10; i++) nums[i] = i + 1;

cout << "Original contents: ";
for(i = 0; i < 10; i++) cout << nums[i] << ' ';
cout << '\n';

cube(nums, 10);

cout << "Altered contents: ";
for(i = 0; i < 10; i++) cout << nums[i] << ' ';

return 0;
}


Since I'm here, I may as well offer some relevant help;

The first thing that jumps out is that although you declare the "cube" function, you haven't provided a DEFINITION for it; therefore my attempts to compile as-is give me unresolved externals.

However, I added this definition in, so I could proceed to test:

Code: [Select]void cube(int *n, int num)
{

for(int i=0;i<=10;i++)
n[i]=n[i]*num;


}

Pretty simple; it simply multiplies each element of the 11 element array (as you declared it; note that declaring a variable like variable[n] will create a array with n as the highest index; therefore you get n+1 elements, since 0 is the lower bound.)

I get the following output, which confirms that it works:


Code: [Select]Original contents: 1 2 3 4 5 6 7 8 9 10 11
Altered contents: 10 20 30 40 50 60 70 80 90 100 110
(I also changed the for loops from " for(i = 0; i < 10; i++)" to " for(i = 0; i <= 10; i++)")


It definitely seems that it works just fine.

truthfully, the square brackets are actually memory indexing operators; you can use them on any type in C, but C++ restricts their use and you get warnings when you do freaky stuff sometimes, but largely, it's possible to use it for nearly anything. Any pointer type, for example, can be indexed into.

with a pointer type (in the "cube" prototype, the first parameter is being passed as a pointer to a int) when you use the array/memory indexing operator (the square brackets) it returns the value in memory at the pointers position plus the array index times the array size. For example, lets say you have a char array "chars" and it contains the string "characters". with a pointer, you can do something like this:
Code: [Select]char *charsp = &chars[0];
singchar = charsp[4];
It looks pretty straightforward, but remember, charsp is not an array type! so how does it work? As I said, it's indexing directly into memory at that location based on the passed index. with your standard char, this means it is accessing the 4th byte after the byte pointed to by the char itself (in this case the first one). However, if instead of char types we were dealing with, say, wide characters, then each char would be two bytes, so the indexing would do the math of 4*2, so it would grab the two byte character at position 10 (we add two because the first element is also two bytes).

I hope this helps clear things up; you weren't specific as tou what kind of trouble you were running into, and the code you provided works fine for me (Visual Studio 2008, btw) So I thought I'd see if I could help clarify the array/pointer business.BCP, I see you cleverly understood what a "cube" function should return... it's always good to help people get top marks for their homework.


Quote from: Salmon Trout on November 14, 2010, 10:24:19 AM

BCP, I see you cleverly understood what a "cube" function should return... it's always good to help people get top marks for their homework.

There is no possible definition for a "cube" function that would accept two parameters that I'm aware of. My first thought was of course to simply make a cube function, but clearly the prototype was important. I had to guess what the function did from the context, and the parameters make the obvious choice of f(x)=x*x*x infeasible. My second guess would be a cube function that for some reason cubes only the nth parameter, but it would be dumb to only cube the 10th parameter and leave everything else untouched, and I certainly hope a book isn't advocating such nonsensical parameter conventions like creating an otherwise bog-standard cube function but making it accept an entire array for the purpose of cubing only a single element.

And since no sample output was provided, I just made a standard function that simply used it's parameters in a meaningful way. To my UNDERSTANDING the entire purpose of the exercise was to deal with arrays; and I would certainly hope they would use their definition of the cube() function rather then mine; being that mine was only created due to the lack of the latter and the inability to compile and test without a meaningful definition.





Thank you very much it was very helpful Quote from: Vikken on November 14, 2010, 12:34:39 PM
Thank you very much it was very helpful

You're welcome

You might want to double-check my information against a trustworthy source; I did no research for it and it's from my memory so chances are I made a few errors in my recollection of the semantics.Quote from: BC_Programmer on November 14, 2010, 09:14:42 AM
actually, it does include the indexing square brackets, but since it was directly in the post, the forum interpreted the [ i ] (without spaces) as an italics tag.
..oh.! plz excuse me sir, for im new here(actualy that was my first post)...n0w i kn0w..thanks.!

@TS
you may define the cube function first..for what u have s just a prototype..
2458.

Solve : Database?

Answer»

Hey I've GOTTEN this assignment to MAKE a application for a doctor.(Fictional assignment)

I have to make a webpage WICH is easy. Then a need to make a database to store the data wich is inputed in the webpage any1 can GIVE a idea?
http://office.microsoft.com/en-us/access-help/create-an-access-database-HP005187442.aspxCan it be set to go with html?Okay i GOT my database made sort of... But can any1 give me and hint to how i could make the webpage i will use to insert data with?

2459.

Solve : Recursion in C++?

Answer»

I am learning programming strategies in c++ and am working on RECURSION. I want to do the following task using recursion: Delete all the nodes in a that match the parameter I pass it, the trick is I want to delete them all but the last occurrence in the linked list.

so if my linked list was:

6->4->6->5->6->7->NULL

and I called the function delallbutlast (6);

The linked list would be as followed after the function call:

4->5->6->7->NULL

What would the pseudo. code be for this? I still trying to figure how recursive algoriths work especially one like this. Please help.There is no reason to USE a recursive algorithm here. An iterative one works just as well.


Of course seeing as your "dellallbutlast" definition, which one might logically conclude to delete all items but the last non-null entry (7) is instead deleting the first and third item of which the only COMMON attribute is the fact they are 6, which might make for a sensible definition (if an oddly named one) if it was not for another 6 element being left, again, for seemingly no reason. This makes it a tad difficult to even know what the point of said function is...

EDIT: oh wait, I see what it does, HEH didn't notice it had an argument. going to look over it.



First: it still doesn't make a whole lot of sense to use a recursive algorithm; an iterative one works just as well.
1. define a variable that holds a pointer to a linkedlist node; referred to as ltemp here.
2. Iterate through the list. With each node:
if the value matches our given parameter:
remove the node pointed to by ltemp, if ltemp!=null; (this is done by setting ltemp.prev.next to ltemp.next and ltemp.next.prev to ltemp.prev, and then deleting ltemp)
assign the value to ltemp.
3. (end of loop).


This would work since it only deletes the previous item it found when it finds a new one; no item will be found after the last one so it will not be deleted or removed.







2460.

Solve : Help with Objects and Inheritance?

Answer»

I have an object CALLED Comparable as my Base Class. Then I have two derived classes from this class called, CmpInt and CmpString.

In CmpInt (short for Comparable Integer) there is a method that GETS the classes integer value called value. The method is called geti().

In CmpString (short for Comparable String) there is a method that gets the classes string value called value. the method name is gets().

I want to create a loop that runs through an array of Comparable Objects and grab this data (value).

How do I check what functions it has? I want to do something like:

Code: [Select]for(int i=1; i&LT;=sz; i++)
{
//I do not know how to write this object checking
if (((CmpInt *)A[i]))//If it is a CmpInt callgeti
{
COUT<<"Object is CmpInt use geti()"<<endl;
cout << ((CmpInt *)A[i])->geti() <<endl;
}
else //It is a CmpString call method gets()
{
cout<<"It not a CmpInt, it needs to call gets()"<<endl;
cout << ((CmpString *)A[i])->gets() <<endl;
}

I need to know what it is to call the right method. How do I do this?

2461.

Solve : gpedit in cmd?

Answer»

is there any command for EDITING gpedit through cmd or bat files PLEASE help

2462.

Solve : Java Quiz Script Help?

Answer»

Hey guys.

I'm working on a quiz script and I just can't get this right. At the moment, I'm doing the grading scale. Each question is worth 50 points. Can someone finish the script or point me in the right direction?

import javax.swing.JOptionPane;


public class TakeATest {
public static void main(String[] args){
double testScore = 0.0;
double newTestScore = 0.0;
boolean questionTwoCorrect = false;
boolean questionOneCorrect = false;
String questionOneAnswer = "blue";
String questionTwoAnswer = "green"; {

String questionOne = JOptionPane.showInputDialog("What color is the ocean?"); {

if (questionOne == questionOneAnswer) {
boolean questionOneCorrect = true;
} else {
boolean questionOneCorrect = false;
}

String questionTwo = JOptionPane.showInputDialog("What color is grass, that is alive?"); {

if (questionTwo == questionTwoAnswer) {
boolean questionTwoCorrect = true;
} else {
boolean questionTwoCorrect = false;
}

}
if (questionOneCorrect == true) {
newTestScore = testScore + 50;
}
}
}
}
}

I keep getting an error that "questionOneCorrect" and "questionTwoCorrect" are duplicate variables (for each of them.)

Any help is welcome,

BRAs for your duplicate definition issue, as I'm sure you're aware, declaring a variable is done in the form:
= (the initialvalue is optional).

Note that you do this multiple times for QuestionOneCorrect and QuestionTwoCorrect; when you assign them to false.

when you are simply assigning a value to an existing variable, you don't include the type specifier, since that means you want to declare a new variable (and of course you can't have two variables with the same name, thus the error).

Also, the METHOD you've used essentially requires copy pasting; I'm sure the entire purpose is to ask a bunch of questions, get a bunch of answers, and tally the results; why not make the computer do the repetitive stuff, rather then you copy-pasting the various questions?

One method to do so would be to USE arrays. This might be something you've not yet learned, but they are essentially designed for THINGS like this. Here is my version, designed intentionally to make it easier to change questions and their corresponding answers:

Code: [Select]import javax.swing.JOptionPane;
public class TakeATest
{
public static void main(String[] args)
{

int TotalPoints=0;
int correctanswers=0;
//Create the two arrays;
String[] Questions = new String[]
{
"What color is the ocean?",
"What color is grass, that is alive?"
};
String[] Answers = new String[]
{
"blue",
"green"

};

//create an answers array that holds the various answers given. this could be used for future additions to the
//results screen.
String[] AllAnswers = new String[Questions.length];


//loop through each item in the array; i will go through each index in the array. each index will be used to get the question and answer for that question.
for(int i=0;i<Questions.length;i++)
{
//ask each question...
String AnswerGiven=JOptionPane.showInputDialog((Object)Questions[i]);
//store the answer they gave into the "AllAnswers" array.
AllAnswers[i] = AnswerGiven;

//see if the answer given is correct:
if(Answers[i].toLowerCase().equals(AnswerGiven.toLowerCase()))
{
//the answer the user gave and the answer we have match; give them points.
TotalPoints+=50;
correctanswers++;

}

}

//display results.
String resultdisplay = "TEST Complete. Out of " + Questions.length + " questions, you got " +
correctanswers + " correct, for a total score of " + TotalPoints;

JOptionPane.showMessageDialog(null,resultdisplay);

}

}

2463.

Solve : MySQL - add integer to column resulted from SUM function?

Answer»

Hey guys,

I need help, I have never done something like this but I'm sure it should be possible.

Basically TAKE this query:

Code: [Select]SELECT SUM(column1) AS total
FROM table1
I would like to KNOW if there is a WAY to add say 5 for example to the total column from the WHERE clause.

Something like this:

Code: [Select]SELECT SUM(column1) AS total
FROM table1
WHERE total + 5
That's all. Reason why I want to achieve this is because I have 2 TABLES which return almost the same data so I need to add column results together. If there is an ALTERNATIVE I would like to hear that too.

Thank you in advance guys.I don't think I quite understand; WHERE is used to determine what fits a query; essentially it either matches, or it doesn't.

if you want to add 5 to the resultset, you can use SELECT SUM(column1) + 5, I believe.

2464.

Solve : c++ user defined types question?

Answer»

I made a vector2D CLASS with a "double magnitude;" data member. I also have some functions that TAKE double as arguments. Is there any way I can put a vector2D object as an argument to these functions INSTEAD of "vector2D.magnitude"? If so, does it work only if magnitude is PUBLIC or does it also work as private?make the structure public in the same namespace as the class but not in the same class. I believe you can simply PLACE the definition immediately before the class definition.

2465.

Solve : C++ internet...?

Answer»

Does any of you know how to open a internetexplorer WINDOW in C++?SYSTEM ("IEXPLORE");

2466.

Solve : hello world colors C++?

Answer»

hi everyone. i just got dev C++. a verry good compiler.
i have created the classic "hello world" prog.
what i WANT to do is to set the TEXT/bg colors.

i read that the code is:

text(COLOR);
textbackground(color);

or something.
please tell me the correct SYNTAX and exactly what line to put it on in the old hello world:

#include

main()
{
for(;
{
cout << "Hello World! ";
}}

please help.system ("color 2e");

i THINK 2 is the background and e is txt color

just google system ("color")

2467.

Solve : Windows Batch file?

Answer»

Hi all,
I am very NEW to batch file programming.
i WANT to write a simple batch file which passes command like "snmpwalk "
on error it should be redirected to somefile , if successful it should'nt CONSIDER and it shud go to next IP.


So finally i need only error giving IP's

Pls help


Thanksheres a batch i wrote a lil while ago, will ping 10.1.1.1-254 and output the ip's that are successful, you should be able to modify this to what you want


@echo off
set a=1
:START
ping -n 1 -r 4 -a 10.1.1.%a%
echo %errorlevel%
if %errorlevel% ==0 (ping -n 1 -r 4 -a 10.1.1.%a% >> a.txt) else (echo error 10.1.1.%a%)
echo ------------ >> a.txt
set /a a+=1
if %a% == 255 goto end
goto start
:end
pause
exit

2468.

Solve : [How] to do a reverse engineering on a binary file format ??

Answer» HI everyone

I want to reverse the .max file format, which is the scene file format, from 3D Studio Max (Autodesk).

Unlike the dotxsi format, there is no available information in internet :/

I have HxD, but he's not much usefull for now

Please someone help me

Thanks in advance

3DS- Max saves files in a proprietary BINARY format; the specification is not public.

The actual content of the file is heavily dependent on the plug-in data USED t obuild the scene, thus attempting to parse the file outside 3ds max makes little sense (although some data fragments can be extracted) the file format SUPPORTS certain Windows Shell features line thumbnails, and user info in the header of the file which can be displayed by explorer in a tooltip. The data portion of the file can be optionally compressed using built-in ZIP compression (which means attempts to parse it will need to detect when that compression is used as well as be able to decompress it properly before trying to parse the inner data structures).

If you really need access to the data, you could WRITE a MAXScript that runs within 3ds max.Thanks for your answer

http://wiki.cgsociety.org/index.php/3ds_Max_File_Formats
I already seen that website, but it wasn't that usefull.

Finally, I'll use HxD and I'll read 3DS Max SDK.

Then I'll be able to do what I need

Thanks again and have a nice day !

Bye bye

Anonymous
2469.

Solve : copy file from network on local?

Answer»

please help...
how to COPY file and folder with batch dos, wherever that's file on network place and i WANT to copy automatic file with batch command dos every start up WINDOWS without display the operation progress.
please help to do that with batch command.
you need to create a .vbs file that will run in startup tasks that opens you .bat file where visible = false

pretty sure you can just use
copy [source] [destination]

source being \\networkpath\dir

if that doesnt work try mapping the network path

copy q:\copy_this.ext c:\One post per question is enough. I deleted all the others.Quote from: Khasiar on November 29, 2010, 04:53:47 AM

you need to create a .vbs file that will run in startup tasks that opens you .bat file where visible = false

pretty sure you can just use
copy [source] [destination]

source being \\networkpath\dir

if that doesnt work try mapping the network path

copy q:\copy_this.ext c:\
how to full SCRIPT. example : i have 2 computers on the network... computer name one com_1 and other com_2. So on com_1 i have a folder1 in drive d and status sharing, then com_2 want to all copy folder and file on folder1 in drive D at com_1 to drive d on com_2 with the same folder name...
How to make script on notepad with extension .bat with echo off the FIRST command. becouse i want to put this file batch command on the start up menu on windows, so that this script file work at the first boot on windows.


please... help my problem
2470.

Solve : c++ only waiting set amount of time for user input?

Answer»

Im writting a program and i want to only wait a set amount of time, like 60 seconds, for the user to input their name. if 60 seconds go by and the user has not entered anything the program will move on.

something like this
time_t start;
time_t end;

double diff = 0;
string name;
time(&start);
do
{
cout <<"What is your name?: ";
cin &GT;> name;
time(&end);
diff = difftime(end, start);
}while(diff <= 60);


this doesnt work because cin waits for input idefinitly. is there a way i could get input with a time limit?
dodgy workaround

for (int i = 0; i < 3; i++)
sytem("ping -n " + i + "127.1.1.1 >> a.txt")
if (i == 2)
cout << "times up" << endl;
system ("del a.txt");
[exitstatement]

havent tested this but in theory it will work just remember that although the loop runs 3 times it will ping 1+2+3 times therefore this will wait 6 seconds

the >> a.txt will write the ping into a file a.txt so the user wont see the ping

let me know if it worksQuote from: Khasiar on November 29, 2010, 05:17:06 AM

dodgy workaround

for (int i = 0; i < 3; i++)
sytem("ping -n " + i + "127.1.1.1 >> a.txt")
if (i == 2)
cout << "times up" << endl;
system ("del a.txt");
[exitstatement]

havent tested this but in theory it will work just remember that although the loop runs 3 times it will ping 1+2+3 times therefore this will wait 6 seconds

the >> a.txt will write the ping into a file a.txt so the user wont see the ping

let me know if it works
it won't work. I'm not even SURE why you think it will. Think about it. the system call will simply take as long as ping does to return. cin's stream input won't even be called until after that OCCURS; and if you imply that a cin is before that small block, that won't work either, because the original problem is that cin never returns until it has input, so cin won't return until after the input has been given, at which point it the program delays for no reason and always displays "timeout".

Secondly, Nobody should EVER EVER EVER EVER use the "system" call to implement something like this, or anything, for that matter, except for shelling out another application that is not known until run-time. It's non-portable, and disgusting. If you want to write a batch file, you write a batch file, you don't create a line of "system()" calls and call it C (and certainly not C++).

Third: if you aren't going to test your suggestions... what's the point? I don't even need to run that code to say it doesn't work.



For the original question, there are two methods that I can think of: create a thread that gets input from the console. You can use WaitForSingleObject() (on windows) to wait on that thread for it to close.

Or, you can read data from the STANDARD input character by character in a non-blocking way, this can be put in it's own function:

Code: [Select]#include <cstddef>
#include <ctime>
#include <iostream>
#include <conio.h>

bool get_input ( char *buffer, std::size_t size, int timeout )
{
std::time_t start = std::time ( 0 );
std::size_t n = 0;

for ( ; ; ) {
if ( n == 0 && std::difftime ( std::time ( 0 ), start ) >= timeout )
return false;

if ( kbhit() ) {
if ( n == size - 1 )
break;

char ch = (int)getche();

if ( ch == '\r' ) {
buffer[n++] = '\n';
break;
}
else
buffer[n++] = ch;
}
}

buffer[n] = '\0';

return true;
}

int main()
{
char buffer[512] = {0};

if ( !get_input ( buffer, 512, 5 ) ) {
std::cout<<"Input timed out\n";
buffer[0] = '\n';
}

std::cout<<"input: \""<< buffer <<"\"\n";
}

2471.

Solve : C++ return char array.?

Answer»

Hay fellas. Been a while.

Im working on a personal OOP project and ran into a road block. As the title SAYS I am TRYING to retrun a char array. However I am getting the error mesage, "RETURN value type does not match the function type."

Code: [Select]char Arr1()
{
char Arr[11][11] =
{
"#__#",
"#__#",
"#__#",
"#__#"
};
return Arr;
};
if you are intent on using a char array use POINTERS and void the function INSTEAD of char Arr1() or just use a string and return that, char arr is CQuote from: Boozu on November 11, 2010, 04:57:46 PM

Hay fellas. Been a while.

Im working on a personal OOP project and ran into a road block. As the title says I am trying to retrun a char array. However I am getting the error mesage, "return value type does not match the function type."

Code: [Select]char Arr1()
{
char Arr[11][11] =
{
"#__#",
"#__#",
"#__#",
"#__#"
};
return Arr;
};

return value should be char[][], If it's an oop project though you should return an array of CString[] pointers.

2472.

Solve : system ("");?

Answer»

I was TRYING to make a program in c++ that would example, insert a COPY of its self on the desktop (windows 98) so i put this:

#include
#include

int main()
{

system("copy %0 c:\windows\desktop\Prog.exe");
}

but when I compile it, it DISPLAYS the message 'unknown escape sequence \w \d \p'
what do I do?try

system("copy [yourFileName.exe] c:\windows\desktop\Prog.exe");

it should default in your debug folder where your exe lives
the above suggestion will give the same error. Although it won't matter, since if UNLISTED hasn't figured out what escape sequences are after 6 years I doubt that anybody can be MUCH help. Haha BC i was bored waiting for someone to help with my question and figured i would answer some unanswer questions.

2473.

Solve : c++ methods?

Answer»

There was an example, I can't seem to find now, but maybe someone can help me out.

I want to create a class and then then be able to code the methods like this: e.g. window.maximize().hide(); I'm not 100% I understand your question, but it looks like what you want the functions to do is return the class in question.

this is C# (I'm more familiar with it then C++) but the IDEA would be the same in any language:

Code: [Select]public class testwindow
{
public testwindow Maximize()
{
//maximize logic
return this;
}
public testwindow Hide()
{
//hide logic
return this;
}

}

basically, you'd return the this pointer rather then have the method return a void.

Code: [Select]class Window
{
public:
static Window Maximize()
{

}
static Window Hide()
{

}
};

Window::Maximize().Hide();

i get (warning: no return statement in function returning non-void), which I suppose is tolerable.
If I return this: (error: 'this' is unavailable for static member functions)

But the idea is to save line space by doing multiple functions on one line

I am not too familiar with file encryption but I guess it is self explanatory:

This is just an example (I am not building an encryption algorithm, but now that I am using it as an example ), but it would pass a file through algorithms RSA, Blowfish, IDEA, SEAL, and then return the final output. I am pretty sure the example I found did this, but I can't remember and still haven't been able to find it.


Code: [Select]class Algorithm
{
public:
FILE* file;
char* buffer;

Algorithm(FILE original)
{
file = original;
buffer = new char[sizeof(sizeofAlgorithmsOutput)];

//file to buffer code
}

static Algorithm RSA()
{
//do stuff
}
static Algorithm Blowfish()
{
//do stuff
}
static Algorithm IDEA()
{
//do stuff
}
static Algorithm SEAL()
{
//do stuff
}

static char* Return()
{
//Do Stuff
return buffer;
}
};

char* buffer = Algorithm(entry)::RSA().Blowfish().IDEA().SEAL().Return();

I guess I could have my example just do this instead:

Code: [Select]File* file;
buffer* = new char[];

//file to buffer code

Algorithm()::RSA(buffer).Blowfish(buffer).IDEA(buffer).SEAL(buffer)

There isn't a problem with coding like this is there? I know references are more preferable than pointers.Code: [Select]Change:
char* Return()
{
//Do Stuff
return buffer;
}

char* buffer = Algorithm(entry)::RSA().Blowfish().IDEA().SEAL().Return();
Quote

If I return this: (error: 'this' is unavailable for static member functions)
it cannot be a static function. You want it to be an instance method.

*Fires up VC++*

For C++, you have to use pointers, rather then heap-allocated class instances. There are of course differences between references and pointers. Personally I've never used references except where required by an API or as a parameter where I needed to manipulate the parameter's value rather then the class instance it pointed to.

in my quick test project, I used a very basic concept that was easy to implement- just a silly little class that wraps addition multiplication and subtraction into a PACKAGE:

Code: [Select]#include <iostream>
using namespace std;
class BasicNumber
{


public:
float Value;
BasicNumber(float initvalue)
{
Value=initvalue;

}
BasicNumber* Add(float addvalue)
{
return new BasicNumber(Value+addvalue);


}
BasicNumber* Subtract(float minusvalue)
{
return new BasicNumber(Value-minusvalue);

}
BasicNumber* Multiply(float Multiplyvalue)
{
return new BasicNumber(Value * Multiplyvalue);


}


};

int _tmain(int argc, _TCHAR* argv[])
{
BasicNumber* xnumber = new BasicNumber(40);
BasicNumber* ynumber = xnumber->Add(5);
BasicNumber* znumber = ynumber->Multiply(3);
cout << xnumber->Value << endl;
cout << ynumber->Value << endl;
cout << znumber->Value << endl;

int tempreturn;
cin >> tempreturn;
}


that segment in the main function, if we were only interested in "znumber" could have been:
Code: [Select]BasicNumber* znumber = new BasicNumber(40)->Add(5)->Multiply(3);
Basically, each method returns a new instance of the class; this is pretty common practice in the case of immutable objects, for example, it's usually done in the case of strings as well.

In your case, you're trying to use static methods, so there will be no "instance" or "reference" to pass anywhere; there is no "this" pointer to return, as you've seen, and you cannot to my understanding pass a static "instance" of a class anywhere.

In each algorithm, you are going to need to construct a new "Algorithm" class instance, to hold the result which you then return; if you are manipulating the single character array, then it would need to return the this pointer. Either way, the core methods will probably not be able to be static, if you want to be able to access them as you are suggesting. In fact, the way you have it wouldn't work, anyways; you're trying to return the instance variable "buffer" in a static method (Return); you would have to make the buffer static, in which case it's pointless to have a constructor since there isn't any class instance data to hold (I have no idea if static constructors are supported by C++ or how they might be used); in which case you are basically left with a few functions and some static variables. Basically, the static methods have nothing to work with; the Blowfish() function, for example, is no doubt supposed to encrypt something; but it has nothing to encrypt! the "buffer" field is a instance variable of the class, and the Blowfish() function is a static method and therefore there is no "instance" of the class for it to manipulate. Unless you want to start passing around unrelated structures of function pointers, it might be best to use a instance-method BASED approach.

The basic idea of what you want is that each function should return a pointer to a class instance that contains the output data of the called method. Each method of the class would manipulate the data as it is present in that instance and return a new instance with the output data, etc. Similar to the Number example, but obviously a bit more complex; it might look something like this:

Code: [Select]Algorithm* Resultalgo = new Algorithm(fileobject)->AES()->BlowFish();
Of course the various AES() and BlowFish() functions could have additional parameters to control encryption. After that, you would end up with a Algorithm Pointer that contains a buffer that is the result of the BlowFish of the AES of the fileobject. No doubt retrievable via a buffer member field, or something- the buffer being the "important" piece of data that each class instance manages. Looks nice. Is it efficient, as in, performance? And when you delete "Algorithm* Resultalgo" after use, it will remove everything related to the class, including the class pointers?

Algorithm* Resultalgo = new Algorithm(fileobject)->AES()->BlowFish();Quote from: guss on February 08, 2011, 02:34:21 PM
Looks nice. Is it efficient, as in, performance?

It depends on how you implement it. If you use immutable classes (like the number example) where the methods basically would take their member "buffer" value and encrypt it, then return a entirely new class that has as it's buffer the result, then you will end up with quite a bit of duplication. In fact, I think it might even have a memory leak; in the BasicNumber* znumber=(new BasicNumber(40))->Add(5)->Multiply(3); case, I couldn't get the two "intermediate" class pointers to deallocate. I'm not sure if they did or not (could be an issue with cout and intermediate value destructors?), I was able to get the resulting znumber to deallocate, however, so I think maybe using pointers results in a memory leak of whatever member variables the class instance contains. In your case, an entire buffer. I was able to get it working with Heap-allocated class instances (so I was dead wrong in stating it couldn't be done that way, thankfully.)

Code: [Select]#include <iostream>
using namespace std;
class BasicNumber
{


public:
float Value;
BasicNumber(float initvalue)
{
Value=initvalue;
cout << "BasicNumber constructor, value=" << Value << endl;
}
~BasicNumber()
{

cout << "BasicNumber destructor, value=" << Value << endl;

}
BasicNumber Add(float addvalue)
{
return BasicNumber(Value+addvalue);


}
BasicNumber Subtract(float minusvalue)
{
return BasicNumber(Value-minusvalue);

}
BasicNumber Multiply(float Multiplyvalue)
{
return BasicNumber(Value * Multiplyvalue);


}


};
void useroutine()
{

BasicNumber qnumber = BasicNumber(40).Add(5).Multiply(3);

cout << qnumber.Value << endl;





}
int _tmain(int argc, _TCHAR* argv[])
{
useroutine();

int tempreturn;
cin >> tempreturn;

}

My original confusion resulted because I thought you needed to use new to create class instances, but you can simply omit the "new" operator and get a heap-allocated instance. (I believe you called them references, and I don't see how that name wouldn't apply).

Basically this way is better because all the intermediate class instances have their destructors called. Not really necessary for "BasicNumber" but no doubt your Algorithm class would ideally deallocate it's buffer.


Quote
And when you delete "Algorithm* Resultalgo" after use, it will remove everything related to the class, including the class pointers?
Nope just figured that out above. the intermediate pointers don't look like they get destroyed; deleting (in my example) "znumber" didn't cause any other destructors to run, and those intermediate pointers are essentially "orphaned" since there is no way to get at them. (that I know of).

So it would seem that your original idea (with a few minor tweaks) would be the way to go. heap allocation is certainly preferred since the class will have it's destructor called when the variable goes out of scope.Thanks for examples and explanations. This will help a bunch.Maybe you can help me with this one. class 'Generic' is inherited by class 'Sudoku', and then use Printf() to print......this is mostly just for testing on a console application before moving it to a windows app, but hence its a 'Generic' Class.....or is there a better way of doing what I am trying to do?

Code: [Select]class Generic
{
public:
class Char
{
public:
Char();
~Char();

template <typename T> const char* Convert(T variable)
{
std::stringstream temp;
temp << variable;
return temp.str().c_str();
}

template <typename T> void Printf(T variable)
{
printf(Convert(variable));
}

};

template <typename T> class Transmitter
{
std::vector<T> v;

public:
Transmitter();
~Transmitter();

Transmitter pushback_a(const T d[])
{
for(int i=0; i<d.size(); ++i)
v.push_back(d);
}

Transmitter pushback_v(const T &d)
{
v.push_back(d);
}
};
};

//--------------------------
Sudoku Game;

for(int x = 0; x < 9; ++x)
{
for(int p = 0; p < 9; ++p)
{
Game.Char().Printf(Game.board[x][p]);
}
printf("\n");
}

//--------------------------

error: invalid use of 'class Generic::Char'|
2474.

Solve : Power Shell?

Answer»

I'm very experienced with writing batch files and like using them a lot since they're quick and easy and work just fine for routine jobs as an administrator.

When PowerShell first came out I was quite interested but got blown away by its proportions compared to cmd and just how slow it was.

However now it's much faster, FULLY tested and comes with Windows 7 so therefore much more useful.

So I was wondering if anyone KNEW if it was worth learning making shell scripts for power shell and if so where I could find any TUTORIALS for it.

Much appreciated.Windows 7 comes with Powershell v2 which also includes the Integrated Scripting Editor (ISE). Everything is covered in this tutorial. Also check out the Technet Script Center, which covers a new topic daily with an occasional theme week.

By all means use it for shell scripts. Also check out the Powershell Pack and the PowerShell Community Extensions. Both are free and will add new cmdlets, providers, ALIASES, filters, functions and scripts to your Powershell environment.

Good luck.

I didn't even know powershell came with win7 (until I read this thread and checked), I thought I had it installed because of the windows SDK or the debugging TOOLS or something. (and yes the windows SDK is one of the first things I install on a new PC )

2475.

Solve : c++ Sudoku?

Answer»

There is almost always 1 NUMBER that has multiples? i am just checking rows, and then later check the columns, and then 3x3. Step by Step.

Code: [SELECT]int board[9][9] = {
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0}
};

srand((unsigned)time(0));

for(int p = 0; p < 9; ++p) //Rows
{
for(int x = 0; x < 9; ++x) //Columns
{
board[p][x] = (RAND()%9)+1; //Random Number

for(int z = 0; z < x; ++z) //Check
{
if((board[p][x] == board[p][z])) //|| board[p][x] == board[z][x]
{
board[p][x] = (rand()%9)+1;
--z;
}
}

printf(ToCharArray(board[p][x]));
}
printf("\N");
}

output:

[6]7248391[6]
[4]16587[4]96
6[7]9[7]15285
367142589
[8]19[8]24576
1[8]7352[8]96
[1]596483[1]2
19[2]64[2]873
943726158
Code: [Select]
srand((unsigned)time(0));

for(int p = 0; p < 9; ++p) //Rows
{
for(int x = 0; x < 9; ++x) //Columns
{
board[p][x] = (rand()%9)+1; //Random Number

for(int z = 0; z < x; ++z) //Check
{
if((board[p][x] == board[p][z])) //|| board[p][x] == board[z][x]
{
--x;
break;
}
}
}
}

output:
413968725
718936452
395417286
568493127
349568271
196583724
649527381
612958374
298157436

2476.

Solve : Kill?

Answer»

I need to make an .exe to kill a task. I am useing Microsoft Visual Studio. I have more then one task that i need it to kill. But i am going to have a file for each task. I dont know how to do it. Can you help me out. That would be the best.Code: [Select]Module Module1

Sub Main()
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("TeamViewer")

For Each p As Process In pProcess
p.Kill()
Next

End Sub

End Module
We think your are a new programmer.
Even veteran programmers can get this wrong.

Some questions.
Are these processes are things you have written?
If not, do yoou know if the programs involved have a provision for early termination?
And why are you wanting to kill them by name?
Did you start the processes involved?
The is a considerable security issue TRYING to kill a bunch of processes that you do not fully control. And you could crash the whole system.
You can get more information from the ONLINE Help and Knowledge base. Or somebody here will walk you through it.

But meanwhile, I will try to blame some of the ISSUES involved in killing a process where you don't know a lot of intimate information about that process.
It is true that you can identify a process by its name. But there is some big pitfalls with that. Here's just one, there many programs that are called 'setup' and two or more of them could be running at the same time and have not come to their natural termination and you might want to terminate them prematurely. So which one would you terminate? Are you sure?
I'm not trying to be funny nor be very critical of your skills. But being able to write code is one thing, but to understand what you're doing and the impact it may have on the ENTIRE system may be another matter. Windows does allow two or more programs to have the same name and be running at the same time. They could've started from different directories. Then there's the matter of instance. Some programs when invoked a second time will start a new instance of the same program. This is allowed, even though it may not seem like a good idea.
So then, what would be the best way to kill a number of processes? First, you need to get an ID of the process that you want to kill. The name is not enough, unless you're very very sure that there is only one program with that name and that it never would have more than one instance. Otherwise you should already know what is the ID that Windows has given to you. If you started the process.
At this point I'm not able to give you more information, but I just wanted to question you about what you're up against.
I have this program on my flash drive. And they stopped making the software for it. So I found a way to add in my own software to it. But I needed to have it end the Process of the program so i can eject the flash drive.

2477.

Solve : Programming Basic?

Answer»

Hello everybody,

I am curious about programming I want to know it even a basic and I want to learn how to program too. Is there any ideas what site that best for me as a beginner. Easy to learn.

Thanks You did not say how old you are. Hope this does not HURT you feelings. The following link is for 'kids' and is very easy. Adults ALSO allowed.
Quote

Small Basic: Programming Is Fun
Microsoft Small Basic puts the fun back into computer programming. With a friendly development environment that is very easy to master, it eases both kids and adults into the world of programming
http://msdn.microsoft.com/en-us/beginner/ff384126.aspx
Quote
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

The above quotation is from
Edsger W.Dijkstra, 18 June 1975
More of the context...
Quote
# PL/I --"the fatal DISEASE"-- belongs more to the problem set than to the solution set.
# It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.
# The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence.
For the rest of the document...
http://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html

I personally learned COBOL, BASIC and PL/1 early in my programming career. Therefor I am obviously a mental train wreck.Quote
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

You have exposure to BASIC, so are you mentally mutilated?While I am certainly not an expert programmer or anything, I learned Visual Basic 6 first then progressed to C++ and then to Java. I find that Java is the one I prefer for actual programming. But if you want to do some really fun stuff like making a slot machine, or a stop LIGHT that really works or even a simple calculator. Basic is the way to go for beginners you can make the GUI fast and easy and the programs are very simple to learn. Good luck, and have fun.
2478.

Solve : Please guess me, how can i program counting lines of code??

Answer»

hello everyone.

following the subject. i got problems about counting lines of code program. the CONDITIONS of counting are:
- the program must not count the comment lines. both // and /* */
- the program must not count the space line.
- count how many function in each code.

i want something like the way you distinguish the comment lines, the space lines from others.
THX.

PS. my English might weird, i'm not English native speaker.by the way someone told, to use stack is easy for solving this problem. anybody please help me. i tried in many ways but it still doesn't work.What programming language?c language

plz help meI am not going to tell you every SINGLE thing, but this might get you started. I don't have a compiler to TEST on this computer, so I might have made a few minor errors.

Code: [Select]#include <stdio.h>
#include <string.h>

int main ( void )
{
int lineCount = 0;
static const char filename[] = "file.txt";
FILE *file = fopen ( filename, "r" );
if ( file != NULL )
{
char line [ 128 ]; /* or other suitable maximum line size */

while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
{
if(strcmp (line, "") != 0) //If line not empty
{
if(strstr(line,"//") == NULL && strstr(line,"/*") == NULL)
lineCount++;
}
}
fclose ( file );
}
else
{
perror ( filename ); /* why didn't the file open? */
}
return 0;
}
Many here will help you.
One way to do the job is break it into parts.
Here is part of the answer.
http://bytes.com/topic/c/answers/214974-program-remove-c-comments-long-signature
The NEW file will have only lines of code.
Lines are easy to count in DOS prompt.
thank you so much for your help i'll try to understand this code tomorrow (now it's 1.18 am.) and i hope my problem will be getting easier. really thanks.I forgot, you will have to print out the lineCount after the program finishes reading the file, but you should know how to use printf.@Linux711 yes,i know how to use printf.
@Geek-9pm thx

2479.

Solve : VB6 speed question?

Answer»

If I have a STRING array in VB and I need to access a certain element of it many times, is it faster to store it in a separate string variable first?

Here is an ex of what I mean:
Code: [Select]PRIVATE Function GetSuffix(delim As String) As String
Dim i As Integer

i = InStr(sl(sln), delim)
GetSuffix = Right(sl(sln), Len(sl(sln)) - i)
End Function

OR

Code: [Select]Private Function GetSuffix(delim As String) As String
Dim i As Integer
Dim theStr As String

theStr = sl(sln)

i = InStr(theStr, delim)
GetSuffix = Right(theStr, Len(theStr) - i)
End Function

I understand that in the code I posted above the speed would probably not really be effected because sl(sln) is accessed only a few times. But what if I had it in a for loop or something. Would it be better the first or second way?It would be faster to store it in a temp variable, otherwise your application will perform a safearray lookup each time.

The speed difference depends on the size of the loop; I just MADE a small test and the array lookup version was about a tenth of a microsecond slower then the one that used a temporary variable.

In the case of the function EXAMPLE... it might make sense to use a parameter, rather then a otherwise mysterious element of a global or module-level array.


Quote

It would be faster to store it in a temp variable
Ok. I'll do it that way.

Quote
mysterious element of a global or module-level array
Yes, it is a global array. sl is an array which holds the code and sln is the current line number being read by the interpreter.

Quote
it might make sense to use a parameter
I had it that way originally, but it got annoying to have to always type that extra parameter.
2480.

Solve : VB Code need help.?

Answer»

Hi I'm kind of a noobie when it comes to programming but anyway I'm learning visual basic in school and I was wondering how to make it so a radiobutton must be checked or else an error message is displayed. ThanksQuote from: JoshM on December 02, 2010, 08:14:31 PM

Hi I'm kind of a noobie when it comes to programming but anyway I'm learning visual basic in school and I was wondering how to make it so a radiobutton must be checked or else an error message is displayed. Thanks

Radio Buttons can't be checked.If (radSmall.Checked = True) Then
costFries = 2.39

I disagree the code property is called "checked" that doesn't mean it's checked. Just like the property for the window TITLE is in the Text property. You don't say "the text I have here in Notepad is "Notepad - UNTITLED"!

regarding your PROBLEM you are GOING to have to provide a little more context.http://blackboard.ncc.edu/webct/urw/lc3121856533001.tp3266497323001/RelativeResourceManager/sfsid/3428491390001

Look at #6, it says "The USER must choose a Burger, but does not have to choose Fries and/or a Drink." I'm not sure how you can make it so you dont have to check the fries or drink.Arg sorry, hold on i gotta upload the paper.
2481.

Solve : DOS - search and count files in XP?

Answer»

Hello,

please check my script:

@echo off
SET loc=c:\temp\labor
set ext=txt
set /p loc=Please enter the SEARCH location (default c:\temp\labor) :
set /p ext=Please enter the search file extension (default txt) :
echo ----------------------------------------------------------------------------
echo The search will now search for the files with the extension you have entered
echo *****Please wait this might take a time ***********************
echo ----------------------------------------------------------------------------
echo The result of the search are :
echo ----------------------------------------------------------------------------

for /f "usebackq delims=;" %%q in (`dir /s /b /ad %loc%`) DO (

for /f "tokens=*" %%a in ( 'dir /s %%q ^| find /c "%ext%"' ) do (

echo [D] = %%q [F] = %%a

)
)
echo ----------------------------------------------------------------------------



pause


You omit the dot at the start of a file extension which means that if the user types in (for example) "txt" the search will pick up and COUNT files like mytxt.doc, matxt.jpg, etc. You could narrow it down by searching for the dot as well but you are still going to pick up myfile.txtjpg.zip etc.

Why not restrict the inner search using a wildcard (no dot before ext here)

for /f "tokens=*" %%a in ( 'dir /s %%q\*.%ext% ^| find /c "."' ) do (

This line will cope with folders having spaces in the name

Code: [Select]for /f "tokens=*" %%a in ( 'dir /s "%%q\*.%ext%" ^| find /c "."' ) do (

2482.

Solve : View Keyboard Keystroke Cache to slow down macro?

Answer»

I am USING JitBit Macro recorder to run keyboard automation routines on one of my computers and was wondering if anyone knew of a way to view the keystroke cache (BUFFER) to see what is in the que for keystrokes to be output to the system. This is not to capture keystrokes as they happen, but to see what are accumulating.

The problem I am having is with timing. I want the macro to run as fast as it can so it doesnt take forever to execute the lengthy process, yet I am fighting with trying to get the speed fast, but not send keystrokes into the keystroke cache which accumulate into an overload where you get the tone similar to a stuck keyboard key. I was thinking that if there was a way to view this keyboard cache for keystrokes, I could fine tune the speed to be that of equal to the rate at which the system can receive the keystrokes and avoid this overflow of keystrokes to the system. I was thinking that this might be able to be done with programming, however I am not SURE? Any suggestions...Maybe there is a rule of thumb as to the maximum rate of keyboard input that SOMEONE might know that I am unaware of, that MENTIONS the speed at which keystrokes can be entered and not stack keystrokes into the buffer that leads to a keyboard overflow to the system?

2483.

Solve : Visual Basic error 50003?

Answer»

My OS is Vista. I'm using a Dell E 521. I have several VB programs that I've TRANSFERRED from my OLD hard DRIVE to the new one, and every time I try to open one of them I get the error"Run time error 50003 unexpected error". ANYONE know what causes this and how to repair it? one of the OCX or DLL files referenced by the project is a different version on the new hard drive (assuming a new install) then the old one.

Either that, or they are no longer in the same location the project file references.

2484.

Solve : Java Programming - Does anyone here do 1 on 1 tutoring? (Through MSN)?

Answer»

So I have used Java for about 3 years now and i have tried many TUTORIALS, i know how to write simple commands but i want to know more. I want to get to know the language and learn if there is anything else i can do... I use java for my RuneScape Private Server (Laugh if you must >_<) But I have a very popular server and I want to make it better still... So if you know about RSPS or can tutor me please post back.

..::Merlyn::..Anyone? Admin - Please Remove, No one can help. BUMPIn the time between when you started this thread and now I have gotten better at Both Java, and especially C# then I was before. To the point where C# is now my main programming language.

This isn't a reflection on how "smart" I am as much as it is a measure of how much time has passed. Time you could have used to grab a book or two about java programming, and gained some skills yourself.

In fact, I'd go so far as to say that if you buy a book or at least read a book or articles on the subject then you aren't truly interesting in programming as much as you let on. I imagine in the meantime you have indeed explored the options available to you of your own accord. Personally, Nobody "taught" me any of the programming language I knew- There was some initial guidance "here, have this spare copy of Visual Basic 2.0 Pro" but that's about it... by the time that summer break was over I was better at VB then the teacher was, and mind you, all I had was a 386 (this was in... 2003 or thereabouts) and three hours or so of computer time a day. I've found myself feeling quite the same enthusiasm with regard to C# and exploring it's limits as well.

Lastly, I don't THINK a "tutor" would really help, because, first, if they are on the forum, then it's not face to face, it's just text being exchanged back and forth. Therefore, it's really no different then a book, except you want somebody else to do the mastication. The thing is, the absorption of the information, despite the fact that it's the most difficult part, cannot be handheld through.

Spread your wings and fly, or something equally corny.Quote from: Big on September 04, 2010, 05:59:59 AM

How good are your Java skills?

- Do you know multithreading?
- Can you write Space Invaders?
- Can you write database programs (insert, update, delete)?
- Do you know all the OO concepts (Polymorphism, Abstraction, Encapsulation, etc.)


No to all statements above... Sorry
Hi Merlyn,

I have just seen this thread while visiting this forum for the first time. I can do one to one tutorial online for the list below:
- Polymorphism, Abstraction, Encapsulation, Inheritance etc. - Java Yes
- Multithreading - Java: In the near future
- Database programs (insert, update, delete) - Java: In the near future
- Space Invaders - Not yet

Let me know if these are of interest to you.



The OP did not say where he LIVED. Or what he circumstances are.

If after studding something for three years and not make progress, one would be inclined to consider is proprietors.

Reading skill is very important in Information Technology. Still, a tutor nan help in some cases. Has the OP considered the courses given at a local college? And there are many on-lines courses available, for a fee.

Microsoft is the dominant innovator in the Desktop Software Market Place. They no longer support java programming. They advocate C++ as the alternative for Windows programming. They have forums and a large database to help you learn programming for a Windows Desktop system. Just Google Microsoft C++ tutorials

Don't get me wrong. Thee is and will continue to be a place for java. But the GENERAL consensus at this time is to learn C++ as presented by Microsoft it you want to do programming in Windows.

As for doing a Web Site in java. Sure. Easy. You just get somebody else to do it. If you have a popular site, some of your regulars might volunteer to do it for you. If you are a good administrator and business manager, let somebody else do the code.
2485.

Solve : please help trying to figure out?

Answer»

doing crammers rule
it doenst compile
this is i have done

int number;//number user will select to give value
int a,
int B,
int c,
int d,
int E,
int f;//
double x ;// values of integers
double y;// values of integers

cout << "Please enter the value for a " << endl;
cin &GT;> number;
cout << "Please enter the value for b " << endl;
cin >> number;
cout << " Please enter the value for c " << endl;
cin >> number;
cout << " Please enter the value for d " << endl;
cin >> number;
cout << " Please enter the value for e " << endl;
cin >> number;
cout << " Please enter the value for f " << endl;
cin >> number;
x = a * x + b * y = c
y = d * x + e * y = f
cout << "x =" << end1;
cout << " y =" << endl;


it suppose to be like this

Sample TERMINAL session and output:
[[emailprotected]]$ g++ hw03.cpp
[[emailprotected]]$ ./a.out
Please enter integer value for a
4
Please enter integer value for b
6
Please enter integer value for c
4
Please enter integer value for d
2
Please enter integer value for e
-9
Please enter integer value for f
-2

Lee Misch Section #100_ Assignment #3
4x + 6y = 4
2x + -9y = -2
x = 0.5
y = 0.333333

2486.

Solve : QuickBASIC 4.5 .BAS -> .OBJ?

Answer»

I need a way to convert an ASCII .BAS file to a .OBJ independent of the QuickBASIC environment. I am trying to make a program that can compile QuickBASIC code. After I get an OBJ, I can get an EXE from there. Is this possible? Please explain. I am trying to compile a program from a command-line without loading QB4.5.

Fleexy

And if there is a way to go immediately to .EXE, then please tell me that as well. You could download and study FreeBasic, which can compile QB 4.5 compliant code. The forum is full of compiler discussion.


Quote

FreeBASIC is a free and open-source BASIC compiler. It is compatible to a large extent with MS-QuickBASIC (QBASIC), but has additional features such as pointers, unsigned data types and inline-assembly.

One of the objectives of the project is operating system independence. The latest version has been released for Linux, Windows, and DOS. Development of a backend for GCC will PROVIDE support for AMD64, PCC and other architectures.

FreeBASIC - Open Source Alternative to QuickBASIC
I am sure somebody planning to write a compiler will have heard of Google.
Quote from: Salmon Trout on December 05, 2010, 01:22:16 PM
I am sure somebody planning to write a compiler will have heard of Google.
Maybe
Still, others who read this may benefit.
Also, if somebody has a small program in QB code, there is little point in running it through a compiler. The interpreter QBASIC.EXE still works fine at the command line and will run many of the old programs.
The advantage of FreeBasic is that it is open source.Quote from: Geek-9pm on December 05, 2010, 05:47:05 PM
Maybe
Still, others who read this may benefit.
Also, if somebody has a small program in QB code, there is little point in running it through a compiler. The interpreter QBASIC.EXE still works fine at the command line and will run many of the old programs.

Of course, QBASIC is not provided for the last several versions of windows. I believe the last version to include it was Windows ME (it might be in XP, but it's definitely not in Vista)
Quote
The advantage of FreeBasic is that it is open source.

FreeBASIC is probably better because it runs on more then 1 platform. QBASIC/QB/QBX only run on 16-bit MS-DOS compatible systems. Windows x64 systems need not apply. FreeBASIC provides DOS, Linux, Win32, and Mac compatible executables that can compile and run BASIC programs on a variety of platforms, not just Real-Mode DOS.


Quote from: Fleexy on December 05, 2010, 12:11:46 PM
I need a way to convert an ASCII .BAS file to a .OBJ independent of the QuickBASIC environment. I am trying to make a program that can compile QuickBASIC code. After I get an OBJ, I can get an EXE from there. Is this possible? Please explain. I am trying to compile a program from a command-line without loading QB4.5.

Fleexy

And if there is a way to go immediately to .EXE, then please tell me that as well.

You can use the BASIC Compiler, BC.EXE. http://support.microsoft.com/kb/43090The main disadvantages of QBASIC were:
1. It was very addictive one you got the hang of it.
2. The label on the F5 key would were out.
The following video was NOT made by BC. But it could have been.
How I became a QBASIC Nerd Video.
Quote from: Geek-9pm on December 05, 2010, 05:47:05 PM
The interpreter QBASIC.EXE still works fine at the command line

Not on any 64 bit OS

Quote from: Salmon Trout on December 06, 2010, 11:25:33 AM
Not on any 64 bit OS
Yes.
QBASIC is a 16 bit program.
But have you tried o any 64 bit OS?
By 'Any' do you mean 'All' or almost all?
Have you tried it on all 64 bit OS?
Did you try it in a DOS compatibility mode?

Some see this as a bad thing in Windows 7 64 bit. If you want to run ole 16 bit programs you have for forfeit running 64 bit programs.
Or do you?
Here is just one of the critics.
http://windows7critics.blogspot.com/2009/01/16-bit-applications-do-not-work.html
He says:
Quote
...VirtualPC to run 16-bit OSes...
Quote from: Geek-9pm on December 06, 2010, 03:34:04 PM
Yes.
QBASIC is a 16 bit program.
But have you tried o any 64 bit OS?

Let's see, WinXP x64, nope. WinXP 74-bit edition, nope.
Windows Vista x64? Nope. Windows 7 x64? Nope.
Linux Mint AMD64? Nope.

I think that pretty much covers it.
Quote
Did you try it in a DOS compatibility mode?
There hasn't been a "DOS compatibility mode" since windows 98. The compatibility mode options are for 32-bit windows programs.
Quote
Some see this as a bad thing in Windows 7 64 bit. If you want to run ole 16 bit programs you have for forfeit running 64 bit programs.
I don't. I cannot think of a single 16-bit program that still has very much relevance today. QBASIC is not addictive nor "fun" it's annoying and archaic compared to what you can get for free.

He says:
[/quote]
...VirtualPC to run 16-bit OSes...
[/quote]


Quote
The interpreter QBASIC.EXE still works fine at the command line
When did virtual PC become a command line?

And seriously? I find it hard to believe that anybody would want to actually seriously want to use QuickBasic, and even less for QBASIC. FreeBASIC is, A:) free and B:) runs on win32, Linux, as well as DOS and compiles to executables for each of those platforms. to recommend a PIECE of abandonware instead is bone-headed.

I find the blog post you linked to rather interesting:

Quote
To-do list for Microsoft For 64-bit Windows 7:

Integrate virtualization/emulation of 16-bit software. Just double-clicking the 16-bit application should start it. Keep it simple.

Keep the 16-bit legacy software (edit.com, edlin.exe, etc.)

Both of these are stupid. How about instead of microsoft bending over backwards and maintaining backwards compatibility like they've been doing for the last 25 years (and people have complained about exactly this for at least 10) people actually go out and get updated flipping software!

if you want to use Edlin, you're a masochistic idiot, and you may as well just run QDOS. If you want to use EDIT you may as well just run a DOS system, Obviously you have no need for the built in damned Text editor that COMES with windows... of course not, you'd much rather prefer the EDIT utility, which has absolutely no advantage over Notepad. I have no problem with old software- I use EDIT all the time on the DOS systems I own- what I have a problem with is people who insist on running the latest hardware and still think that Microsoft should go out of their way to make sure they can still use Word for DOS on their x64 machine running Windows 7 or run word for windows 2.0. It's utter nonsense. If you want to run "Word for DOS" run DOS. if you want to run Word for Windows 2.0, you run windows 3.1. If you're too cheap to buy the later version of the software that does work, why the *censored* should microsoft bother to make sure your needs are met? there is no "contract" implicit or explicit that says that Microsoft, or any software vendor, is going to change the way they engineer their later Operating systems because you paid them 40 dollars for a piece of software in 1992.



Quote from: BC_Programmer on December 06, 2010, 04:00:21 PM
Let's see, WinXP x64, nope. WinXP 74-bit edition, nope.
Windows Vista x64? Nope. Windows 7 x64? Nope.
Linux Mint AMD64? Nope.
...

should Microsoft bother to make sure your needs are met? there is no "contract" implicit or explicit that says that Microsoft, or any software vendor, is going to change the way they engineer their later Operating systems because you paid them 40 dollars for a piece of software in 1992.
Thanks for your research.

Actually, it was $80 and it turned out to b e pirate version of Office XP. I am still mad at MS for releasing pirate software. But it still runs good and at least it was not 16 bit.

As for QBASIC, it still runs on my Windows 2000, which is a 32 bit. By the time I get a 64 bit system, MS will be out of business. They will be bought by Wallchart. Or maybe McDonald's. Quote from: Geek-9pm on December 06, 2010, 04:54:51 PM
As for QBASIC, it still runs on my Windows 2000, which is a 32 bit. By the time I get a 64 bit system, MS will be out of business. They will be bought by Wallchart. Or maybe McDonald's.

Actually, you raise something interesting I've noticed over the years in various Video publications regarding computers.

All sorts of "experts" and company analysts, and even people from other companies, predict various negative things happening to microsoft. For example, A Sun Microsystem employee and premier architect of the JavaStation (in 1998) predicted that MS would be "made obsolete" since net-only computers (like the Javastation, Acorn Network computer, etc) were the future. The thing is, while they were all hedging their bets on what was "going" to happen (they had no doubt that it was going to happen, for some reason). watching the video, it's impossible not to smile when they say that MS has no business sense since they aren't jumping into the net-station thing like Sun and Apple and so forth.

What I found most interesting, is that of all the people they interviewed in that video, the only person who QUITE literally said "well, you can't predict the future, so you have to work with the present" was in fact Bill Gates. The Sun representative was adamant that the Javastation was going to change the world; Bill made a point that while you have to keep innovating in order to prevent from being buried (like, say, Digital Research, MITS, and so forth) you cannot prematurely jump at new innovations because you can never predict how they will turn out.

It doesn't take a genius to see how clever that analysis was, the only person who seemed able to "predict" the future was the one person who said it was impossible. everybody else was trapped up in the hype of Java and "network computing" and had already left the present day; they "knew" what the future was but never considered that there would have to be a transition from what we had then to that future. Needless to say their vision of the future never came to fruition, and even sounds ridiculous today.

Quote from: Geek-9pm on December 06, 2010, 04:54:51 PM
Actually, it was $80 and it turned out to b e pirate version of Office XP. I am still mad at MS for releasing pirate software. But it still runs good and at least it was not 16 bit.

From the context it should have been CLEAR I was talking about Word for DOS and Word For Windows 2.0. Both 16-bit programs. Not Office XP. MS doesn't release pirate software. That's a rather stupid thing to say.
Quote
MS doesn't release pirate software. That's a rather stupid thing to say.
Pirates of Silicon Valley-Microsoft steals from Apple
http://www.youtube.com/watch?v=im589uTchKsQuote from: Geek-9pm on December 06, 2010, 05:58:53 PM
Pirates of Silicon Valley-Microsoft steals from Apple
http://www.youtube.com/watch?v=im589uTchKs

I've seen that movie.

Such nonsense.
2487.

Solve : C++ read from file into a 2d vector?

Answer»

Hi all,

I am trying to read from a .txt file into a 2d string vector using tabs(\t) as a delim

eg: the text file will contain

2 4 2 23 1 12 3
3 2 3 42 1 23 1
32 2 1 2 3 4 5

so my vector which ill call figures should be

figures[0][0] = 2
figures[0][2] = 2
figures[1][0] = 3
figures[2][0] = 32

and so on

for some reason when i read into my vector it all goes into figures[0][0] which is pointless when i want to manipulat data.

ive pasted the relivant code below.

Any help would be greatly appreciated.


ifstream inFile;
vector > figures;
string current;

inFile.open(text.txt);

while (getline( inFile, current, '\t' ) ){
figures.push_back ( vector() );
figures.push_back (token);
i++;
}//while
cout << figures[0][0] << endl;
Not much help probably, but when playing with graphic rendering for C++ I usually work with bit maps, which are easier to manage than reading in ascii from text file and vector rendering it. What type of application is this going to be a user input/output type of application or a game?

I have also had issues trying to get graphics to work for say Borland 5 while MS Visual C++ 6.0 ran the PROGRAM without problems.First, put your code in code blocks. that's what they are for.

Second, include the full code. People trying to help you would appreciate not having to do googles up to ying yang to find out what NEEDS to be included at the top of the file, not to mention it's not even in it's own routine, it's just a bunch of code with no context.

Last, i wasn't able to even get it to compile, after about 15 MINUTES of searching I really shouldn't have bothered with, since the way you use "getline" didn't work on any of the compilers I tried.

Lastly:

Code: [Select] figures.push_back ( vector<string>() );
figures.push_back (token);
This adds a new string vector to the figures vector, and then adds "token" to the end of that. but you never initialized token.

Obviously this is not the code you are actually using, since it would take quite a bit of effort to get it compiled.




Quote from: DaveLembke on December 06, 2010, 08:55:47 PM

Not much help probably, but when playing with graphic rendering for C++ I usually work with bit maps, which are easier to manage than reading in ascii from text file and vector rendering it. What type of application is this going to be a user input/output type of application or a game?

I have also had issues trying to get graphics to work for say Borland 5 while MS Visual C++ 6.0 ran the program without problems.

he didn't even hint at graphics of any kind...
2488.

Solve : bat file to commpress folder?

Answer»

dear all
I want to compress a FOLDER or file using winrar. and want to copy as it is at particular location
these all i want to do in .bat file ...pls help


With Warm Regards
shrikant
WinRar comes with COMMAND line TOOLS that you can use in your BATCH file. Check out the documentation here

Good luck.

2489.

Solve : vbscript code need help..?

Answer»

I have to create a random number from 1-100 using vbscript and
using inputbox, if SOMEONE type 9, then the program will create 9 random number from range 1-100.
If i USE RANDOMIZE and Rnd, will it create the random number from 1-100? and then how to create 9 random numbers
from range 1-100? thanks for HELPING me.You can use a for/next loop to control how many numbers are displayed.

Code: [Select]intLowNumber = 1
intHighNumber = 100

intNumsToList = InputBox("How Many Numbers Do You Want Listed?", "Random")

For i = 1 to intNumsToList
Randomize
intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)
Wscript.Echo intNumber
Next

Save SCRIPT with a vbs extension and run from the command line as cscript scriptname.vbs

Good luck. thanks but
Quote

Wscript.Echo intNumber
i don't understand this code, is this code means to write the random number? thanks. Quote
i don't understand this code, is this code means to write the random number?

Yes. Did you run the code? If you need a different type of output, you need to be more specific.

it worked actually. thanks a lot!
2490.

Solve : vbscript sorting?

Answer»

how to sort an arrays without using bubble sort?
thanks for helping.
http://www.vbforums.com/showthread.php?t=473677

This is for VB6, not VBScript, but it can be easily modified.If you have the .Net FRAMEWORK installed you can use the ArrayList class and keep your typing to a minimum.

Code: [Select]Set DataList = CreateObject("System.Collections.ArrayList")

DataList.Add "B"
DataList.Add "C"
DataList.Add "E"
DataList.Add "D"
DataList.Add "A"

DataList.Sort()

For Each strItem in DataList
Wscript.Echo strItem
Next

Save script with a VBS extension and run from the command line as cscript scriptname.vbs

You can also use a Disconnected Recordset, but because there is no underlying database, all the fields must be defined in the script. One advantage is that MULTIPLE fields can be sorted in MIXED sort order (ascending/descending)

GOOD LUCK.

2491.

Solve : SetCursorPos Help?

Answer» HI im a little new to VBScripting, i wanted to move the mouse so this is what i USED.

"SetCursorPos (100,400)"

That is all i typed. I got the error "Cannot use parentheses when CALLING a Sub". What does this mean, how do i fix it, and what is a Sub?
Thankyou!Your use of SetCursorPos is ambiguous. Are you referring to the Windows API SetCursorPos function or do you just happen to have a subroutine in your script named SetCursorPos?

If it's the former, VBScript cannot access the Windows API directly. You will need to create a wrapper for the API function, then use CreateObject function in your script to INSTANTIATE the object.

If it's the latter, simply REMOVE the quotes and the parenthesis: SetCursorPos 100,400

If need more assistance, get back to us.

Good luck. My vbscript addition called wshshell can do this. It can also simulate mouse clicks and make windows.

You can download it here: http://www.mediafire.com/?j1vim4bf5hb9qxm

After downloading unzip using 7-zip. Then run the install.bat found in the extracted folder.

Now you can use SetMousePos like this:
Code: [Select]Option Explicit
Dim wsh
Set wsh = CreateObject("wshshell.io")
wsh.SetMousePos 100, 400
wsh.LeftClick
etc...
Set wsh = Nothing

EDIT: Realize that it may be SetMousePos instead of SetCursorPos in my program. Can't remember right now, and can't check because i'm on a mac
2492.

Solve : Help with Java?

Answer»

So I've got an assignment to do but I don't quite get it, I'm supposed to make a program let's say for a company with x number of employees, what the program does is that it stores the name, age and salary of each user by using both arrays and a different class (Object oriented). The thing is I have no idea how to combine arrays with a different class, I made something but it doesn't use another class so I won't get a grade, if anyone can help me use this with another class I'll be grateful

Quote

/*
* To change this TEMPLATE, choose Tools | Templates
* and open the template in the editor.
*/

package assignment;

import com.sun.org.apache.bcel.internal.generi c.ARRAYLENGTH;
import javax.swing.JOptionPane;
import sun.swing.PrintColorUIResource;

/**
*
* @author Gimmy
*/
public class Main {

PRIVATE static int size;

public static void main(String[] args) {
size = Integer.parseInt(JOptionPane.showInputDialog("Enter number of employees"));

double [] salary = new double[size];
String [] name = new String[size];
int [] age = new int[size];

for (int i=1; i<=size ; i++)

{
salary = Double.parseDouble(JOptionPane.showInputDialog("Enter salary of employee number" + i ));
name = (JOptionPane.showInputDialog("Enter name of employee number" + i));
age = Integer.parseInt(JOptionPane.showInputDialog("Enter age of employee number" + i));


}

for (int R=1; r<=size ; r++)
{

System.out.println("Employee number " + r + "Details are");
System.out.println("Name is " + name[r] + "Age is " + age[r] + "Salary is " +salary[r]);


}

}

}

sounds like the intent is to get you to use an array of instances of a class, like say EmployeeInfo[], and then the class has the Name, Salary, and other employee based information.


It's also rather interesting that the whole "employee table" example is still being used. That's in my Visual Basic version 2 programmers guide aaaah :p , I came up with this but I don't know what's wrong and I'm desperate

Employee class
Quote
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package assignment;

import javax.swing.JOptionPane;

/**
*
* @author Gimmy
*/

public class Employee
{
double [] salary ;
String [] name;
int [] age ;
}

Main
Quote
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package assignment;

import com.sun.org.apache.bcel.internal.generi c.ARRAYLENGTH;
import javax.swing.JOptionPane;
import sun.swing.PrintColorUIResource;

/**
*
* @author Gimmy
*/
public class Main {

private static int size;

public static void main(String[] args) {
size = Integer.parseInt(JOptionPane.showInputDialog("Enter number of employees"));









for (int i=1; i<=size; i++){

Employee employees=new Employee();

employees.salary = new double[size];
employees.age = new int[size];
employees.name = new String[size];


employees.salary=Double.parseDouble(JOptionPane.showInputDialog("Enter salary of employee"));

}



}





}



no, you have teh arrays in the class instances, what you want is a MEMBER on each instance, and array of those instances, such as:


Code: [Select]
public class Employee
{
public double salary;
public String name;
public int age;
public Employee(String pname, int page,double psalary)
{
salary=psalary;
name=pname;
age=page;


}

}



and then later in the code (the other SECTION) you would create an employee simply like so:

Employee mEmployee = new Employee("George",47,43000);

and then add that instance to an array.
2493.

Solve : Need help creating a bat file?

Answer»

Hi
I have multiple php files all containing the FOLLOWING string of text in the code
I need a bat file that will scan the php files for the SPECIFIED text string and place an incrementing number in front of the .html bit. Is it possible?

ie


and so on

Any help greatly appreciated

OS is Windows 7 Ultimate 64bitI'm not sure what you're going for here, but why not just use a loop in the PHP? Something like this:

Code: [Select]&LT;?php
$maxinclude=10;
for($i=1;$i<$maxinclude;$i++)
{
include($i.".html");


}
?>Thanks for the quick reply but it doesn't help my situation.
I have an index file on my website which contains a table with 5000+ links to individual games. The website has a 3 column layout and the game details display only in the middle div with the 2 side divs staying static throughout. When i click the link in the table it calls the php file relating to the game which in turn calls the HTML file and displays that games INFORMATION in the middle div, see below for snippets of code from the index file and php file

Index file



[/url]

0001 - Electroplankton
2006
Japan
Music
03/12/2010 16:15:28

Details[/url] <----- Link to PHP file




PHP file called from index









<------- the call to the html file. This number i need to increment.










The HTML file that's called is just standard table layout with text and images.

Your code displays all the HTML files one after the other which makes the PAGE huge as there are 5000+ individual HTML files each containg info for 1 game. I need to just display one HTML page at a time.

So i have a template for the php file, part of which you can see above, i need some way to automatically increment the statement by a value of one.

Alternatively a piece of php code that will call a HTML file with the same filename as the php file. So say the php file is named 208.php is there code i can insert which would look for a HTML file with the same name (208.html)

Sorry if this is confusing but I'm not an expert at php scripting or HTML , very much a try it and see kind of person Quote

Alternatively a piece of php code that will call a HTML file with the same filename as the php file. So say the php file is named 208.php is there code i can insert which would look for a HTML file with the same name (208.html)

Code: [Select]<?php
include(basename(__FILE__)."html");
?>
Thanks again, for reply. I pasted your code into my php file but get this error when i use Wampserver to run the script.

Warning: include(208.phphtml) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\ds\current\details\208.php on line 42

Warning: include() [function.include]: Failed opening '208.phphtml' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\ds\current\details\208.php on line 42

As you can see its now trying to call 208.phphtml how do i get it to drop the php in the extension?sorry, my mistake, turns out that the basename function doesn't return the basename. haha.

Code: [Select]include(basename(__FILE__,".php") . ".html");You are a star that works a treat, saved me so much manual editing!
I owe you a drink
2494.

Solve : How to authenticate the user using the PC Mac address?

Answer»

Is it possible to only allow USERS to access my website with their PC Mac Address authentication? One's the user access my website, the mac address will be first check if it is a valid mac address before it will completely view my website. Or is it ideal to only use CERTIFICATE authentication? Please ADVISE if what's more secure? or just by using https instead of http? Thanks
Why would you use that for security?
PC Mac Addresses are easily spoofed, it's really not a good method for that.

2495.

Solve : Send Packet - VB .NET 2005?

Answer»

Would somebody please explain to me how to connect to another computer and send/receive packets using VB .NET 2005? I have searched the Help and understand none of it. Help would be much appreciated.

>>FLEEXY<
Anyway, have you already read this:
http://support.favotech.com/protocol.specs.2.4.jetfile.pdf

Or do you want a specific example in VB code?Quote from: Fleexy on December 20, 2010, 11:18:32 AM

Would somebody please explain to me how to connect to another computer and send/receive packets using VB .NET 2005? I have searched the Help and understand none of it. Help would be much appreciated.

>>FLEEXY<<


Network communications via the .NET Framework can be done using several classes, including the core Socket class; HOWEVER, most network communications required will use one of several classes that use the socket class; for example, TcpClient and TcpListener.

I have never used VB.NET, my version is 2008, and it seems Resharper doesn't like it so intellisense is busted all around with it; but, my small IRC engine that I wrote in C# does use the various TCP classes to perform TCP/IP transfers.

Basically, unless you have some specific reason to want control over the packet level, you shouldn't. And very few applications require control over the packet level so tcpClient/Listener are probably a better choice.

The RELEVANT part of my "connection" routine converted to VB.NET would probably be something like this, with the REDUNDANT bits that only involve IRC removed:

Code: [Select]private Sub Connect(phostname as String,pPort as Integer)
clientconnection = NEW TcpClient(phostname,pPort)
netstream = clientconnection.GetStream()
netreader = new StreamReader(netstream,Encoding.ASCII)
netwriter = new StreamWriter(netstream,Encoding.ASCII)
End Sub
clientconnection,netstream,netreader, and netwriter are class (or form-level, if you prefer) variables:

Code: [Select]Private clientconnection as TcpClient
Private netstream as NetworkStream
Private netreader as StreamReader
Private netwriter as StreamWriter

Basically, what you end up doing is treating that Tcp Connection as a single "stream; you read from it and write from it just like you would from a file-based stream. In my program, in order to follow the IRC protocol, whenever I read "PING" from the stream, I need to respond with a "PONG", this is done simply by writing it to netwriter.

If you aren't familiar with File I/O, you should take some time to familiarize yourself with it; Network I/O uses largely the same classes, the only difference is those classes are dealing with NetworkStream, rather then a FileStream. If you are familar with File I/O then you're already familiar with everything you need to use tcpClient.

If you want to Listen, you use TcpListener, listen to the local Port:

Code: [Select]Dim localAddr As IPAddress = IPAddress.Parse("127.0.0.1")

Dim server As New TcpListener(localAddr, port)

server.Start()

At that point you would wait (either with a loop, ideally on a separate thread) until something connects to your listener, at which point you can use the AcceptTcpClient() to get back a TcpClient object, just like the one you create to connect to something; then you can acquire the streams in the same way and start communication with whatever connected as needed.


Quote from: Geek-9pm on December 20, 2010, 11:24:53 AM
VB .NET has some revisions. Why limit yourself to a five year old product?
While in concept I would agree, there are several things to consider:

1. using Version 2008 would require .NET 3.5; using Version 2010 would require .NET 4.0. and while you can create .NET 2.0 (2005) applications with those, it doesn't really add much when you do so.

2. Unless you are planning on using LINQ and WPF, or you need specific functionality that the new version provides, there is absolutely no reason to use the newer frameworks nor is there any reason to code against those newer frameworks; code should be written to the lowest common denominator whenever possible to run on the most machines.

3. They asked how to do something on Visual Basic 2005. you turn around and basically ask them why they are using Visual Basic 2005 when there are newer versions. It doesn't even come close to answering their question nor do you provide any insight into how the version they are using is even remotely relevant to the task they want to perform. Then you provide a link to some long-dead RS232 terminal communication protocol.


Quote
3. They asked how to do something on Visual Basic 2005. you turn around and basically ask them why they are using Visual Basic 2005 when there are newer versions. It doesn't even come close to answering their question nor do you provide any insight into how the version they are using is even remotely relevant to the task they want to perform. Then you provide a link to some long-dead RS232 terminal communication protocol.

FOR Foot in Mouth 1 & 2
WhineLine <My Bad>
NEXT Foot
2496.

Solve : run Batch-file export in excel (its for a Movie database) Helpme?

Answer»

Hi

I would like a Batch file that read the folders and files and Export in *.TXT or *.Excel
I have my movies ARRANGED such that each movie has its own folder.

Like this:

>Movies
>>The Boondock Saints (1999)
>>>the.boondock.saints.avi
>>>Seen.txt

>>The Matrix (1999)
>>>matrix.MKV
>>>unseen.txt

>>Troy
>>>troy.WMV
>>>

After i run the Batch file it export a TXT or Excel,
If the batch does not read any of TXT like the one in TROY. It display Unknown

a Filter should display All unseen first then, Second Unknown, third SEEN
a Filter should display Unseen, unKnown, Seen in different colors LOL
a Filter should display the Title from A-Z and Number first for example: 1234Abcd-z

The batch file need to count all Folders in Movies

Export TXT or excel in C:\

THe content of the TXT/ Excel looks
Like this:

Unseen The Matrix
Unknown Troy
Seen Bad boys
Seen The Boondock Saints (1999)
Seen Titanic

TOTAL movies 3

- Is this possible ?
- If I Run an batch file daily is that bad for the computer?
- Does batch files also work in Windows 7. I still got XP Later upgrade to Windows 7

Thank you alll
RayUnseen The Matrix
Unknown Troy
Seen Bad boys
Seen The Boondock Saints (1999)
Seen Titanic

Total movies 3 Total movies = 5Batch code can do some of the work, but you'll need an Excel macro for other parts like COLOR.

Code: [Select]@echo off
set mdir=c:\temp
if exist %mdir%\text.csv del %mdir%\text.csv

for /f "tokens=* delims=" %%i in ('dir %mdir% /ad /b') do (
if /i exist %%~dpnxi\seen.txt (echo Seen,%%i >> %mdir%\text.csv
) else if /i exist %%~dpnxi\unseen.txt (echo Unseen,%%i >> %mdir%\text.csv
) else (echo Unknown,%%i >> %mdir%\text.csv
)
)

sort /r %mdir%\text.csv /output %mdir%\sorted.csv
e:\microsoft\office\office10\excel %mdir%\sorted.csv

You need to change the path to Excel and probably the mDir variable which points to the top level movie directory. The output file (sorted.csv) is comma delimited and is easily imported to Excel.

Quote

a Filter should display Unseen, unKnown, Seen in different colors LOL
a Filter should display the Title from A-Z and Number first for example: 1234Abcd-z

The NT sort command does not support multiple sort keys. Use Excel instead. You can color code the data by grouping in Excel.

Quote
If I Run an batch file daily is that bad for the computer?

No. Computer are very good at repetition. Put it to work and make your own LIFE easier.

Quote
Does batch files also work in Windows 7. I still got XP Later upgrade to Windows 7

Batch files still run in Win7 and probably beyond for the foreseeable future. Win7 also has other tools such as VBSCRIPT (installed on Win98 forward) and Powershell (installed on Win7; add-on back to Win2000)

Good luck.
2497.

Solve : javac Command Prompt Issue?

Answer»

Hello all,

I am trying to learn Java (just for fun at the moment) and am working on reading "Fundamentals of Java: AP COMPUTER Science Essentials for the A Exam" 3rd Edition (2006) by Ken Lambert and Martin Osborne. I am in the second chapter ("First Java Programs") and am trying to run the "HelloWorld" program. My problem is in compiling the program. I am using a computer running Windows XP Home SP3 and am using the Command Prompt to attempt to run the program rather than what the book calls an Integrated DEVELOPMENT Environment.
In order to run a program, the book explains you need to install a Java development environment, so I went to Oracle's website and downloaded (and installed) the "jdk-6u23-windows-i586.exe" file. After installing, I typed in the Hello World code given in the book in Notepad and saved it as a ".java" file. I opened the Command Prompt window, navigated to the directory which contained the HelloWorld.java file and typed in "javac HelloWorld.java". Instead of compiling into byte code however, I got a message in the Command Prompt window saying " 'javac' is not recognized as an internal or external command, operable program or batch file."

If anyone could help identify why I can't get the HelloWorld file to compile into byte code I would be very grateful.

Thanks

Here's the code I used in my HelloWorld.java file (I modified slightly for appearance):


// Example 2.11: Our First Program

public class HelloWorld
{

public static void main(String [] args)
{
SYSTEM.out.println(" d ");
System.out.println(" o l ");
System.out.println(" l r ");
System.out.println(" l o ");
System.out.println(" e w ");
System.out.println(" H ");
System.out.println(" ***************** ");
System.out.println(" * * * ");
System.out.println(" * * * ");
System.out.println(" * ***** ");
System.out.println(" * * ");
System.out.println(" * * ");
System.out.println(" * * ");
System.out.println(" ************* ");
}
}The folder that contains javac.exe should be in your PATH system variable if you just want to type javac xxx.java. If it is not on your PATH and it seems like yours is not, you have to type the full path to javac.exe. Do you know which folder it is installed into? Did you follow the install instructions carefully? have you restarted the computer since installing Java?
Quote from: Salmon Trout on December 23, 2010, 10:19:51 AM

The folder that contains javac.exe should be in your PATH system variable if you just want to type javac xxx.java. If it is not on your PATH and it seems like yours is not, you have to type the full path to javac.exe. Do you know which folder it is installed into? Did you follow the install instructions carefully? have you restarted the computer since installing Java?

Hey Salmon, thanks for your response.

I found the javac.exe file in "C:\Program Files\Java\jdk1.6.0_23\bin" (I had the JDK install in its suggested location). I did find the "java.exe", "javaw.exe", and "javaws.exe" in "C:\WINDOWS\system32" folder (that would be the Path folder right?; I don't know hardly anything about Paths) in addition to being in "C:\Program Files\Java\jdk1.6.0_23\bin" folder.

When I did the installation (I installed it yesterday), I followed the instructions provided by the installer dialogue box, but I MIGHT have over looked special instructions if they were on Oracle's website.
As far as a restart, I did not restart the computer right after the installation completed but instead tried to get the Hello World program to run (obviously unsuccessfully). Since yesterday and today however, the computer has been restarted.

Would you recommend uninstalling the JDK and reinstalling it or is there a simpler fix to this issue?Did you uninstall any PREVIOUS versions of Java (JRE for example) before you installed the JDK?


2498.

Solve : vb express append to file?

Answer»

in VISUAL basic express how would i append a string called list to a text file call recipes.txt in the current directoryyou should always check MSDN first (or google). Use the append mode when opening the file for writingno the problem is i cant write to the file at all i should have been more specificQuote from: mat123 on December 24, 2010, 06:33:30 PM

no the problem is i cant write to the file at all i should have been more specific
and why are you not being specific about why you can't write to file , when you know you should?
What error messages? did you open you file properly? Without your code, there's no way to know what went wrong isn't it?Code: [Select]
Dim path As String = My.Computer.FileSystem.CurrentDirectory()
Debug.Write(path)
Dim sw As System.IO.StreamWriter
Dim Loc = path + "recipes.txt"
sw = My.Computer.FileSystem.OpenTextFileWriter(Loc, True
code]
then a sw.writeline(list)tips:

-Stay AWAY from the My Namespace stuff. IMO it's a pretty big hack; also, it doesn't exist in any other .NET language, so in a way it's SOMEWHAT "non-standard".
- Use Path.Combine() to combine paths. Example:


Code: [Select] Dim destfile as String = Path.Combine(Environment.CurrentDirectory,"recipes.txt")
Dim fstream As FileStream = new FileStream(destfile,FileMode.Append)
dim twriter as StreamWriter = new StreamWriter(fstream)
dim list as String="list"
twriter.WriteLine(list)

twriter.Close()

I haven't a clue what your list variable was SUPPOSED to be.

i still does not write to the file there is no error thoughWhy don't you check out MSDN (which i have already told you in my first post ) and see what they say. EXECUTE the example code provided, and see if you can write to file.i finally got it work but how do it get it to be a exe the publish option makes a setup file i just want a stand alone exeuse Build->Build Solution. (Assuming the express versions are similar in menu structure to Professional)

thank you both of you for your help.
2499.

Solve : Batch Script To Log Only The Names Of Files In a Backup Job?

Answer»

Please I need a batch script that will log only the names of files in a backup job. I'm using the batch script below but the log FILE includes the path of the source files as well, how do I remove the path from the log?

@echo off
:: variables
set drive=E:\Backup
set backupcmd=XCOPY /s /c /d /e /h /i /r /y

echo ### Backing up My Documents...
%backupcmd% "%USERPROFILE%\My Documents\My Pictures" "%drive%\My Documents" >> "c:\Batch\somelogfile.txt"

echo Backup Complete!
@pause
I found the answer to my question avove just in case someone else is interested here is the script:

echo ### Backing up %Extension%... To: SingleDirectory Folder
FOR /R "C:\" %%a in ("*%Extension%") DO xcopy "%%a" "%Drive%\SingleDirectory"
:: http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_21509134.html
dir "%Drive%\SingleDirectory"\*.* /b > "%Drive%\SingleDirectorylog.txtJust a note: experts-exchange is a pay site (you have to subscribe with a credit card to SEE "solutions". They say "30 day free trial" but are you prepared to risk that they will not honor your cancellation and charge the card anyway? Given that they are charging you to see information that (a) they did not find themselves and (b) that you could find elsewhere for free, I don't rate their ethics very highly)


Please note that I did not pay a panny to experts-exchange.com the code above was on their website just scroll down to the bottom of the page.Quote from: JavaAndCsharp on DECEMBER 26, 2010, 10:57:54 PM

Please note that I did not pay a panny to experts-exchange.com the code above was on their website just scroll down to the bottom of the page.

The solution is blurred out until you login/register, the latter of which requires GIVING credit card details.When I got the code it wasn't blurred out, good job this was so as I need the code for a project I was working on at the time. Quote from: BC_Programmer on December 26, 2010, 11:00:12 PM
The solution is blurred out until you login/register, the latter of which requires giving credit card details.

It's not blurred out in Google's cache... am I allowed to say that here?
2500.

Solve : Need help with tictactoe network game?

Answer»

So my project is due tomorrow and I'm not sure (Actually I have no idea) what's wrong with it, it's all working good except somehow the if conditions are wrong because it NEVER sets text in the jlabel to say win, here's the code


Server main
Code: [Select]/*
* Main.java
*
* Created on November 10, 2010, 10:57 PM
*
* To change this template, choose Tools | Template Manager
* and OPEN the template in the editor.
*/

package server;

/**
*
* @author Jamaica
*/
public class Main {

public static void main(STRING args[]) {
final serverFrame b=new serverFrame();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
b.setVisible(true);
}
});
b.recieve();
}




}
Server frame
Code: [Select]/*
* serverFrame.java
*
* Created on November 10, 2010, 9:53 PM
*/

package finalserver;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
*
* @author essam
*
*/
public class serverFrame extends javax.swing.JFrame {
int x;
ServerSocket ss=null;
Socket s1=null;
ObjectOutputStream out=null;
ObjectInputStream in=null;
String msg=null;

/** Creates new form serverFrame */
public serverFrame() {
initComponents();
try {
ss=new ServerSocket(2000);
s1=ss.accept();
out=new ObjectOutputStream(s1.getOutputStream());
in=new ObjectInputStream(s1.getInputStream());
} catch (IOException ex) {
ex.printStackTrace();
}

}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton1.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton3.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jButton4.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jButton5.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

jButton6.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});

jButton7.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});

jButton8.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});

jButton9.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});

jLabel2.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent evt) {
jLabel2ComponentShown(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(46, 46, 46)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
.addGap(54, 54, 54))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
);

pack();
}// </editor-fold>

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
if (x==0){
jButton9.setText("O");
jButton9.setEnabled(false);
x=1;
send("9");
}
}

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
if (x==0){
jButton8.setText("O");
jButton8.setEnabled(false);
x=1;
send("8");
}
}

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
if (x==0){
jButton7.setText("O");
jButton7.setEnabled(false);
x=1;
send("7");
}
}

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
if (x==0){
jButton6.setText("O");
jButton6.setEnabled(false);
x=1;
send("6");
}
}

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
if (x==0){
jButton5.setText("O");
jButton5.setEnabled(false);
x=1;
send("5");
}
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
if (x==0){
jButton4.setText("O");
jButton4.setEnabled(false);
x=1;
send("4");
}
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
if (x==0){
jButton3.setText("O");
jButton3.setEnabled(false);
x=1;
send("3");
}
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
if (x==0){
jButton2.setText("O");
jButton2.setEnabled(false);
x=1;
send("2");
}// TODO add your handling code here:
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

if (x==0){
jButton1.setText("O");
jButton1.setEnabled(false);
x=1;
send("1");
}


}

private void jLabel2ComponentShown(java.awt.event.ComponentEvent evt) {
// TODO add your handling code here:
}
public void send(String x){
try {
out.writeObject(x);
} catch (IOException ex) {
ex.printStackTrace();
}
}
public void recieve(){
while (true){
try {
msg=(String) in.readObject();
check(msg);
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
public void check(String y){
if (y.equals("1")){
jButton1.setText("X");
jButton1.setEnabled(false);
x=0;
}
if (y.equals("2")){
jButton2.setText("X");
jButton2.setEnabled(false);
x=0;
}
if (y.equals("3")){
jButton3.setText("X");
jButton3.setEnabled(false);
x=0;
}
if (y.equals("4")){
jButton4.setText("X");
jButton4.setEnabled(false);
x=0;
}
if (y.equals("5")){
jButton5.setText("X");
jButton5.setEnabled(false);
x=0;
}
if (y.equals("6")){
jButton6.setText("X");
jButton6.setEnabled(false);
x=0;
}
if (y.equals("7")){
jButton7.setText("X");
jButton7.setEnabled(false);
x=0;
}
if (y.equals("8")){
jButton8.setText("X");
jButton8.setEnabled(false);
x=0;
}
if (y.equals("9")){
jButton9.setText("X");
jButton9.setEnabled(false);
x=0;
}
}

public void cwin(){
if(jButton1.getText().equals(jButton2.getText()) && jButton3.getText().equals(jButton1.getText())&&jButton1.getText().equals("o")) {
jLabel2.setText("You win");

CLOSE();


} else
if(jButton4.getText().equals(jButton5.getText())
&& jButton4.getText().equals(jButton6.getText())
&& jButton4.getText().equals("O"))
{
jLabel2.setText("You win");

close();
}
else
if(jButton7.getText().equals(jButton8.getText())
&& jButton7.getText().equals(jButton9.getText())
&& jButton7.getText().equals("O"))
{
jLabel2.setText("You win");


close();
}
else
if(jButton1.getText().equals(jButton4.getText())
&& jButton1.getText().equals(jButton7.getText())
&& jButton1.getText().equals("O"))
{
jLabel2.setText("You win");

close();

}
else
if(jButton2.getText().equals(jButton5.getText())
&& jButton2.getText().equals(jButton8.getText())
&& jButton2.getText().equals("O"))
{
jLabel2.setText("You win");

close();

}
else
if(jButton4.getText().equals(jButton5.getText())
&& jButton4.getText().equals(jButton6.getText())
&& jButton4.getText().equals("O"))
{
jLabel2.setText("You win");

close();

}
else
if(jButton3.getText().equals(jButton6.getText())
&& jButton3.getText().equals(jButton9.getText())
&& jButton3.getText().equals("O"))
{
jLabel2.setText("You win");


close();
}
else
if(jButton1.getText().equals(jButton5.getText())
&& jButton1.getText().equals(jButton9.getText())
&& jButton1.getText().equals("O"))
{
jLabel2.setText("You win");

close();

}
else
if(jButton4.getText().equals(jButton5.getText())
&& jButton4.getText().equals(jButton6.getText())
&& jButton4.getText().equals("O")){
jLabel2.setText("You Win");

close();

}
else
if(jButton3.getText().equals(jButton5.getText())
&& jButton3.getText().equals(jButton7.getText())
&& jButton3.getText().equals("O"))
{
jLabel2.setText("You win");

close();

}
}

private void close() {
throw new UnsupportedOperationException("Not yet implemented");
}

private void sendmassege(String string) {
throw new UnsupportedOperationException("Not yet implemented");
}




/**
* @param args the command line arguments
*/


// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
// End of variables declaration

}


Client main
Code: [Select]/*
* Main.java
*
* Created on November 10, 2010, 10:56 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package client;

/**
*
* @author Jamaica
*
*/
public class Main {

public static void main(String args[]) {
final clientFrame c=new clientFrame();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
c.setVisible(true);
}
});
c.recieve();
}


/** Creates a new instance of Main */
}

Client's frame
[code]
/*
* clientFrame.java
*
* Created on November 10, 2010, 9:53 PM
*/

package client;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;


/**
*
* @author essam
*/
public class clientFrame extends javax.swing.JFrame {

int X;
Socket s1=null;
ObjectOutputStream out=null;
ObjectInputStream in=null;
String msg=null;

public clientFrame() {
initComponents();
try {
s1=new Socket("localhost",2000);
out=new ObjectOutputStream(s1.getOutputStream());
in=new ObjectInputStream(s1.getInputStream());
} catch (UnknownHostException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//
private void initComponents() {

jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLO SE);

jButton1.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton3.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jButton4.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jButton5.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

jButton6.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});

jButton7.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});

jButton8.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});

jButton9.setFont(new java.awt.Font("Tahoma", 1, 24));
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG, false)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE))
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)
.addGroup(javax.swing.GroupLayout.Alignment.TRAIL ING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)
.addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.Alignment.TRAIL ING, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem ent.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
.addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem ent.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem ent.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL ING, false)
.addComponent(jButton8, javax.swing.GroupLayout.Alignment.LEADI NG, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton9, javax.swing.GroupLayout.Alignment.LEADI NG, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem ent.RELATED)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem ent.UNRELATED)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)
.addContainerGap())))
);

pack();
}//

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
if (X==0){
jButton9.setText("X");
jButton9.setEnabled(false);
X=1;
send("9");
}
}

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
if (X==0){
jButton8.setText("X");
jButton8.setEnabled(false);
X=1;
send("8");
}
}

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
if (X==0){
jButton7.setText("X");
jButton7.setEnabled(false);
X=1;
send("7");
}
}

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
if (X==0){
jButton6.setText("X");
jButton6.setEnabled(false);
X=1;
send("6");
}
}

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
if (X==0){
jButton5.setText("X");
jButton5.setEnabled(false);
X=1;
send("5");
}
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
if (X==0){
jButton4.setText("X");
jButton4.setEnabled(false);
X=1;
send("4");
}
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
if (X==0){
jButton3.setText("X");
jButton3.setEnabled(false);
X=1;
send("3");
}
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
if (X==0){
jButton2.setText("X");
jButton2.setEnabled(false);
X=1;
send("2");
}
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if (X==0){
jButton1.setText("X");
jButton1.setEnabled(false);
X=1;
send("1");
}
}
public void send(String X){
try {
out.writeObject(X);
} catch (IOException ex) {
ex.printStackTrace();
}
}

public void recieve(){
while (true){
try {
msg=(String) in.readObject();
check(msg);
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}

public void check(String B){
if(B.equals("1")){
jButton1.setText("O");
jButton1.setEnabled(false);
X=0;
}
if(B.equals("2")){
jButton2.setText("O");
jButton2.setEnabled(false);
X=0;
}
if(B.equals("3")){
jButton3.setText("O");
jButton3.setEnabled(false);
X=0;
}
if(B.equals("4")){
jButton4.setText("O");
jButton4.setEnabled(false);
X=0;
}
if(B.equals("5")){
jButton5.setText("O");
jButton5.setEnabled(false);
X=0;
}
if(B.equals("6")){
jButton6.setText("O");
jButton6.setEnabled(false);
X=0;
}
if(B.equals("7")){
jButton7.setText("O");
jButton7.setEnabled(false);
X=0;
}
if(B.equals("8")){
jButton8.setText("O");
jButton8.setEnabled(false);
X=0;
}
if(B.equals("9")){
jButton9.setText("O");
jButton9.setEnabled(false);
X=0;
}
}

public void cwin(){
if(jButton1.getText().equals(jButton2.getText())
&& jButton1.getText().equals(jButton3.getText())
&& jButton1.getText().equals("X"))
{
jLabel1.setText("You win");
sendmessage("You lose");
close();
}

if(jButton4.getText().equals(jButton5.getText())
&& jButton4.getText().equals(jButton6.getText())
&& jButton4.getText().equals("X"))
{
jLabel1.setText("You win");
sendmessage("You lose");
close();
}

else
if(jButton7.getText().equals(jButton8.getText())
&& jButton7.getText().equals(jButton9.getText())
&& jButton7.getText().equals("X"))
{
jLabel1.setText("You win");
sendmessage("You lose");
close();

}
else
if(jButton1.getText().equals(jButton4.getText())
&& jButton1.getText().equals(jButton7.getText())
&& jButton1.getText().equals("X"))
{
jLabel1.setText("You win");
sendmessage("You lose");
close();

}
else
if(jButton2.getText().equals(jButton5.getText())
&& jButton2.getText().equals(jButton8.getText())
&& jButton2.getText().equals("X"))

{
jLabel1.setText("You win");
sendmessage("You lose");
close();
}
else
if(jButton4.getText().equals(jButton5.getText())
&& jButton4.getText().equals(jButton6.getText())
&& jButton4.getText().equals("X"))
{
jLabel1.setText("You win");
sendmessage("You lose");
close();

}
else
if(jButton3.getText().equals(jButton6.getText())
&& jButton3.getText().equals(jButton9.getText())
&& jButton3.getText().equals("X"))
{
jLabel1.setText("You win");
sendmessage("You lose");

close();

}
else
if(jButton1.getText().equals(jButton5.getText())
&& jButton1.getText().equals(jButton9.getText())
&& jButton1.getText().equals("X"))

{
jLabel1.setText("You win");
sendmessage("You lose");

close();

}

else
if(jButton4.getText().equals(jButton5.getText())
&& jButton4.getText().equals(jButton6.getText())
&& jButton4.getText().equals("X")){
jLabel1.setText("You Win");
sendmessage("You lose");

close();
}
else
if(jButton3.getText().equals(jButton5.getText())
&& jButton3.getText().equals(jButton7.getText())
&& jButton3.getText().equals("X")){
jLabel1.setText("You Win");
sendmessage("You lose");

close();

}




}

private void sendmessage(String string) {
throw new UnsupportedOperationException("Not yet iQuote

Code: [Select]if(jButton1.getText().equals(jButton2.getText()) && jButton3.getText().equals(jButton1.getText())&&jButton1.getText().equals("o")) {

The last condition is checking wether it's equal to "o" but you have been setting them to "O" (capitalized).