× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Ok, here's a boatload of code to sift through. ;) I hope I have
everything here that's required. I really appreciate people looking
into this. I don't mind the workaround I have, but I would like to know
what is wrong.

Thanks,

--- This is the code that opens the IFS file then reads it in. It calls
the $ReadIFSFile procedure which is defined below. Additional
prototypes and the contents of the IFS File are also listed after the
code. The %scan, in this code, would return a zero any time the x'25'
character was in the data being scanned.

D VAR_Phone C '[phone#]'
D Data S 1024a Inz
D FileDesc S 10i 0 Inz
D IFSFile S 512a Inz
D newData S 1024a Varying
D O_RDOnly S 10i 0 Inz( 1 )
D Start S 5u 0


// IFSFile field contains a filepath to the file to be
read.
// Open the default Email Body Template file.
FileDesc = $OpnIFSFile( IFSFile: O_RDOnly );

// Read the default Email Body Template file.
DoU NOT BytesRead;
Clear Data;
BytesRead = $ReadIFSFile( FileDesc: Data: %len( Data )
);

// Write the data read to the Temporary Email Message
file.
If BytesRead;

// Insert the contact phone number if the IFS body
has
// that variable in it. Leave the loop afterward.
start = %scan( VAR_Phone: Data );
If start > 0;
newData = %subst( Data: 1: (start - 1) ) +
RQ#CntctPhone
+ %subst( Data: (start + %len( VAR_Phone ))
);
Else;
newData = Data;
EndIf;

$WrtIFSFile( EmlMsgDesc: newData );
EndIf;
EndDo;
--- prototypes

// Open an IFS File ( IFSSProc )
D $OpnIFSFile PR 10i 0
D FileName 512a Const
D OpenAccess 10i 0 Const Options( *Omit:
*NoPass )

// Write to an IFS File ( IFSSProc )
// (Data is varying so extra spaces aren't written to the
file)
D $WrtIFSFile PR
D FileHandle 10i 0 Const
D Data 1024a Value Varying
D CarriageReturns...
D 3u 0 Const Options( *Omit:
*NoPass )
D ReturnCode 10i 0 Options( *Omit:
*NoPass )

--- Our wrapper around the IFS read. We have most of our IFS-related
code in a service program

P $ReadIFSFile B Export
D PI n
D FileHandle 10i 0 Const
D Data 1024a
D ReadLength 5i 0 Const Options( *Omit:
*NoPass )
D ReturnCode 10i 0 Options( *Omit:
*NoPass )

//---------------------------------------------------------------*

// Define Local Indicators
D DataRead S n Inz( *Off )

// Define Local Variables
D BytesRead S 10i 0 Inz
D ReadBytes S 10i 0 Inz( %len( Data ) )


//================================================================*
/Free

// If the Read Length parameter was passed, set the number of
// bytes to read.
If %addr( ReadLength ) <> *Null and %parms >= 3;
ReadBytes = ReadLength;
EndIf;

BytesRead = read( FileHandle: %addr( Data ): ReadBytes );

// If the Return Code is requested, set the value for the
Return Code.
If %addr( ReturnCode ) <> *Null and %parms = 4;
ReturnCode = BytesRead;
EndIf;

// Set the Return Indicator to indicate if data was read.
If BytesRead > *zero;
DataRead = *On;
Else;
DataRead = *Off;
EndIf;

Return DataRead;

/End-Free
P $ReadIFSFile E

//---------------------------------------------------------------*

---Contents of IFS File:
<-- new line
Please call [phone#] to contact us if you have any questions.
<-- new line
-- end of file.


Kurt Anderson
Application Developer
Highsmith Inc

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Monday, July 23, 2007 1:13 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: %scan and the new line character

Hi Kurt,

Once I moved the field that was based on the buffer into a
program-defined variable field, I can scan that new variable field
without the %scan ending at the first x'25' found.

The code you've described in this thread SHOULD work just fine. (I
frequently do stuff like this!) So I guess I don't understand why it's
failing, unless there's a bug in your code? Can you post the code that

fails?
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.