Hi Michael,

Something like this ?

Search where "<?xml " starts

Search where it ends (first >)

Get first tag after xml header

Find where this tag ends

Remove characters in the middle.

test
	set complex=1
	set crlf=$c(13,10)
	set file="text 1"
	set file=file_crlf_"text 2"
	set file=file_crlf_"<?xml version=""1.0"" encoding='UTF-8'?>"
	
	if complex {
		set file=file_crlf_"<Results xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
    	set file=file_crlf_"     xmlns='urn:tcleDoctorReport'"
		set file=file_crlf_"         xsi:schemaLocation='urn:tcleDoctorReport DoctorReport.xsd'>"
	} else {
		set file=file_crlf_"<Results>"
	}
	
	set file=file_crlf_"	<ReportPageFormat/>"
	set file=file_crlf_"	<Department>"
	set file=file_crlf_"		<Section>"
	set file=file_crlf_"			<TestSet>"
	set file=file_crlf_"				<TestSetDesc>Blood Culture (Aerobic+Anaerobic)</TestSetDesc>"
	set file=file_crlf_"			</TestSet>"
	set file=file_crlf_"			<TestSet>"
	set file=file_crlf_"				<TestSetDesc>Blood Culture Positive Result</TestSetDesc>"
	set file=file_crlf_"			</TestSet>"
	set file=file_crlf_"		</Section>"
	set file=file_crlf_"	</Department>"
	set file=file_crlf_"	<EpisodeData>"
	set file=file_crlf_"		<EpisodeNumber>240000100</EpisodeNumber>"
	set file=file_crlf_"		<FirstName>Lily</FirstName>"
	set file=file_crlf_"	</EpisodeData>"
	set file=file_crlf_"</Results>"
	set file=file_crlf_"text 3"
	set file=file_crlf_"text 4"
	
	set xmlheadstart=$f(file,"<?xml ")-6
	set xmlheadend=$f(file,">",xmlheadstart)-1
	
	;zzdump $e(file,xmlheadstart,xmlheadend)
	set firsttag=$tr($p($e(file,xmlheadend+1,*),">",1)_">",$c(13,10))
	;zzdump firsttag
	set tag=$p($e($p(firsttag," ",1),2,*),">",1)
	;write !,tag
	
	set xmlend=$f(file,"</"_tag_">")
	
	zzdump $e(file,1,xmlheadstart-1)_$e(file,xmlend,*)

What I get:

USER>d ^test2
 
0000: 74 65 78 74 20 31 0D 0A 74 65 78 74 20 32 0D 0A         text 1..text 2..
0010: 0D 0A 74 65 78 74 20 33 0D 0A 74 65 78 74 20 34         ..text 3..text 4
USER>

Regards

Manel

Hi Stuart

And using CONTINUE command ?

set list = "ABC~DEF~GHI~JKL~MNO~[~PQR~]"
set SegmentList = $LISTFROMSTRING(list,"~")
set SegmentCount = $LISTLENGTH(SegmentList)
set OptionalSegment="N"
FOR = 1:1:SegmentCount{
  if $LISTGET(SegmentList,i)= "[" set OptionalSegment = "Y" continue
  if $LISTGET(SegmentList,i)= "]" set OptionaSegment="N" continue
  write !, "Current Segment: "_$LISTGET(SegmentList,i)," ",OptionalSegment
  ;set SegmentFields = $LISTFROMSTRING(object.SegmentSubStructure,"~")
  ;set SegFieldCount = $LISTLENGTH(SegmentFields)
}

Another option is to use the open command where first argument is the OS command. Then you can get the answer from OS. For example:

 set old=$zu(68,40,1) ; Enable $zeof

 kill ^TMP($zn,$j)
 set cmd="find /logs/* -printf '%Td/%Tm/%TY %f\n'"

 open cmd:"Q"
 use cmd for x=1:1 read line quit:$zeof=-1 set ^TMP($zn,$j,"FILE",x)=line
 close cmd

 if $zu(68,40,old) // Restore previous mode

Regards

Manel

Hi John,

You understood me well.

But it's curious, after to run a Template, the list is never populated. I see always "Template 1", nevertheless , my "Add in" menu is populated...

I have searched the name using regedit

Add list is there:

Equipo\HKEY_CURRENT_USER\Software\InterSystems\Cache Studio\Recent Add Ins List

I can see also "Recent Template List n" from 0 to 6

Equipo\HKEY_CURRENT_USER\Software\InterSystems\Cache Studio\Recent Template List n

If you have something there, can you tell me the format, please ?

I will try to add it into my register

Thanks

Manel

Hi John,

My sample was using PCL but I don't know what printer are you using.

First thing should be to know what escape sequence do you need to send to the printer for to get bold.

Escape sequences are different if printer is HP, Epson, etc...

My suggestion is to check first doing an open printer, use printer, write escape sequence text, close printer if printer is doing bold.

After to get the correct escape sequence, you can write a mnemonic routine for to get bold in terminal, printer1, etc.. without change your code.

You will need different mnemonic routines for different printer types.

Hope this helps

Manel

Hi John,

I think you can do it using mnemonics:

write /SGR(1),"bold",/SGR(0)," normal"

Probably the printer will not understand this, but you can define another mnemonic for the printer, sending the correct escape sequence to it

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GIOD_intro#GIOD_intro_definemnemomic

and then use the |PRN| device with your mnemonic:

USE "|PRN|"::"^%PCL"

For example, if printer is PCL you should send:

%PCL
  quit
SGR(%1)
  if %1=1 write $c(27),"(s3" // Bold
  if %1=0 write $c(27),"(s0" // Normal
  quit

Hi,

You can do a routine for to do it, for example:

set rou=""
for {
  set rou=$o(^rMAC(rou)) quit:rou=""

  write !,rou
  set lines=^rMAC(rou,0,0)

  for x=lines:-1:2 {
    set ^rMAC(rou,0,x+1)=^rMAC(rou,0,x)
  }
  set ^rMAC(rou,0,2)=$c(9)_"#include %occInclude"
  set ^rMAC(rou,0,0)=lines+1
  set ^rMAC(rou,0)=$now()

  do COMPILE^%RCOMPIL(rou,"MAC",.success)
}

Regards

Manel