WildBamaBoy 19 Junior Poster

Not really understanding what you mean...You can have as many if statements as you want wherever you want pretty much.

WildBamaBoy 19 Junior Poster

Antivirus programs search a virus executable for a known piece of code or some other sort of signature that uniquely identifies it. Exactly how a virus is identified depends upon how the antivirus was made. The "signatures" or "definitions" you download just about every day is a database containing these identifications.

A virus isn't known and removable until it has already been released, hit some computers, and either submitted to or caught by Antivirus companies who add an ID for the virus to their database and release an update. To combat new viruses that are unknown, what's called a heuristic scan may be performed.

A heuristic scan picks apart an executable and searches for patterns commonly found in viruses, such as disabling parts of Windows, raising a fake error when something is opened, etc. Most viruses (in this case I am talking about extremely common 'rouge antiviruses') are just cheap copies of earlier ones. Several are identical to one another other than a slightly different GUI, name, and possibly hiding techniques. You can see how this actually works well! If a program is flagged by heuristics it is usually flagged as "Suspicious" as the antivirus doesn't really know if it is a threat or not.

Anyway, It depends on exactly what you are doing in the background. If you're accessing the internet in any way, it'll probably respond by asking the user to allow the program through the firewall. (assuming the antivirus has one, it SHOULD if …

WildBamaBoy 19 Junior Poster

The ChrW() function "returns a character associated with the specified character code."

Here's a list of character codes. DEC 59 is a ';'. :)

EDIT: I am sorry, I've never even heard of ZedGraph.

WildBamaBoy 19 Junior Poster

Did that work?

WildBamaBoy 19 Junior Poster

Erm..that code above is already in C#.

WildBamaBoy 19 Junior Poster

Its taking a string called ligne, splitting it at char 59 (that's a semicolon), and assigning valeur as index zero of the split.

C# equivalent of that

string valeur = ligne.Split(';')[0];
samueal commented: Good one. +4
WildBamaBoy 19 Junior Poster

Your gmail address and password, yes.

WildBamaBoy 19 Junior Poster

Try incorporating what is in the web.config into the code itself. This worked for me.

MailMessage message = new MailMessage();
            SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");

            message.From = new MailAddress("testing@gmail.com");
            message.To.Add("alex@hotmail.com");
            message.To.Add("alex2@hotmail.com");
            message.Subject = "Test Mail";
            message.Body = "This is for testing SMTP mail from GMAIL";

            smtpClient.Port = 587;
            smtpClient.Credentials = new System.Net.NetworkCredential("Address", "Password");
            smtpClient.EnableSsl = true;

            smtpClient.Send(message);
WildBamaBoy 19 Junior Poster

This will do it.

for (int I = 1; I <= 4; I++)
            {
                this.Controls["label" + I].Text = "Some text";
            }
WildBamaBoy 19 Junior Poster

Try increasing the size to 1048576 and see if it works.

WildBamaBoy 19 Junior Poster

Your buffer needs to be 1048576 if you want to get up to a megabyte. Warning though, reading cuts off when the buffer is full so if your image turns out to be bigger than a megabyte you're not going to have the full image and it will throw an exception like it is now.

WildBamaBoy 19 Junior Poster

I don't believe you're going to be able to easily get the path of a file just by having its file name. That's what Search does. The first thing that popped up in my head was to create a dictionary. Make the key be the file's name and make the value the full path to the file.

You'll need to add to the dictionary while you have the file's FileInfo by using its Name (just the file's name) and FullName (the full path to it) properties. Then in that second foreach you'll need to look up the path from the dictionary.

Here's your code edited to do the above. I can not test it right now.

Your first block.

public Dictionary<string, string> FileDict = new Dictionary<string, string>(); //make a new dictionary, with its key being a string and value being a string

        private void button1_Click(object sender, EventArgs e)
        {
            DirectoryInfo di = new DirectoryInfo(dDir);

            FileInfo[] vpkFiles = di.GetFiles("*.vpk");
            foreach (FileInfo fi in vpkFiles)
            {
                FileDict.Add(fi.Name, fi.FullName); //assign key as the file's name, and value as the full path to it.
                checkedListBox1.Items.Add(fi.Name);
            }
        }

Second block.

foreach (object itemChecked in checkedListBox1.CheckedItems)
            {
                string P = FileDict[itemChecked.ToString()]; //lookup the value of the current item
                DirectoryInfo di = new DirectoryInfo(P);
                FileInfo[] maps = di.MoveTo(dDir); //MoveTo doesn't return FileInfo[] :)
            }
WildBamaBoy 19 Junior Poster

Try this. I don't understand the problem fully but this is what I use to get the computer's 'external' IP that you can connect to it from, especially if it is behind a router.

string IP = new WebClient().DownloadString("http://automation.whatismyip.com/n09230945.asp");
WildBamaBoy 19 Junior Poster

There's an infinite recursion going on. Here's what is happening.

Line 127: You make a BattleshipBoard object called 'b' giving it the value of a new BattleshipBoard class. It's going to go through and assign any variables you tell it to and make its methods available to the object you assign it to.

Line 10: You create a new Player object called 'p' with the value of a new Player class. It will assign values and make the methods available to 'p'.

Line 48: Inside the Player class, you create another new BattleshipBoard.

The program will now go back to BattleshipBoard, which creates a new player, which creates a new BattleshipBoard, which creates a new player, and so on.

ddanbe commented: Nice observation and explanation! +14
WildBamaBoy 19 Junior Poster

AM and PM have nothing to do with it, say you have a timespan of 37 hours 15 minutes and and 13 seconds. Would that be AM or PM?
I think this is about hours worked, right?

He was telling me how my idea wouldn't work. :P

If you're going AM to AM I did the same thing just without converting to military hour. However I believe it does have a problem with PM to AM, but it worked for my needs how it was so I didn't bother to fix it. Not the best thing for you then.

WildBamaBoy 19 Junior Poster

Hey! I've done something exactly like this before! :)

DateTime and TimeSpan didn't work so well for me and required extra crap like Days, Year, Seconds, etc. I didn't like that. I only wanted the distance between two hours in one day. What I ended up doing was, if the time was a PM time, I converted that to military hours and subtracted from the start time.

For example:
Start Time = 5:00am
End Time = 2:00pm

2pm Military Time = 14:00. So I did 14 - 5 and 0 - 0, which gives me 9.

It'll get a bit more involved if the time isn't right on the hour. Minutes will tend to be wacked up, but there's an easy workaround. I have code if you want it.

WildBamaBoy 19 Junior Poster

You don't need to fill the spaces but if you want those unused variables, oh well.

You're still calling the function 'second' before you call 'first'.

WildBamaBoy 19 Junior Poster

Read your directions. The function 'first' should print "in function first()" and then it calls 'second'.

Your code right now calls second, and then first.

You also don't need the variable 'my_string' or the "any text here" because you don't use it. I only used that as an example.

WildBamaBoy 19 Junior Poster

No, you have not coded that yet.

All you need to do is check if their input is greater than or less than the number they're trying to guess.

Note: You've commented in your code where the guessing loop should go. Where is it? The code you have now will ask only three times because you call ask_number 3 times and then it will act as if their guess was correct. You don't need to do that, just put ONE call in a loop that continues until their response is equal to the number they're guessing.

WildBamaBoy 19 Junior Poster

Yes. Your function definition.

WildBamaBoy 19 Junior Poster

global scope lines are top-level lines outside the functions without indentation like line 6 in your code.

def first(my_string):
    print "In function", first('first()')

def second(my_string):
    return my_string
first("any text here") #call to function 'first' in global scope
WildBamaBoy 19 Junior Poster

That means no value was returned. Look at your find_discount() function. You've set what discount should be on all occasions, but you only return on one occasion! You need to move it back so it returns after all the if and else statements.

Here's how it should be.

def find_discount(total):
    if total <120:     #Check for this
        discount = 0   #It's True! Skip the else: statement.

    else:              #Above is not true, execute this block of code
        if total <300: #You get the picture..
            discount = 0.03*total
        else:
            if total <500:
                discount = 0.05*total
            else:
                discount = 0.07*total

    #All checks are done, so return
    return discount

Also, line 39 needs to be: print "The total is " + str(discounted_total) This makes it a string. You must do this because your discounted total is a float, and you can't add letters and numbers.

WildBamaBoy 19 Junior Poster

To call a function you simply type its name and a pair of parenthesis. Between the parenthesis is where you'll supply any parameters the function takes.

Replace line 6 with: first("any text here") Consider redoing your code a little bit. It's a little confusing and it will not do what you want just yet.

WildBamaBoy 19 Junior Poster

C'mon, show a little effort. It's not hard, I promise.

This page might help.

WildBamaBoy 19 Junior Poster

You have the function inside your while loop. Functions must always be called so they will execute their code. To call it you need to type the name of the function and include any variables it needs within the parenthesis. Like so: ask_number("Type a number: ", 1, 100) In this case this will not work because Python begins the while() loop, which defines your function, before it reaches your function call. Also, placing the call before the while() loop will not work because your function is not defined yet.

You simply need to rearrange your code so the function is outside of your loop, and add the function call at the end.

import random

secretNum = random.randrange(100)+1
      
tries = 0

def ask_number(question, high, low):
    """Ask a yes or no question"""
    
    while tries < 5:
        try:
            response = None
            while response not in range(low, high):
                response = int(raw_input(question))
                return response              
                                                                       
        except ValueError:
            print('Please enter a number')

ask_number("Type a number: ", 1, 100)