go to post Vitaliy Serdtsev · Dec 18, 2018 Source code of class %Net.Remote.Utility is open, so you can use it to make your "RunCommandViaCPIPE" method and already use it. PS: it's just a wrapper around low-level commands, see Local Interprocess Communication.
go to post Vitaliy Serdtsev · Nov 2, 2018 No. If you beware to use %occLibrary, you may look into side %Regex.Matcher Here is another documented solution: #include %systemInclude n try{ #define TAB $c(9) s csv="""ABC,"_$c(10)_" Company,"",""123 Main St, Ste 102"",""Anytown, DC"",10001,234-567-8901,""Anytown"_$$$TAB_"DC""" d ##class(%DeepSee.TermList).%ParseCSVRecord(csv,.arr) w csv,!!,$$WriteCSVRecord(.arr,$$$TAB) }catch(ex){ w "Error ", ex.DisplayString(),! } WriteCSVRecord(&pRecord, pDelim=",", pEncode=$$$YES) { // made on the basis of the method %WriteCSVRecord Set r = "" Set k = $O(pRecord("")) While (k'="") { Set tValue = $G(pRecord(k)) Set:$G(pEncode) tValue = $ZCVT(tValue,"O","UTF8") Set r = r _ $S((tValue["""")||(tValue[",")||(tValue[pDelim):$$$quote(tValue),1:tValue) Set k = $O(pRecord(k)) Set:k'="" r = r _ pDelim } Quit r }Result: USER>d ^dc "ABC, Company,","123 Main St, Ste 102","Anytown, DC",10001,234-567-8901,"Anytown DC" "ABC, Company," "123 Main St, Ste 102" "Anytown, DC" 10001 234-567-8901 "Anytown DC"
go to post Vitaliy Serdtsev · Nov 1, 2018 #include %systemInclude s csv="ABC Company,""123 Main St, Ste 102"",""Anytown, DC"",10001,234-567-8901" s list=$$CSVtoList^%occLibrary(csv) f i=1:1:$ll(list) s:$li(list,i)["," $li(list,i)=$$$quote($li(list,i)) w csv,!,$lts(list,$c(9))Result: USER>d ^test ABC Company,"123 Main St, Ste 102","Anytown, DC",10001,234-567-8901 ABC Company "123 Main St, Ste 102" "Anytown, DC" 10001 234-567-8901
go to post Vitaliy Serdtsev · Nov 1, 2018 Maybe the name of the topic to specify a CSV-string instead of string ? After clarification, the question became more clear.
go to post Vitaliy Serdtsev · Nov 1, 2018 I was looking at the generated INT code for &sql(select lpad('1',4,'0') n) Unfortunately, for COS at the moment I have not found an analogue LPADSQL. Can you offer a documented LPADCOS ?
go to post Vitaliy Serdtsev · Oct 30, 2018 Once upon a time promised to make Server-Side JavaScript alongside with Caché ObjectScript and Caché Basic: JavaScript: Not Just a Client-side Language Tuesday, 10:15 AM Technical level: Advanced Mobile and browser-based applications frequently use JavaScript for their user interfaces. We are working towards implementing JavaScript as one of our server-side scripting languages, thereby allowing developers to use it throughout their applications. In this session we will demonstrate our progress to date. Keywords: Mastering Mobile, Caché, Ensemble, concurrent Server-Side JavaScript Monday, 4:00 PM – 4:45 PM, FLW Ballroom H Wednesday, 11:00 AM – 11:45 AM, FLW Ballroom H Presenter: Steve LeBlanc Task: Use JavaScript to define business logic for applications based on InterSystems’ technology Approach: Leverage InterSystems’ new support for server-side JavaScript Tags: JavaScript I found a JS Runtime Shell that uses Node.JS & esprima: SAMPLES>d ##class(%CPT.JS.Runtime.Shell).Run() JRS> ? .L CLASS - load javascript methods from CLASS into JS global namespace .LV var,.. - load the given COS public vars into JS global namespace .S FUNC - list the source of the method which implements function FUNC - FUNC must be in the global namespace - the whole implementing method is shown, even for an inner function - this will also work for non-javascript methods .M - list MAC code from latest compilation .I - list INT code from latest compilation .T - show latest tree .G - list global symbols .N CODE - execute JS on node.js .N - execute the last-entered line of JS on node.js .CONFIG ... - passed to %CPT.CalloutShell 'CONFIG' command .SET ... - passed to %CPT.CalloutShell 'SET' command .CLEAR ... - passed to %CPT.CalloutShell 'CLEAR' command .SHOW ... - passed to %CPT.CalloutShell 'SHOW' command !COS - execute a line of COS Anything else is interpreted as JS. :- * if preceded by "=" it must be a single function definition * otherwise it can be either a single expression or a sequence of statements separated by ";"s Either way it will be compiled into a function body and :- * if preceded by "==" it is stored as a JS global with the new function's name * otherwise it will just be executed \n can be used to represent a newline. You can also take input from a file :- <FILE - read JS from FILE and compile+execute it <=FILE - read JS from FILE and compile+store it The result of the execution is shown and also stored in global variable '_'. For a global variable, set it without using 'var' (this will be fixed) JRS> .N var obj = { name: "John", age: 30, city: "New York" }; JSON.stringify(obj); {result: "{""name"":""John"",""age"":30,""city"":""New York""}"} JRS> .N Math.random() {result: .5670654247514904} JRS> .N var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.sort(); {result: ["Apple", "Banana", "Mango", "Orange", 1: "Apple", 2: "Banana", 3: "Mango", 4: "Orange"]} JRS> q SAMPLES>
go to post Vitaliy Serdtsev · Oct 30, 2018 If you do universal LPAD, it is best $$lpad^%qarfunc, because for certain arguments may produce an incorrect result, for example: #define lpad(%s,%len,%pad) $tr($j(%s,%len)," ",%pad) s s="a b",len=8,pad="0" w $$$lpad(s,len,pad),! ,$$lpad^%qarfunc(s,len,pad),! ,$$$lpad(s,len,s),! ,$$lpad^%qarfunc(s,len,s),!Result: USER>d ^test 00000a0b 00000a b aaaaaaab a ba a b
go to post Vitaliy Serdtsev · Oct 29, 2018 Also LPADSQL USER>d $system.SQL.Shell() SQL Command Line Shell ---------------------------------------------------- The command prefix is currently set to: <>. Enter q to quit, ? for help. USER>>select lpad('1',4,'0') n 1. select lpad('1',4,'0') n n 0001 1 Rows(s) Affected
go to post Vitaliy Serdtsev · Oct 29, 2018 The functions from %qarfunc are actively used in system classes, so I don't think ^%qarfunc will be removed in the near future, otherwise everything will stop working.
go to post Vitaliy Serdtsev · Oct 29, 2018 See: Implied Namespace Mapping What Is Accessible in Your Namespaces
go to post Vitaliy Serdtsev · Oct 19, 2018 Try ClientMethod changeParams() [ Language = javascript ] { var query = zen('categorieBeneficiaire'); var param1 = zen('catBParam1'); var param2 = zen('catBParam2'); param1.value='OS'; param2.value='NSAL'; query.refreshContents(); } /// This client event, if present, is fired when the page is loaded. ClientMethod onloadHandler() [ Language = javascript ] { zenPage.changeParams(); }
go to post Vitaliy Serdtsev · Oct 9, 2018 You don't need anything else to work with globals directly: Using the Globals API. See the code examples in <install-dir>\dev\dotnet\samples\globals
go to post Vitaliy Serdtsev · Oct 9, 2018 Another variants: USER>k s args=3,args(1)="-h",args(2)=21,args(3)="community.intersystems.com" do $system.OBJ.DisplayError(##class(%Net.Remote.Utility).RunCommandViaCPIPE("tracert",,.output,,900,.args)) w output or USER>k s args=3,args(1)="-h",args(2)=21,args(3)="community.intersystems.com" do $system.OBJ.DisplayError(##class(%Net.Remote.Utility).RunCommandViaZF("tracert",,.output,,900,,.args)) w output
go to post Vitaliy Serdtsev · Oct 9, 2018 See Handling of static dataEN or Обработка статикиRU. In your case, is enough will be the standard class %CSP.StreamServer (see streamserve.csp from CSP Samples). And you can use it to download external files, for example: %25CSP.StreamServer.cls?FILE=blablabla PS: by the way, it is not safe to transmit OID in open form, so pay attention to the method %CSP.Page:Encrypt(oid).
go to post Vitaliy Serdtsev · Oct 2, 2018 Changed a bit and added new code: /// d ##class(Scratch.test).ClassVsInst() ClassMethod ClassVsInst(N = {1e6}) [ ProcedureBlock = 0, PublicList = st ] { n p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, xClass, xInst, st s p1="пропоывшыщзшвыщшв" ,p2="гшщыгвыовлдыовдьыовдлоыдлв" ,p3="widuiowudoiwudoiwudoiwud" ,p4="прпроыпворыпворыпворыпв" ,p5="uywyiusywisywzxbabzjhagjЭ" ,p6="пропоывшыщзшвыщшв" ,p7="гшщыгвыовлдыовдьыовдлоыдлв" ,p8="widuiowudoiwudoiwudoiwud" ,p9="прпроыпворыпворыпворыпв" ,p10="uywyiusywisywzxbabzjhagjЭ" ,xClass="(args...) f i=1:1:N s sc=##class(Scratch.test).%1(args...)" ,xInst="(args...) f i=1:1:N s sc=st.%1(args...)" s st=##class(Scratch.test).%New() w $p($zv,"(Build"),!! d runClassmethod("dummyClass10", p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) ,runMethod("dummyClass10", p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) ,runMethod("dummyInst10", p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) ,runClassmethod("dummyClass5", p1, p2, p3, p4, p5) ,runMethod("dummyClass5", p1, p2, p3, p4, p5) ,runMethod("dummyInst5", p1, p2, p3, p4, p5) ,runClassmethod("dummyClassNull") ,runMethod("dummyClassNull") ,runMethod("dummyInstNull") ,runX("dummyClass10",xClass, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) ,runX("dummyInst10",xInst, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) ,runX("dummyClass5",xClass, p1, p2, p3, p4, p5) ,runX("dummyInst5",xInst, p1, p2, p3, p4, p5) ,runX("dummyClassNull",xClass) ,runX("dummyInstNull",xInst) runMethod(methodname,args...) n t,i,sc s t=$zh f i=1:1:N s sc=$method(st, methodname, args...) s t=$zh-t w methodname,?16,"total time = "_t,?38,"avg time = "_(t/N),! q runClassmethod(methodname,args...) n t,i,sc s t=$zh f i=1:1:N s sc=$classmethod("Scratch.test", methodname, args...) s t=$zh-t w methodname_"*",?16,"total time = "_t,?38,"avg time = "_(t/N),! q runX(methodname,x,args...) n t,i,sc s t=$zh x ($$$FormatText(x,methodname), args...) s t=$zh-t w "X"_methodname,?16,"total time = "_t,?38,"avg time = "_(t/N),! q }Result: USER>d ##class(Scratch.test).ClassVsInst() Cache for Windows (x86-64) 2018.1 dummyClass10* total time = .328227 avg time = .000000328227 dummyClass10 total time = .27655 avg time = .00000027655 dummyInst10 total time = .259913 avg time = .000000259913 dummyClass5* total time = .286983 avg time = .000000286983 dummyClass5 total time = .25666 avg time = .00000025666 dummyInst5 total time = .240312 avg time = .000000240312 dummyClassNull* total time = .274406 avg time = .000000274406 dummyClassNull total time = .250926 avg time = .000000250926 dummyInstNull total time = .234486 avg time = .000000234486 XdummyClass10 total time = .312917 avg time = .000000312917 XdummyInst10 total time = .264871 avg time = .000000264871 XdummyClass5 total time = .286985 avg time = .000000286985 XdummyInst5 total time = .238557 avg time = .000000238557 XdummyClassNull total time = .278684 avg time = .000000278684 XdummyInstNull total time = .236815 avg time = .000000236815