How to get Requestfile$() to Open in my Progs Dir

BlitzPlus Forums/BlitzPlus Beginners Area/How to get Requestfile$() to Open in my Progs Dir

aPoPhus(Posted 2011) [#1]
Hiya,

Can someone help me please ?

I need Requestfile$() to open in my programs folder (the folder that my executable is run from)

Can anybody help ?

All help is really appreciated,
Thankyou


Floyd(Posted 2011) [#2]
SystemProperty( "appdir" ) is the full path to the location of the .exe file.


aPoPhus(Posted 2011) [#3]
Sorry, thats not it.

Say for instance, that the user copies my executables folder (folder Name = My Clock) to say "E:" drive, that would look like "E:/My Clock".
So now the user wants to load a new alarm sound, i need the "Requestfile$()" to open up in "E:/My Clock" folder.

I hope you understand what i mean ??


xlsior(Posted 2011) [#4]
If your program got launched from "E:\My Clock", then thge appdir would return "e:\my clock" as well... did you actually try running it?


xlsior(Posted 2011) [#5]
does this work for you?

test$=RequestFile$( "Requester","txt,bin,dat",0,SystemProperty("AppDir"))


Last edited 2011


aPoPhus(Posted 2011) [#6]
When i try the above code, it does not even open up a requester
Below is what i used:

filename$=RequestFile$( "Choose alarm sound","wav,mp3",0,SystemProperty("AppDir"))

I dont know whats going on, sorry :(

Last edited 2011


xlsior(Posted 2011) [#7]
Do you have the latest version of Blitzplus?

IIRC the requestfile$ originally didn't support specifying a start folder, that was added in a later version.


Floyd(Posted 2011) [#8]
It seems that the defname$ parameter expects a filename, not just a path. Just using SystemProperty( "appdir" ) doesn't do anything.

Using SystemProperty( "appdir" + "hello.txt" ) will give the desired folder, and also display hello.txt as the default file selection.

Remember that "*" can be used to represent an arbitrary file name.
Trying SystemProperty( "appdir" + "*" ) we get almost the desired effect. The path is right, but * is actually displayed as a file name. It's a little annoying, but certainly tolerable for personal use.

I don't if any of this is expected behavior, but it's what I get with BlitzPlus 1.47 and Windows 7.


aPoPhus(Posted 2011) [#9]
@xlsor, I am running V1.47 on Windows 7 :)

@Floyd, i will try what you pointed out & see what happens.

Thankyou both of you for your time & wisdom.


aPoPhus(Posted 2011) [#10]
Using the code below, still opens the "Documents" folder

filename$=RequestFile$( "Choose alarm sound","wav,mp3",0,SystemProperty("AppDir"+"*"))

Im begining to think that the requestfile$ command is broken :(


Floyd(Posted 2011) [#11]
Sorry, that was careless of me. I typed it in manually rather than copying working code.

What I meant was to append "*.*" to the path returned by SystemProperty( "appdir" ). So it should have been

SystemProperty( "appdir" ) + "*.*"


aPoPhus(Posted 2011) [#12]
@Floyd, Strange, i have tried it again using the following amended code:

filename$=RequestFile$("Choose alarm sound","wav,mp3",0,SystemProperty("AppDir"+"*.*"))

And it still opens the Documents folder, instead of opening in its own folder :(

Maybe its not totaly compatable in windows 7 ??


Yasha(Posted 2011) [#13]
filename$=RequestFile$("Choose alarm sound","wav,mp3",0,SystemProperty("AppDir"+"*.*"))


Move the +"*.*" outside the call to SystemProperty. That's the change Floyd meant - the extra .* is incidental.

The difference? At the moment, you're requesting the system property "AppDir*.*", which obviously doesn't exist.

What you want is to retrieve the value of system property "AppDir", which may for example be "C:\MyApp\", and then append "*.*" to that, to give "C:\MyApp\*.*".


i.e. At the moment, you're appending the stars to the argument to SystemProperty, when what you need to do is append them to its result.



Good: SystemProperty("AppDir") + "*.*"

Bad: SystemProperty("AppDir" + "*.*")

Note the difference!

Last edited 2011


aPoPhus(Posted 2011) [#14]
@Yasha, Thankyou that worked perfectly :)

I dont suppose you could tell me how i can check for more than one occurance of my executable, just so i can makesure that it wont open duplicates if double clicked ?
Thankyou.


xlsior(Posted 2011) [#15]
There's a couple of ways of doing it -- the best way would be to use the windows API calls to view the process list of running processes, and look if there is another one with the same name as your program already running.

I'd expect that there is probably some code in the code archives for that already.


aPoPhus(Posted 2011) [#16]
Ok, thankyou for your help :)