Comatose 290 Taboo Programmer Team Colleague

Heavens Yes! Watch this thread get deleted... just like my tutorials.

Comatose 290 Taboo Programmer Team Colleague

Well, the moderators who are supposed to strip those posts out would need to keep saging off..... posting new questions in old threads isn't supposed to happen (or receive any kind of answer other than "how 'bout you post a new thread") anyway.

verruckt24 commented: Exactly +3
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
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

*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

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

*mumbles something about find_last_of*

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

*Mumbles something about std::reverse()*

verruckt24 commented: Like the way you say it. +2
Comatose 290 Taboo Programmer Team Colleague

Antibiotics anyone..... antibiotics?

Nick Evan commented: Hehe +14
Comatose 290 Taboo Programmer Team Colleague

hmmm \b?

cikara21 commented: haha.. +1
Comatose 290 Taboo Programmer Team Colleague

First, you don't want your instructor to know that you simply copied the code from this web page. Getting assistance by using the page is one thing.... basically plagiarizing the code is another altogether. However, the output is correct, and the program does work.

The reason it is likely "just closing" is because you are running this through a GUI of some kind, that launches the code, and exits (hence, closing the otuput window). You can run this through a command line, or put a cin.ignore() just before the return 0; (which you don't have, but should have as the last line before the ending }). If one cin.ignore() doesn't work, try two.

StuXYZ commented: well spotted that it was a copy!!! +5
Comatose 290 Taboo Programmer Team Colleague

Even though I strongly empathize with your situation, the code that you are requesting is highly illegal, and has major moral implications as well. As the site rules (sometimes unfortunately) dictate, this type of help (even though the situation may warrant it) is forbidden on the site. I'm sorry.

ddanbe commented: Nice handling of a delicate situation. +4
Comatose 290 Taboo Programmer Team Colleague
shell "cmd.exe /c dir \"
samir_ibrahim commented: Very cool one command line +1
Comatose 290 Taboo Programmer Team Colleague
dim somedate as string
somedate = "2/3/2009"
parts = split(somedate, "/")

if ubound(parts()) < 2 then
     msgbox "Error Parsing Date String"
     exit sub
else
     mymonth = somedate(0)
     myday = somedate(1)
     myyear = somedate(2)

     combo1.additem(mymonth)
     combo2.additem(myday)
     combo3.additem(myyear)
end if
Ramy Mahrous commented: Nice +6
Comatose 290 Taboo Programmer Team Colleague

don't type else part of if statements!just write two if statements!this would save you some time when you want to later view the program!

What The Hell? Please don't post crappy advice.

Rashakil Fol commented: <circlejerk/> +9
Comatose 290 Taboo Programmer Team Colleague

Indeed but that is hardly generic.

You need to look at the core components.

While I fully agree with you here, his question was about getting access to the individual characters in the string... not about how to proceed with the rest of his project. ;)

iamthwee commented: Yeah true. +18
Comatose 290 Taboo Programmer Team Colleague

One problem, is that you didn't create your own thread.... using someone else's thread to post your question is a sure way to get flamed and not get the answer you desire. It also helps to use code tags.... we see code, all ugly and without colors or indentation, and quite frankly, makes us not want to read it or help.

So, step one to solving your issue, start a new thread and use code tags.

StuXYZ commented: Many thx: I hate thread hijack +4
Comatose 290 Taboo Programmer Team Colleague

Call "c:\windows\system32\dfrg.msc" with shell or system processes or wsh.run or shellexecute.

Ramy Mahrous commented: That's the perfect answer! +6
Comatose 290 Taboo Programmer Team Colleague
Ramy Mahrous commented: Good reference +6
Jx_Man commented: Great :) +12
Comatose 290 Taboo Programmer Team Colleague

I'm pretty sure the only way is to refer to the object and assign it directly. That is, something along the lines of:

form2.txtBudget.text = form1.txtBudget.text
nor_d83 commented: Works very well.. +1
Comatose 290 Taboo Programmer Team Colleague

I wonder if the

#if (_WIN32_WINNT >= 0x0501)

isn't working correctly... (In ws2tcpip.h)

Comatose 290 Taboo Programmer Team Colleague
int calcList() 
{
	std::string inputVal;
	int cnt = 0;
	int list[100];

	while (inputVal != "complete") {
		std::cout << "Enter an integer: ";
		std::getline(std::cin, inputVal);

		if (inputVal != "complete") {
			list[cnt] = (int)inputVal.c_str();
			cnt++;
		}
	}

	return 0;
}

or something.

1bennyd commented: Nice, simple, code. +1
Comatose 290 Taboo Programmer Team Colleague

You are using std::string, you need to be using array of char.

EDIT: Didn't see Narue Posted... My responses never do so well following hers... discard this :p

Comatose 290 Taboo Programmer Team Colleague

,,,someone professional in Java, the next step should be C# not VB.NET:)

I couldn't agree more.

To answer your question, however: AddHandler :)

Ramy Mahrous commented: I like his behavior in VB.NET forum +6
javaAddict commented: Exactly what I was looking for +5
Comatose 290 Taboo Programmer Team Colleague

1) You shouldn't post in red. It doesn't alter our level of urgency, and actually annoys us. I know your reason was probably to distinguish between your code and your words, but see 3 for that.
2) Let's not post in all caps. Makes it seem like you are yelling at me, and that doesn't inspire me to be helpful.
3) Use Code Tags. when you post code, you can use them by typing (without the spaces between [ and ]):
[ code=c++ ]
// your code here
[ /code ]

Since I am fairly unsure about a number of things in your code (such as missing parenthesis, why you are adding 1 to i during your output, and whatever convinced you to use >>) however, if you are wanting to add a simple if statement, as in the one you mentioned above:

if (tinssold > 52) {
     tinprice *= 2; // multiply by two is doubled right?
}
Salem commented: Well said. It's still horrid even without the wax crayon colouring in. +26
Comatose 290 Taboo Programmer Team Colleague
/* ************************************* */
/* Function To Run A Shell Command, And  */
/* Read The Output Back Into Our Program */
/* ************************************* */
std::string run_command(string cmd)
{
        string data;
        FILE *stream;
        char buffer[1024];

        // Open The Command With Read Flag  
        stream = popen(cmd.c_str(), "r");
        while (fgets(buffer, 1024, stream) != NULL) {
                data.append(buffer);
        }
        pclose(stream);

        return data;
}

Usage Case:

// Find Running SSH Daemons In Linux
std::string grepvals = run_command("ps aux | grep \"sshd\"");
Comatose 290 Taboo Programmer Team Colleague

sure, windows.h includes everything that we need. The standard C++ stuff, is just the includes, using namespaces (the namespaces and the #include <iostream> isn't even needed...it just came with the Code::Blocks IDE Blank Project, so I just left it) . So, Basically, the include directive tells the pre-compiler that we want to copy the contents of <windows.h> into our file at the top. The next step is the main function, known as the exe's entry point (the first piece of code that will run when the OS launches it) The only real line of code in the program is the SendMessage call, which is found in the windows.h file... SendMessage is a function used to basically make another window/program behave as you would want it to (ie: you can send messages to have a window minimize, maximize, close... whatever) .

SendMessage wants to know what window to send the message to. We used another function (defined in windows.h) called GetDesktopWindow, which will give us the "handle" or "hwnd" of the Desktop Window. An Hwnd is a unique hex value assigned to a window so that it can be identified by the OS. Every window has one. So, we get the hwnd for the desktop (with GetDesktopWindow) and use that hwnd, so that SendMessage knows which window we are sending a message to. The WM_SYSCOMMAND, let's the window know that we are about to send it a system command of some kind. The SC_SCREENSAVE (both WM_SYSCOMMAND and SC_SCREENSAVE are also …

clutchkiller commented: Helpful +1
Comatose 290 Taboo Programmer Team Colleague

Ok, let's try to tackle this step by step....

1. There are a number of ways to find data within a string. What we really need to know, is the format of these files.... for example, does the file look like this: 1. c:\windows\somefile.txt or does it look like this: c:\windows\somefile.txt, 1 This is important, because the code is going to be different based on how the first file looks inside. In the first example, you could get item number 5 like so (this also solves the last question, because it loops through the entire file):

' /* This Assumes format: 1. c:\path\file.txt */
open "c:\windows\somefile.txt" for input as #1
     do until eof(1)
          line input #1, tmpvar
          if left(tmpvar, 1) = "5" then
               ' /* Do something here with line 5 of the file */
               msgbox "Line 5 is: " & tmpvar
          end if
     loop
close #1

2. There are a couple of ways to go about extracting data from a string.... if you know the layout of the file, it's easy enough to do something like instr, or split. So, let's say that we have a file, and inside it looks like this: error: c:\somefile.txt is a duplicate , we can do some fancy code, that will extract c:\newfile.txt from that line, with split:

' /* Extract Path From Line of File */
open "c:\newfile.txt" for input as #1
     do until eof(1)
          line input #1, tmpvar
          partsarray = split(tmpvar, " ")
          path = partsarray(1)
     loop
close …
jonc commented: A blinding example of working with text files... just had to add rep for it. +1
Comatose 290 Taboo Programmer Team Colleague
#!/usr/bin/perl

while ($uinput ne "quit") {
        print "# "; $uinput = <>;

        chomp($uinput);

        if ($uinput eq "ls") {
                open(LS, "ls -AF1 |");
                        while (<LS>) {
                                chomp;
                                push @flist, $_;
                        }
                close(LS);

                foreach $file (@flist) {
                        print "$file\n";
                }
        }
}
crestaldin commented: great ! This post has given me a valuable piece of information that I've been trying to get ...Thanks a lot +2
Comatose 290 Taboo Programmer Team Colleague

Is this in XP (there has a been a few threads going around about problems with reading/writing serial ports in XP with VB). Also, I'm not sure if the output is supposed to be a string, or if it's supposed to be those values in hex.....

Comatose 290 Taboo Programmer Team Colleague

It's a problem with my code (BAH):

if right(SearchString, 1) = chr(13) or right(SearchString, 1) = chr(10) then
     ' /* Should be Left, Not Right */
     SearchString = left(SearchString, len(SearchString) -1)
end if
Comatose 290 Taboo Programmer Team Colleague
if right(SearchString, 1) = chr(13) or right(SearchString, 1) = chr(10) then
     SearchString = right(SearchString, len(SearchString) -1)
end if

Would Also Do The Trick... There's more than one way to strip a newline (ok, that one's bad).

WolfPack commented: Done. +3
Comatose 290 Taboo Programmer Team Colleague

That is the best way to do it. A couple things I would note on this. One of them, is the use of an empty string in the replace function. I know on small applications, that it doesn't make a serious difference, but an empty string uses memory space (well, more than a null value). A Character holds (I believe it's) 8 bytes. A Null Value holds like 1, or 2. So, in really big VB applications, changing "" to vbnullstring can speed up the app (benchmarks show by 40%) by using vbnullstring instead of "". So, you could redo the function as SearchString = Replace(SearchString, Chr(13), vbnullstring) to perform the same action, and save RAM usage. Again, I know this isn't extremely important, especially with modern machines, but it's good to know, and a nice practice to have.

The other thing, and I'm not sure if this is the intended result or not, but the above code will remove ALL chr(13's) from the string, not just the trailing one (when reading files, it's usually not a problem, since input will separate lines by newlines as it's read in, but a lot of apps that I have built require reading a file (or from a socket) 1 character at a time). An alternative method, if you are just wanting to remove the trailing newline, would be to use the left function SearchString = left(SearchString, Len(SearchString) -1) .

I'm sure that the replace function is a fine solution for …

WolfPack commented: Useful points there. +3
Comatose 290 Taboo Programmer Team Colleague

E-mail what? What Code Exactly?

Comatose 290 Taboo Programmer Team Colleague

why can't you do it on mouse_move? On mousedown set a boolean flag variable that says that the mouse is down. On mouseup clear the boolean flag variable (set it to false). On the mousemove procedure, check if the flag variable is true, and if so, draw the line..... if the flag variable is false, don't draw the line.... or am I completely missing the mark here?

Comatose 290 Taboo Programmer Team Colleague

Moved To Geeks Lounge (For discussion). I fully agree with you Aparnesh, in fact, I raise the question of: what kind of code are you writing using a cell phone keypad?? I have a bad enough time dealing with a VB IDE and a keyboard :cheesy:

Comatose 290 Taboo Programmer Team Colleague

I wouldn't suggest going about it that way. You can add a textbox to the form, and set it's "multiline" property to true. Then go to the "scrollbars" property, and choose if you want vertical, horizontal, or both. They will only be active when the data goes beyond the textbox, and basically works as you would expect.

Comatose 290 Taboo Programmer Team Colleague

I don't see why you can't just port over the code that's in the VBScript WSH. If you send me (or post the code) to the .VBS, I can show you how to import it into VB. Since you are using express, there may be minor touch up details that you'll have to fix, but the basis will be solid.

Comatose 290 Taboo Programmer Team Colleague

It's possible that you are trying to create an instance of a class (an object) from a class that is present on the machines you tested it on, but not on the machine it's been deployed to..... for example, I happen to know that I can make a VB program utilize a class for Nero Burning Rom.... I can make a nero object, and use it's methods and properties...... but that will only work on machines that have the Nero libraries installed. If it's not installed, when you try to make the object (either through early or late bindings with new or createobject), the variable that SHOULD refer to the object is still set to Nothing, because the library failed to create an instance of the requested class.....

Basically, you are trying to make an object from a class that doesn't exist on the NT box.

Comatose 290 Taboo Programmer Team Colleague

One of the most important things to understand when automating office, is that it's heavily [search]OOP[/search], and therefore you are forced to work with objects. In order to create an object that is external to your application (for example an office application, whereas a button or textbox would be internal to your application), you have to tell VB that you want to make an object. This is where the createobject function comes in, allowing your program to create an "instance" of a class so that you can manipulate its object.

CreateObject can take two arguments, the second of which (ServerName) has to do with the computer that the object was created on in a network, and will cause more trouble than it's worth. The first parameter (Class), however, allows you to make an object of a given type. So, if you want to make an office application you could set oApp = createobject("Office.Application") . Naturally you can't leave the "office.application" just like it is. It has to know which application you want to mess with (be it Word, Excel, etc), so in order to create a Word object, you can do some fancy stuff like set oApp = createobject("Word.Application") , and your application will create a new Word application. You can refer to your copy (Instance) of Word with the Object Variable oApp.

What is that you say? You don't see a copy of Word anywhere? That's because you haven't done anything with the properties just yet. The …

Comatose 290 Taboo Programmer Team Colleague

Well, the difference between a thin client and a fat client is:
thin client: the bulk of processing is done on the server
fat client: the processing is done on the client

A thin client usually has no hard-drive, and loads it's OS and software from a server.... a lot like a terminal.

I dunno about the whole software layers thing, but I'm guessing the question wants you to draw out, a diagram of the layout. So, for the thin client layout, I'm sure it would want a picture that represents the server, a picture that represents the client, and a description of the hard-ware (the client has no hard-drive, the server does) etc, etc.

Sulley's Boo commented: =') +2
Comatose 290 Taboo Programmer Team Colleague

Make sure to read the sticky thread: http://www.daniweb.com/techtalkforums/thread41057.html to get you started. Read this page for info on the error message: http://support.microsoft.com/kb/155666

Comatose 290 Taboo Programmer Team Colleague

As far as I know you can't. I believe you could port your source to VB6 with minor modifications, and then compile the EXE from VB, but I'm pretty sure that VBA (macro's and such) are interpreted, and must remain that way.

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

Ghost in the machine?

MartyMcFly commented: :) +2
Comatose 290 Taboo Programmer Team Colleague
<?php
$dir = ".";

$dh = opendir($dir);

while (($file = readdir($dh)) !== false) {
        echo "<A HREF=\"$file\">$file</A><BR>\n";
}

closedir($dh);
?>
karthik_ppts commented: useful post +6
Comatose 290 Taboo Programmer Team Colleague

There seems to be a serious number of posts regarding the use of VB with an Access Database... Due To The High Volume of questions about access, I'm posting this link. Please, Go through the tutorial, and if you have questions regarding access with VB still (after reading through the tutorial) Post your question, and I will try to help you.

Link To Tutorial:
http://www.timesheetsmts.com/adotutorial.htm

jonc commented: Excellent tutorial you've linked to... +2