English
SDK-aide/ Tools

XProfanX2-ParameterReplacer

 

Stephan
Sonneborn
Hello together,

i don't know, obs you already time so goes:
there program one lasting weeks a umfangreiche software with diversen Unterprogrammen (*.inc), circa then sometime to ascertain: means The Namensgebung with manchen variables can already time To wish spare!
what power one?
1. OK, is even so and remaining so.
2. really should I The names Change, then can I the Source later rather nachverfolgen...

If means in the Hauptprogramm (*.PRF) variables declared are, The as globale variables too in Unterroutinen used and be these then umbenannt go should, goes The work go: each Include to whom variables search and then supplant.

the could really too one Program make (or one Source-editor ).

from the hardship is therefore the ParameterReplacer emerged.

he's sure not perfect and quick is it already none. but nevertheless rather as everything To foot To supplant.

I habs with a Program with over 8000 Lines and altogether 22 Source code (1x *.prf + 21x *.inc) tested and thereby on a shock 60 Variablenamen swapped and the geänderte Program launch yet!

The Replacer places Sicherheitskopien on, before it The Variablennamen swaps. nevertheless Please softly-softly testing.
CompileMarkSeparation
'***************************************************************************************************
'* Programmname: XProfanX2-ParameterReplacer                                                       *
'* Version     : 1.00                                                                              *
'* Stand       : 10.04.2012                                                                        *
'* Änderung    :                                                                                   *
'* Inhalt      : Hauptprogramm                                                                     *
'* Lizenz      : Freeware                                                                          *
'* Autor       : Stephan Sonneborn                                                                 *
'*               DIESE SOFTWARE WIRD OHNE JEDLICHE GARANTIE ODER GEWÄHRLEISTUNG ZUR                *
'*               VERFÜGUNG GESTELLT. DAS NUTZEN DES PROGRAMMS ERFOLGT AUF EIGENE GEFAHR!           *
'*               VOR DER NUTZUNG DES PROGRAMMS SOLLTEN KOPIEN DES ZU VERARBEITETEN QUELLCODES      *
'*               ERSTELLT WERDEN.                                                                  *
'***************************************************************************************************
'***************************************************************************************************
'* Header laden                                                                                    *
'***************************************************************************************************
 $H MESSAGES.PH
'***************************************************************************************************
'***************************************************************************************************
'* Includes laden                                                                                  *
'***************************************************************************************************
 $I User.INC
'***************************************************************************************************
'***************************************************************************************************
'* Globale Variablen                                                                               *
'***************************************************************************************************
DECLARE GB&[], T&[], E&[], B&[], PGB&, FileList&, STB&, SW#
DECLARE Ende%, aux$, Last_aux$, i&, Lines&, Replaces&, DateiNr%, ZeileNr%, Line$
DECLARE SourceFile$, Pfad$, CopyNr%
DECLARE Font&[]
DECLARE Such$, Ersatz$, RegAusdruck$[], z$, i%,o%, TrackCommand&
VAR PRGName$ = "XProfanX2-ParameterReplacer"
VAR Version$ = "V1.00 - 10.04.2012"
'***************************************************************************************************
'***************************************************************************************************
'* Schalter setzen                                                                                 *
'***************************************************************************************************
SET("LISTDEL", "|-|")
'***************************************************************************************************
'***************************************************************************************************
'* Definitionen                                                                                    *
'***************************************************************************************************
DEF GetAsyncKeyState(1) !"USER32" , "GetAsyncKeyState"
DEF GetSysColor(1)      !"USER32" , "GetSysColor"
'***************************************************************************************************
'***************************************************************************************************
'* Parameter der *.PRF - Datei einlesen (Variablen im Hauptprogramm)                               *
'***************************************************************************************************

PROC ReadParameters

    PARAMETERS File$
    DECLARE    FileNo%, Line$ , aux$, i%, ParameterName$
    DECLARE    SuchString#
    SET("RegEx", 0)
    DIM SuchString#, 256
    File$   = TRANSLATE$(TRANSLATE$(File$,"\\","\"),"\","\\")
    FileNo% = ASSIGN(File$)
    RESET #FileNo%

    WHILENOT EOF(#FileNo%)

        INPUT #FileNo%, Line$
        Line$ = TRIM$(Line$)
        aux$  = SUBSTR$(Line$, 1," ")

        SELECT UPPER$(aux$)

            CASEOF "DECLARE"

            aux$ = TRIM$(SUBSTR$(TRANSLATE$(Line$, aux$, UPPER$(aux$)), 2, "DECLARE"))

            CASEOF "VAR"

            aux$ = TRIM$(SUBSTR$(TRANSLATE$(Line$, aux$, UPPER$(aux$)), 2, "VAR"))
            OTHERWISE
            aux$ = ""

        ENDSELECT

        i% = 1

        WHILE TRIM$(SUBSTR$(aux$, i%, ",")) <> ""

            ParameterName$ = TRIM$(SUBSTR$(TRIM$(SUBSTR$(aux$, i%, ",")),1,"["))

            IF INSTR("$", ParameterName$) OR \

                INSTR("%", ParameterName$) OR \
                INSTR("&", ParameterName$) OR \
                INSTR("!", ParameterName$) OR \
                INSTR("#", ParameterName$)
                ParameterName$ = TRIM$(SUBSTR$(ParameterName$, 1, " "))
                ParameterName$ = TRIM$(SUBSTR$(ParameterName$, 1, "="))
                ParameterName$ = TRIM$(SUBSTR$(ParameterName$, 1, ":"))
                ParameterName$ = TRIM$(SUBSTR$(ParameterName$, 1, "'"))
                STRING SuchString#,0 = ParameterName$
                ParameterName$ = TRIM$(ParameterName$)

                IF SENDMESSAGE(E&[3], ~LB_FINDSTRING, -1, ADDR(ParameterName$)) < 0

                    ADDSTRING(E&[3], ParameterName$)

                ENDIF

            ENDIF

            i% = i% + 1

        ENDWHILE

    ENDWHILE

    CLOSE  #FileNo%
    ASSIGN #FileNo%, ""
    DISPOSE SuchString#

ENDPROC

'***************************************************************************************************
'***************************************************************************************************
'* Quelltext rekursiv aufrufen                                                                     *
'***************************************************************************************************

PROC AddSource

    PARAMETERS File$
    DECLARE Line$, Index$
    DECLARE FileNo%, LineNo%
    File$   = TRANSLATE$(TRANSLATE$(File$,"\\","\"),"\","\\")
    FileNo% = ASSIGN(File$)
    LineNo% = 0
    Index$  = FORMAT$("00", FileNo%) + "." + FORMAT$("00000", LineNo%)
    ADDSTRING(E&[5], Index$ + GET("LISTDEL") + File$)
    SETTEXT STB&, 5, STR$(GETCOUNT(E&[5]))
    SETTEXT STB&, 7, STR$(GETCOUNT(E&[5]))
    RESET #FileNo%

    WHILENOT EOF(#FileNo%)

        LineNo% = LineNo% + 1
        Index$  = FORMAT$("00", FileNo%) + "." + FORMAT$("00000", LineNo%)
        INPUT #FileNo%, Line$
        ADDSTRING(E&[5], Index$ + GET("LISTDEL") + Line$)
        SETTEXT STB&, 5, STR$(GETCOUNT(E&[5]))
        Line$   = TRIM$(Line$)

        IF UPPER$(LEFT$(Line$, 3)) = "$I "

            AddSource(Pfad$+SUBSTR$(Line$, 2, "$I "))

        ENDIF

    ENDWHILE

    CLOSE #FileNo%

ENDPROC

'***************************************************************************************************
'***************************************************************************************************
'* HAUPTPROGRAMM                                                                                   *
'***************************************************************************************************
WINDOWSTYLE  2 + 8+ 16 + 32 + 512
WINDOW       800, 600
WINDOWTITLE  PRGName$ + " - " + Version$
CLS          GetSysColor(15)
DIM          SW#, 8*4
LONG         SW#, 0 = 050, 400,475,500, 575, 650, 725, -1
STB&       = CREATE("STATUSWINDOW", %HWND , "", 8, SW#)
SETWINDOWPOS STB& = 0,0-0,0;0
SETTEXT      STB&, 0, "Status:"
SETTEXT      STB&, 2, "Dateien:"
SETTEXT      STB&, 4, "Akt. Zeile:"
SETTEXT      STB&, 6, "Sum. Zeilen:"
'*-------------------------------------------------------------------------------------------------*
Font&[0]  = CREATEFONT("MS Sans Serif",10,0,0,0,0)'Standardfont
Font&[1]  = CREATEFONT("MS Sans Serif",10,0,1,0,0)
Font&[2]  = CREATEFONT("Courier New"  ,14,0,0,0,0)
GB&[0] = Create("Groupbox", %HWND , "Datei"           ,  10             , 10,Width(%HWND)-20, 60)
T&[0]  = Create("Text"    , GB&[0], "XProfan Hauptprogramm:",  10             , 23,130,20)
E&[0]  = Create("Edit"    , GB&[0], ""             , 140             , 20,width(GB&[0])-140-95,20)
B&[0]  = Create("Button"  , %HWND ,"wählen"        , width(GB&[0])-75, 30, 75,25)
GB&[1] = Create("Groupbox", %HWND , "Parameter"    ,  10, 90,Width(%HWND)-20, 200)
T&[1]  = Create("Text"    , GB&[1], "Suchen nach:" , 210, 23,080, 20)
E&[1]  = Create("Edit"    , GB&[1], ""             , 290, 20,220, 20)
T&[2]  = Create("Text"    , GB&[1], "Ersetzen mit:", 210, 58,080, 20)
E&[2]  = Create("Edit"    , GB&[1], ""             , 290, 55,220, 20)
T&[3]  = Create("Text"    , GB&[1], "Summe:"       ,  10,175,050, 20)
E&[6]  = Create("Edit"    , GB&[1], ""             ,  60,173,050, 20)
T&[4]  = Create("Text"    , GB&[1], "Summe:"       , 665,175,050, 20)
E&[7]  = Create("Edit"    , GB&[1], ""             , 715,173,050, 20)
B&[1]  = Create("Button"  , %HWND ,"übernehmen"    , 300,180,090, 25)
B&[2]  = Create("Button"  , %HWND ,"Start"         , 430,180,090, 25)
E&[3]  = Create("Listbox" , %HWND , 1,               020,110,190,145)
E&[4]  = Create("Gridbox" , %HWND , "Suchen nach;0;120;Ersetzen mit;0;120",1, 530,110,Width(GB&[1])-530,145)
E&[5]  = Create("Gridbox" , %HWND , "Datei-Nr.Zeile;1;120;Quelltext;0;640",1, 10,300,Width(%HWND)-20,Height(%HWND)-330)
CREATEOBJECT GB&[1],"msctls_progress32","PROGRESSBAR",210,HEIGHT(GB&[1])-25, 300,015,"$54000000","$020000"
PGB& = @&(0)
SETPROZESSPOS PGB&, 0
'*-------------------------------------------------------------------------------------------------*

WHILELOOP 0, SIZEOF(T&[]) -1, 1

    SETFONT T&[&LOOP], Font&[0]

WEND

WHILELOOP 0, SIZEOF(E&[]) -1, 1

    SETFONT E&[&LOOP], Font&[0]

WEND

SETFONT E&[5], Font&[2]

WHILELOOP 0, SIZEOF(B&[]) -1, 1

    SETFONT B&[&LOOP], Font&[1]

WEND

'*-------------------------------------------------------------------------------------------------*
CREATE("TOOLTIP",%HWND, E&[0], "Zu analysierendes Hauptprogramm an.")
CREATE("TOOLTIP",%HWND, E&[1], "\
Geben Sie hier den Suchbegriff des Parameters an.\n\
^ \t= Suche am Wortanfang, z.B. ^Anfang\n\
 $ \t= Suche am Wortende, z.B. $Ende\n\
. \t= beliebieges Zeichen, z.B. be.iebig\n\
[abc]\t= Einzeichenmuster, z.B. M[ei][ai]er\n\
(abc|def)\t= Alternativen, z.B. M(ei|ai)er\n\
? \t= Ausdruck kommt 0 oder 1 mal vor\n\
+ \t= Ausdruck kommt mind. 1 mal vor\n\
* \t= Ausdruck kommt beliebig oft vor\n\
{von, bis}= Ausdruck kommt von ... bis vor")
CREATE("TOOLTIP",%HWND, E&[2], "Geben Sie hier den Ersatznamen des Parameters an.")
CREATE("TOOLTIP",%HWND, E&[3], "Liste aller gefundenen Parameter im Hauptprogramm.")
CREATE("TOOLTIP",%HWND, E&[4], "Suchbegriff und Ersatzname")
CREATE("TOOLTIP",%HWND, E&[5], "Gesamter Quellcode")
'*-------------------------------------------------------------------------------------------------*
ENABLEWINDOW E&[6], 0
ENABLEWINDOW E&[7], 0
'*-------------------------------------------------------------------------------------------------*
Ende% =  0
GetAsyncKeyState(1)
GetAsyncKeyState(2)
'*-------------------------------------------------------------------------------------------------*

WHILENOT Ende%

    SETTEXT STB&, 1, "Bereit"
    SETTEXT E&[6], STR$(GETCOUNT(E&[3]))
    SETTEXT E&[7], STR$(GETCOUNT(E&[4]))
    WAITINPUT

    IF %KEY = 2'Abbruch

        Ende% = 1

    ELSEIF GetAsyncKeyState(2) <> 0'RMT

        IF GETSELCOUNT(E&[4]) = 1

            CREATEMENU
            APPENDMENU 1001, "Markierten Eintrag löschen"
            APPENDMENU 1002, "Alle Einträge löschen"
            TrackCommand& = TRACKMENU()

            SELECT TrackCommand&

                CASEOF 1001

                DELETESTRING(E&[4], GETCURSEL(E&[4]))

                CASEOF 1002

                CLEARLIST E&[4]

            ENDSELECT

        ENDIF

    ELSEIF CLICKED(B&[0])'Datei laden

        SETTEXT STB&, 1, "Hauptprogramm laden"
        SourceFile$ = LoadFile$("Laden", "*.prf")

        IF SourceFile$ <> ""

            SETTEXT E&[0], SourceFile$
            SETTEXT E&[6], ""
            SETTEXT E&[7], ""
            SETTEXT STB&, 1, "Variablen sammeln..."
            SETTEXT STB&, 3, ""
            SETTEXT STB&, 5, ""
            SETTEXT STB&, 7, ""
            CLEARLIST E&[3]
            CLEARLIST E&[4]
            CLEARLIST E&[5]
            ReadParameters Sourcefile$
            Pfad$   = SUBSTR$(SourceFile$, 1, SUBSTR$(SourceFile$, -1,"\\"))
            USECURSOR 2
            SETTEXT STB&, 1, "Quellcode rekursiv analysieren..."

            WHILELOOP 99

                ASSIGN #&LOOP, ""

            WEND

            AddSource SourceFile$
            SETTEXT STB&, 3, SUBSTR$(GETSTRING$(E&[5], GETCOUNT(E&[5])-1), 1, ".")
            SETTEXT STB&, 5, FORMAT$("00000",0)
            SETTEXT STB&, 7, FORMAT$("00000",GETCOUNT(E&[5]))

            WHILELOOP 99

                ASSIGN #&LOOP, ""

            WEND

            USECURSOR 0

        ENDIF

    ELSEIF CLICKED(B&[1])'Übernehmen

        IF GETTEXT$(E&[1]) <> ""

            WHILELOOP 2

                IF RIGHT$(GETTEXT$(E&[&LOOP]), 1) = "$"

                    RegAusdruck$[&LOOP] = LEFT$(GETTEXT$(E&[&LOOP]), LEN(GETTEXT$(E&[&LOOP]))-1)

                ELSE

                    RegAusdruck$[&LOOP] = GETTEXT$(E&[&LOOP])

                ENDIF

            ENDWHILE

            RegAusdruck$[1] = "(?i)" + RegAusdruck$[1]

            WHILELOOP 0, GETCOUNT(E&[3])-1, 1

                aux$ = GETSTRING$(E&[3], &loop)
                SET("RegEx", 1)

                IF MATCH$(RegAusdruck$[1], aux$) <> ""

                    Such$   = RegAusdruck$[1]
                    Ersatz$ = RegAusdruck$[2]
                    ADDSTRING(E&[4], aux$ + GET("LISTDEL") + TRANSLATE$(aux$, Such$, Ersatz$))

                ENDIF

                SET("RegEx", 0)

            ENDWHILE

        ENDIF

    ELSEIF CLICKED(B&[2])'Start

        USECURSOR 2
        SETTEXT STB&, 1, "Variablennamen aktualisieren..."
        SETPROZESSPOS PGB&, 0
        Lines&    = GETCOUNT(E&[5])
        Replaces& = GETCOUNT(E&[4])

        WHILELOOP 0, Lines&-1

            SETTEXT STB&, 5, STR$(&LOOP)
            SETPROZESSPOS PGB&, &LOOP*100/Lines&
            aux$ = GETSTRING$(E&[5], &LOOP)
            i& = 0

            WHILENOT i&>(Replaces&-1)

                Such$   = "(?i)" + SUBSTR$(GETSTRING$(E&[4], i&),1,GET("LISTDEL"))
                Ersatz$ =          SUBSTR$(GETSTRING$(E&[4], i&),2,GET("LISTDEL"))
                SET("RegEx", 1)
                aux$    = TRANSLATE$(aux$, Such$, Ersatz$)
                SET("RegEx", 0)
                i&      = i& + 1

            WEND

            SETTEXT E&[5], &LOOP, 1, SUBSTR$(aux$,2,GET("LISTDEL"))

        WEND

        USECURSOR 0

        WHILELOOP 99

            ASSIGN #&LOOP, ""

        WEND

        DateiNr% = 0
        SETPROZESSPOS PGB&, 0

        WHILELOOP 0, Lines&-1

            SETTEXT STB&, 5, STR$(&LOOP)
            SETPROZESSPOS PGB&, &LOOP*100/Lines&
            aux$    = GETSTRING$(E&[5], &LOOP)
            DateiNr%= VAL(SUBSTR$(SUBSTR$(aux$, 1, GET("LISTDEL")),1,"."))
            ZeileNr%= VAL(SUBSTR$(SUBSTR$(aux$, 1, GET("LISTDEL")),2,"."))
            Line$   = SUBSTR$(aux$, 2, GET("LISTDEL"))
            SETTEXT STB&, 1, "Speichere Datei-Nr. " + FORMAT$("00", DateiNr%)

            IF ZeileNr% = 0

                CASE DateiNr% : CLOSE #DateiNr%
                aux$ = FINDFIRST$(Line$ + "*")

                WHILE %IORESULT = 0

                    aux$ = FINDNEXT$(Line$ + "*")
                    CASE aux$ <> "": Last_aux$ = aux$

                ENDWHILE

                aux$    = Last_aux$
                CopyNr% = VAL(SUBSTR$(aux$,-1,".")) + 1
                COPY Line$ > Line$ + "." + FORMAT$("000", CopyNr%)
                ASSIGN #DateiNr%, Line$
                REWRITE #DateiNr%

            ELSE

                PRINT #DateiNr%, Line$

            ENDIF

        WEND

        CASE DateiNr% : CLOSE #DateiNr%

        WHILELOOP 99

            ASSIGN #&LOOP, ""

        WEND

        SETPROZESSPOS PGB&, 0
        SETTEXT STB&, 5, ""

    ELSEIF %KEY = 3'Doppelklick in Liste

        SETTEXT E&[1], GETSTRING$(E&[3], GETCURSEL(E&[3]))
        SETTEXT E&[2], GETSTRING$(E&[3], GETCURSEL(E&[3]))

    ENDIF

ENDWHILE

'*-------------------------------------------------------------------------------------------------*
DISPOSE SW#

WHILELOOP 0,2,1

    DELETEOBJECT Font&[&../../funcion-referencias/XProfan/loop/'>LOOP]

ENDWHILE

'*-------------------------------------------------------------------------------------------------*
END
'***************************************************************************************************

2 kB
Kurzbeschreibung: user.INC
Hochgeladen:04/10/12
Downloadcounter216
Download
 
Schöne Grüße aus Wittgenstein
von Stephan

Programmierumgebung:| XProfan X4 | WIN10 | AMD FX6100 3,3 GHz
04/10/12  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

4.196 Views

Untitledvor 0 min.
Gast.081508/29/24
RudiB.10/21/21
Stephan Sonneborn10/04/20
Matthias Arlt06/22/20
More...

Themeninformationen

this Topic has 1 subscriber:

Stephan Sonneborn (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie