Welcome Guest | My Membership | Login

Tech Tip - Reading/Writing OS files

Article

Reading and writing OS files is very important in the new hybrid systems we have to write these days. Most of our applications are pretty self-contained,and don't need to interact with programs or applications outside the MV environment. But that is slowly changing.

We now have e-mail sending programs, printer overlay programs, SQL Command lines, and many, many other applications that use OS files. The need to read/write OS files continues to go up, and each programmer does it differently.

If you don't already do this on your own, we have compiled some SUBROUTINE (Stored Procedures) that will make it easier for you. If you already read and write OS files, then these subroutines will provide you with a comparison.

Since each MultiValue database implements writing to OS files differently, you have some options to choose from. It also makes it difficult to implement a common set of subroutines without creating limitations.

The major limitation of these subroutines is that they load the complete record into memory. This is not a problem with small OS files, but if you are working with large file (3MB, 4MB, or 10MB), it can become a problem. In these cases you will have to implement a means of reading and writing chunks from the file.

The general syntax for these subroutines is shown in figure 1. You'll notice in the example (fig. 2) that the directory is based on LINUX/UNIX file system structures. If you are writing windows files, you will need to us Windows file systems structures.

SUBROUTINE IS.READ.OS(DIRECTORY,DATA.ITEM,FILE.NAME,ERROR.ITEM)
DIRECTORY = the path/directory location in the OS file system to read the information from
DATA.ITEM = the information from the file with CR:LF/LF Replaced with AM
FILE.NAME = File name, without the DIRECTORY information.
ERROR.ITEM = Information about errors when reading the file
    <1> = 0 - Successful
    <1> = 1 - Item Not Found
    <1> = 2 - Access Denied
    <1> = 99 - Unknown Error


SUBROUTINE IS.WRITE.OS(DIRECTORY,DATA.ITEM,FILE.NAME,ERROR.ITEM)
DIRECTORY = the path/directory location in the OS file system to Wite the information to.
DATA.ITEM = the information for the file with AM.  AM will be replaced with CR:LF/LF
FILE.NAME = File name, without the DIRECTORY information.
ERROR.ITEM = Information about errors when reading the file
    <1> = 0 - Successful
    <1> = 1 - Item Not Found
    <1> = 2 - Access Denied
    <1> = 99 - Unknown Error

Fig. 1

* Example
FILE.NAME = "temp.txt"
CALL IS.READ.OS("/temp",TEMP.ITEM,FILE.NAME,ERROR.ITEM)
IF ERROR.ITEM<1> > 0 THEN CRT "Error Reading ": FILE.NAME
*
CRT TEMP.ITEM
END
Fig. 2

To access the code, go to the following link:

http://www.intl-spectrum.com/s/19xS1 IS

Do you have a Tech Tip to share? E-mail it to editor@intl-spectrum.com

 

# # #          # # #          # # #

 

Related Articles

  • Convert C#/VB.NET Date/Time to Internal Date

    This Article will show you how to convert a C# or VB.NET Date/Time object into an Internal MultiValue Date. It will show you how to do it using the ICONV functions, and well as how to generate an Internal Date without using the ICONV function.

  • Convert Internal Date into C#/VB.NET Date/Time

    This article will show how to convert a MultiValue (PICK) Internal Date into a DateTime object that you can use in C# and VB.NET. The article will cover how use the OCONV statement, as well as, how to generate the DateTime object without using the OCONV statement.

  • Numeric to Alpha Translation

    Database: D3, Advanced Pick, AREV, jBase, Mentor/PRO, mv*Base, mvEnterpise, OpenInsight, OpenQM, Reality, Ultimate, UniVerse, UniData, UniVision

    The attached subroutine will convert a numeric values to their alphabetic values. The number "4" converts to "four"; "25" converts to twenty five, etc. There is also an option that will allow you to change a numeric value into an alphabetic count. For example, 4 converts to "forth", "25" converts to twenty-fifth.


Return to top