Special Filing Systems: DOS, DOSTXT, URL, URLB
CTO and AREV32 support several special filing systems that allow you to access non-traditional data as though it were normal OpenInsight data. The DOS and DOSTXT filing systems allow the user to read, write, and delete Windows files, while the URL and URLB filing systems allow the user to “read” and “write” to web addresses (URLs).
To access the DOS or DOSTXT filing systems, the user would use the table name “DOS” or “DOSTXT”, and the “record name” or “record id” should be the Windows file name (either relative to your OpenInsight directory, or with a fully qualified path). The user can then read this record, write to this record, or delete this record programmatically, or through the use of any commands that normally accept a tablename and record id (eg, COPY, ED/EDIT, etc.). Note that on the command line in CTO, the user should quote the file path to ensure proper parsing.
When using the DOSTXT filing system, any carriage return/line feed delimiters in the record are converted to field marks when the record is read; any field marks are converted to carriage return/line feed delimiters when the record is written. When using the DOS filing system, no conversions of the data are performed at all.
Reading from a record whose record name specifies a directory will return special information. The first field will be the word DIR; the second field will be a value-mark-delimited list of the files in that directory; the third field will be a value-mark-delimited list of the subdirectories of that directory.
Examples:
1. Read a record (without any conversions) into a variable:
OPEN “DOS” TO DOS.FL THEN READ BINARY.INFO FROM DOS.FL,”C:\SOMEIMG.JPG” ELSE BINARY.INFO = “”
2. Read a record (with text conversions) into a variable:
OPEN ‘DOSTXT’ TO TXT.FL THEN READ RECORD FROM TXT.FL,’C:\SOME.TXT’ ELSE RECORD = ‘’
3. Return and process some directory information:
OPEN ‘DOSTXT’ TO DOS.FL THEN READ DIR.INFO FROM DOS.FL, “C:\SOMEDIR\*.TXT” THEN NUM.FILES = COUNT(DIR.INFO<2>, @VM) + 1 FOR EACH.FILE = 1 TO NUM.FILES THIS.FILENAME = DIR.INFO<2,EACH.FILE> READ INFO FROM DOS.FL, THIS.FILENAME ELSE INFO = “”
To access the URL or URLB filing systems, the user would use the table name “URL” or “URLB”, and the “record name” or “record id” should be the full URL. The user can then either read this record (eg, use an HTTP GET to retrieve the URL information) or “write” to this record (eg, use an HTTP PUT to send information to this URL) programmatically, or through the use of any commands that normally accept a tablename and record id (eg, COPY, ED/EDIT, etc.). Note that on the command line in CTO, the user should quote the URL to ensure proper parsing.
When using the URL filing system, any carriage return, line feed, or carriage return/line feed delimiters in the record are converted to field marks when the record is retrieved; any field marks are converted to carriage return/line feed delimiters when the record is “written”. When using the URLB filing system, no conversions of the data are performed at all, making this the appropriate “table” to use when accessing binary data.
After “writing” a record, the user may wish to retrieve the response generated by the URL. This information is available in a common variable named URL_WRITE_RESPONSE@. To access this variable, please insert the URLBFS_COMMON insert record.
Examples:
1. Retrieve a web page:
OPEN “URL” TO URL.FL THEN READ PAGE FROM URL.FL, “https://www.revelation.com” ELSE PAGE = “”
2. Retrieve a binary result from a URL:
OPEN “URLB” TO URL.FL THEN READ IMG FROM URL.FL, “https://www.revelation.com/icon.jpg” ELSE IMG = “”
3. Send information to a URL:
$INSERT URLBFS_COMMON OPEN “URL” TO URL.FL THEN WRITE ORDERINFO TO URL.FL, “https://www.somepage.com/REST/neworder” * Examine result of the call RESPONSE = URL_WRITE_RESPONSE@