Homepage
Mailinglist
Editor Extensions
Linklist
Imprint
The Editor-Extensions of GFA BASIC 32 are a great tool to extend the very good editor
with other useful functions. Indeed, the including of a complete editor extension is
in my eyes not really practicably. On the one hand because you often have own
extensions which you don't want to loose and to use the other extensions is a little
problem because it needs a lot of trust. I want to go here another way and offer single
routines. Here I briefly describe the function and give the complete source code of a
single extension. Everybody can decide what is interesting for himself and the suitable
routines insert in own extension. By the revealed source code (as a kind of PD) is
guaranteed to him that no hidden bad routines are included.
Who also wants to make available own editor Extensions, should send me these to e-mail.
I will publish them then here on the side.
Stores on every program start the actual program state in a temporary file
I have developed the function to have always backups of my projects.
By every start the actual program state will be saved in a file whose file name contents
of the actual file name (or of Test.g32) and a time stamp
'In Standard onRun-Sub einbauen
Sub GFA_onrun
Dim Dateiname As String, Dateiname_Pos As Long
Dateiname = Gfa_FileName
'Falls noch nicht gespeichert, Standard-Namen setzen
If Dateiname = "" Then
Dateiname = "Test.g32"
End If
Dateiname_Pos = RInStr(Dateiname, "\")
'Pfadnamen entfernen
If Dateiname_Pos 0 Then
Dateiname = Mid$(Dateiname, Succ(Dateiname_Pos))
End If
'Dateiname um Datumsstempel erg舅zen
If Dateiname "" Then
Dateiname = Left$(Dateiname, Len(Dateiname) - 4) & " " & Format$(Now, "yyyymmdd hhnnss") & ".g32"
'und in temporärem Verzeichnis speichern
Gfa_SaveFile "H:\Temp_G32\" & Dateiname
End If
End Sub
Shows the current procedure name in the status line
Just in long procedures or while using the search function it can be
interesting which is the current procedure name, without leaving the topical line.
This function writes this name in the status line.
'beliebige Gfa_Ex-Prozedur
Sub Gfa_Ex_1()
'aktuelle Procedure
Gfa_StatusText = Gfa_Text(Pred(Gfa_ProcLine))
End Sub
Jumps or shows the definition place of variables and procedures
A very useful function in VB is the jump to a Sub/function by locating it with the cursor
This is possible with the following functions now also in GFA BASIC.
You must call at the beginning the routine "GFA_Bezeichner_Init" in the initialization routine GFA_Init.
Then the calls are:
GFA_Bezeichner_Suchen True
shows the line with the definition in the status line
GFA_Bezeichner_Suchen False
jumps to the position of the procedure or to the definition of the variables.
The location for the jump back to the cursor position is stored.
GFA_Bezeichner_Ruecksprung
Jumps back to the stored cursor position
The routines are not very effective programmed, but they work properly ;-).
Even in big Listings the results are delivered quickly.
Procedure GFA_Bezeichner_Init
'Initialisiere Bezeichner-Variablen
Global GFA_Bezeichner(255) As Boolean, GFA_Nummer As Long, GFA_PrgZeile As String
Global GFA_Ruecksprung(1, 10) As Long, GFA_Ruecksprung_Pos As Long
'Initialisiere Buchstaben und Ziechen f?r Variablennamen
For GFA_Nummer = 0 To 255
If InStr(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_abcdefghijklmnopqrstuvwxyz", Chr$(GFA_Nummer)) = 0 Then
GFA_Bezeichner(GFA_Nummer) = False
Else
GFA_Bezeichner(GFA_Nummer) = True
End If
Next GFA_Nummer
End Proc
Procedure GFA_Bezeichner_Suchen(GFA_Bezeichner_nur_Ausgabe As Boolean)
'Bezeichner unter Cursor erkennen und hinspringen
Dim GFA_Bezeichnung As String, GFA_Zeile_Nr As Long, GFA_Pos As Long, GFA_Klammer As Long
GFA_Bezeichnung = GFA_Bezeichner_hole_name()
GFA_Zeile_Nr = Gfa_ProcLine
'1. Durchlauf f?r lokale Definitionen
Repeat
GFA_Nummer = 0
GFA_PrgZeile = Gfa_Text(GFA_Zeile_Nr)
'Pr?fe auf die diversen Schl?sselw?rter
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "DECLARE ", 8, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "SUB ", 4, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "SUBA ", 5, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "FUNCTION ", 9, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "FUNCTIONA ", 10, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "PROCEDURE ", 10, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "GLOBAL ", 7, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "PUBLIC ", 7, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "DIM ", 4, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "PRIVATE ", 8, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "LOCAL ", 6, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "STATIC ", 7, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "CONST ", 6, GFA_Nummer)
If GFA_Nummer > 0 Then
'Definitions-Kommando gefunden, Suche nach Bezeichner
GFA_Nummer = InStr(1, GFA_PrgZeile, GFA_Bezeichnung)
End If
If GFA_Nummer = 0 Then
'Keine Fundstelle, gehe zur n臘hsten Zeile
Inc GFA_Zeile_Nr
End If
Until GFA_Nummer <> 0 Or GFA_Zeile_Nr >= Gfa_ProcLine + Gfa_ProcLineCnt
'Wenn GFA_Nummer <> 0, dann wurde der Bezeichner gefunden
If GFA_Nummer = 0 Then
'2. Durchlauf f?r globale Definitionen
GFA_Zeile_Nr = 0
Repeat
GFA_Nummer = 0
GFA_PrgZeile = Gfa_Text(GFA_Zeile_Nr)
'Pr?fe auf die diversen Schl?sselw?rter
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "DECLARE ", 8, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "SUB ", 4, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "SUBA ", 5, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "FUNCTION ", 9, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "FUNCTIONA ", 10, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "PROCEDURE ", 10, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "GLOBAL ", 7, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "PUBLIC ", 7, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "DIM ", 4, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "PRIVATE ", 8, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "LOCAL ", 6, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "STATIC ", 7, GFA_Nummer)
GFA_Nummer = GFA_Bezeichner_Check(GFA_PrgZeile, "CONST ", 6, GFA_Nummer)
If GFA_Nummer > 0 Then
'Definitions-Kommando gefunden, Suche nach Bezeichner
GFA_Nummer = InStr(1, GFA_PrgZeile, GFA_Bezeichnung)
End If
If GFA_Nummer = 0 Then
'Keine Fundstelle, gehe zur n臘hsten Zeile
Inc GFA_Zeile_Nr
End If
Until GFA_Nummer <> 0 Or GFA_Zeile_Nr >= Gfa_LineCnt
End If
If GFA_Nummer = 0 Then
'Bezeichner nicht gefunden
Gfa_StatusText = "Bezeichner '" & GFA_Bezeichnung & "' nicht erkannt !"
Else
If GFA_Bezeichner_nur_Ausgabe Then
'Ausgabe des Textes in der Statuszeile
GFA_PrgZeile = Gfa_Text(GFA_Zeile_Nr)
GFA_Nummer = InStr(1, GFA_PrgZeile, GFA_Bezeichnung)
GFA_Pos = GFA_Nummer + Pred(Len(GFA_Bezeichnung))
GFA_Klammer = 0
Repeat
Inc GFA_Pos
Select Mid$(GFA_PrgZeile, GFA_Pos, 1)
Case "("
Inc GFA_Klammer
Case ")"
If GFA_Klammer > 0 Then
Dec GFA_Klammer
Inc GFA_Pos
End If
End Select
Until GFA_Klammer = 0 And (Mid$(GFA_PrgZeile, GFA_Pos, 1) = "," Or Mid$(GFA_PrgZeile, GFA_Pos, 1) = ")" Or GFA_Pos > Len(GFA_PrgZeile))
Gfa_StatusText = Mid$(GFA_PrgZeile, GFA_Nummer, GFA_Pos - GFA_Nummer)
Else
'Ruecksprung_Adresse merken
GFA_Ruecksprung(0, GFA_Ruecksprung_Pos) = Gfa_Line
GFA_Ruecksprung(1, GFA_Ruecksprung_Pos) = Gfa_Col
GFA_Ruecksprung_Pos = Mod(Succ(GFA_Ruecksprung_Pos), 11)
Gfa_Line = Succ(GFA_Zeile_Nr)
GFA_Nummer = InStr(1, Gfa_Text, GFA_Bezeichnung)
'Position anspringen
If GFA_Nummer > 0 Then
Dec GFA_Nummer
Gfa_Col = GFA_Nummer
Gfa_SelCol = Gfa_Col + Len(GFA_Bezeichnung)
End If
End If
End If
End Proc
Procedure GFA_Bezeichner_Ruecksprung
' Nach Procedur-Sprung zur?ck zur gemerkten Position
'Die R?cksprung-Positionen werden in einem Array gespeichert
'beim letzten Element, wird auf das erste gesprungen, es werden maximal 11 Positionen gespeichert
If GFA_Ruecksprung_Pos = 0 Then
GFA_Ruecksprung_Pos = 10
Else
Dec GFA_Ruecksprung_Pos
End If
'Pr?fen auf gespeicherte R?cksprungadresse
If GFA_Ruecksprung(0, GFA_Ruecksprung_Pos) = 0 Then
'nichts gefunden, zur?ck zur alten Position
GFA_Ruecksprung_Pos = Mod(Succ(GFA_Ruecksprung_Pos), 11)
Else
'Cursor-Position setzen
Gfa_SelCol = Gfa_Col
Gfa_Line = GFA_Ruecksprung(0, GFA_Ruecksprung_Pos)
Gfa_Col = GFA_Ruecksprung(1, GFA_Ruecksprung_Pos)
GFA_Ruecksprung(GFA_Ruecksprung_Pos) = 0
EndIf
End Proc
Function GFA_Bezeichner_hole_name() As String
Dim GFA_Position As Long, GFA_Zeile As String, GFA_Anfang As Long, GFA_Ende As Long
'Cursor-Position und Text holen
GFA_Anfang = Gfa_Col
GFA_Ende = Gfa_Col
GFA_Zeile = Gfa_Text
'Von Cursor-Position aus den Anfang suchen, Auftreten des 1. Zeichens, das kein Variablenname ist
While GFA_Anfang > 1 And GFA_Bezeichner(Asc(Mid$(GFA_Zeile, GFA_Anfang, 1)))
Dec GFA_Anfang
Wend
'Von Cursor-Position aus das Ende suchen, Auftreten des 1. Zeichens, das kein Variablenname ist
While GFA_Ende < Len(GFA_Zeile) And GFA_Bezeichner(Asc(Mid$(GFA_Zeile, GFA_Ende, 1)))
Inc GFA_Ende
Wend
'Anfangs und End-Position korrigieren
If Not GFA_Bezeichner(Asc(Mid$(GFA_Zeile, GFA_Anfang, 1))) Then
Inc GFA_Anfang
End If
If Not GFA_Bezeichner(Asc(Mid$(GFA_Zeile, GFA_Ende, 1))) Then
Dec GFA_Ende
End If
'Bezeichner zur?ck geben
GFA_Bezeichner_hole_name = Mid$(GFA_Zeile, GFA_Anfang, GFA_Ende - GFA_Anfang + 1)
End Func
Function GFA_Bezeichner_Check(ByRef GFA_Check_PrgZeile As String, GFA_Check_Name As String, GFA_Check_Laenge As Long, GFA_Check_Nummer As Long) As Long
'Pr?fen auf Kommando
If UCase$(Left$(Trim$(GFA_Check_PrgZeile), GFA_Check_Laenge)) = GFA_Check_Name Then
GFA_Check_PrgZeile = Mid$(Trim$(GFA_Check_PrgZeile), Succ(GFA_Check_Laenge))
GFA_Bezeichner_Check = 1
Else
GFA_Bezeichner_Check = GFA_Check_Nummer
End If
End Func