Comatose 290 Taboo Programmer Team Colleague

I suggest you use SDL_net For networking. The library is pretty much procedural, but writing a quick wrapper class so it behaves in an OOP manner is trivial.

One thing about Anti-Viruses, is that they rely on a signature database. Typically there is an underlying engine that simplifies the majority of this processes. Understand, that this is no minor undertaking..... writing an A.V. is down-right cumbersome, even at the simplest level. That's not to mention making it consume less resources so that your performance doesn't end up like Norton's... I strongly suggest downloading the source code of the Free Software AV called Clamwin, or the OpenAntiVirus Project.

Comatose 290 Taboo Programmer Team Colleague

Gvim FTW!

Comatose 290 Taboo Programmer Team Colleague
Comatose 290 Taboo Programmer Team Colleague

to run the perl script from VB.NET, you need to shell to the system. I guess this works:

dim wsh
set wsh = createobject("WScript.Shell")
wsh.run "c:\perl\perl.exe somefile.pl", 0, 0

as for accessing the database with perl, look up the DBI Perl Module.

Comatose 290 Taboo Programmer Team Colleague

Your loop, where you have buttons = button... yeah, that doesn't create new instances of ButtonFoo. You are taking button[0] and pointing it to button. Then taking button[1] and pointing it to the same object as button[0]....

Comatose 290 Taboo Programmer Team Colleague

Just remember scope when playing with those braces. If you declare something inside the braces, it will only exist between the braces:

int main(int argc, char **argv)
{

	int a;
	
	{
		int a;
		a=5;
	}

	cout << a << endl;
}

That is a whole different beast. Be careful of that "Gotcha!".

Comatose 290 Taboo Programmer Team Colleague

With a loop. If you are using windows, then focus on Getcursorpos, and Setcursorpos.

Comatose 290 Taboo Programmer Team Colleague

A Structure in C++ is a class. The only difference between the struct keyword and the class keyword, is that by default struct makes all members not explicitly identified as public. A Class makes all members (unless otherwise noted) private. That's it. No other difference. Struct has a default constructor, or you could specify one. It has a destructor too.... If you make a new struct via new, and you never call delete on it, you will have a memory leak.

Comatose 290 Taboo Programmer Team Colleague

You sure it's not WM_CLOSE?

Comatose 290 Taboo Programmer Team Colleague

If your e-mail client handles HTML, you can simply enclose it in <b> </b> tags. You are really heavily reliant on the e-mail client for this.

Comatose 290 Taboo Programmer Team Colleague

I would make the .pl file, look for a temp file. Something like clpdata.dat or something, and have perl write the entry to the temp file. Then, I would have it scan the process list for other instances of my program... and when I see that I am the last process (assuming windows launches these sequentially) open the file, copy to the clipboard, and delete the file......I'll think about this one today.... KevinADC might have a better solution to this one.

Comatose 290 Taboo Programmer Team Colleague

You have gcc (The C compiler) installed, but not g++ (The C++ compiler). cc1plus is the binary you need, but it comes bundled with g++ (not gcc). Look for build-essential, or at a prompt apt-get install build-essential. Possibly you might just do apt-get install g++, but I think build-essential has more tools.

Alibeg commented: Quick&precise problem allocation +1
Comatose 290 Taboo Programmer Team Colleague

Bah :icon_eek:

Wish I would have caught that it was homework :/

Comatose 290 Taboo Programmer Team Colleague
dim x as string
x = "hello world"
if instr(1, x, " ") <> 0 then
     msgbox "yeah, space."
else
     msgbox "no sir!"
end if
nagatron commented: Thank you, here is good reputation for you. +1
Comatose 290 Taboo Programmer Team Colleague

qw (quote word) is used to generate a list of words. In the case above, where you use it as parameters to use module (which still wouldn't have worked, since you had a semicolon between use socket and qw). Basically, it allows you to specify a list with simple syntax. If I want to assign an array with values, I can do it like this @names = ('karthik.c', 'kevinadc', 'comatose'); which is ok I guess, but the syntax is a little ugly. I could use qw to simplify it like @names = qw(karthik.c kevinadc comatose); and that does the same thing. I guess simply said, qw is a quick way to specify a lot of little single-quoted words.

My my my. Ok, let's talk about scope. Scope is a particular area inside or between opening and closing braces. A variable in a given scope, is only accessible, inside those braces. Furthermore, the variable gets destroyed when the closing brace is reached. Let's look at an example:

#!/usr/bin/perl

my $name = "comatose";
{
     my $name = "karthik.c";
}
print "$name\n";

You would probably think that the last line should print karthik.c to the screen with a newline. No. Since "my" was used inside the braces $name is a different $name than the one outside of the braces. So the one that gets assigned karthik.c, gets destroyed when it reaches the }, and now the outer $name is the only one that exists. If you remove the my from $name …

Comatose 290 Taboo Programmer Team Colleague

Capitalize socket in your third line. use Socket, not use socket. Also, remove the qw line following it.

Comatose 290 Taboo Programmer Team Colleague

*waves his hand like a Jedi*
You want to code an open source active directory clone.....

Rashakil Fol commented: Win. +9
Salem commented: This isn't the free homework service you're looking for, move along now, move along :) +29
Comatose 290 Taboo Programmer Team Colleague

Well for one, you try to treat scores as an array of type int, but you declare it as a single int with size. (int scores, size). Guess you might want to pass it as a pointer or reference, but if you declare it as int scores[], you are going to have to give it a size. The displayScores function wants an int, but you try to pass it an array of ints... should probably make it a pointer. In your nameFile function, you receive a reference to an ifstream, and try to shift into it from stdin... you probably want infile to be a string, instead of an ifstream... I guess the question isn't what is wrong, but what is right.

Comatose 290 Taboo Programmer Team Colleague

First, there is going to be an issue with the fact that you use the word "string" as a variable.... yeah no. You included iostream, and are using the std namespace, so string is a type. Can you have a variable named int? So, create a new char array, like bstring or something, and use that instead of "string". After you do that, you are going to have a bunch of issues with having to dereference your char arrays (such as string = (string + tempstr) ).

A suggestion here... stick with a programming style. You have a bunch of if's with opening braces { and then close them in some arbitrary and seemingly random location. Look at the first if you have (in the while loop inside of formatering). You have the if and expression on one line, then the brace on another, with code right there next to it. If you want to go ANSI style fine, but at least do that part right. then your last if, which is near the bottom there, has the brace on the same line as the if and the expression.... how 'bout you pick one and be consistent? Anyway, it will work once you change string, and make modifications to the unreferenced pointers so that they point to the values and not the locations. You will get a warning in g++ however, alerting you against the unsafe use of gets.

Comatose 290 Taboo Programmer Team Colleague

For which browser (firefox)?

Comatose 290 Taboo Programmer Team Colleague

I wonder if somehow the C++ program is introducing an EOF character prematurely. I strongly doubt it's a crlf \n issue (that is linux uses a different mechanism for new lines than does DOS/Windows). If I'm not mistaken, in linux EOF is ^D, and in M$ I think it's ^Z.... soooooooooo maybe there is an issue there... also, make sure it's not a permissions issue, though I imagine if it were, the web server would give you an error, other than a blank HTML.

Comatose 290 Taboo Programmer Team Colleague

The problem is, the method you use to read from the file handle, slurps the file, and then iterates over each line by replacing $line with $_. If you really want to prove this, you can throw the special variable $. into your code. $. is a special variable in perl that represents the "current line number" in the file. If you run this code:

#!/usr/bin/perl

$log="test.log";
open(LOGFILE, $log) or die("Could not open log file.");
foreach $line (<LOGFILE>) {
    chomp($line); 
	if($line eq "Raghu") {
		print "Found a group\n";
		print "$.\n";
		$var = <LOGFILE> or die ("couldn't read: $!\n"); # Error Checking
		chomp($var);
		print "$var\n";
	}
}
close(LOGFILE);  # // How 'bout you close your open file handles :p

Your output from this will be:

Found a group
10
couldn't read:

Naturally, your line number (ie: the 10 here) will probably be different, depending on the number of lines in your file. It is important to note, that the program (with my minor modifications) dies after it tries to read from the file handle a second time.... this is because perl has slurped the file, so we have already seeked to EOF (end of file). The 10 here, shows that the current line number (in my case 10) is already at the end of the file. If this were not the case, then we would see the line with 10 change from 1 to 2 to 3, etc.

A better method for iterating over each line of the …

KevinADC commented: Well said +4
Comatose 290 Taboo Programmer Team Colleague

Alright, let me give you the break down. Typically when people refer to shell scripting they refer to *nix only. You don't shell script in windows. In windows you can write a batch file... in windows you can write a "script", usually known as WSH (Windows Scripting Host), VBS (VBScript), or JScript (Microsoft's hacked up version of javascript). When people talk about "shell scripts" though, they are referring to scripts that work on a specific shell in unix / linux.

I guess some definitions are in order. The shell is an old term that pretty much means an interface for the users. In XP, it would be accurate to say that explorer.exe (not internet explorer, explorer.exe is the program that provides you with a start button and a desktop) /IS/ the graphical shell. I'm guessing this came about, because it protects the OS from you, and shields you from it.

A Script, is a file that has programming in it. A Script does not need to be compiled into machine language prior to it being run.... this happens when you run the script, on the fly. This is an important distinction between a scripting language, and a "programming language." A programming language needs a separate program, which is used to turn what the programmer types into machine code. This program is called a compiler. Scripts don't need this program, because there is a different program that translates the code into machine language, which runs at the …

Salem commented: Nice answer +29
Comatose 290 Taboo Programmer Team Colleague

go to start, run, type in cmd and press ok.
you'll get a black window with the version number and everything.

Comatose 290 Taboo Programmer Team Colleague

Ok... What have you tried up to this point? (post some code <snip>)

Comatose 290 Taboo Programmer Team Colleague

I normally don't like to post after such a great explanation, but it's sort of important to point out, that the lines are the implementation of the class. You have the class definition which basically is the structure of the class.... but then you have functions (methods) in the class. Those are the locations where you actually write code for the class methods. You should research ::, which is actually the scope operator, and allows you to do a number of cool things.

Comatose 290 Taboo Programmer Team Colleague

Sounds to me like you have either a dead-lock.

Comatose 290 Taboo Programmer Team Colleague

replace will work, and is more efficient than using left$().

Comatose 290 Taboo Programmer Team Colleague

Module:

Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Play Button:

CommandString = "open """ & FileName & """ type mpegvideo alias " & FileName
RetVal = mciSendString(CommandString, vbNullString, 0, 0)

Then research MCI with vb6.

Comatose 290 Taboo Programmer Team Colleague

Split the data in the textbox by space... and then trim the extra characters... so something like:

parts = split(textbox1.text, " ")
rlname = parts(0)
rfname = parts(1)
rmname = parts(2)
label1.caption = rlname
label2.caption = rfname
label3.caption = rmname

You may want to do some error checking and exception handling... but meh.

Comatose 290 Taboo Programmer Team Colleague

what does Inst = A(4); do?

Comatose 290 Taboo Programmer Team Colleague

try to use

SAVESETTINGS
GETSETTINGS
DELETE SETTINGS

for the purpose.

That doesn't answer his question or tell him how to use the registry from VB. It limits him to using HKLM\Software\hisapp.... what if he wants to modify the run key, or clear an MRU?

Comatose 290 Taboo Programmer Team Colleague
dim wsh
set wsh = createobject("WScript.Shell")
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\funstuff", "fun value", "REG_SZ" ' // Write To Value To Registry, Also For Editing

msgbox wsh.regread "HKLM\Software\Microsoft\Windows\Currentversion\Run\funstuff\fun value" ' // Read From Registry

wsh.regdelete "HKLM\Software\Microsoft\Windows\Currentversion\Run\funstuff" ' // Delete Value From Registry

http://support.microsoft.com/kb/178755

Comatose 290 Taboo Programmer Team Colleague

1) make sure you are adding a \n to the end of the data stream (I've found it to work).
2) Install wireshark. Then you can sniff the traffic on that port, and check all incoming and outgoing (ehem) traffic.

Comatose 290 Taboo Programmer Team Colleague

I don't get it on your post here... I don't get it on the first link, but I do get it Here. I'm guessing he added those <b></b>'s into the code perhaps?

Comatose 290 Taboo Programmer Team Colleague

you need to compile your other .cpp's into .o's first... so something like g++ -c marble.cpp -o marble.o then you should be able to add it into your compile line I guess like g++ vector_jar_test.cpp marble.o . Should create an a.out for you.

Comatose 290 Taboo Programmer Team Colleague

I think if you are on linux, you should use a real database (like mysql). Sorry I can't give you a better response than that, but I'm just not sure it's plausible.

Comatose 290 Taboo Programmer Team Colleague

I would get the source code for like, linphone or some such, and see how they did it. There may even be a library to handle the SIP information for you. If not, you can at least see what they did. A Good place to start is the SIP RFC.

Comatose 290 Taboo Programmer Team Colleague

Not end sub.... exit sub...

Comatose 290 Taboo Programmer Team Colleague

I didn't think quickbooks came with a vb accessible API library. Interesting that it does. You should be able to do this then, with no problem. Once you add a reference to the library, you can press (I think F2) to go to the object explorer. It usually enumerates all the functions in a library, and how to use them.

Comatose 290 Taboo Programmer Team Colleague

*mumbles something about find_last_of*

Ancient Dragon commented: perfect solution :) +36
Comatose 290 Taboo Programmer Team Colleague

I agree, this happens with me too. I've dedicated myself to just being a prick, and leaving them with a downrep.... but it would be awesome to be able to pull myself away from the dark side, and little more near the neutral side of the rep force.

Comatose 290 Taboo Programmer Team Colleague

Nice. You are in vista like he is?

Comatose 290 Taboo Programmer Team Colleague
int main()
{
    system("C:\\test.bat");

    return 0;
}

works just fine for me on WinXP. same batch file as yours.

If nothing else works, change "msg" to "C:\Windows\System32\msg.exe"

>i dont wish to run it "trough" my program, just as if i had found the destination and doubleclick'ed it.

I believe using system, execl, and the like, will force the C++ program to wait until the program returns.... I don't think shellexecute is going to force the c++ program to wait for the shelled application to return.

Comatose 290 Taboo Programmer Team Colleague

You can try using /'s. A lot of compilers and what not will read / in windows machines. You could also try quoting the parameter on the command line, for instance: yourprogram.exe "c:\program files\radio\audio"

Comatose 290 Taboo Programmer Team Colleague

stick a msgbox right after strData = trim (msgbox strData) then do one after strlocal = trim, and one strRemote. Make sure that it's not your code that is truncating the file. If needed, find the PutFiles sub, and throw some messageboxes in there too. Basically, trace your file name from the moment the program gets it, to the point where it gets sent to the wire. Then you'll know if it's your code, or say, the server.

Comatose 290 Taboo Programmer Team Colleague

Then I guess you should have sent her a PM instead of posting a thread on a public forum... FACE.

Comatose 290 Taboo Programmer Team Colleague

It's a very bad practice to use goto in programming. It is strongly frowned upon by professional programmers, and actually forbidden in business code. Instead, you can use "exit sub" to replace that goto statement. Even that (since it is just a single if statement and nothing else) isn't even necessary, as the code will simply end once the if statement is completed.

Comatose 290 Taboo Programmer Team Colleague

first, format the code so that it uses proper indentation, and braces. That's the first step.

Comatose 290 Taboo Programmer Team Colleague

Just because something is syntactically accurate doesn't mean "there is nothing wrong with the code." An important thing to mention about code, is that you are supposed to make it easy to read. Just because "it compiles fine" doesn't mean another programmer can look at it, and decipher your code without major effort. Some of these things include proper indentation. Indentation allows someone to see which blocks of code fall under which conditions and loops. It is meant to simplify the debugging process, and make life easier for you later on, and any other programmers who might work on your code. I'll wager that Salem's comment, wasn't merely a quick fix to a problem, it was meant to address a much deeper issue as well, such as the entirety of the style. I'll guess it should look something more like:

#include <iostream.h>
#include <conio.h>

using namespace std;

int main(int argc, char **argv)
{
	clrscr();
	int a[10],n,min,max,i;
	cout<<"Enter the number of elements in the matrix \t";
	cin>>n;
	cout<<"enter the elements of the matrix \n";

	for(i=0;i<n;i++) {
		cin>>a[i];
		max=min=a[0];

		 for(i=0;i<n;i++) {
			 if(a[i]>max) {
				max=a[i];

			 } else if(a[i]<min) {
			 	min=a[i];
			 }
		 }
	}

	cout<<"Largest is "<<max<<" and Smallest is "<<min;
	getch();

	return 0;
}