• Welcome to Valhalla Legends Archive.
 

I want to learn how to add proxy support

Started by ChR0NiC, November 17, 2003, 01:56 AM

Previous topic - Next topic

Stealth

Quote from: TriCk on November 21, 2003, 10:56 PM

       sckBNET.Close
       X = Form2.BNCSPort.Value
       ' or just X = 6112 if you want to hardcode the port
       Y = varServer
       If Form2.Proxy.Value = 1 Then
       TextAdd "SOCK: Connecting..."
       X = 1080
       Y = varProxy
       End If
       sckBNET.Connect Y, X


Also, let's talk about meaningful variable names and that magical TAB key. This code is a sloppy mess! Allow me to rewrite it using slightly more meaningful names:


       sckBNET.Close

       If Form2.Proxy.Value = 1 Then

            TextAdd "SOCK: Connecting..."
            lngPort = 1080
            strServer = varProxy

       Else 'user doesn't want to use a proxy

            lngPort = CLng(Form2.BNCSPort.Value) ' or just = 6112 if you want to hardcode the port
            strServer = varServer

       End If

       sckBNET.Connect strServer, lngPort 'Makes much more literal sense than "connect y, x"!
       'You connect to the SERVER on the PORT, not the Y on the X.



Compare the two blocks of code. Which one is more readable? White space is cheap, the adding tabs and blank lines in your code does not affect the performance of your program but makes things MUCH easier on yourself and other people -- especially if you want help with your code.
- Stealth
Author of StealthBot

Spht

#16
Picky. The only thing I agreed with was the tabbing. X, Y and Z's are prime variable names in examples!

Kp

Quote from: Stealth on November 22, 2003, 02:42 PMAlso, let's talk about meaningful variable names and that magical TAB key. This code is a sloppy mess!

You want to write better in the posting box, go ahead.  I didn't see the need to clean up his tabbing style since tabs don't work in the posting box; X and Y are simple variable names, so I picked them in preference to long ones that would be more work to type.  Incidentally, I don't find your variable names much better.  They're a nuisance to type.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Stealth

#18
All right, so maybe I was a little harsh. Sorry.. it's been a long week.  ::)

[edit] And, I didn't realize that the code you posted was an EXAMPLE; I thought it was his original code. Yeesh, I need to sleep.
- Stealth
Author of StealthBot