Author | Message | Time |
---|---|---|
Topaz | There's one for C++ / Java, now tell me where to get one for vb6 projects! | April 10, 2005, 6:01 AM |
The-FooL | Find a 3rd party tool that plugs into the IDE. There are freeware ones where line counting is one of the most basic features. | April 10, 2005, 6:15 PM |
Yegg | Here's a thought. Make a program that reads the code (the lines) of your program as a text document, it will then add all of the lines (one by one) to a list in your program (ListBox, ListView). Simply do Len(ListName), or however you would check how many items are in the list, and then you will know how many lines there are. | April 10, 2005, 11:19 PM |
Spht | I think UserLoser wrote one. | April 11, 2005, 10:42 AM |
Grok | In Project References, add "Microsoft Visual Basic 6.0 Extensibility". Also look for the VB Help topic "Programming in the Extensibility Model" for programming examples. This library gives you access to the programmable interfaces of the VB IDE. | April 11, 2005, 11:14 AM |
Ban | [quote author=Yegg link=topic=11228.msg108087#msg108087 date=1113175175] Here's a thought. Make a program that reads the code (the lines) of your program as a text document, it will then add all of the lines (one by one) to a list in your program (ListBox, ListView). Simply do Len(ListName), or however you would check how many items are in the list, and then you will know how many lines there are. [/quote] You forgot that blank lines should NOT be counted towards that final result. | April 11, 2005, 2:49 PM |
Adron | [quote author=Ban link=topic=11228.msg108172#msg108172 date=1113230994] [quote author=Yegg link=topic=11228.msg108087#msg108087 date=1113175175] Here's a thought. Make a program that reads the code (the lines) of your program as a text document, it will then add all of the lines (one by one) to a list in your program (ListBox, ListView). Simply do Len(ListName), or however you would check how many items are in the list, and then you will know how many lines there are. [/quote] You forgot that blank lines should NOT be counted towards that final result. [/quote] Actually, instead of having to make a new listbox, you could do some code reuse here. Let's assume you already have a chat bot, with a listbox for the users in the channel. Most bots display the number of users in the channel as a caption or somewhere. Now, what you need to do is create an application that processes data from the file, and feeds it to the bot's listbox. You'll have to start with two winsocks, one that listens for a connection and another to accept it. You'll want to listen on port 6112. Now, what you do is you listen for a connection. Then you load the bot, have it connect to 127.0.0.1. That's the magic number to have it connect to your new line counting application. When the connection comes, you print the regular old "username:" and "password:" stuff to the winsock, and then user name / channel name, just make something up. At this time, the bot will think it is connected to a battle.net. Little does it know that its code is being reused! Now, many bots might not allow really long usernames. They may also have a problem with the same username appearing more than once, or usernames containing spaces. For this reason we will have to translate the lines read from the file into something else to pass to the bot for counting. We will have to "generate" usernames. As we need each username to be unique, but it doesn't matter what it is, the easiest way is to have a string variable that you just increase each letter one by one in. Here's some sample code to do that: [code] Function GetNextName As String Static n As String ' This is the name Dim i As Integer ' This is used for moving through the string i = 1 Do ' Check if name must be longer! If i > Len(n) Then n = n & "A": Exit Do ' Check if this is we can use the next letter If Mid(n, i, 1) < "Z" Then Mid(n, i, 1) = Chr(Asc(Mid(n, i, 1)) + 1): Exit Do ' Reset this letter and move on Mid(n, i, 1) = "A" i = i + 1 Loop GetNextName = n End Function [/code] Now, using this very powerful function we can actually create a unique name for each line! Through this method, you will be able to give each line its own name, and pass that to the bot for counting. However, not all lines deserve a name. We may not want to count empty lines as lines for this purpose. In order not to give a name to lines that are empty, we must check for each line whether it's a good line before we let it have a name. This can be done through the following function: [code] Function IsGoodLine(ByVal line As String) As Boolean ' Empty lines are bad lines! If line = "" Then IsGoodLine = False: Exit Function ' OK So it's not empty, well then what character is there? Select Case Left(line, 1) Case " ", vbTab ' A space doesn't make a line good! Check the rest! IsGoodLine = IsGoodLine(Mid(line, 2)) Case Else ' Oooh neat, there's something else on the line! This line is a good line! IsGoodLine = True End Select End Function [/code] OK, now you have the important functions. I leave the rest of the coding up to you. It should all be very simple coding, given that you have the central parts of the line counting bot reuse application already in this post. Please share the remainder of the code after you have written it, so that others may learn how to count the lines of their source codes as well! | April 11, 2005, 6:14 PM |
The-FooL | [quote author=Adron link=topic=11228.msg108193#msg108193 date=1113243285] Now, what you need to do is create an application that processes data from the file, and feeds it to the bot's listbox. You'll have to start with two winsocks, one that listens for a connection and another to accept it. You'll want to listen on port 6112. Now, what you do is you listen for a connection. Then you load the bot, have it connect to 127.0.0.1. That's the magic number to have it connect to your new line counting application. [/quote] Lmfao Adron | April 11, 2005, 8:54 PM |
Ban | [quote author=The-FooL link=topic=11228.msg108227#msg108227 date=1113252856] [quote author=Adron link=topic=11228.msg108193#msg108193 date=1113243285] Now, what you need to do is create an application that processes data from the file, and feeds it to the bot's listbox. You'll have to start with two winsocks, one that listens for a connection and another to accept it. You'll want to listen on port 6112. Now, what you do is you listen for a connection. Then you load the bot, have it connect to 127.0.0.1. That's the magic number to have it connect to your new line counting application. [/quote] Lmfao Adron [/quote] It's almost as though Adron didn't realize that its more difficult to do that than simply read the lines ;) | April 12, 2005, 5:33 PM |
UserLoser. | [quote author=Spht link=topic=11228.msg108155#msg108155 date=1113216120] I think UserLoser wrote one. [/quote] I didn't create a VB line counter project, I used some older tool I found somewhere on the web to do that. However, I did create a replacement for link.exe which allowed me to passover my own options such as better optimizations, section data sizes, section names, function exports, compile as a dll, windows, console, etc. | April 12, 2005, 7:16 PM |
R.a.B.B.i.T | http://www.mztools.com/ MZTools is great, and adds a lot of handy stuff in addition to just line counting (it can check for unused variables, for instance). | April 12, 2005, 11:19 PM |