Qbasicnews.com
Dir$ and more GFX - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+--- Thread: Dir$ and more GFX (/thread-6149.html)

Pages: 1 2


Dir$ and more GFX - GordonSweet - 02-20-2005

Can anyone please explain how to get a list of all files. Using Print Dir$(“*.exe”) displays only one .EXE file, while Print Dir$(“*.*”) shows none.

Also what are we to do with all the files in lib/win32? If these need converting to DLL perhaps that explains why I cannot get any of the files in the example/gfx to run after compiling.

Thanks Gordon


Dir$ and more GFX - GordonSweet - 02-20-2005

Just in case everyone is not aware of the fact, fmodtest.bas also plays .MID files - at least the version of FMOD.DLL I dwnloaded does! Gordon


Dir$ and more GFX - Z!re - 02-20-2005

*.a is a special format for FBC, sort of the *.QLB for quickbasic.

It's not used in the EXE version, it's only used when you compile.


After you've compiled it, you need the real DLL, which can be found on the apropriate library site.

For example, SDL -> www.libsdl.org


For more info read this FAQ: http://fbtk.qbtk.com/phpBB2/qa.php

You might find http://fbtk.qbtk.com/phpBB2/qa.php#8 to be interessting.


Happy coding


Dir$ and more GFX - Sterling Christensen - 02-20-2005

How to use DIR$:
Code:
PRINT "Here's the first EXE file: " + DIR$("*.exe")
PRINT "and here's the second: " + DIR$("")
PRINT "the third: " + DIR$("")
PRINT
PRINT "Here's the first TXT file: " + DIR$("*.txt")
PRINT "the second TXT file: " + DIR$("")

So basically, you pass a string to start and then "" to continue.


Dir$ and more GFX - Z!re - 02-20-2005

To get all files in a directory:
Code:
t$ = DIR$("*.EXE")
Do while t$ <> ""
       Print t$
       t$ = DIR$("")
Loop



Dir$ and more GFX - GordonSweet - 02-20-2005

Thanks Zire for the Dir$ help. but I think the following is simpler to select a file for FMODTEST.BAS

Gordon

Code:
shell "DIR *.mod /w /o:n"  
shell "DIR *.mid /w /o:n"  
print : print tab(20);"********** Enter any MOD or MID filename **********"
input  File$
screen 12

DefSng A-Z
'$Include: 'fmod.bi'

Declare Sub ErrorQuit (Message$)

Const FALSE = 0
Const MusicFile = ""
    Dim Shared Handle As Long

    If FSOUND_GetVersion <= FMOD_VERSION Then
          ErrorQuit "FMOD version " + STR$(FMOD_VERSION) + " or greater required"
    End If

    If FSOUND_Init(44100, 32, 0) = FALSE Then
          ErrorQuit "Can't initialize FMOD"
    End If

    Handle = FMUSIC_LoadSong(File$)
    If Handle = FALSE Then
          ErrorQuit "Can't load music file " + CHR$(34) + MusicFile + CHR$(34)
    End if

    FMUSIC_PlaySong(Handle)

    Print "FMOD test for freeBASIC"
                  Print "Press any key to quit." : SLEEP 2000



Dir$ and more GFX - Nexinarus - 02-20-2005

dir$ information at http://www.hybd.net/~mms/fb/help/current/command%20reference.html#dir$


Dir$ and more GFX - GordonSweet - 02-21-2005

Thanks for all you help.

For all those trying to get FB to generate SOUND, here is a method you can use if you have QuickBasic. Hope it has not bee mentioned before recently. Compile the QB program into a PULSE.EXE and copy into the the same Directory as FB. Then compile the FB progam and run. The TIMER delay in the QB program is to prevent Windows closing the program before a SOUND is produced. So if you get no sound because you have a super fast CPU, try increasing the .2 (reads point 2)

Gordon

Code:
REM QuickBasic Tones
P = VAL(COMMAND$)
SOUND P, 1
tim = TIMER
WHILE TIMER < tim + .2
WEND
SYSTEM


REM FB tone test
FOR N = 100 TO 1000 STEP 200
OP$ = "PULSE.EXE "+STR$(N)
SHELL OP$
SLEEP 50
NEXT N
END



Dir$ and more GFX - steven_basic - 02-21-2005

This seems to work:

Code:
#include once "win\winbase.bi"
#inclib "kernel32"

Declare Function Sound Alias "Beep" (ByVal dwFreq As Integer, ByVal dwDuration As Integer) As Integer

sound 100, 200



Dir$ and more GFX - GordonSweet - 02-21-2005

Thanks Steven,

I rather guessed someone would have found a better way of achieving SOUND instead of my crude method of SHELL to another program.

I wonder if you are able to access the 128 instrument sounds in Windows WINMM.DLL similar to as shown to me on my site with Liberty Basic.

Gordon.