Author Topic: QB64 Modset by Steve  (Read 6583 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
QB64 Modset by Steve
« on: September 19, 2018, 05:22:48 pm »
Code: QB64: [Select]
  1. _TITLE "QB64 $AUTOSAVE Mod"
  2. OPEN "source\qb64.bas" FOR BINARY AS #1
  3. OPEN "source\qb64-MOD.bas" FOR OUTPUT AS #2
  4.  
  5. INPUT "Time before QB64 does an $AUTOSAVE for us (in minutes):"; AutoSaveTime
  6.  
  7.  
  8.     LINE INPUT #1, text$
  9.     IF INSTR(text$, "QB64 COMPILER ONCE ONLY SETUP CODE ENDS HERE") THEN
  10.         PRINT #2, ""
  11.         PRINT #2, "'************  START OF AUTOSAVE INITIALIZATION"
  12.         PRINT #2, ""
  13.         PRINT #2, "BackupTimer = _FREETIMER"
  14.         PRINT #2, "BackupMinutes =" + STR$(AutoSaveTime) + " * 60 '60 seconds"
  15.         PRINT #2, "ON TIMER(BackupTimer, BackupMinutes) Backup"
  16.         PRINT #2, "IF NOT NoIDEMode THEN TIMER(BackupTimer) ON"
  17.         PRINT #2, "DIM SHARED AutoSave AS INTEGER"
  18.         PRINT #2, ""
  19.         PRINT #2, ""
  20.         PRINT #2, "'************  END OF AUTOSAVE INITIALIZATION"
  21.     END IF
  22.     IF INSTR(text$, "$VIRTUALKEYBOARD:ON") AND VKOfound = 0 THEN
  23.         VKOfound = -1
  24.         PRINT #2, "IF temp$ = " + CHR$(34) + "$AUTOSAVE" + CHR$(34) + " THEN AutoSave = -1: layout$ = " + CHR$(34) + "$AUTOSAVE" + CHR$(34) + ": GOTO finishedlinepp"
  25.         PRINT #2, ""
  26.         PRINT #2, ""
  27.     END IF
  28.  
  29.     PRINT #2, text$
  30.     IF INSTR(text$, "'clear/init variables") THEN PRINT #2, "AutoSave = 0"
  31.     IF INSTR(text$, "a3u$ = UCASE$(a3$)") THEN PRINT #2, "IF a3u$ = " + CHR$(34) + "$AUTOSAVE" + CHR$(34) + " then GOTO finishednonexec"
  32. PRINT #2, ""
  33. PRINT #2, ""
  34. PRINT #2, "SUB Backup"
  35. PRINT #2, "STATIC backidet$"
  36. PRINT #2, "IF NOT Autosave THEN EXIT SUB"
  37. PRINT #2, "IF _DIREXISTS(" + CHR$(34) + "internal\autosave" + CHR$(34) + ") THEN"
  38. PRINT #2, "ELSE"
  39. PRINT #2, "    MKDIR " + CHR$(34) + "internal\autosave" + CHR$(34)
  40. PRINT #2, "END IF"
  41. PRINT #2, "IF backidet$ <> idet$ THEN"
  42. PRINT #2, "    IF ideprogname = " + CHR$(34) + CHR$(34) + " THEN"
  43. PRINT #2, "        ProposedTitle$ = FindProposedTitle$"
  44. PRINT #2, "        IF ProposedTitle$ = " + CHR$(34) + CHR$(34) + " THEN"
  45. PRINT #2, "            savename$ = " + CHR$(34) + "untitled" + CHR$(34) + " + tempfolderindexstr$"
  46. PRINT #2, "        ELSE"
  47. PRINT #2, "            savename$ = ProposedTitle$ + " + CHR$(34) + ".bas" + CHR$(34)
  48. PRINT #2, "        END IF"
  49. PRINT #2, "    ELSE"
  50. PRINT #2, "        savename$ = ideprogname"
  51. PRINT #2, "    END IF"
  52. PRINT #2, "    t$ = DATE$ + " + CHR$(34) + " - " + CHR$(34) + " + TIME$"
  53. PRINT #2, "    DO"
  54. PRINT #2, "        l = INSTR(t$, " + CHR$(34) + ":" + CHR$(34) + ")"
  55. PRINT #2, "        MID$(t$, l) = " + CHR$(34) + "-" + CHR$(34)
  56. PRINT #2, "    LOOP UNTIL l = 0"
  57. PRINT #2, "    savename$ = " + CHR$(34) + "internal\autosave\" + CHR$(34) + " + savename$ + " + CHR$(34) + " (" + CHR$(34) + " + t$ + " + CHR$(34) + ") .bas" + CHR$(34)
  58. PRINT #2, "    OPEN savename$ FOR OUTPUT AS #1510"
  59. PRINT #2, "    FOR i = 1 TO iden"
  60. PRINT #2, "        tempstring$ = idegetline(i)"
  61. PRINT #2, "        PRINT #1510, tempstring$"
  62. PRINT #2, "    NEXT"
  63. PRINT #2, "    CLOSE #1510"
  64. PRINT #2, ""
  65. PRINT #2, "    backidet$ = idet$"
  66. PRINT #2, "END IF"
  67. PRINT #2, "END SUB"
  68.  
  69. SHELL "qb64 -x source\qb64-MOD.bas"
  70. SHELL "qb64-MOD.exe"
  71.  

A slightly tweaked (and I think improved) version of the routine found here: http://qb64.freeforums.net/thread/67/qb64-autosave-mod

Read the major comments at the other thread; I'm not going to repeat them here again. 

The difference of this version and the one currently over at my backup forums?  This adds a new metacommand to QB64 which has to be present to enable the autosave routine to work.   Aptly enough, it's called "$AUTOSAVE"....

EDIT: Before I forget, it also allows the user to set the backup time for themselves, so they can backup at whatever interval they think is the most appropriate for their disk space and security needs.

I dunno if anyone else in the world is interested in this type of change for QB64, but I personally find these types of backup programs to be essential to my mental well being sometimes.  CTRL-Z is nice, but it has its limits with how far back it'll go, how much it can hold, and how many dang times it may need to be clicked to see which alteration killed the code I was working on.

Individual time/date stamped backups has saved me a lot of hassle in the past, and if it's something the rest of you guys might be interested in, you can now add the capability to QB64 anytime you wish (for both 32-bit and 64-bit versions).   ;)

*****************************
*****************************

Soon(tm), I'm going to work up another little script like this one to add the $REPLACE command (as discussed here: https://www.qb64.org/forum/index.php?topic=588.0 ) into folks' IDE who might be interested in it.

Then, those who like these abilities/changes, can have them for any version they want (even older versions, though I haven't tested to see how far back one could actually pop these into the IDE...  They may even work in SDL.  If not, they should with just a few minor tweaks for placement or directory paths/structure.)

It seems like the best of both worlds to me:  A way to add flexibility for the folks who would be interested in these thing; while keeping QB64 from "bloating" itself with new features that others might not find the least bit appealing. 
« Last Edit: September 21, 2018, 03:25:24 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: QB64 Mod: $AUTOSAVE
« Reply #1 on: September 19, 2018, 05:27:09 pm »
Another side advantage to little scripts like this:  Folks who might be interested in making their own changes to QB64 can probably use it as a template to find WHERE to make the additions and alterations necessary for their own customization's.   :)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: QB64 Mod: $AUTOSAVE
« Reply #2 on: September 21, 2018, 01:36:18 pm »
Code: QB64: [Select]
  1. _TITLE "QB64 $AUTOSAVE Mod"
  2. OPEN "source\qb64.bas" FOR BINARY AS #1
  3. OPEN "source\qb64-MOD.bas" FOR OUTPUT AS #2
  4.  
  5.     LINE INPUT #1, text$
  6.     IF INSTR(text$, "QB64 COMPILER ONCE ONLY SETUP CODE ENDS HERE") THEN
  7.         PRINT #2, ""
  8.         PRINT #2, "'************  START OF TIMED EVENTS INITIALIZATION"
  9.         PRINT #2, ""
  10.         PRINT #2, "TimeEvent = _FREETIMER"
  11.         PRINT #2, "ON TIMER(TimeEvent, 1) TimedEvent 'A once a second timer"
  12.         PRINT #2, "IF NOT NoIDEMode THEN TIMER(TimeEvent) ON"
  13.         PRINT #2, "DIM SHARED AutoSave AS INTEGER, AutoSaveTimer AS DOUBLE "
  14.         PRINT #2, ""
  15.         PRINT #2, ""
  16.         PRINT #2, "'************  END OF TIMED EVENTS INITIALIZATION"
  17.     END IF
  18.     IF INSTR(text$, "$VIRTUALKEYBOARD:ON") AND VKOfound = 0 THEN
  19.         PRINT #2, "VKOfound = -1 'only the first time this appears in the code."
  20.         PRINT #2, "IF LEFT$(temp$,10) = " + CHR$(34) + "$AUTOSAVE:" + CHR$(34) + " THEN "
  21.         PRINT #2, "    AutoSave = -1"
  22.         PRINT #2, "    temp1$ = MID$(temp$,11)"
  23.         PRINT #2, "    l1 = INSTR(temp1$, " + CHR$(34) + "*" + CHR$(34) + ")"
  24.         PRINT #2, "    IF l1 THEN"
  25.         PRINT #2, "        AutoSaveTimer = VAL(LEFT$(temp1$,l1)) * VAL(MID$(temp1$,l1+1))"
  26.         PRINT #2, "    ELSE"
  27.         PRINT #2, "        AutoSaveTimer = VAL(MID$(temp$,11))"
  28.         PRINT #2, "    END IF"
  29.         PRINT #2, "    IF AutoSaveTimer = 0 THEN a$ = " + CHR$(34) + "ERROR: No Time Set on AutoSave" + CHR$(34) + ": GOTO errmes"
  30.         PRINT #2, "    layout$ = " + CHR$(34) + "$AUTOSAVE:" + CHR$(34) + " + LTRIM$(STR$(AutoSaveTimer))"
  31.         PRINT #2, "    GOTO finishedlinepp"
  32.         PRINT #2, "END IF"
  33.         PRINT #2, ""
  34.         PRINT #2, ""
  35.     END IF
  36.  
  37.     PRINT #2, text$
  38.     IF INSTR(text$, "'clear/init variables") THEN PRINT #2, "AutoSave = 0"
  39.     IF INSTR(text$, "a3u$ = UCASE$(a3$)") THEN PRINT #2, "IF LEFT$(a3u$,9) = " + CHR$(34) + "$AUTOSAVE" + CHR$(34) + " THEN GOTO finishednonexec"
  40. PRINT #2, ""
  41. PRINT #2, ""
  42. PRINT #2, "SUB TimedEvent"
  43. PRINT #2, "STATIC backidet$, TimeElapsed AS _UNSIGNED LONG"
  44. PRINT #2, "TimeElapsed = TimeElapsed +1"
  45. PRINT #2, "IF NOT Autosave THEN EXIT SUB"
  46. PRINT #2, "IF AutoSaveTimer = 0 THEN EXIT SUB"
  47. PRINT #2, "IF TimeElapsed MOD AutoSaveTimer = 0 THEN"
  48. PRINT #2, "  IF NOT _DIREXISTS(" + CHR$(34) + "internal\autosave" + CHR$(34) + ") THEN MKDIR " + CHR$(34) + "internal\autosave" + CHR$(34)
  49. PRINT #2, "  IF backidet$ <> idet$ THEN"
  50. PRINT #2, "    IF ideprogname = " + CHR$(34) + CHR$(34) + " THEN"
  51. PRINT #2, "        ProposedTitle$ = FindProposedTitle$"
  52. PRINT #2, "        IF ProposedTitle$ = " + CHR$(34) + CHR$(34) + " THEN"
  53. PRINT #2, "            savename$ = " + CHR$(34) + "untitled" + CHR$(34) + " + tempfolderindexstr$"
  54. PRINT #2, "        ELSE"
  55. PRINT #2, "            savename$ = ProposedTitle$ + " + CHR$(34) + ".bas" + CHR$(34)
  56. PRINT #2, "        END IF"
  57. PRINT #2, "    ELSE"
  58. PRINT #2, "        savename$ = ideprogname"
  59. PRINT #2, "    END IF"
  60. PRINT #2, "    t$ = DATE$ + " + CHR$(34) + " - " + CHR$(34) + " + TIME$"
  61. PRINT #2, "    DO"
  62. PRINT #2, "        l = INSTR(t$, " + CHR$(34) + ":" + CHR$(34) + ")"
  63. PRINT #2, "        MID$(t$, l) = " + CHR$(34) + "-" + CHR$(34)
  64. PRINT #2, "    LOOP UNTIL l = 0"
  65. PRINT #2, "    savename$ = " + CHR$(34) + "internal\autosave\" + CHR$(34) + " + savename$ + " + CHR$(34) + " (" + CHR$(34) + " + t$ + " + CHR$(34) + ") .bas" + CHR$(34)
  66. PRINT #2, "    OPEN savename$ FOR OUTPUT AS #1510"
  67. PRINT #2, "    FOR i = 1 TO iden"
  68. PRINT #2, "        tempstring$ = idegetline(i)"
  69. PRINT #2, "        PRINT #1510, tempstring$"
  70. PRINT #2, "    NEXT"
  71. PRINT #2, "    CLOSE #1510"
  72. PRINT #2, ""
  73. PRINT #2, "    backidet$ = idet$"
  74. PRINT #2, "  END IF"
  75. PRINT #2, "END IF"
  76. PRINT #2, "END SUB"
  77.  
  78. SHELL "qb64 -x source\qb64-MOD.bas"
  79. SHELL "qb64-MOD.exe"
  80.  

Another update to the routine here, to make it a little more flexible -- we can now set the amount of time IN PROGRAM and not need to set it in QB64.bas like the previous version above does.

NOTE:  Notice that I've configured this to run as a timed event which counts in SECONDS now, instead of MINUTES.  For testing purposes, all you need to do is set something incredibly fast such as $AUTOSAVE:1 and it'll save your work every second into separate, individual, time-stamped BAS files.

NOTE2:  I'm also lazy and don't want to calculate how many seconds are in a sequence of minutes.  If I want it to autosave my work every 27.2 minutes, how many seconds is that?  I dunno!  And, I don't want to have to get out a calculator to figure it out!!

So, this is a "smart" metacommand which calculates for us, as I'll illustrate below:

$AUTOSAVE:10      <--- This will autosave our work every 10 seconds into timestamped BAS files
$AUTOSAVE:60      <--- This will do it once a minute
$AUTOSAVE:27.2*60    <---  This will do it once every 27.2 minutes, AND it'll calculate that math and automagically replace the value for us so we can see how many seconds 27.2*60 is.

So, in the end, usage is now:

$AUTOSAVE:seconds

Just remember, seconds can include multiplication to be precalculated for us.  It doesn't do variables, addition, subtraction, or division -- JUST multiplication!  After all, if you're trying to divide the number of seconds you autosave, you're doing something wrong...

**********************
**********************

And just out of personal curiosity, am I the only person who is interested in such things?  These topics seldom ever get a response, so I'm often wondering if there's no need to bother sharing such code.  (I don't care though; I'll continue to share anyway, just so these little "Mod-Projects" are archived in various places across the net, and available to help me hunt them down for myself, if I ever need them again in the future.  Ptttttbbbttt!!)

Surely I'm not the only person out there to ever need/want to be able to have QB64 save my code at set intervals, for me??  The longer the project, the more I like/require things to be regularly backed up so I can maintain a working chain in case of total brain failure and code collapse.  Am I the only one who does this?  :P
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline freetrav

  • Newbie
  • Posts: 45
    • View Profile
Re: QB64 Mod: $AUTOSAVE
« Reply #3 on: September 21, 2018, 02:11:11 pm »
If you can tweak this to support addition and variables, then it becomes possible to do

MINUTES = 60
SECONDS = 1

$AUTOSAVE:2 *MINUTES + 30 *SECONDS

Alternatively, allow the parameter to parse for a colon (:), and each one multiplies by 60:

$AUTOSAVE:30 is every 30 seconds

$AUTOSAVE:2:30 is every two minutes thirty seconds - 150 seconds (2*60 + 30)

$AUTOSAVE:1:30:00 is every one hour thirty minutes - 5400 seconds (((1*60)+30)*60+0)

FellippeHeitor

  • Guest
Re: QB64 Mod: $AUTOSAVE
« Reply #4 on: September 21, 2018, 02:45:48 pm »
And just out of personal curiosity, am I the only person who is interested in such things?  These topics seldom ever get a response, so I'm often wondering if there's no need to bother sharing such code.  (I don't care though; I'll continue to share anyway, just so these little "Mod-Projects" are archived in various places across the net, and available to help me hunt them down for myself, if I ever need them again in the future.  Ptttttbbbttt!!)

Surely I'm not the only person out there to ever need/want to be able to have QB64 save my code at set intervals, for me??  The longer the project, the more I like/require things to be regularly backed up so I can maintain a working chain in case of total brain failure and code collapse.  Am I the only one who does this?  :P

I've voiced my opinion on this particular mod the first time you came up with it a while back. My point was that the IDE already saves a snapshot with every keystroke we type and that was enough for me. At the time you argued that using multiple instances could hinder the ability to recover lost code etc.

I still don't think it's optimal to have a bunch of duplicates with minor differences in one's hard drive, but do respect others wanting it. I'm used to versioning control done differently.

Marked as best answer by SMcNeill on October 29, 2018, 12:15:42 am

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: QB64 Modset by Steve
« Reply #5 on: September 21, 2018, 03:36:51 pm »
Code: QB64: [Select]
  1. _TITLE "QB64 Modset by Steve"
  2. OPEN "source\qb64.bas" FOR BINARY AS #1
  3. OPEN "source\qb64-MOD.bas" FOR OUTPUT AS #2
  4.     CLS
  5.     _LIMIT 30
  6.     PRINT "TOGGLE the following settings below:"
  7.     IF NOT autosave THEN PRINT "1) DON'T do the $AUTOSAVE mod" ELSE PRINT "1) Do the $AUTOSAVE mod"
  8.     IF NOT showclock THEN PRINT "2) DON'T show a clock at the bottom of the screen." ELSE PRINT "2) Do show a clock at the bottom of the screen."
  9.     PRINT
  10.     PRINT "0) Make modifications as set above"
  11.  
  12.     i$ = INKEY$
  13.     _KEYCLEAR
  14.     SELECT CASE i$
  15.         CASE "1", "!": autosave = NOT autosave
  16.         CASE "2", "@": showclock = NOT showclock
  17.         CASE "0", ")": EXIT DO
  18.     END SELECT
  19.     _DISPLAY
  20.  
  21.  
  22.     LINE INPUT #1, text$
  23.     IF autosave OR showclock THEN
  24.         IF INSTR(text$, "QB64 COMPILER ONCE ONLY SETUP CODE ENDS HERE") THEN
  25.             PRINT #2, ""
  26.             PRINT #2, "'************  START OF TIMED EVENTS INITIALIZATION"
  27.             PRINT #2, ""
  28.             PRINT #2, "TimeEvent = _FREETIMER"
  29.             PRINT #2, "ON TIMER(TimeEvent, 1) TimedEvent 'A once a second timer"
  30.             PRINT #2, "IF NOT NoIDEMode THEN TIMER(TimeEvent) ON"
  31.             IF autosave THEN PRINT #2, "DIM SHARED AutoSave AS INTEGER, AutoSaveTimer AS DOUBLE "
  32.             PRINT #2, ""
  33.             PRINT #2, ""
  34.             PRINT #2, "'************  END OF TIMED EVENTS INITIALIZATION"
  35.         END IF
  36.     END IF
  37.     IF autosave THEN
  38.         IF INSTR(text$, "$VIRTUALKEYBOARD:ON") AND VKOfound = 0 THEN
  39.             PRINT #2, "VKOfound = -1 'only the first time this appears in the code."
  40.             PRINT #2, "IF LEFT$(temp$,10) = " + CHR$(34) + "$AUTOSAVE:" + CHR$(34) + " THEN "
  41.             PRINT #2, "    AutoSave = -1"
  42.             PRINT #2, "    temp1$ = MID$(temp$,11)"
  43.             PRINT #2, "    l1 = INSTR(temp1$, " + CHR$(34) + "*" + CHR$(34) + ")"
  44.             PRINT #2, "    IF l1 THEN"
  45.             PRINT #2, "        AutoSaveTimer = VAL(LEFT$(temp1$,l1)) * VAL(MID$(temp1$,l1+1))"
  46.             PRINT #2, "    ELSE"
  47.             PRINT #2, "        AutoSaveTimer = VAL(MID$(temp$,11))"
  48.             PRINT #2, "    END IF"
  49.             PRINT #2, "    IF AutoSaveTimer = 0 THEN a$ = " + CHR$(34) + "ERROR: No Time Set on AutoSave" + CHR$(34) + ": GOTO errmes"
  50.             PRINT #2, "    layout$ = " + CHR$(34) + "$AUTOSAVE:" + CHR$(34) + " + LTRIM$(STR$(AutoSaveTimer))"
  51.             PRINT #2, "    GOTO finishedlinepp"
  52.             PRINT #2, "END IF"
  53.             PRINT #2, ""
  54.             PRINT #2, ""
  55.         END IF
  56.     END IF
  57.     PRINT #2, text$
  58.     IF autosave THEN
  59.         IF INSTR(text$, "'clear/init variables") THEN PRINT #2, "AutoSave = 0"
  60.         IF INSTR(text$, "a3u$ = UCASE$(a3$)") THEN PRINT #2, "IF LEFT$(a3u$,9) = " + CHR$(34) + "$AUTOSAVE" + CHR$(34) + " THEN GOTO finishednonexec"
  61.     END IF
  62. IF autosave OR showclock THEN
  63.     PRINT #2, ""
  64.     PRINT #2, ""
  65.     PRINT #2, "SUB TimedEvent"
  66.     PRINT #2, "STATIC backidet$, TimeElapsed AS _UNSIGNED LONG"
  67.     PRINT #2, "TimeElapsed = TimeElapsed +1"
  68.     IF showclock THEN
  69.         PRINT #2, "D = _DEST: DC = _DEFAULTCOLOR: BC = _BACKGROUNDCOLOR"
  70.         PRINT #2, "_DEST 0: COLOR 0, 3"
  71.         PRINT #2, "LOCATE idewy + idesubwindow, idewx - 32: PRINT TIME$;"
  72.         PRINT #2, "LOCATE idecy - idesy + 3, maxLineNumberLength + idecx - idesx + 2"
  73.         PRINT #2, "COLOR DC, BC: _DEST D"
  74.     END IF
  75.     IF autosave THEN
  76.         PRINT #2, "IF NOT Autosave THEN EXIT SUB"
  77.         PRINT #2, "IF AutoSaveTimer = 0 THEN EXIT SUB"
  78.         PRINT #2, "IF TimeElapsed MOD AutoSaveTimer = 0 THEN"
  79.         PRINT #2, "  IF NOT _DIREXISTS(" + CHR$(34) + "internal\autosave" + CHR$(34) + ") THEN MKDIR " + CHR$(34) + "internal\autosave" + CHR$(34)
  80.         PRINT #2, "  IF backidet$ <> idet$ THEN"
  81.         PRINT #2, "    IF ideprogname = " + CHR$(34) + CHR$(34) + " THEN"
  82.         PRINT #2, "        ProposedTitle$ = FindProposedTitle$"
  83.         PRINT #2, "        IF ProposedTitle$ = " + CHR$(34) + CHR$(34) + " THEN"
  84.         PRINT #2, "            savename$ = " + CHR$(34) + "untitled" + CHR$(34) + " + tempfolderindexstr$"
  85.         PRINT #2, "        ELSE"
  86.         PRINT #2, "            savename$ = ProposedTitle$ + " + CHR$(34) + ".bas" + CHR$(34)
  87.         PRINT #2, "        END IF"
  88.         PRINT #2, "    ELSE"
  89.         PRINT #2, "        savename$ = ideprogname"
  90.         PRINT #2, "    END IF"
  91.         PRINT #2, "    t$ = DATE$ + " + CHR$(34) + " - " + CHR$(34) + " + TIME$"
  92.         PRINT #2, "    DO"
  93.         PRINT #2, "        l = INSTR(t$, " + CHR$(34) + ":" + CHR$(34) + ")"
  94.         PRINT #2, "        MID$(t$, l) = " + CHR$(34) + "-" + CHR$(34)
  95.         PRINT #2, "    LOOP UNTIL l = 0"
  96.         PRINT #2, "    savename$ = " + CHR$(34) + "internal\autosave\" + CHR$(34) + " + savename$ + " + CHR$(34) + " (" + CHR$(34) + " + t$ + " + CHR$(34) + ") .bas" + CHR$(34)
  97.         PRINT #2, "    OPEN savename$ FOR OUTPUT AS #1510"
  98.         PRINT #2, "    FOR i = 1 TO iden"
  99.         PRINT #2, "        tempstring$ = idegetline(i)"
  100.         PRINT #2, "        PRINT #1510, tempstring$"
  101.         PRINT #2, "    NEXT"
  102.         PRINT #2, "    CLOSE #1510"
  103.         PRINT #2, ""
  104.         PRINT #2, "    backidet$ = idet$"
  105.         PRINT #2, "  END IF"
  106.         PRINT #2, "END IF"
  107.     END IF
  108.     PRINT #2, "END SUB"
  109.  
  110. IF showclock THEN
  111.     OPEN ".\source\ide\ide_methods.bas" FOR BINARY AS #1
  112.     OPEN ".\source\ide\ide_temp.bas" FOR OUTPUT AS #2
  113.     DO
  114.         LINE INPUT #1, temp$
  115.         IF flagset = 2 AND INSTR(temp$, "TIME$") = 0 THEN PRINT #2, "LOCATE idewy+ idesubwindow, idewx - 32: PRINT TIME$;"
  116.         IF flagset = 2 THEN flagset = 3
  117.         PRINT #2, temp$
  118.         IF INSTR(temp$, "'update cursor pos in status bar") THEN flagset = 1
  119.         IF INSTR(temp$, "PRINT a$;") THEN flagset = 2
  120.     LOOP UNTIL EOF(1)
  121.     CLOSE
  122.     KILL ".\source\ide\ide_methods.bas"
  123.     NAME ".\source\ide\ide_temp.bas" AS ".\source\ide\ide_methods.bas"
  124.  
  125.  
  126.  
  127. SHELL "qb64 -x source\qb64-MOD.bas"
  128. SHELL "qb64-MOD.exe"

We now have an install system which makes it even easier to install the various modifications which I like to tweak into my version of QB64.

Currently we have the $AUTOSAVE modification for folks who like that type of ability, and we now also have the ability to add a clock to the bottom of the IDE (something which I personally miss a lot).

Now, some of you might ask, "Why put a clock into a series of modifications like this, and not into the standard IDE?"

The reason for that is rather simple:  It's on ON TIMER event which could possibly lag down older computers which might be running QB64.  I have no issues with editing/coding/working in QB64 -- not even with something large like QB64.bas loaded into the editor -- but I'm worried that it could become an issue for others if it was standard for all downloads.

This offers the best option for users, I think:  Those who want a clock on the IDE can easily install one there.  If it causes lag or unresponsiveness for them, it's easy enough to get rid of -- just go back to QB64.exe instead of the QB64-Mod.exe which this builds for you.  :P

******************
******************

To do soon(tm):

Add a modification for the $REPLACE ability as I was speaking about elsewhere here on the forums.

Add an option for the SUB/FUNCTIONS to go anywhere in our code.  (This will require work with the autoformatter and spacing, so it may take a bit to perfect.)

Add the ability to instantly convert from 32-bit to 64-bit, for those who have the 64-bit compiler in the main folder when running the installation program. 

**********************
**********************

Eventually, the goal is to end up making this a one-stop shop for all the little modifications which I try to track and offer for various changes to QB64.  :)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: QB64 Mod: $AUTOSAVE
« Reply #6 on: September 21, 2018, 05:08:08 pm »
... AND it'll calculate that math and automagically replace ...

"automagically"!?! I think that is going to be my new favorite word!

anywho, I see an autosave being a handy 'Option'. I wouldn't want some 2 or 3 line test crude being auto saved but would find it handy with longer more involved code, especially when more than one IDE open for testing host\client programs and tweaking them on the fly.
Granted after becoming radioactive I only have a half-life!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: QB64 Modset by Steve
« Reply #7 on: September 21, 2018, 05:24:23 pm »
Beats autotragically. You need FreeBASIC for that. ;)

Here is another clock example that can run in the title bar. It is combined in an INPUT keyboard routine.

Code: QB64: [Select]
  1. maxspaces% = 40
  2. WIDTH 80, 25
  3.     CLS
  4.     LOCATE 10, 5
  5.     PRINT "Input Name: ";
  6.     showcursor% = 7 ' Use 7 to show the cursor or zero to hide it. A value of 30 makes it a small square.
  7.  
  8.     CALL getinput(word$, maxspaces%, limitinput$, showcursor%, autoenter%)
  9.  
  10.     LOCATE 12, 5: PRINT "The input is now in the variable word$ as: "
  11.     LOCATE 14, 41 - LEN(word$) / 2 ' Centers the print in the next line.
  12.     PRINT word$
  13.  
  14.     ' Now here is another way to use the sub and keep the clock running.
  15.     LOCATE 16, 5
  16.     PRINT "Try again? Y/N "; ' Remember to always use a ";" after the print statement to keep your input on the same line.
  17.     limitinput$ = "YyNn"
  18.     autoenter% = 1 ' Automatically enter response after one key is pressed.
  19.     maxspaces% = 10
  20.     showcursor% = 0 ' Hide the cursor for yes/no responses.
  21.  
  22.     CALL getinput(word$, maxspaces%, limitinput$, showcursor%, autoenter%)
  23.  
  24.     limitinput$ = "" ' Always erase variable for other uses.
  25.     autoenter% = 0 ' Always erase variable for other uses.
  26.     IF LCASE$(word$) = "n" THEN END
  27.  
  28. SUB getinput (word$, maxspaces%, limitinput$, showcursor%, autoenter%)
  29. ' Input Statement with clock.
  30. startpos% = POS(0)
  31. endpos% = startpos% + maxspaces%
  32. word$ = "" ' Erases last entry to begin next entry.
  33. LOCATE , , 1, 7, showcursor%
  34.  
  35.     IF TIME$ >= "12:00:00" THEN
  36.         TIME1 = ASC(MID$(TIME$, 1, 1)) - 1
  37.         TIME2 = ASC(MID$(TIME$, 2, 1)) - 2
  38.         IF TIME2 < 48 THEN TIME2 = TIME2 + 10: TIME1 = TIME1 - 1
  39.         TIMECONV$ = CHR$(TIME1) + CHR$(TIME2) + MID$(TIME$, 3, LEN(TIME$)) + " PM"
  40.     ELSE
  41.         TIMECONV$ = MID$(TIME$, 1, 8) + " AM"
  42.     END IF
  43.     IF MID$(TIMECONV$, 1, 2) = "00" THEN MID$(TIMECONV$, 1, 2) = "12"
  44.     _TITLE SPACE$(61) + TIMECONV$
  45.  
  46.     ' KEY INPUT GOES HERE....................................................
  47.  
  48.     IF autoenter% THEN
  49.         ' Used for a non-enter response, like answering yes or no.
  50.         IF LEN(word$) = autoenter% THEN EXIT SUB
  51.     END IF
  52.  
  53.     mykey$ = INKEY$
  54.  
  55.     IF mykey$ <> "" THEN
  56.         yy% = CSRLIN: xx% = POS(0)
  57.  
  58.         SELECT CASE mykey$
  59.             CASE CHR$(0) + "K"
  60.                 mov% = -1: GOSUB action
  61.             CASE CHR$(0) + "M"
  62.                 mov% = 1: GOSUB action
  63.             CASE CHR$(0) + "S"
  64.                 GOSUB wash: GOSUB delete
  65.             CASE CHR$(0) + "R"
  66.                 IF ins% = 0 THEN ins% = -1 ELSE ins% = 0
  67.                 IF ins% = 0 THEN LOCATE , , 1, 7, 7 ELSE LOCATE , , 1, 7, 30
  68.             CASE CHR$(0) + "O"
  69.                 IF word$ <> "" THEN LOCATE yy%, startpos% + LEN(word$)
  70.             CASE CHR$(0) + "G"
  71.                 LOCATE yy%, startpos%
  72.             CASE CHR$(8)
  73.                 IF xx% > startpos% THEN
  74.                     LOCATE , POS(0) - 1
  75.                     xx% = POS(0)
  76.                     GOSUB wash: GOSUB delete
  77.                 END IF
  78.             CASE CHR$(13)
  79.                 ' Exits the input sub back to your main program.
  80.                 EXIT SUB
  81.             CASE CHR$(27)
  82.                 ' Quit and removes program winsow.
  83.                 SYSTEM
  84.             CASE CHR$(32) TO CHR$(126)
  85.                 IF INSTR(limitinput$, mykey$) OR limitinput$ = "" THEN
  86.                     key$ = mykey$
  87.                     GOSUB action
  88.                 ELSE
  89.                     BEEP ' Input error, retry.
  90.                 END IF
  91.         END SELECT
  92.         mov% = 0: key$ = ""
  93.     END IF
  94.  
  95. action:
  96. IF POS(0) + mov% >= startpos% AND POS(0) + mov% < endpos% THEN
  97.     DO
  98.         IF key$ <> "" THEN
  99.             SELECT CASE ins%
  100.                 CASE 0
  101.                     IF LEN(word$) + LEN(key$) > endpos% - startpos% THEN EXIT DO
  102.                     word$ = MID$(word$, 1, POS(0) - startpos%) + key$ + MID$(word$, POS(0) - startpos% + 1)
  103.                 CASE -1
  104.                     word$ = MID$(word$, 1, POS(0) - startpos%) + key$ + MID$(word$, POS(0) - startpos% + 2)
  105.             END SELECT
  106.         END IF
  107.         IF POS(0) - startpos% >= LEN(word$) - LEN(key$) AND key$ <> "" OR key$ = "" OR ins% = -1 THEN
  108.             IF key$ = "" AND mov% = 1 THEN IF POS(0) - startpos% = LEN(word$) THEN EXIT DO
  109.             LOCATE , POS(0) + mov%: PRINT key$;
  110.         ELSE
  111.             LOCATE yy%, startpos%: PRINT MID$(word$, 1, xx% - startpos%); key$;: xx2% = POS(0): PRINT MID$(word$, xx% - startpos% + 2);: LOCATE yy%, xx2%
  112.         END IF
  113.         EXIT DO
  114.     LOOP
  115.  
  116. wash:
  117. IF POS(0) >= startpos% AND word$ <> "" AND POS(0) - startpos% < LEN(word$) THEN
  118.     LOCATE yy%, startpos% + LEN(word$) - 1
  119.     PRINT " ";
  120.     LOCATE yy%, xx%
  121.  
  122. delete:
  123. IF POS(0) - startpos% = 0 THEN
  124.     word$ = MID$(word$, 2)
  125.     word$ = MID$(word$, 1, POS(0) - startpos%) + MID$(word$, POS(0) - startpos% + 2)
  126. PRINT MID$(word$, xx% - startpos% + 1);: LOCATE yy%, xx%
  127.  

What I could see useful for the way I code is a progressive version SAVE AS option in an IDE. peteprog.bas is the original, my next save is "automagically" named peteprog-0002.bas and so on and so forth. Of course this leads to other considerations like what to do if the user opens up peteprog-0003.bas, an older version, and tries to save it? It should look to see what the last version was and add one to it but that would mean an edited older version just jumped in front of the latest version. Oh well, at least my ideas keep the people who make aspirin busy.
« Last Edit: September 21, 2018, 05:37:28 pm by Pete »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/