Announcement

Collapse
No announcement yet.

Just a thought

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sven Blumenstein
    replied
    Originally posted by Lance Edmonds:
    Sven, can you explain what you mean here please? I played with your code and it seems to work fine for me (ignoring the IDE keyword highlighting problem).

    No, there is no Problem with the compiler. But my Code cuts of one or two bytes of a file
    I've mixed up the numbers.


    ------------------
    E-Mail (home): mailto:[email protected][email protected]</A>
    E-Mail (work): mailto:[email protected][email protected]</A>

    [This message has been edited by Sven Blumenstein (edited July 02, 2001).]

    Leave a comment:


  • Lance Edmonds
    replied
    Originally posted by Sven Blumenstein:
    [B]Hmmm.... there is a Bug in the STRINSERT / STRDELETE part.
    But I can't find it (perhaps I'm too tired. It's 2 AM here in Germany )
    Sven, can you explain what you mean here please? I played with your code and it seems to work fine for me (ignoring the IDE keyword highlighting problem).




    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Scott Turchin
    replied
    Sometimes I transfer .BAS files around and I do this so I know it is the correct version...

    Think you all missed the point, although th ey are great suggestions!!!

    I was just asking this as a feature enhancement...I can manually update it without a pro blem it's less effort and more reliable to launch the PB icon and manually change it..


    Just would be a cool feature to be able to use (enable/disable) in a future version


    Thanks tho!

    ------------------
    Scott

    Leave a comment:


  • Gregery D Engle
    replied
    Here is my approach...

    Compile EXE and then click on Window, then Options and change the
    compiler to point to this EXE.

    Code:
    'BUILD: "4" FOR D:\PBDLL60\PBUPD.BAS ON 07-02-2001 00:13:12 BY Greg Engle
    #COMPILE EXE
    #INCLUDE "win32api.inc"
    
    $PBCOMPILE = "D:\PBDLL60\BIN\PBDLL.EXE"
    
    TYPE UPDStruct
         szSourceFileName AS ASCIIZ * %MAX_PATH
         szUserName AS ASCIIZ * 25
         sDate AS STRING * 10
         sTime AS STRING * 8
         lBuild AS LONG
    END TYPE
    
    SUB Split(BYVAL expression AS STRING, BYVAL delimeter AS STRING, StrArray() AS STRING)
        LOCAL c AS LONG
        LOCAL x AS LONG
        IF LEN(delimeter) = 0 THEN
            delimeter = " "
        END IF
        c = MAX(PARSECOUNT(expression, delimeter), 1)
        REDIM StrArray(0 TO c - 1) AS STRING
        FOR x = 1 TO c
            StrArray(x - 1) = PARSE$(expression, delimeter, x)
        NEXT
    END SUB
    
    SUB UpdateBAS(OLDUpd AS UPDStruct, NewUPD AS UPDStruct)
        OldString$ = "'BUILD: " & CHR$(34) & FORMAT$(OLDUPD.lBuild) & CHR$(34) & " FOR " & OLDUPD.szSourceFilename & " ON " & _
                     OLDUPD.sDate & " " & OLDUPD.sTime & " BY " & OLDUPD.szUserName
        NewString$ = "'BUILD: " & CHR$(34) & FORMAT$(NewUPD.lBuild) & CHR$(34) & " FOR " & NewUPD.szSourceFilename & " ON " & _
                     NewUPD.sDate & " " & NewUPD.sTime & " BY " & NewUPD.szUserName
    
        OPEN NewUpd.szSourceFileName FOR BINARY AS #1
        GET$ #1,LOF(1), sBuffer$
    
        IF INSTR(sBuffer$, OldString$) > 0 THEN
            REPLACE OldString$ WITH NewString$ IN sBuffer$
                ELSE
            sBuffer$ = NewString$ & $CRLF & sBuffer$
        END IF
    
        SEEK 1, 1: SETEOF 1
        PUT 1,,sBuffer$
        CLOSE #1
    END SUB
    
    SUB CreateUPD(UPDFileName AS STRING, UPD AS UPDStruct)
       OPEN UPDFilename FOR OUTPUT AS #1
       PRINT #1, UPD
       CLOSE #1
    END SUB
    
    SUB GetUPD(UPDFileName AS STRING, UPD AS UPDStruct)
       OPEN UPDFilename FOR RANDOM AS #1
       GET #1,1, UPD
       CLOSE #1
    END SUB
    
    FUNCTION PBMAIN() AS LONG
        DIM Params(0 TO 0) AS STRING
        DIM UPD AS UPDStruct
        DIM OLDUpd AS UPDStruct
        '**** Split on Chr$(32)
        IF TALLY(COMMAND$, CHR$(32)) > 0 THEN
            Split COMMAND$, CHR$(32), Params()
                ELSE
            a& = SHELL($PBCOMPILE & " " & COMMAND$)
        END IF
    
        '**** Get the Source Filename
        FOR lcounter& = 0 TO UBOUND(Params())
            IF INSTR(Params(lCounter&), ".") > 0 THEN
                UPD.szSourceFileName = UCASE$(Params(lCounter&))
            END IF
        NEXT
    
        '**** Create or Update .UPD File
        sUPDFileName$ = UPD.szSourceFileName: REPLACE ".BAS" WITH ".UPD" IN sUPDFileName$
        SELECT CASE LEN(DIR$(sUPDFileName$)) > 0
            CASE -1
                GetUPD sUPDFileName$, OLDUpd
                UPD = OLDUpd
                UPD.sDate = DATE$
                UPD.sTime = TIME$
                INCR UPD.lBuild
                GetUserName UPD.szUserName, SIZEOF(UPD.szUserName)
                CreateUPD sUPDFileName$, UPD
                UpdateBAS OLDUPD, UPD
                SHELL $PBCOMPILE & " " & COMMAND$
            CASE 0
                GetUserName UPD.szUserName, SIZEOF(UPD.szUserName)
                UPD.sDate = DATE$
                UPD.sTime = TIME$
                UPD.lBuild = 1
                CreateUPD sUPDFileName$, UPD
                UpdateBAS OldUPD, UPD
                SHELL $PBCOMPILE & " " & COMMAND$
        END SELECT
    END FUNCTION
    ------------------
    -Greg

    [This message has been edited by Gregery D Engle (edited July 01, 2001).]

    Leave a comment:


  • Sven Blumenstein
    replied
    Hmmm.... there is a Bug in the STRINSERT / STRDELETE part.
    But I can't find it (perhaps I'm too tired. It's 2 AM here in Germany )

    Code:
    #COMPILE EXE "pbdll.exe"
    #INCLUDE "win32api.inc"
    
    DECLARE FUNCTION FileDateTime(BYVAL Filenam AS STRING) AS STRING
    
    FUNCTION PBMAIN
    
       cmd$ = COMMAND$ ' save commandline
    
       bas$ = EXTRACT$(cmd$, ".bas") + ".bas"
    
    '   MSGBOX bas$
    
       file$ = STRREVERSE$(EXTRACT$(STRREVERSE$(bas$), "\"))
    
    '   MSGBOX file$
    
       OPEN bas$ FOR BINARY AS #1
            l& = LOF(1)
            GET$ #1, LOF(1), buff$
       CLOSE #1
    
    
       FILECOPY bas$, bas$ + ".bak"
    
       b& = INSTR(buff$, " - Last Modified: ")
       IF b& <> 0 THEN
            buff$ = STRDELETE$(buff$, b& + 18, 18) ' 18 == len(" - Last Modified: ")
            buff$ = strinsert$(buff$, FileDateTime(bas$) + $CRLF, b& + 18)
    
            c& = INSTR(buff$, "'Filesize:")
            buff$ = strdelete$(buff$, c& + 10, 10)
            buff$ = strinsert$(buff$, STR$(l&) , c& + 10)
       ELSE
            tmp$ = "'" + file$ + " - Last Modified: " + FileDateTime(bas$) + $CRLF _
                    + "'Filesize:" + STR$(l&) + $CRLF + $CRLF
       END IF
    
    
    'Winlog.bas - Last Modified date 6/28/01
    'Filesize 123 bytes
    
    
       OPEN bas$ FOR BINARY AS #1
            PUT$ #1, tmp$
            PUT$ #1, buff$
       CLOSE #1
    
       SHELL "pbdll_org.exe " + cmd$, 0
    
    
    END FUNCTION
    
    FUNCTION FileDateTime(BYVAL Filenam AS STRING) AS STRING
    ' FileDateTime for PB/DLL 5.0' Copyright (c) 1998 by PowerBASIC, Inc.
    LOCAL fd AS WIN32_FIND_DATA
    LOCAL fh AS LONG
    LOCAL zText AS ASCIIZ * 255
    LOCAL st AS SYSTEMTIME
    LOCAL Temp AS STRING
    
    zText = Filenam
    
    ' -- Find the file
    fh = FindFirstFile(zText, fd)
    IF fh = %INVALID_HANDLE_VALUE THEN
    EXIT FUNCTION
    END IF
    FindClose fh
    
    ' -- Convert the file time from UTC to local time
    FileTimeToLocalFileTime fd.ftLastWriteTime, fd.ftLastWriteTime
    
    ' -- Convert the file time into a compatible system time
    FileTimeToSystemTime fd.ftLastWriteTime, st
    
    ' -- Create a date string using the local settings
    GetDateFormat %LOCALE_USER_DEFAULT, %DATE_SHORTDATE, st, BYVAL %NULL, zText, 255
    Temp = zText
    
    ' -- Create a time string using the local settings
    GetTimeFormat %LOCALE_USER_DEFAULT, %TIME_NOSECONDS, st, BYVAL %NULL, zText, 255
    
    ' -- Return the file date and time
    FUNCTION = Temp + " " + zText
    
    END FUNCTION
    P.S.: I know, that's not the best way. The INSTR and STRDELETE / STRINSERT
    part aren't a good choice. If someone has a better idea, please post
    it here!

    P.P.S.: There is also a Bug in the PB IDE:
    STRINSERT, STRREVERSE and STRDELETE are highlighted, but
    STRINSERT$, STRREVERSE$ and STRDELETE$ are the correct keywords


    ------------------
    E-Mail (home): mailto:[email protected][email protected]</A>
    E-Mail (work): mailto:[email protected][email protected]</A>



    [This message has been edited by Sven Blumenstein (edited July 01, 2001).]

    Leave a comment:


  • Sven Blumenstein
    replied
    Greg,
    yes, that's my thought. I just sayed "pbedit.exe" because
    It would be pretty cool to have the editor open up a .BAS file, insert a comment like:


    I'm sure we'll see such a App in the Source-Code section soon

    ------------------
    E-Mail (home): mailto:[email protected][email protected]</A>
    E-Mail (work): mailto:[email protected][email protected]</A>

    [This message has been edited by Sven Blumenstein (edited July 01, 2001).]

    Leave a comment:


  • Gregery D Engle
    replied
    Sven,

    I would think you would write a program and call it PBDLL.EXE
    then rename the original PBDLL.EXE to PBDLLOLD.EXE and the
    PBDLL.EXE calls the PBDLLOLD.EXE with the same switches that
    was passed to the PBDLL.EXE

    Kind of confusing but I'm sure it would work fine.

    ------------------
    -Greg

    Leave a comment:


  • Sven Blumenstein
    replied
    Why don't you write an own "pbedit.exe" wich changes the bas File like this an then shell's the original pbedit.exe?
    If you don't understand, what I mean, I can write a sample App.

    regards,
    Sven

    ------------------
    E-Mail (home): mailto:[email protected][email protected]</A>
    E-Mail (work): mailto:[email protected][email protected]</A>

    Leave a comment:


  • Gregery D Engle
    replied
    Scott,

    It wouldn't be very hard at all to make a PB/CC or PB/DLL
    application to do that automatically. I'm off for a few days,
    I will see what I can dig up.

    By the way, on another post about the Enum Add/Remove programs,
    I got some source code if you want it, let me know.

    ------------------
    -Greg

    Leave a comment:


  • Bern Ertl
    replied
    Scott,

    I do something very similar and agree that if the IDE could
    auto-update a couple of comment lines at the top of the current
    file it would be pretty cool...



    ------------------
    Bernard Ertl

    Leave a comment:


  • Scott Turchin
    started a topic Just a thought

    Just a thought

    It would be pretty cool to have the editor open up a .BAS file, insert a comment like:

    'Winlog.bas - Last Modified date 6/28/01
    'Filesize 123 bytes


    as well as any other pertinent information that would let me know..
    Sometimes I transfer .BAS files around and I do this so I know it is the correct version...


    ------------------
    Scott
Working...
X