Robert Cemper · Jul 31, 2019 go to post

c'mon - it even works with text files:

USER>s file="fizzbuzz.txt"
 
USER>o file:"WNS":0 W $t
1
USER>u file f i=1:1:100 w:i#3=0 "Fizz" w:i#5=0 "Buzz" w:'$x i w !
 
USER>c file
 
USER>$type fizzbuzz.txt
 
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
Robert Cemper · Jul 31, 2019 go to post

it doesn't show numbers at end  
if you run it as single line command in a standard Caché terminal supporting $X,$Y.

newline sets $x=0, $i($Y)

USER>f i=1:1:100 w:i#3=0 "Fizz" w:i#5=0 "Buzz" w:'$x i w !
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Robert Cemper · Jul 21, 2019 go to post

I stated:

name your config SMP<port>  that is SMP57772 or just 57772

then the config name reflects the SMP port

Robert Cemper · Jul 20, 2019 go to post

on WIN  the config name is burned  into the registry 

Computer\HKEY_CURRENT_USER\Software\InterSystems\Cache\Configurations\......

UNIX/Linux has some structure simulating Win_Registry.  Support experts will know the details. 

Robert Cemper · Jul 20, 2019 go to post

Hi Evegeny,

I found nothing sophisticated but very straight.

just from any namespace or routine / method.

USER>w ^%SYS("SSPort")  ;;SuperServer
1972
USER>w ^%SYS("WebServer","Port")  ;; WebServer
57772
USER>
Robert Cemper · Jul 19, 2019 go to post

ENSEMBLE may have some signal mechanic.

BUT at Caché level you still have Special Variable $HALT as the last chance handler.
all details https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_vhalt

Most important: 

If you have $HALT set and also have code defined for ^%ZSTOP when a HALT is issued, the $HALT is executed first. $HALT can prevent the termination of the process, if its halt trap routine does not contain a HALT command.   !!!!

Robert Cemper · Jul 19, 2019 go to post

if you test your example from terminal prompt it needs some important change:

open file:("WNS"):3
if ('$test{  write !,"Failed to open "_file  quit  }
use file do ALL^%SS      ;; must be the same line
close file
quit

Robert Cemper · Jul 18, 2019 go to post

the popular use of is INTERACTIVE.

But there is a BATCH option:   

SAMPLES>zn "%SYS"
 
%SYS>d BATCH^GBLOCKCOPY
 
1) Manage Batches
2) Run a Batch
3) Restart a Batch
4) Add Processes to a running Batch
5) Stop a Running batch
6) Monitor Running Batch
7) Batch Report
8) Exit
 
Option? 1
 
1) Create a Batch
2) Edit a Batch
3) List Batches
4) Delete a Batch
5) Exit
 
Option?

I never used it myself.

it seems to me you should find it in  ^%SYS("GBLOCKCOPY")

But the source code is open in %SYS and easy to read:

BATCH
 !
 !,"1) Manage Batches"
 !,"2) Run a Batch"
 !,"3) Restart a Batch"
 !,"4) Add Processes to a running Batch"
 !,"5) Stop a Running batch"
 !,"6) Monitor Running Batch"
 !,"7) Batch Report"
 !,"8) Exit"
 !
 Option=$$OPTION("Option? ",8,8)
 Option=1 BATCHMANAGE BATCH
 Option=2 BATCHRUN BATCH
 Option=3 BATCHRESTART BATCH
 Option=4 BATCHADDPROCESSES BATCH
 Option=5 BATCHSTOP BATCH
 Option=6 BATCHMONITOR BATCH
 Option=7 BATCHREPORT BATCH
 q
BATCHMANAGE
 !
 !,"1) Create a Batch"
 !,"2) Edit a Batch"
 !,"3) List Batches"
 !,"4) Delete a Batch"
 !,"5) Exit"
 !
 Option=$$OPTION("Option? ",5,5)
 Option=1 BATCHCREATE BATCHMANAGE
 Option=2 BATCHEDIT BATCHMANAGE
 Option=3 BATCHLIST BATCHMANAGE
 Option=4 BATCHDELETE BATCHMANAGE
 q
BATCHCREATE $zt="BATCHE"
 Name=$$GETNAME("Batch name to create? ",0,0) q:POP
 f  !!,"Adding to batch: "_Name BATCHSETUP q:POP
 BATCHCREATE
BATCHEDIT   $zt="BATCHE"
 Name=$$GETNAME("Batch name to edit? ",1,0) q:POP
 Status=$$GETSTATUS(Name,1)
 $p(Status,"~",4)'="Queue" !,"Batch "_Name_" has been run, please re-enter" BATCHEDIT
 $$YN("Do you want to add to the batch","Y")="Y" f  !!,"Adding to batch: "_Name BATCHSETUP q:POP
 $$YN("Do you want to delete entries from batch "_Name,"N")="N" BATCHEDIT
BATCHEDIT1
 SUMMARYREPORT(Name,0)
 Option=$$OPTION("Delete which entry? ",0,+$o(^|"^^"_$zu(12)|%SYS("GBLOCKCOPY",Name,""),-1))
 Option=0 BATCHEDIT
. . . . . . . .

HTH,

Robert Cemper · Jul 18, 2019 go to post

Sorry, this is a description of how to run a program of WINDOWS or LINUX from Caché.

What you address here ar Caché Routines or ClassMethods. 

Robert Cemper · Jul 17, 2019 go to post

to count the number of changes you may use this approach

 Set ^Data("Cambridge") = "1" if  $increment(change("Cambridge"))
 Set ^Data("New York") = "2" if  $increment(change("New York"))
 Set ^Data("Boston") = "3" if  $increment(change("Boston"))
 Set ^Data("London") = "4" if  $increment(change("London"))
 Set ^Data("Athens") = "5" if  $increment(change("Athens"))
 Set ^Data("Athens") = "6" if  $increment(change("Athens"))
 Set ^Data("Athens") = "7" if  $increment(change("Athens"))

zw change

change("Athens")=3
change("Boston")=1
change("Cambridge")=1 
change("London")=1 
change("New York")=1
Robert Cemper · Jul 13, 2019 go to post

"using object methods while running the report"

This is a rather generic statement.
If you are using CLASS METHODS (as I 'd assume) you can project each class method as Stored SQL Procedure too.

By this,  you can make them available to be used over JDBC.

Could be an eventual workaround.

Robert Cemper · Jul 12, 2019 go to post

This is a rather common misunderstanding.
The naming GLOBAL was created in the 60ties.
Long before any other programming language even had anything named Global or similar.

GLOBAL in Caché is a persistent storage component that builds the backbone of (SQL) Tables and Persistent Objects.

see this documentation: Using Caché Globals

Robert Cemper · Jul 11, 2019 go to post

OK !
They look rather similar.

BUT:

  • Process Private Globals are "unlimited". 
    Clear there is a physical limit, but it's far away compared to local variables.
  • PPGs are best suited as Storage location + Index location of temporary tables.
    Without limit as any ordinary Global. 

So it depends on your needs.

Robert Cemper · Jul 10, 2019 go to post

the data property is a standard HTML page.
I'm not aware of some function in Caché that converts HTML to JSON.

But asking Google "convert HTML to JSON"  shows that this a standard feature in JavaScript. 
so I see 2 options:

- write your own parser (or someone in the community has done this before ???

- call an external tool (eg. node.js) to it for you

see:   https://stackoverflow.com/questions/34504050/how-to-convert-selected-html-to-json

or  https://stackoverflow.com/questions/12980648/map-html-to-json

or https://stackoverflow.com/questions/43469412/convert-html-source-code-to-json-object

Robert Cemper · Jul 10, 2019 go to post

it's not related to ENS . the error is pure HTTP

<Ens>ErrHTTPStatus: Received non-OK status 404 from remote HTTP server: 'HTTP/1.1 404 Not Found':<html>

simply tells you that your URL is wrong.

try it in browser to verify it exists

Robert Cemper · Jul 8, 2019 go to post

as a quick approach:

  set instring="........whatever you  need .........."
  set len=75
  for part=0:1 {
    set segment=$extract(instring,part*len+1,part+1*len)
    do OBX(segment)
  if $length(instring)<(part+1*len+1)  quit      ; nothing left
  }

;;; have no details how OBX looks like but this are the pieces
Robert Cemper · Jun 29, 2019 go to post

I prefer this solution as it is in full accordance with the documentation and
with no need also for beginners to fiddle into internals .
https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_flist

  • $LIST(list,position,end) returns a “sublist” (an encoded list string) containing the elements of the list from the specified start position through the specified end position (inclusive). If position and end specify the same element, $LIST returns this element as an encoded list.

</snip> 

Robert Cemper · Jun 28, 2019 go to post

(XMLPROJECTION="wrapped");

should separate your items.

from docs:  https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GXMLPROJ_basics#GXMLPROJ_basics_collections

Effect of XMLPROJECTION on Collection Properties

Value of XMLPROJECTION Effect on Collection Properties
"WRAPPED" The property is projected as an element with subelements; each subelement corresponds to an item of the collection. This is the default for collection properties.
"ELEMENT" Each item in the collection is projected as an element, without being wrapped in the parent property.
 
Robert Cemper · Jun 27, 2019 go to post

I miss   Public {   } in your example
it ensures that only parameters are visible as <Private variables>  or all %*
 

Robert Cemper · Jun 27, 2019 go to post
MyFunc(Param1,Param2) Public {
    if $d(Param2)  write " 2 params",! 
    else  write " 1 param",!
  
    S Param2="it's all good"

   Q 1

}
Robert Cemper · Jun 27, 2019 go to post

did you try to Save your Stream.Container ?

set tSC tRequest.%Save()

before 

set tSC = ..SendRequestAsync(..TargetConfigNames,tRequest)