Seite 1 von 1

PB-KonstantenWerte --> ClipBoard (kleiner PrgGenerator)

Verfasst: 12.10.2007 17:14
von sibru
Hallo,

ich hab´ hier mal ´n kleines PB-Prg zur Anzeige von nummerischen PB-Konstanten:
1. Konstanten in jaPBe, PB-Editor oder sonstwo markieren (auch über mehrere Zeilen,
kann auch andern Kram´s oder Notizen enthalten) und via [Strg] + [C] in Zwischen=
Ablage ablegen
2. dieses Prg starten: die ZwischenAblage wird eingelesen, alle PB-Konstanten rausge=
fischt und es wird in der ZwischenAblage ein PB-Prg. generiert zur Anzeige aller
gefundenen Konstanten.
3. im leeren PB-Editor oder jaPBe/neu ZwischenAblage abrufen via [Strg] + [V]: das
generierte Prg erscheint.
4. Prg. mit Debugger starten: die Konstanten sowie dessen nummerische Werte werden im
Debugger-Fenster angezeigt und auch in der ZwischenAblage hinterlegt.
5. falls erforderlich: in irgendeinem TextEditor (z.B. NotePad) kann die Debugger-An=
zeige mittels ZwischenAblage (nochmals [Strg] + [V]) eingebettet werden...

Besonders für PB-WerkzeugPrg´s und für API-ParameterErforschung
dürfte das interessant sein...

Code: Alles auswählen

;PureBasic-QuellCode "ClipBoard_Const" mit allen ModulBody´s
;generiert durch PB_Inc2Mod Vers. 7723a am 12.10.2007, 16:40 Uhr

#Prg_Name = "ClipBoard_Vars"
#Prg_Vers = "7A12a"          ;set by PB_VersUpd Vers. 7225a

;==========  Begin Modul "C:\ALSTERSOFT\PUREBASIC\MODULE\WORT.PBI"  ==========
;jaPBe/Procedure = Wort(@String$) - liefert nächstes Wort von String$ (bis Leerzeichen bzw. geklammert) und verkürzt String$ entsprechend
Procedure.s Wort(*WO_Param)
   Global Wort_Ende$, Wort_Klammer$
   Protected WO_Param$, Wort$
   WO_Param$ = LTrim(PeekS(*WO_Param))
   If Wort_Ende$ = ""
      If Wort_Klammer$ = ""
         Wort_Klammer$ = Chr(34)+Chr(39)+Chr(180)+Chr(255)
      EndIf
      If FindString(Wort_Klammer$,Left(WO_Param$,1),1) And WO_Param$>""
         Wort_Ende$ = Left(WO_Param$,1)
         WO_Param$ = Right(WO_Param$,Len(WO_Param$)-1)
      Else 
         Wort_Ende$ = " "
      EndIf
   EndIf
   While Left(WO_Param$,1)<>Wort_Ende$ And WO_Param$>""
      Wort$ = Wort$+Left(WO_Param$,1)
      WO_Param$ = Right(WO_Param$,Len(WO_Param$)-1)
   Wend
   Wort_Ende$ = "" : Wort_Klammer$ = ""
   PokeS(*WO_Param,LTrim(Right(WO_Param$,Len(WO_Param$)-1)))
   ProcedureReturn Wort$
EndProcedure
;==========  Ende Modul "C:\ALSTERSOFT\PUREBASIC\MODULE\WORT.PBI"  ==========
;==========  Begin Modul "C:\ALSTERSOFT\PUREBASIC\MODULE\CHARCHG.PBI"  ==========
;jaPBe/Procedure = CharChg(base$, such$, ersatz$) - Zeichen(ketten)-(Mehrfach-)Austausch
#CharChg_WordChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Procedure.s CharChg (CC_Base$, CC_Such$, CC_Repl$)
   Protected Base$,Pos.l
   Global CharChg_Cnt.b
   Global CharChg_noCase.b
   Global CharChg_Word.b
   CharChg_Cnt = 0
   If CharChg_noCase : CC_Such$ = LCase(CC_Such$) : Base$ = LCase(CC_Base$) : CharChg_noCase = 0
   Else : Base$ = CC_Base$
   EndIf
   If CC_Such$>""
      charChg_suchen:
      Pos = FindString(Base$,CC_Such$,Pos+1)
      If Pos
         If CharChg_Word
            If FindString(#CharChg_WordChars,Mid(" "+Base$,Pos-2,1),1) Or FindString(#CharChg_WordChars,Mid(Base$+" ",Pos+1+Len(CC_Such$),1),1)
               Pos+1
               Goto charChg_suchen
            EndIf
         EndIf 
         CC_Base$ = Left(CC_Base$,Pos-1)+CC_Repl$+Mid(CC_Base$,Pos+Len(CC_Such$),99999)
         Base$ = Left(Base$,Pos-1)+CC_Repl$+Mid(Base$,Pos+Len(CC_Such$),99999)
         CharChg_Cnt = CharChg_Cnt+1
         Pos+Len(CC_Repl$)-Len(CC_Such$)
         Goto charChg_suchen
      EndIf
   EndIf
   CharChg_noCase = 0 : CharChg_Word = 0
   ProcedureReturn CC_Base$
EndProcedure
;==========  Ende Modul "C:\ALSTERSOFT\PUREBASIC\MODULE\CHARCHG.PBI"  ==========

;****************************************************************
;**                         MainSource                         **
;****************************************************************

LF$ = Chr(13)+Chr(10)               ;LineFeed (^13 + ^10) definieren

out$ = ";Dieses Programm zeigt den Wert zu PB-Kontanten im Debug-Fenster an." + LF$
out$ + ";Die Anzeige wird auch in die ZwischenAblage übertragen und kann via" + LF$
out$ + ";Tasten [Strg] und [V] in einem TextEditor (z.B. jaPBe, NotePad....)" + LF$
out$ + ";übernommen werden."+LF$
out$ + LF$

Lines$ = CharChg(GetClipboardText(),Chr(10),"") ;ClipBoard-Inhalt einlesen, CR (=^13+^10) auf 1 Zeichen schrumpfen, evt. nur ^13 ?)
While Lines$>""
   CR = FindString(Lines$,Chr(13),1);ZeilenUmbruch suchen
   If CR                            ;Zeile separieren
      Zeile$ = Left(Lines$,CR-1)
      Lines$ = Mid(Lines$,CR+1,99999) ;emulate RIGHT$() of ANSI-BASIC
   Else                             ;letzte Zeile
      Zeile$ = Lines$
      Lines$ = ""
   EndIf
   Pos = FindString(Zeile$,";",1) : If Pos : Zeile$=Trim(Left(Zeile$,Pos-1)) : EndIf ;REM´s raus
   Zeile$ = CharChg(Zeile$,Chr(9)," ");Tab´s --> Blank´s
   If Trim(Zeile$)>""
      Var$ = Trim(Wort(@Zeile$))    ;Wort holen bis nächstes LeerZeichen
      If Left(Var$,1)="#"           ;PB-Konstante ?
         out$+"Debug "+Chr(34)+Var$+" = "+Chr(34)+" + Str("+Var$+")"+LF$ ;Anzeige-Aufbau
         out$+"Clip$+"+Chr(34)+Var$+" = "+Chr(34)+" + Str("+Var$+")+Chr(13)+Chr(10)"+LF$ ;ClipBoard-Aufbau
         cnt+1                      ;Zähler generierter Ausgabe-Zeilen
      EndIf
   EndIf
Wend
If cnt                              ;überhaupt ´ne Konstante gefunden ?
   out$+"SetClipboardText(Clip$)"   ;ClipBoard-Aufbau abschließen
   SetClipboardText(out$)           ;Ausgabe in ClipBoard speichern
   MessageRequester("ZwischenAblage belegt !!!", "In der Zwischenablage befindet sich nun ein"+Chr(10)+"PB-Programm zur Anzeige von Konstanten."+Chr(10)+"Datei/neue Datei aufrufen, dort [Strg]+[V]"+Chr(10)+"eintipsen sowie [F6] !!!", #MB_OK|#MB_ICONWARNING)
Else
   MessageRequester("keine Konstanten in der Zwischenablage !!!", "Dieses Programm dient dem Aufbaun eines PB-Prg´s,"+Chr(10)+"das bestimmte Konstanten sowie derren nummerischen"+Chr(10)+"Wert anzeigt. Vor dem Start dieses Prg´s müßen die an="+Chr(10)+"zuzeigenden Konstanten in die Zwischenablage eingetragen"+Chr(10)+"werden (markieren und [Strg] + [C] betätigen)", #MB_OK|#MB_ICONWARNING)
EndIf
End
Gruss Siggi

Verfasst: 12.10.2007 18:07
von #NULL
hey, das is ja mal spitze universell :)
danke!

<edit>
kleiner parser bug
ausgabe hat geschrieben:

Code: Alles auswählen

;[..]
Clip$+"#PB_EventType_LeftDoubleClick = " + Str(#PB_EventType_LeftDoubleClick)+Chr(13)+Chr(10)
Debug "#PB_EventType_RightDoubleClick: = " + Str(#PB_EventType_RightDoubleClick:)
Clip$+"#PB_EventType_RightDoubleClick: = " + Str(#PB_EventType_RightDoubleClick:)+Chr(13)+Chr(10)
Debug "#PB_EventType_Focus = " + Str(#PB_EventType_Focus)
;[..]

Verfasst: 12.10.2007 19:19
von sibru
Hi #NULL,

ok, ändere Anleitung: "... kann auch andern Kram´s oder Notizen enthalten)" zu "... kann auch andern Kram´s oder Notizen nach mind. 1 Leerzeichen hinter Konstanten-Bezeichner enthalten)"


Ist einfacher, als das Progi zu ändern... das währ´ nämlich ´n dickes Ding!

Gruss Siggi

Verfasst: 12.10.2007 20:21
von #NULL
naja ..dickes ding?
hier ne gut lesbare variante (kommt ja hier auf die geschwindigkeit nicht so an):

Code: Alles auswählen

text.s = GetClipboardText()

NewList const.s()
AddElement(const())

For i=1 To Len(text)
  char = Asc( Mid(text,i,1) )
  If char = 35;"#"
    switch = 1
    const()+"#"
  ElseIf switch And Not FindString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_", Chr(char), 1)
    switch = 0
    AddElement(const())
  ElseIf switch
    const()+Chr(char)
  EndIf
Next

text=""
ForEach const()
  If const()
    text + const() + #CRLF$
  endif
Next

SetClipboardText(text)







; [text zum probieren..]
; 
; 
; 
; Description
; After a WindowEvent() <windowevent.html> Or WaitWindowEvent() <waitwindowevent.html> function, use this function To determine of which type the event is. The following values are possible, If an event of the type #PB_Event_Gadget (library Gadget <../gadget/index.html>) Or #PB_Event_SysTray (library Systray <../systray/index.html>) occurs: 
;   #PB_EventType_LeftClick       : Left mouse button click
;   #PB_EventType_RightClick      : right mouse button click
;   #PB_EventType_LeftDoubleClick : Left mouse button double click
;   #PB_EventType_RightDoubleClick: Right mouse button double click
;   #PB_EventType_Focus           : Get the focus.
;   #PB_EventType_LostFocus       : Lose the focus.
;   #PB_EventType_Change          : Content change.
;   #PB_EventType_DragStart       : The user tries To start a Drag & Drop <../dragdrop/index.html> operation.
; The following gadgets support EventType(): 
; 
; - ExplorerListGadget() <../gadget/explorerlistgadget.html> 
; - ExplorerTreeGadget() <../gadget/explorertreegadget.html> 
; 
; 'ParentWindowID' is an optional parameter which specify on which window the new window belongs To. 'ParentWindowID' value can be easily obtained With WindowID(). 
; 
; Possible flags are: 
;   #PB_Window_SystemMenu    : Enables the system menu on the window title bar.
;   #PB_Window_MinimizeGadget: Adds the minimize gadget To the window title bar. #PB_Window_SystemMenu is automatically added.
;   #PB_Window_MaximizeGadget: Adds the maximize gadget To the window title bar. #PB_Window_SystemMenu is automatically added.
;   #PB_Window_SizeGadget    : Adds the sizeable feature To a window.
;   #PB_Window_Invisible     : Creates the window but don't display. Not supported on AmigaOS.
;   #PB_Window_TitleBar      : Creates a window With a titlebar.
;   #PB_Window_BorderLess    : Creates a window without any borders.
;   #PB_Window_ScreenCentered: Centers the window in the middle of the screen. x,y parameters are ignored.
;   #PB_Window_WindowCentered: Centers the window in the middle of the parent window ('ParentWindowID' must be specified). x,y parameters are ignored.
;   #PB_Window_Maximize      : Opens the window maximized. (Note: on Linux, Not all Windowmanagers support this)
;   #PB_Window_Minimize      : Opens the window minimized.
; 
; If the optional Flags parameter is Not specified, #PB_Window_SystemMenu will be used. 
; 
; All possible events in a window are handled With the WindowEvent() And WaitWindowEvent() functions. For special situations callbacks are used, see description at SetWindowCallback(). On Windows, the height And width of a window With a titlebar can't be less than around 100 pixels. To open smaller windows, use the "#PB_Window_BorderLess" flag. 
; 
; Note: When opening a Window from a thread, the thread must also call WindowEvent() Or WaitWindowEvent() in a loop To process events For this window, As window events are Not sent between different threads. 
; Supported OS 
; 
; All
; 


Verfasst: 12.10.2007 20:36
von #NULL
..und hier noch die ausgabe als PB-"Debug"-code:

Code: Alles auswählen

text.s = GetClipboardText()

NewList const.s()
AddElement(const())

For i=1 To Len(text)
  char = Asc( Mid(text,i,1) )
  If char = 35;"#"
    switch = 1
    const()+"#"
  ElseIf switch And Not FindString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_", Chr(char), 1)
    switch = 0
    AddElement(const())
  ElseIf switch
    const()+Chr(char)
  EndIf
Next

text=""
ForEach const()
  If const()
    text + ";" + const() + #CRLF$
  EndIf
Next
text + #CRLF$
ForEach const()
  If const()
    text + "Debug " + Chr(34) + const() + " = " + Chr(34) + " + Str(" + const() + ")" + #CRLF$
  EndIf
Next

SetClipboardText(text)

Verfasst: 13.10.2007 16:40
von sibru
tja, da merk´ ich mal wieder meine FachIdiotentum...
Hatte so mehr an die Zeilen-Zerstückelungs-Funktion gedacht (Wort()),
und Deine Idee, das Clipboard erstmal zu filtern, ist natürlich viel
effizienter !!!

Siggi