SETCURRENTDIR()

Previous topic - Next topic

Hemlos

In order for SETCURRENTDIR to work i have to add SLEEP 1
Is this normal?

SETCURRENTDIR("sounds"); SLEEP 1

Bing ChatGpt is pretty smart :O

Kitty Hello


Schranz0r

#2
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 !
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Hemlos

#3
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?
Bing ChatGpt is pretty smart :O

MrTAToad

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.

Hemlos









I have it posted in my forum signature footer:
Bing ChatGpt is pretty smart :O

Kitty Hello

how are you creating test.mid?
Did you use CLOSEFILE?

Hemlos

#7
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]
Bing ChatGpt is pretty smart :O

Kitty Hello

Ah. Getfile/Putfile might be asychrone!

Hemlos

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
Bing ChatGpt is pretty smart :O

Kitty Hello

flush the file with:
GETFILE "", x

Hemlos

Thanks, that did the trick, danke
That solved all issues.  :booze:
Bing ChatGpt is pretty smart :O