GLBasic forum

Main forum => Bug Reports => Topic started by: Hemlos on 2008-Oct-30

Title: SETCURRENTDIR()
Post by: Hemlos on 2008-Oct-30
In order for SETCURRENTDIR to work i have to add SLEEP 1
Is this normal?

SETCURRENTDIR("sounds"); SLEEP 1

Title: Re: SETCURRENTDIR()
Post by: Kitty Hello on 2008-Oct-30
uhm. No!?
Title: Re: SETCURRENTDIR()
Post by: Schranz0r on 2008-Oct-30
Code (glbasic) Select
dir$ = GETCURRENTDIR$()

SETCURRENTDIR("sounds")

dir2$ = GETCURRENTDIR$()



PRINT dir$, 10,10

PRINT dir2$, 10, 30

SHOWSCREEN
KEYWAIT
END


Works fine!

EDIT: Tested on V5 and V6 !
Title: Re: SETCURRENTDIR()
Post by: Hemlos on 2008-Oct-30
Something isnt working right...

Code (this reports: 1 0. and killfile fails) Select

ok=SETCURRENTDIR("sounds"); //SLEEP 100
ok2=DOESFILEEXIST("tabs.mid")
PRINT  ok+" "+ok2,10,10
KILLFILE "tabs.mid"
SHOWSCREEN
KEYWAIT




Code (this reports 1 1 and killfile succeeds) Select

ok=SETCURRENTDIR("sounds"); SLEEP 100
ok2=DOESFILEEXIST("tabs.mid")
PRINT  ok+" "+ok2,10,10
KILLFILE "tabs.mid"
SHOWSCREEN
KEYWAIT


Maybe DOESFILEEXIST is slow?
Title: Re: SETCURRENTDIR()
Post by: MrTAToad on 2008-Oct-30
That would mean SETCURRENTDIR and DOESFILEEXIST run cocurrently - which I dont think is correct.

What OS are you trying it on - it works fine here on Windows, Mac and Linux.
Title: Re: SETCURRENTDIR()
Post by: Hemlos on 2008-Oct-30








I have it posted in my forum signature footer:
Title: Re: SETCURRENTDIR()
Post by: Kitty Hello on 2008-Oct-30
how are you creating test.mid?
Did you use CLOSEFILE?
Title: Re: SETCURRENTDIR()
Post by: Hemlos on 2008-Oct-30
Quote from: Kitty Hello on 2008-Oct-30
Did you use CLOSEFILE?

Naturally,
Code (glbasic) Select

ok=SETCURRENTDIR("sounds"); //SLEEP 100
ok2=DOESFILEEXIST("tabs.mid")
PRINT  ok+" "+ok2,10,10
KILLFILE "tabs.mid"
SHOWSCREEN
KEYWAIT
SETCURRENTDIR(".."); // SLEEP 100

TABREADER()

SETCURRENTDIR("sounds"); // SLEEP 100

OPENFILE(1,"tabs.mid",FALSE)
WRITE_MIDI(0x01,0x02)
CLOSEFILE 1
SLEEP 100
MCI_PLAY("tabs.mid",FALSE)

SETCURRENTDIR(".."); //  SLEEP 100

I thought this was it too, but i double checked it, and yes, its closefiled

And if you want to see the tab reader...

Code (glbasic) Select

rv=0; SHELLCMD("notepad Tablet.txt",TRUE,TRUE,rv)
//read tablet:
DIMDATA TAB$[], " ", " "
DIMDATA tabinstrument[], -1
FOR i = 0 TO 1
GETFILE "Tablet.txt",i,a$
TAB$[i]=a$
NEXT

I have been messing with this code 100 different ways, i found only putting a sleep allows the DOESFLEEXIST work. I thought it was a problem with the setdirectory, but maybe its the doesfileexist.

[attachment deleted by admin]
Title: Re: SETCURRENTDIR()
Post by: Kitty Hello on 2008-Oct-30
Ah. Getfile/Putfile might be asychrone!
Title: Re: SETCURRENTDIR()
Post by: Hemlos on 2008-Oct-30
Darn, i was just using that for a workaround to a fast editor

Curious how is getfile affecting the doesfileexist tho?

i call getfile/putfile afterwards
Title: Re: SETCURRENTDIR()
Post by: Kitty Hello on 2008-Oct-30
flush the file with:
GETFILE "", x
Title: Re: SETCURRENTDIR()
Post by: Hemlos on 2008-Oct-31
Thanks, that did the trick, danke
That solved all issues.  :booze: