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.

Newcomers DBPro Corner / File search help

Author
Message
aarrowh
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 1st Feb 2009 00:13 Edited at: 1st Feb 2009 00:14
I've been attempting to get a simple file search working, but have been un-able to do so... it keeps saying that there are no other files in the current directory. Any help appreciated

Thanks in advance,

Aarrowh

*edit* whoops...forgot the code...




There it is...



Image thanks goes to AndrewT
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 1st Feb 2009 12:16

code not tested

this should work better i think


Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 1st Feb 2009 18:43 Edited at: 1st Feb 2009 18:44
Actually, you shouldn't call get file name$ before you have issued a find command.
(As shaunrw already implied with his snippet).

This should be a fairly safe method (yours would fail if the file was in fact not found in the specified directory):


"We know some things about poodles, for example that they are alive, they can bark, they eat meat..."
- Extract from Objects first with Java.
aarrowh
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 2nd Feb 2009 17:05
Thanks for the help, I'm trying to create some type of media player, so i'm trying to search and find music, I took the code you gave me and put it into a function, but it will not work anymore...anything I could have done wrong?






Image thanks goes to AndrewT
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 3rd Feb 2009 11:31
you need to declare some variables as global to use functions. Other wise they'll register as empty from inside the function.

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Feb 2009 16:30
Also, that code would fail since the get$ variable will end with "...\My musicSongname". You should put in a backslash after the path and before the file name, like so: get$ = path$ + "\" + c$.

"We know some things about poodles, for example that they are alive, they can bark, they eat meat..."
- Extract from Objects first with Java.
aarrowh
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 4th Feb 2009 00:49 Edited at: 4th Feb 2009 01:52
PRoF - I'll give that a try, thanks!

Rudolpho - I thought I had already added an extra to the end of the path...hmmm...hafta fix that...


*edit*

It worked, now I have a new problem. I'm trying to keep the screen uncluttered with things so I put together a simple IF statement to test a variable, and every time it went through the function, the variable had 1 added to it...but I'm getting an error, saying types "useage$" and "1" are incompatible....





Image thanks goes to AndrewT
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Feb 2009 11:05
If you put a '$' sign at the end of a variable, you declare it as a string. Try renaming it to simply useage and it should work
(What the error message is saying is that you can't add an variable of one type to that of another (here integer to string); you can, but you need to convert them first though).

"We know some things about poodles, for example that they are alive, they can bark, they eat meat..."
- Extract from Objects first with Java.

Login to post a reply

Server time is: 2024-09-28 02:28:10
Your offset time is: 2024-09-28 02:28:10