|
Post by johnno56 on Jul 11, 2022 13:47:19 GMT -6
Hey N00b,
There may be occasions that a program needs to access (read/write) to/from files on the system. I am going to assume two things: 1. RC does not use a "shell" command (none listed in documentation) and 2. The "Directory" commands would be the way to go... Would you please be so kind as to provide examples of how these commands can access system files? Thank you.
J
|
|
|
Post by n00b on Jul 11, 2022 19:19:42 GMT -6
I made a video response here: youtu.be/-VVjAQ_10DkAlso, here is examples of all the code from the video: '-----GET AND SET CURRENT WORKING DIRECTORY
'Dir will return the current working directory Print "Original Location: "; Dir$
'ChangeDir will change the current working directory ChangeDir("temp_1")
'Dir should now be set to temp_1 location Print "\n"; "New Location: "; Dir$
'--------------------------------------------
'-----CHECK IF DIRECTORY EXISTS
'If temp_1 folder exists then this will output "temp_1 folder was found" If DirExists("temp_1") Then Print "temp_1 folder was found" End If
'-------------------------------------------
'-----MAKE AND DELETE DIRECTORY
'This will make a folder called temp_3 MakeDir("temp_3")
'This will delete temp_3 RemoveDir("temp_3")
'----------------------------------------------
'-----LIST FILES IN CURRENT DIRECTORY
'Get the first file in the current directory file$ = DirFirst$
'Print all the files in the current directory While file$ <> "" Print file$ file$ = DirNext$
Wend
'-----------------------------------------
'-----READ A TEXT FILE
f = FreeFile
FileOpen(f, "hello2.txt", TEXT_INPUT)
While Not EOF(f) Print ReadLine$(f)
Wend
FileClose(f)
'-------------------------------------------
'-----WRITE A TEXT FILE
FileOpen(f, "hello2.txt", TEXT_OUTPUT)
WriteLine(f, "this is a test")
WriteLine(f, "hello world")
FileClose(f)
'------------------------------------------------
'-----COPY A FILE
CopyFile("hello2.txt", "hello3.txt")
'------------------------------------------------
'-----DELETE A FILE
RemoveFile("hello2.txt")
'------------------------------------------------
'-----CHECK IF A FILE EXISTS
If FileExists("hello.txt") Then Print "hello.txt was found" End IF
'------------------------------------------------
'-----MOVE A FILE
MoveFile("hello3.txt", "hello4.txt")
'-----------------------------------------------
'---- RENAME A FILE
RenameFile("hello4.txt", "hello5.txt")
'-----------------------------------------------
|
|
|
Post by johnno56 on Jul 11, 2022 19:46:58 GMT -6
Thank you sir. As they say here in Australia, "Your blood's worth bottling..." (your homework is to look up the meaning... lol)
|
|