How to read Windows directory/file information such as disk free space and file size from Plain English.
Plain English can’t access the windows file system directly but a batch file can be used to write certain information from windows directories and files then the created file can be read and parsed by a Plain English program running in the CyberStation.
Here is an example:
-A batch file (DIskspace.bat ) is created on the disk.
-A Plain English program running in the CyberStation uses the Shell command to run the batch file.
-The batch file outputs disk information to DSKSPACE.TMP and DSKSPACE2.TMP
-PE program parses DSKSPACE2.TMP to obtain the amount of free space on the disk and puts it in an Analog Value object in CyberStation.
PE code is shown here for illustration purposes only, it is up to the programmer to implement an verify a solution appropriate for his/her use case.
The Plain English program uses the shell command to run the batch file.
Shell "cmd.exe /c DiskSpace.bat"
The Plain English program uses the OpenFile and ReadFile commands to get to the information
OpenFile("\winnt\System32\DSKSPACE2.TMP", ReadOnly, Dskspace)
Result = ReadFile(Dskspace, localSTR, 128, CharsRead, "|13")
If Result = Eof then Goto DoneReading
Then parses the information using the Search command
If search(localSTR, "bytes free") > 0 then
BytesFreePoint = StrToNum(left(localSTR, len(localSTR) - 10))