All messages should be posted in plain text.  HTML will be converted to
attachments.    The meditech-l web site is MTUsers.com
======================================

The modified macro is now crash resistant, but the caveat is it only
reads the first 255 characters of the line.

;This macro obtains the text file via @File.open.dialog, then places the
contents, line by
;line into /TEXT[LINE].
;Macro supplied by Brian Schmidt, Picis.
@DELETE.TEXT.ARRAY,
[EMAIL PROTECTED]("C:\","*","")^FILE_.=.;
   @Memory.allocate(1)^MEM,
   @Memory.clear(MEM),
   @Memory.beginning(MEM),
   @Memory.load.file(MEM,FILE),
   [EMAIL PROTECTED](MEM) @Memory.read.line(MEM,255)^TEXT,
                        IF{TEXT;" "}:0X^/TEXT[-/TEXT[""]+1]},
   @Memory.free(MEM)},
@CLEAN.UP

DELETE.TEXT.ARRAY
""^X,
DO{>/TEXT[X]^X ""^/TEXT[X]}

CLEAN.UP
""^FILE^MEM^TEXT

 
Thank you,
Mitch Lawrence
Senior Applications Analyst - Advanced Report Writer
General Financials Support
CHRISTUS Information Management
Tel 361.881.3408  Fax 361.888.6117
Mob 361.549.8456
[EMAIL PROTECTED]
 

If someone has "Made your day", send them a Spirit Buck! 

-----Original Message-----
From: Brian Schmit [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 05, 2006 9:35 AM
To: [EMAIL PROTECTED]
Cc: Lawrence, Mitchell; [email protected]; [EMAIL PROTECTED]
Subject: RE: [MEDITECH-L] RE: Can an NPR report read the contents of
anASCIItext file from disk? (Client Server 5.5)

Hi Leslie,

That is a great point.  I have not run into any files yet with lines
over 255 characters, so I do not have an answer for you in regards to
that.  If you do encounter that situation, I would love to hear the
results.  

I think you can use the NPR Macro @Memory.read.line in place of
@Memory.read.text.  It requires two arguments: the Memory Buffer Handle,
and the Maximum Length of characters to read.  In this case, you would
run it like this:

@Memory.read.line(MEM,255)^TEXT

@Memory.read.text removes the control characters, such as carraige
returns and line feeds, but I don't think @Memory.read.line does that,
so you would need to use the TEXT:0X syntax when assigning this variable
to the /TEXT array.

Thanks,

Brian Schmit
Sr. Programmer, Picis
Direct: 781 557 3315
Fax: 781 557 3140
100 Quannapowitt Parkway
Suite 405
Wakefield, MA 01880
[EMAIL PROTECTED]
www.picis.com

Please visit www.picis.com/meditech for additional information about our
NPR Report Writing Trainings.

The information in this email is confidential and may be legally
privileged. It is intended solely for the addressee. Access or use by
any other person to this internet email is not authorized and may be
unlawful. If you are not the intended recipient, please delete or
destroy this email. If you do not wish to receive future emails from the
sender, please reply directly to this email requesting you be removed
from any mailing list.


-----Original Message-----
From: Leslie Mann [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 05, 2006 9:50 AM
To: Brian Schmit
Cc: [EMAIL PROTECTED]; [email protected];
[EMAIL PROTECTED]
Subject: RE: [MEDITECH-L] RE: Can an NPR report read the contents of
anASCIItext file from disk? (Client Server 5.5)


Brian:

What happens if you have a line of text greater than 255 chars?  Haven't

tested but I suspect that you would crash your session.  I use a similar

  routine but I ensure that the input files always have line lengths 
less than 255.

Les

________________________________________________
Leslie Mann
Clinical Application Specialist
Timmins and District Hospital
Voice: 705-267-2131 x2147
Fax: 705-267-6321
[EMAIL PROTECTED]
_________________________________________________

> 
> Hi Mitch,
> 
> How about the following:
> 
> @DELETE.TEXT.ARRAY,
> [EMAIL PROTECTED]("C:\","*","")^FILE_.=.;
>    @Memory.allocate(1)^MEM,
>    @Memory.clear(MEM),
>    @Memory.beginning(MEM),
>    @Memory.load.file(MEM,FILE),
>    [EMAIL PROTECTED](MEM) @Memory.read.text(MEM)^TEXT,
>                         IF{TEXT;" "}^/TEXT[-/TEXT[""]+1]},
>    @Memory.free(MEM)},
> @CLEAN.UP
> 
> DELETE.TEXT.ARRAY
> ""^X,
> DO{>/TEXT[X]^X ""^/TEXT[X]}
> 
> CLEAN.UP
> ""^FILE^MEM^TEXT
> 
> The only modifications are in the DO loop.  I have added the use of
the NPR Macro called @Memory.more.  It should return a non-nil value if
there is anything more to read in the Memory buffer (even blank lines).
I have also added an IF statement so that a blank space is assigned to
the /TEXT array if there is no value in the local variable called TEXT.
> 
> I have not had a chance to try this out, but I think it should work
for you.  Please let me know if it doesn't.
> 
> Thanks,
> 
> Brian Schmit




_______________________________________________
meditech-l mailing list
[email protected]
http://mtusers.com/mailman/listinfo/meditech-l

Reply via email to