codeTag v3.0 Public Beta

Volte
01-20-2002, 09:27 AM
codeTag v3.0

Well, some of you may remember how about 2 months ago I finshed writing codeTag, and program for tagging the code you post here with markup tags for readability. I've totally rewritten it a total of four times now, and I think it's as good as it's going to get for a while. :) Here is an example of what it does:Private Sub MyTestingSub(sParamater1 As String, sParamater2 As Long, ByVal sParamater3 As Double)
'******************
'*** MyTestingSub
'*** codeTag Test
'******************

Dim a As Single
Dim b As String
Static c As String

b = "The quick brown fox jumps over the lazy dog"
a = 5

Exit Sub 'Test Test
'Test
'Test
End Sub

So, download it, try it out, post your thoughts. Running it through really large code (like 1000+ lines) can take about 20 seconds.

Download it Here (www.kwic.com/~junior/codeTag3.zip)

[EDIT -- I just realized I forgot to make the Copy to Clipboard button do anything :o Do it manually for now.]

ChiefRedBull
01-20-2002, 10:29 AM
Any chance you could insert a progress meter? Or at least change the mouse icon to an hourglass or something while its colorizing...
Other than that - spiffing!!

Volte
01-20-2002, 10:36 AM
Well, generally speaking it takes less that half a second to do, but sure :)

Visual Developer
01-20-2002, 12:31 PM
Just testing:Option Explicit

' Reg Key Security Options...
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL

' Reg Key ROOT Types...
Const HKEY_LOCAL_MACHINE = &H80000002
Const ERROR_SUCCESS = 0
Const REG_SZ = 1 ' Unicode nul terminated string
Const REG_DWORD = 4 ' 32-bit number

Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
Const gREGVALSYSINFOLOC = "MSINFO"
Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
Const gREGVALSYSINFO = "PATH"

Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long


Private Sub cmdSysInfo_Click()
Call StartSysInfo
End Sub

Private Sub cmdOK_Click()
Unload Me
End Sub

Private Sub Form_Load()
lblDescription.Caption = "The complete development system for managing and editing source files including HTML, ASP, C++, Java, VBScript, JScript and XML." & String(3, vbCrLf) & "Developed And designed by Shuaib Latif."
End Sub

Public Sub StartSysInfo()
On Error GoTo SysInfoErr

Dim rc As Long
Dim SysInfoPath As String

' Try To Get System Info Program Path\Name From Registry...
If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
' Try To Get System Info Program Path Only From Registry...
ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
' Validate Existance Of Known 32 Bit File Version
If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
SysInfoPath = SysInfoPath & "\MSINFO32.EXE"

' Error - File Can Not Be Found...
Else
GoTo SysInfoErr
End If
' Error - Registry Entry Can Not Be Found...
Else
GoTo SysInfoErr
End If

Call Shell(SysInfoPath, vbNormalFocus)

Exit Sub
SysInfoErr:
MsgBox "System Information Is Unavailable At This Time", vbOKOnly
End Sub

Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
Dim i As Long ' Loop Counter
Dim rc As Long ' Return Code
Dim hKey As Long ' Handle To An Open Registry Key
Dim hDepth As Long '
Dim KeyValType As Long ' Data Type Of A Registry Key
Dim tmpVal As String ' Tempory Storage For A Registry Key Value
Dim KeyValSize As Long ' Size Of Registry Key Variable
'------------------------------------------------------------
' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
'------------------------------------------------------------
rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key

If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error...

tmpVal = String$(1024, 0) ' Allocate Variable Space
KeyValSize = 1024 ' Mark Variable Size

'------------------------------------------------------------
' Retrieve Registry Key Value...
'------------------------------------------------------------
rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value

If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors

If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ' Win95 Adds Null Terminated String...
tmpVal = Left(tmpVal, KeyValSize - 1) ' Null Found, Extract From String
Else ' WinNT Does NOT Null Terminate String...
tmpVal = Left(tmpVal, KeyValSize) ' Null Not Found, Extract String Only
End If
'------------------------------------------------------------
' Determine Key Value Type For Conversion...
'------------------------------------------------------------
Select Case KeyValType ' Search Data Types...
Case REG_SZ ' String Registry Key Data Type
KeyVal = tmpVal ' Copy String Value
Case REG_DWORD ' Double Word Registry Key Data Type
For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit
KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char. By Char.
Next
KeyVal = Format$("&h" + KeyVal) ' Convert Double Word To String
End Select

GetKeyValue = True ' Return Success
rc = RegCloseKey(hKey) ' Close Registry Key
Exit Function ' Exit

GetKeyError: ' Cleanup After An Error Has Occured...
KeyVal = "" ' Set Return Val To Empty String
GetKeyValue = False ' Return Failure
rc = RegCloseKey(hKey) ' Close Registry Key
End Function

Volte
01-20-2002, 01:04 PM
About how long did it take you to colorize that code? One or two seconds maybe?

Squirm
01-20-2002, 01:32 PM
Two of the Const keyword are black instead of blue

JDT
01-20-2002, 01:40 PM
Step is black instead of blue and the String$() function is blue instead of black.

JDT
01-20-2002, 02:14 PM
Here is some code with some uncommon keywords:

Option Explicit
Option Compare Binary
Option Base 1
DefStr A-Z

''this declare param is long, I changed it to any to test the color
Private Declare Function RegCloseKey Lib "advapi32" Alias "Test" ( _
ByVal hKey As Any) As Long
Rem this is a remark

Dim WithEvents x As CommandButton


Sub Form_Load()

Dim a
Dim aa As Object
Dim ss As Long

On Local Error GoTo Errors

a = " ' "[/color]

If a = "s" Then
Open "somefile" For Random Access Read Write Lock Read Write As #1 Len = 100
Close #1

ElseIf a = "a" Then 'Do nothing

End If

ss = ss Xor ss
ss = ss Imp ss

Errors:

End Sub






JDT

JDT
01-20-2002, 02:16 PM
It *should* look like this:

It should look like this:

Option Explicit
Option Compare Binary
Option Base 1
DefStr A-Z

''this declare param is long, I changed it to any to test the color
Private Declare Function RegCloseKey Lib "advapi32" Alias "Test" ( _
ByVal hKey As Any) As Long
Rem this is a remark

Dim WithEvents x As CommandButton


Sub Form_Load()

Dim a
Dim aa As Object
Dim ss As Long

On Local Error GoTo Errors

a = " ' "

If a = "s" Then
Open "somefile" For Random Access Read Write Lock Read Write As #1 Len = 100
Close #1

ElseIf a = "a" Then 'Do nothing

End If

ss = ss Xor ss
ss = ss Imp ss

Errors:

End Sub


JDT

Banjo
01-20-2002, 02:49 PM
OMG, is rem still valid. I had no idea. Is it just there for compatiblity or does it have use?

orufet
01-20-2002, 02:57 PM
One thought...

Remember that users can change the default VB coloring. For example, for a while I used grey for comments rather than green. Perhaps there is a way to detect their color scheme?

JDT
01-20-2002, 03:06 PM
Ya its still there.:) I think it is for compatability. I've never used it and never will.:p

Volte
01-20-2002, 03:35 PM
I'm not gonna bother with Rem... it's never used, probably never will be, and it'll just slow everything down. Other thing, is Len on yours always blue? If it isn't, is it a special handler in the code?

Volte
01-20-2002, 03:38 PM
Option Explicit
Option Compare Binary
Option Base 1
DefStr A-Z

''this declare param is long, I changed it to any to test the color
Private Declare Function RegCloseKey Lib "advapi32" Alias "Test" ( _
ByVal hKey As Any) As Long
Rem this Is a remark

Dim WithEvents x As CommandButton


Sub Form_Load()

Dim a
Dim aa As Object
Dim ss As Long

On Local Error GoTo Errors

a = " ' "

If a = "s" Then
Open "somefile" For Random Access Read Write Lock Read Write As #1 Len = 100
Close #1

ElseIf a = "a" Then 'Do nothing

End If

ss = ss Xor ss
ss = ss Imp ss

Errors:

End SubHow about now?

Squirm
01-20-2002, 04:13 PM
Still a bug with the Rem part.

I, like Banjo, thought that REM went out with QBasic. Perhaps I was wrong...

*types Rem test into IDE*

Yes, I was wrong...... heh :D

Volte
01-20-2002, 04:48 PM
No, that's not a bug -- I'm not gonna bother with Rem. Unnecessary slowness.

Legshot
01-20-2002, 05:19 PM
I wonder if a forum for users to anounce their progs would be a good addition to the board?

What do you think?

Robby
01-20-2002, 05:21 PM
Originally posted by Legshot
I wonder if a forum for users to anounce their progs would be a good addition to the board?

What do you think?

We have the Code Library for that purpose.

Legshot
01-20-2002, 05:52 PM
Originally posted by Robby


We have the Code Library for that purpose.

Oh okay ;) my fault...

I just thought about it because this thread was started under random thoughts :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum