Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

The 20 Line Challenge / Itty Bitty Random Sound Picker

Author
Message
Old Dreamer
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location:
Posted: 15th Dec 2005 23:06
Hope I can post this here even though it's but slightly altered from the earlier version I posted in the Newcomer's forum. I use DBPro, but I think it will work in Dark Basic, since it's so... uh... basic.

It has to be placed in a "C:\wavs" folder/directory to work, or you can take the code and change it to work wherever you have a bunch of .wav files posted.

I know, it's not much, I just wanted to encourage other people, with better programming skills, to try things besides games.

http://home.att.net/~david.bump
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th Dec 2005 14:09
Sorry but the source code isn't there.

All new people on this forum aren't able to post source code.

Put the code between [[/b]code[b]] and [[/b]/code[b]] to get something like this:



Immunity and Annihalation makes Immunihalation...
Old Dreamer
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location:
Posted: 17th Dec 2005 02:18
Thanks, right... use the button and all that. I'm learning. Or... "All new people on this forum aren't able to post source code."? So the following won't even show up?


http://home.att.net/~david.bump
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Dec 2005 04:59
What you have done is not wrong, but as you stated you were learning, a couple of things are worth mentioning which although are very minor, are worth bearing in mind when your programs start getting a bit bigger:

There's a command called Perform Checklist For Files which makes the Find First/Find Next process easier. It puts everything it finds into a list (array), has an associated function called Checklist Quantity() which tells you how many items it found, and others which tell you if the items are files or directories.

Quote: "
totalfiles=totalfiles + 1
if right$(get file name$(),3) = "wav" OR right$(get file name$(),3) = "WAV"
"


You can save your fingers a little typing with these by using

Inc totalfiles
if Upper$(right$(get file name$(),3)) = "WAV"

Finally, (ignoring the ';' typo which DB oddly lets pass) there's no need to have

play$="" : files=0 : totalfiles=0 : wavcount = 0

at the end of the program as they aren't variables that use memory which has to be freed up when you've finished with them.

TDK_Man

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Dec 2005 14:51
Quote: "Thanks, right... use the button and all that. I'm learning. Or... "All new people on this forum aren't able to post source code."? So the following won't even show up?
"

Haha, no no. I meant that you won't be able to post source in the source button (source window). Code snippets are displayed.
Old Dreamer
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location:
Posted: 17th Dec 2005 23:05
Ah yes, my small programming experience is also showing its age. Nearly everything about Dark Basic seems like a luxury compared to the ancient forms I trained myself on -- TI99/4a, Q Basic, a bit of TRS-80...

It will be SO nice to start taking advantage of the new features. Thanks for pointing some out.

Oh, as for the cleanup section, that's mostly because I had a debugging loop running at one point which ran several sounds in a row, and I had to reset a couple things. I may have gotten carried away even at that, but I figured "better safe than sorry" as I whipped this little bit together. Then, I didn't see any reason to take it out. As you say, though, on bigger programs, you don't want to have any extra deadwood that might slow execution, etc.

Thanks again for the tips!

http://home.att.net/~david.bump

Login to post a reply

Server time is: 2024-04-18 18:27:11
Your offset time is: 2024-04-18 18:27:11