Question
· Apr 28, 2021

How to check the file existence or file size inside a method (BPL)

Hello all,

I'm a newcomer in ObjectScript and Ensemble and I would like to ask for any help. 

I have a method which is called inside a BPL in order to create or append some data in a file by an operation. This is the current code:

 

Method GetSMSText(nhc As %String, servicio As %String, hospital As %String, telefono As %String) As %Stream
{
quit ..SMSOperation_"##" _ hospital _"##" _ $ZDATE($H,4) _ "##" _ $piece($ZDATETIME($HOROLOG,3)," ",2) _ $char(13,10) _
telefono _ "##La interconsulta del paciente con numero de historia: " _nhc _" ha sido resuelta por el servicio: "_ servicio _"##" _ $char(13,10)
}
...

<code name='Call SMS MedicoPeti' xpos='740' ypos='1050' >
<![CDATA[ Set tRequest = ##class(Ens.StreamContainer).%New()
 Set tRequest.Stream = ##class(%Stream.GlobalCharacter).%New()
 Do tRequest.Stream.Write(process.GetSMSText(request.Paciente.nhc, request.Pedido.unidad.cod, request.Mensaje.centro, context.InterconsultaInfo.TelefonoMedicoPeti))
 Set tSC = process.SendRequestAsync(process.TargetConfigName,tRequest, 0)]]>
</code>

 

What I would need to do now is to change the method in a way that check first the file existence or file size:

 

Method GetSMSText(nhc As %String, servicio As %String, hospital As %String, telefono As %String) As %Stream
{
// check if the file exist or is not empty
if ("path/filename"  || filesize = 0){
quit ..SMSOperation_"##" _ hospital _"##" _ $ZDATE($H,4) _ "##" _ $piece($ZDATETIME($HOROLOG,3)," ",2) _ $char(13,10) _
telefono _ "##La interconsulta del paciente con numero de historia: " _nhc _" ha sido resuelta por el servicio: "_ servicio _"##" _ $char(13,10)
else {
quit ..SMSOperation_telefono _ "##La interconsulta del paciente con numero de historia: " _nhc _" ha sido resuelta por el servicio: "_ servicio _"##" _ $char(13,10)
} }

How could I put the condition in the if conditional please.

Thanks in advance for the help.

Bes regards,

Victor

Product version: Caché 2017.1
$ZV: Cache for Windows (x86-64) 2017.2.1 (Build 801_3U) Thu Apr 12 2018 10:02:23 EDT
Discussion (5)1
Log in or sign up to continue