Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Non-Specified Directory
#1
I've been trying to work up programs with less hardcoding.

When running in QM to debug before making the whole thing an executable, where files go when there is not a specified path?

I noticed when I use a code like this:
Code:
Copy      Help
str s="Text"
s.setfile("Test.txt")
run ""

The file is in the last folder where I saved the most recent executable file.

I would probably prefer everything to go into a folder in the My QM directory while I am designing the program.

Is there anyway to set this up?

Thanks,
jimmy Vig
#2
Ok...so if I use "SetCurDir" I can get everything to save right where I want it.

So I would use this during the design phase of things and then disable it when I make the program an executable?
Is there a way to find out if QM is running the function and then have it use "SetCurDir"? That way I don't have to worry about remembering to disable things in the code at the end. Or re-working them back in if I have to work on the code.

Possibly if I could even have a folder be created in QM based on the functions name that's running it...

like:
if (QM Function is running not as an executable)
str CurrentDirectory="$my qm$"/(current function)"
SetCurDir CurrentDirectory

Thanks!
#3
maybe use GetCurDir function?

Macro
Code:
Copy      Help
str test = GetCurDir
if (test= "C:\Windows\SysWOW64")  ;;result of GetCurDir when ran through qm for me
,out "run through qm"
,str name.getmacro(getopt(itemid) 1)
,out name
,str directory = "$my qm$/"
,directory + name
,out directory
,iff- directory
,,out "doesnt exist"
,,mkdir directory
,else
,,out "already exists"
,;SetCurDir(directory)
else
,out "run through exe"
,mes test
,;set directory to whatever, maybe GetCurDir?

test = "testtt textt"
test.setfile("test.txt")
SetCurDir("C:\Windows\SysWOW64") ;;without resetting the curdir, it would only work the first time through
#4
I avoid using current directory. Always use full path, if possible. Relative path can be used, for example, with some console programs that don't support spaces in paths and quotes.

Macro Macro1274
Code:
Copy      Help
#if EXE
SetEnvVar "xxx" "$desktop$\f2"
#else
SetEnvVar "xxx" "$desktop$\f1"
#endif

str s="vvvvvvvvv"
s.setfile("%xxx%\file.txt")


Forum Jump:


Users browsing this thread: 1 Guest(s)