Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 308
» Latest member: Donaldvem
» Forum threads: 1,741
» Forum posts: 17,901

Full Statistics

Latest Threads
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 762
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,034
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,261
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 315
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155

 
  Auto relaunch of running program
Posted by: Richard - 12-30-2022, 03:14 AM - Forum: Help Me! - Replies (3)

Looking for suggestions...


With windows 22H2 (and similar) - various things just are not working like they used to - getting worse as time goes on.


Previously I could have a program run continuously for 3 days - now this does not seem to be possible.

I am looking for suggestions/ideas (that might work) to have a running program gracefully shut itself down and restart itself - the on-going log files generated by the program will assist in the restarted program continuing as if nothing had happened.

Various things I tried such as Task Scheduler and so appears to be unstable (because of Windows updates).


So, for example, program X starts off (manually run) - then say after 10 minutes (+/- 1 minute) it shuts itself down in a controlled manner, and then restarts itself.

Print this item

  custom desktop
Posted by: MrCreemy - 12-29-2022, 10:32 PM - Forum: Works in Progress - Replies (3)

https://www81.zippyshare.com/v/13pCCwvq/file.html

above link, is a tiny video, showing my "custom desktop" I was going to use to deploy my software.

was inspired to post this, after reading the "windowing" thread

I was trying, at one time, to find a "teeny tiny" linux.
it was something like "minimal linux live" or something.

I was able to run QB64 programs that did *not* use any graphics screens.

I was thinking about trying to get "X" onto it... which *should* allow me to run compiled QB64 graphics programs.

which would allow my DESKTOP to run...
==========================================
this idea, combined with the other guy doing to "windowing" project? Might make a pretty cool result.

you boot into either your software, or, the desktop and your software.

absolute minimum *anything* other than just what you need to run your software... absolutely *nothing* would be able to disrupt it. software thus? would be beyond cross platform... if theres a 64 bit computer? it runs your software. period.

Print this item

  incorporate sound files in code
Posted by: mdijkens - 12-29-2022, 10:50 AM - Forum: Help Me! - Replies (6)

I always like to distribute my final program as just one single exe.
Therefore I include (small)images in DATA statements most of the time, by reading them in a Long array and _PutImage that array:

Code: (Select All)
Function data2image&
  Read iWidth%, iHeight%
  Dim alpha As _Byte, cval As Long, imgArray(iWidth% * iHeight%) As Long: imgArray(0) = iHeight% * 2 ^ 16 + iWidth%
  Read lin$: i64$ = String$(6 * iWidth% * iHeight%, 0): i64pos~& = 1
  Do While lin$ <> "*"
    l% = Len(lin$): Mid$(i64$, i64pos~&, l%) = lin$: i64pos~& = i64pos~& + l%: Read lin$
  Loop
  i$ = _Inflate$(base64decode$(Left$(i64$, i64pos~& - 1))): cn& = -3
  Do While n& < iWidth% * iHeight%
    cn& = cn& + 4: cval = CVL(Mid$(i$, cn&, 4)): alpha = _Alpha32(cval)
    If alpha = &H10 Then
      it& = cval - &H10000000: cn& = cn& + 4: cval = CVL(Mid$(i$, cn&, 4))
      Do While it& > 0
        n& = n& + 1: imgArray(n&) = cval: it& = it& - 1
      Loop
    Else
      n& = n& + 1: imgArray(n&) = cval
    End If
  Loop
  hImg& = _NewImage(iWidth%, iHeight%, 32): _Dest hImg&: Put (0, 0), imgArray(): _Dest 0: data2image& = hImg&
End Function


Is something like that also possible for ogg/wav/mp3 files?
Storing them in code in DATA statements, reading them in the correct (_MEM) structure and provide a Long pointer to that?

Print this item

  using QB64 to make "end credits" to a movie
Posted by: MrCreemy - 12-29-2022, 04:36 AM - Forum: Works in Progress - No Replies

so... I was starting to get into video editing. Then? I got an *itch* to try to do "professional" end credits. Like you see at the end of the movie.

wrote a little program to let me do "rolling credits". I record it, and use it to insert into the video editor, then mix my music in with it.

This? Is the ending of the movie "Shooter"... except, I edited in my own "end credits", with my own music too. I don;t think my "end credits demo:" came out too bad, but, thats for the viewer to decide.

But? Thats "powered by QB64" doing the end credits...

https://www10.zippyshare.com/v/jieU7aAe/file.html

Print this item

Music Control Audacious, play last 30 seconds of music
Posted by: mnrvovrfc - 12-29-2022, 01:41 AM - Forum: Utilities - No Replies

If you're on Linux, using Audacious music player and have loads of music that you don't have time to listen to entirely, I have written a tool to make your life a bit easier.

Press escape key at any time in the run to quit the program. This program expects Audacious started with a playlist ready to go. It prints on the screen the filename of the song that it's currently on. If you don't like this then press escape to get away from this QB64 user program, then change the current track in Audacious and try again to run this program.

Each song is first played for its first five seconds, then a seek is performed to about 30 seconds before the end to play that portion. These values could be adjusted in the program. It's easier to seek from the beginning of a song, but to seek from the end, first the playback length of the media file must be acquired.

While the 30 seconds of playback go down, the user could press escape to leave the program, or spacebar or enter to advance to the next track in the playlist.

This program makes use of an utility called "audtool" that should have been installed with Audacious. At the moment it works with one instance of Audacious that was ever opened.

Code: (Select All)
''by mnrvovrfc 2022-dec-28
option _explicit
dim as integer i, j, hm, hs, ff, coln
dim afile$, aname$, ke$, b$

afile$ = "audahelp-thistrak.txt"

_TITLE "Audacious App Helper"
do : loop until _screenexists

print "*** Make sure Audacious is running and with a playlist! ***"
print "Press escape to quit."
for i = 5 to 1 step -1
    print "Starting in..."; i
    _delay 1
    ke$ = inkey$
    if ke$ = chr$(27) then system
next
shell _hide "audtool -1 --playback-play"

for i = 1 to 20
    shell _hide "audtool -1 --current-song-length > " + afile$
    shell _hide "audtool -1 --current-song-filename >> " + afile$
    ff = freefile
    open afile$ for input as ff
    line input #ff, b$
    line input #ff, aname$
    close ff
    coln = instr(b$, ":")
    hm = val(left$(b$, coln - 1))
    hs = val(mid$(b$, coln + 1))
    hs = hs - 32
    if hs < 0 then
        hm = hm - 1
        hs = hs + 60
    end if
    hs = hs + hm * 60
    print i; "name: "; aname$
    print i; "for 5 seconds..."
    for j = 1 to 5
        _delay 1
        ke$ = inkey$
        if ke$ = chr$(27) then system
    next
    shell _hide "audtool -1 --playback-seek" + str$(hs)
    print i; "final 30 seconds..."
    for j = 1 to 30
        _delay 1
        ke$ = inkey$
        if ke$ = chr$(27) then system
        if ke$ = chr$(13) or ke$ = " " then exit for
    next
    if i = 20 then exit for
    shell _hide "audtool -1 --playlist-advance"
next

shell _hide "audtool -1 --playback-stop"
print "OVER"
_delay 5
system

Print this item

  Remove Spaces (or other characters) from a String
Posted by: George McGinn - 12-29-2022, 01:28 AM - Forum: Utilities - Replies (10)

Awhile back I needed to remove SPACES (and sometimes other characters) from a string in some of my C code.

The need to do so in QB64 reared its ugly head again today, so I resurrected my code and now have incorporated it into any QB64 program I will need it in.

You pass the function 2 parameters - The string you want to change, and the character(s) you want removed. For example, if I want spaces and periods to be removed from a sentence, I pass " ." in the second argument. You don't need to run this function multiple times to accomplish this.

Here is the C/C++ Header file:

Code: (Select All)
#include <stdio.h>
/* search for character(s) */
int string_search_chr(char *tokens,char s){
        if (!tokens || s=='\0')
        return 0;
    for (;*tokens; tokens++)
        if (*tokens == s)
            return 1;
    return 0;
}
char *string_remove_chr(char *str,const char *tokens) {
    char *src = str , *dst = str;
    /* validate input */
    if (!(str && tokens))
        return NULL;
    while(*src)
        if(string_search_chr(tokens,*src))
            src++;
        else
            *dst++ = *src++;  /* assign first, then incement */
    *dst='\0';
    return str;
}

Here is the QB64 program that tests the above:
Code: (Select All)
DECLARE LIBRARY "./removeStr"
    FUNCTION __REMOVESPACES$ ALIAS string_remove_chr(qString$, charValue$)
END DECLARE

QBMain:
    PRINT "QB64: Test #1 - Remove SPACES from 'New York Yankees"
    qString$ = "New York Yankees"
    retValue$ = __REMOVESPACES$(qString$+CHR$(0), " ")
    PRINT "QB64: qString$ = "; qString$
    PRINT "QB64: retValue$ = "; retValue$
    PRINT
    PRINT "QB64: Used in a PRINT stmt, function returns: "; __REMOVESPACES$(qString$+CHR$(0), " ")  
    PRINT

    PRINT "QB64: Test #2 -Remove SPACES and PERIODS from 'New York Yankees."
    qString$ = "New York Yankees"
    retValue$ = __REMOVESPACES$(qString$+CHR$(0), " .")
    PRINT "QB64: qString$ = "; qString$
    PRINT "QB64: retValue$ = "; retValue$
    PRINT
    PRINT "QB64: Used in a PRINT stmt, function returns: "; __REMOVESPACES$(qString$+CHR$(0), " ")  
    PRINT

    SYSTEM 0

This is the output from running the above code:
Quote:QB64: Test #1 - Remove SPACES from 'New York Yankees
QB64: qString$ = New York Yankees
QB64: retValue$ = NewYorkYankees

QB64: Used in a PRINT stmt, function returns: NewYorkYankees

QB64: Test #2 -Remove SPACES and PERIODS from 'New York Yankees.
QB64: qString$ = New York Yankees
QB64: retValue$ = NewYorkYankees

QB64: Used in a PRINT stmt, function returns: NewYorkYankees



------------------
(program exited with code: 0)
Press return to continue

Print this item

  Two-dimensional array
Posted by: Kernelpanic - 12-28-2022, 09:55 PM - Forum: Wiki Discussion - Replies (16)

Is there an interest for the wiki in a program for filling a two-dimensional array? As an an example.

Print this item

  so, there's no more manual built in?
Posted by: MrCreemy - 12-28-2022, 06:01 PM - Forum: General Discussion - Replies (8)

I am assuming, there's no more of that "auto manual" popping up in the IDE?

(I liked that)

looking like workaround, is....
download giant PDF file
do command checks by hand, like old days with manual?

or... is there a workaround to "hook things back up"

Print this item

  Miscellaneous handy goodies
Posted by: grymmjack - 12-28-2022, 01:44 AM - Forum: One Hit Wonders - Replies (9)

Well, damn.

I had a very nicely formatted post all queued up and the browser crashed when I right clicked on a word to check its definition and spelling in this text area.

Anyway.

I will return to this to explain but mostly this is self-explanatory stuff.

Code: (Select All)
' For concatenating integers and stripping spaces
FUNCTION n$ (integ%)
    n$ = _TRIM$(STR$(integ%))
END FUNCTION

' For showing friendly versions of my boolean constants
FUNCTION b$ (integ%)
    IF integ% = -1 THEN
        b$ = "TRUE"
    ELSEIF integ% = 0 THEN
        b$ = "FALSE"
    ENDIF
END FUNCTION

' For concatenating longs and stripping spaces
FUNCTION ln$ (longval!)
    ln$ = _TRIM$(STR$(longval!))
END FUNCTION


' For incrementing integers - x=inc(1) takes up 3 more chars than x=x+1 but inc is a bit easier for me to read.
FUNCTION inc% (value%)
    inc% = value% + 1
END FUNCTION

' Same as above but decrement
FUNCTION dec% (value%)
    dec% = value% - 1
END FUNCTION

' Inverting int
FUNCTION inv% (value%)
    inv% = value% * -1
END FUNCTION

' Force int to be not less than min
FUNCTION min% (value%, minimum%)
    IF value% < minimum% THEN value% = minimum%
    min% = value%
END FUNCTION

' Force int to be not more than max
FUNCTION max% (value%, maximum%)
    IF value% > maximum% THEN value% = maximum%
    max% = value%
END FUNCTION

' Force int to be between a min and a max, when greater - clamp it between min and max
FUNCTION clamp% (value%, minimum%, maximum%)
    IF value% > maximum% THEN
        clamp% = maximum%
    ELSEIF value% < minimum% THEN
        clamp% = minimum%
    ELSE
        clamp% = value%
    END IF
END FUNCTION

' Determine if a int is in range of a min and a max
FUNCTION in_range% (value%, minimum%, maximum%)
    IF value% >= minimum% AND value% <= maximum% THEN
        in_range% = TRUE
    ELSE
        in_range% = FALSE
    END IF
END FUNCTION

' Randomize the sign of an int
FUNCTION rand_sign% ()
    DIM r AS INTEGER
    r% = -1 + INT(RND*2)
    IF r% = 0 THEN r% = 1
    rand_sign% = r%
END FUNCTION

' Create a random integer between min and max
FUNCTION rand_in_range% (minimum%, maximum%)
    rand_in_range% = INT(RND * (maximum% - minimum% + 1)) + 1
END FUNCTION

' Randomly choose an int from an array of ints
FUNCTION rand_int_choice% (arr_choices%())
    DIM AS INTEGER minimum, maximum
    minimum% = LBOUND(arr_choices%) : maximum% = UBOUND(arr_choices%)
    rand_int_choice% = arr_choices%(rand_in_range(minimum%, maximum%))
END FUNCTION

' Randomly choose a string from an array of strings
FUNCTION rand_str_choice$ (arr_choices$())
    DIM AS INTEGER minimum, maximum
    minimum% = LBOUND(arr_choices$) : maximum% = UBOUND(arr_choices$)
    rand_str_choice$ = arr_choices$(rand_in_range(minimum%, maximum%))
END FUNCTION

Print this item

  MergeFile
Posted by: SMcNeill - 12-27-2022, 05:26 PM - Forum: Works in Progress - Replies (8)

Code: (Select All)
$If WIN Then
    Const Slash$ = "\"
$Else
        const Slash$ = "/"
$End If

target$ = ".\source\qb64pe.bas"
outfile$ = ".\qb64onefile.bas"

If target$ = "" Then
    Print "Give me a QB64 program to unravel => ";
    Input target$
    Print "Give me a name to save the new file under => ";
    Input outfile$
End If

Open outfile$ For Output As #1
MergeFile target$

Sub MergeFile (whatfile$)
    f = FreeFile
    CurrentDir$ = _CWD$
    i = _InStrRev(whatfile$, Slash$)
    newdir$ = Left$(whatfile$, i)
    If i > 0 Then
        ChDir newdir$
        whatfile$ = Mid$(whatfile$, i + 1)
    End If
    Open whatfile$ For Binary As #f
    Do
        Line Input #f, temp$
        If Left$(UCase$(_Trim$(temp$)), 11) = "'$INCLUDE:'" Then
            temp$ = _Trim$(temp$)
            file$ = Mid$(temp$, 12)
            file$ = Left$(file$, Len(file$) - 1)
            MergeFile file$
        Else
            Print #1, temp$
        End If
    Loop Until EOF(f)
    ChDir CurrentDir$
    Close #f
End Sub


@grymmjack Was asking for a quick little program to merge $INCLUDE files into a single BAS file, so I sat down and wrote this one up in about 15 minutes.  I haven't tested it extensively as I'm kinda distracted with my niece's kids visiting today, but it appeared to work without any issues with QB64PE.BAS and merged it all into one file easily enough.

Give it a try if you're interested in this type of thing, and if you manage to break it, post me a note on how you did so an I'll update it with a fix as soon as I get a little free time later.  Wink

Print this item