midrange.com code scratchpad |
Name:
Readtest
|
Scriptlanguage:
Plain Text
|
Tabwidth:
4
|
Date:
03/10/2010 07:34:54 pm
|
IP:
Logged
|
|
Description:
Program to illustrate first "read" returning a blank.
|
Code:
- hoption(*nodebugio:*srcstmt) dftactgrp(*no)
- d Read pr 10i 0 extproc('read')
- d handle 10i 0 value
- d buffer * value
- d bytes 10U 0 value
-
- d Open pr 10i 0 extproc('open')
- d filename * value options(*string)
- d openflags 10i 0 value
- d mode 10u 0 value options(*nopass)
- d codepage 10u 0 value options(*nopass)
- d txtcreatid 10u 0 value options(*nopass)
-
- d Close pr 10i 0 extproc('close')
- d handle 10i 0 value
-
-
- d O_TEXTDATA c 16777216
- d ReadOnly c 1
-
- d fd_in s 10i 0
- d ifsFile s 256a
- d wChar s 1a
- d wBuffer s 20a
- d x s 5s 0
-
- c eval ifsFile='/joe/test.txt'
-
- * without dummy read......
- c eval fd_in = open(%trim(ifsFile):
- c ReadOnly+O_TEXTDATA)
-
- c***** callp Read(fd_in: %addr(wChar): 1)
- c dou Read(fd_in: %addr(wChar): 1) < 1
- c eval x=x+1
- c eval %subst(wBuffer:x:1)=wChar
- c enddo
-
- c dsply wBuffer
-
- c callp Close(fd_in)
-
- * with dummy read......
- c eval x=0
- c eval wBuffer=*blanks
- c eval fd_in = open(%trim(ifsFile):
- c ReadOnly+O_TEXTDATA)
-
- c callp Read(fd_in: %addr(wChar): 1)
- c dou Read(fd_in: %addr(wChar): 1) < 1
- c eval x=x+1
- c eval %subst(wBuffer:x:1)=wChar
- c enddo
-
- c dsply wBuffer
-
- c callp Close(fd_in)
-
- c seton lr
- c return
|
|
|