I wrote the following tool when I first got started with FB. It is an .exe that I added as a TOOL in FBEdit. Then I gave it a shortcut key of 'u'.Boris the Old wrote:An easy way to avoid writing declares is to use a simple utility program to do it for you.
So I use it by hilighting the sub/function definition line, then COPY it to the clipboard, then ALT + T + U and the declare is placed in the clipboard. Then you just paste it where you want it.
You can also go the other way and take the declare line, hilight/COPY it, and ALT + T + U to put the sub/function declaration into the clipboard.
I use it all the time and can't live without it.
I was going to expand on it but never did. I wanted to mark the location in the bas file where the declares would go, with something like:
Code: Select all
'-------------------------------
' Declares:
'-------------------------------
My code here comes complete with incorrect handling of array parameters, incorrect handling of type declares and probably some other issues I don't remember. I want to also mention that it is Windows only, and the clipboard handling routine was taken from a search for "clip board" of posts in this forum.
Code: Select all
'===================================================================================================
' MethodStubs
'===================================================================================================
#Include "windows.bi"
Declare Sub CreateDeclare(clipText As String)
Declare Function get_clipboard () As String
Declare Sub set_clipboard (Byref x As String)
Declare Sub CreateProcedure(txt As String)
Declare Sub HandleClipboardText()
Function get_clipboard () As String
Dim As Zstring Ptr s_ptr
Dim As HANDLE hglb
Dim As String s = ""
If (IsClipboardFormatAvailable(CF_TEXT) = 0) Then Return ""
If OpenClipboard( NULL ) <> 0 Then
hglb = GetClipboardData(cf_text)
s_ptr = GlobalLock(hglb)
If (s_ptr <> NULL) Then
s = *s_ptr
GlobalUnlock(hglb)
End If
CloseClipboard()
End If
Return s
End Function
Sub set_clipboard (Byref x As String)
Dim As HANDLE hText = NULL
Dim As Ubyte Ptr clipmem = NULL
Dim As Integer n = Len(x)
If n > 0 Then
hText = GlobalAlloc(GMEM_MOVEABLE Or GMEM_DDESHARE, n + 1)
Sleep 15
If (hText) Then
clipmem = GlobalLock(hText)
If clipmem Then
CopyMemory(clipmem, Strptr(x), n)
Else
hText = NULL
End If
If GlobalUnlock(hText) Then
hText = NULL
End If
End If
If (hText) Then
If OpenClipboard(NULL) Then
Sleep 15
If EmptyClipboard() Then
Sleep 15
If SetClipboardData(CF_TEXT, hText) Then
Sleep 15
End If
End If
CloseClipboard()
End If
End If
End If
End Sub
'Screenres 800, 600, 32
Sub CreateDeclare(clipText As String)
'
Dim As String s
Dim As Integer x, y, n
s = "Declare " + clipText
set_clipboard(s)
End Sub
Sub CreateProcedure(txt As String)
'
Dim As String s
s = Trim(Mid(txt, 9))
set_clipboard(s)
End Sub
Sub HandleClipboardText()
'
Dim txt As String
txt = get_clipboard()
txt = Trim(txt, Any " " + Chr(9))
If LCase(Left(txt, 4)) = "sub " Then
' create a declare statement for the clipboard
CreateDeclare(txt)
EndIf
If LCase(Left(txt, 9)) = "function " Then
' create a declare statement for the clipboard
CreateDeclare(txt)
EndIf
If LCase(Left(txt, 8)) = "declare " Then
' create proc stub from declare statement
CreateProcedure(txt)
EndIf
End Sub
HandleClipboardText()
'Screenres 800, 600, 32
'Declare Sub HandleClipboardText()
'sleep