go to post Vitaliy Serdtsev · Jul 24, 2019 Thank you for your comment. This code is taken from the source code %SYS, which in theory should be an example for application developers. I hope that InterSystems developers will see your comment and make appropriate changes.
go to post Vitaliy Serdtsev · Jul 16, 2019 See $(REST - CSP - (-HyperEvents) + EasyUI + File Upload). Part 2
go to post Vitaliy Serdtsev · Jul 16, 2019 Intel i5-2400 10000 digits ~ 58 sec. calcPI(n) public { s $lb(len,nines,predigit,r)=$lb(10*n\3,0,0,"") f i=1:1:len s a(i)=2 f j=1:1:n { s q=0 f i=len:-1:1 s x=10*a(i)+(q*i), a(i)=x#(2*i-1), q=x\(2*i-1) s a(1)=q#10, q=q\10 i q=9 { s nines=nines+1 }elseif q=10 { s r=r_(predigit+1)_$$repeat^%qarfunc(0,nines), predigit=0, nines=0 }else{ s r=r_predigit, predigit=q s:nines r=r_$$repeat^%qarfunc(9,nines), nines=0 } } q r_predigit }
go to post Vitaliy Serdtsev · Jul 12, 2019 And if so? w $zobjref(^||PPG(1)).NameStill take a look at $$$objOrefToInt/$$$objIntToOref (%occObject.inc) PS: it should be noted that OREF ≠ OID and serve different purposes.
go to post Vitaliy Serdtsev · Jul 10, 2019 I found out the reason for the difference in the result BASIC256: Instead s len = 10*n\4, must be s len = 10*n\3,Error on site.
go to post Vitaliy Serdtsev · Jul 10, 2019 Translation of: LUA calcPILua(n=1000) public { s len = 10*n\3, nines = 0, predigit = 0 f j=1:1:len s a(j)=2 f j=1:1:n { s q=0 f i=len:-1:1 { s x = 10*a(i) + (q*i), a(i)=x#(2*i-1), q=x\(2*i-1) } s a(1)=q#10, q=q\10 i q=9 { s nines = nines + 1 }elseif q=10 { w predigit+1 f k = 1:1:nines w 0 s predigit = 0, nines = 0 }else{ w predigit s predigit = q i nines { f k = 1:1:nines w 9 s nines = 0 } } } w predigit }The result of this example is exactly the same as the result of the program C# (tested at n=10000).
go to post Vitaliy Serdtsev · Jul 10, 2019 Translation of: BASIC256 calcPI(n=1000) public { s len = 10*n\4, needdecimal = $$$YES, nines = 0, predigit = 0 ;# {First predigit is a 0} f j=1:1:len s a(j-1)=2 ;# {Start with 2s} f j=1:1:n { s q=0 f i=len:-1:1 { ;# {Work backwards} s x = 10*a(i-1) + (q*i), a(i-1)=x#(2*i-1), q=x\(2*i-1) } s a(0)=q#10, q=q\10 i q=9 { s nines = nines + 1 }elseif q=10 { s d = predigit+1 d outputd i nines>0 f k = 1:1:nines s d = 0 d outputd s predigit = 0, nines = 0 }else{ s d = predigit,predigit = q d outputd i nines { f k = 1:1:nines s d = 9 d outputd s nines = 0 } } } w predigit q outputd() if needdecimal { q:d=0 w d_"." s needdecimal = $$$NO } else { w d } }The greater "n", the higher the accuracy. If there is a lack of RAM, you can easily replace the local array "a" with globals ^||a or ^a.
go to post Vitaliy Serdtsev · Jul 3, 2019 Is this normal? Yes. 2015.x (pJournalFlag = 0) Latest (pJournalFlag = 1)
go to post Vitaliy Serdtsev · Jun 27, 2019 w $$MyFunc(1),!, $$MyFunc(1,.V)," V=",V,! MyFunc(p...) s Answer=p_" params" s:p=2 p(2)="it's all good" q Answer USER>do ^test 1 params 2 params V=it's all good
go to post Vitaliy Serdtsev · May 21, 2019 Can be easier: ClassMethod GetPrivateProp( oref, propName) As %String { d ##class(%Studio.General).DumpObjectExecute(.arr,oref) q arr(propName) }
go to post Vitaliy Serdtsev · May 21, 2019 Date and Time Constructs Try this: SELECT LBTS_RowID ,LBTS_CollectedDate FROM SQLUser.LB_TestSet JOIN SQLUser.LB_Transfer ON ($LISTBUILD(LBTS_RowID) %INLIST LBTR_TestSetList) WHERE LBTS_CollectedDate BETWEEN {d '2019-01-01'} AND {d '2019-05-10'}
go to post Vitaliy Serdtsev · May 17, 2019 Try this: XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ] { <page xmlns="http://www.intersystems.com/zen"> <tableNavigatorBar tablePaneId="tp1"/> <tablePane id="tp1" OnCreateResultSet="CreateRS" OnExecuteResultSet="ExecuteRS" maxRows="0" pageSize="10" useSnapshot="true" > <parameter value="USER1"/> </tablePane> <tableNavigatorBar tablePaneId="tp2"/> <tablePane id="tp2" OnCreateResultSet="CreateRS" OnExecuteResultSet="ExecuteRS" maxRows="0" pageSize="10" useSnapshot="true" > <parameter value="USER2"/> </tablePane> </page> }
go to post Vitaliy Serdtsev · May 17, 2019 For example so: Class dc.test Extends %ZEN.Component.page { XData Style { <style type="text/css"> </style> } XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ] { <page xmlns="http://www.intersystems.com/zen"> <tablePane OnCreateResultSet="CreateRS" OnExecuteResultSet="ExecuteRS" > <parameter name="ns" value="USER1"/> </tablePane> <tablePane OnCreateResultSet="CreateRS" OnExecuteResultSet="ExecuteRS" > <parameter name="ns" value="USER2"/> </tablePane> </page> } Method ExecuteRS( myRS As %ResultSet, Output pSC As %Status, pInfo As %ZEN.Auxiliary.QueryInfo) As %Boolean { d myRS.Prepare("select * from xyz") d myRS.Execute() s tSC=$$$OK q $$$YES } Method CreateRS( Output tSC As %Status, pInfo As %ZEN.Auxiliary.QueryInfo) As %ResultSet { s rs=##class(%RemoteResultSet).%New() s rs.UserName="_system" s rs.Password="SYS" s rs.ConnectionString=$$$FormatText("localhost[%1]:%2",##class(%SQL.Manager.API).GetPort(),pInfo.parms(1)) s tSC=$$$OK q rs } }
go to post Vitaliy Serdtsev · May 17, 2019 For example so: Class myapp.jsonProvider Extends %ZEN.Auxiliary.jsonProvider { ClassMethod getOrderedProps( pClass As %Dictionary.CompiledClass, ByRef pList) [ Internal ] { d ##super(pClass,.pList) s key = "" f { s key = $o(pList(key)) q:""=key zk:$lf(^||skipProps,pList(key)) pList(key) } } } Class myapp.myclass Extends %RegisteredObject { Property property1 As %String; Property property2 As %String; Property property3 As %String; /// d ##class(myapp.myclass).Test() ClassMethod Test() { s myClass = ..%New() s myClass.property1 = "value 1" s myClass.property2 = "value 2" s myClass.property3 = "value 3" f i=$lb("property3"),$lb("property2","property1") { s ^||skipProps=i d ##class(myapp.jsonProvider).%WriteJSONStreamFromObject(.tStream,myClass,,,$$$YES,"ed") w "skip:",$lts(i),?25," -> ",tStream.Read(),! } } } USER>d ##class(myapp.myclass).Test() skip:property3 -> {"property1":"value 1","property2":"value 2"} skip:property2,property1 -> {"property3":"value 3"}
go to post Vitaliy Serdtsev · May 8, 2019 Made a small demo with two options. Include %occResultSet Class dc.test [ Abstract ] { ClassMethod MultiRS(i As %Integer) [ ReturnResultsets, SqlProc ] { i i#2 { $$$ResultSet("select 'Name1_1' s1,'Name2_1' s2 union all select 'Name1_2','Name2_2'") } else { $$$ResultSet("select 1 i1,4 i2,3 i3 union all select 2,5,6 union all select 3,6,9") $$$ResultSet("select '+1' n union all select '-2' union all select '3.1' union all select '4_4'") } } Query MyCustomQueryCube(pCubeName As %String) As %Query [ SqlProc ] { } ClassMethod MyCustomQueryCubeExecute( ByRef qHandle As %Binary, pCubeName As %String) As %Status { s qHandle("pCubeName")=pCubeName i pCubeName="a" { s N=2 f i=1:1:N s qHandle(N+1-i)=$lb("Name1_"_i,"Name2_"_i) }else{ s N=3 f i=1:1:N s qHandle(N+1-i)=$lb(i,i+3,i*3) } s qHandle=N q $$$OK } ClassMethod MyCustomQueryCubeFetch( ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = MyCustomQueryCubeExecute ] { i qHandle=0 { s Row="" s AtEnd=1 }else{ s Row=qHandle(qHandle) s qHandle=qHandle-1 } q $$$OK } ClassMethod MyCustomQueryCubeClose(ByRef qHandle As %Binary) As %Status [ PlaceAfter = MyCustomQueryCubeFetch ] { k qHandle q $$$OK } ClassMethod MyCustomQueryCubeGetInfo( ByRef colinfo As %List, ByRef parminfo As %List, ByRef idinfo As %List, ByRef qHandle As %Binary, extoption As %Integer = 0, ByRef extinfo As %List) As %Status { i qHandle("pCubeName")="a" { s colinfo=$lb($lb("s1",10,"s1"),$lb("s2",10,"s2")) }else{ s colinfo=$lb($lb("i1",5,"i1"),$lb("i2",5,"i2"),$lb("i3",5,"i3")) } s parminfo=$lb($lb("pCubeName","10")) s idinfo=$lb(0,"") q $$$OK } ClassMethod MyCustomQueryCubeGetODBCInfo( ByRef colinfo As %List, ByRef parminfo As %List, ByRef qHandle As %Binary) As %Status { i qHandle("pCubeName")="a" { s colinfo=$lb(2, "s1",12,50,0,2,"s1","test","dc","",$c(0,0,0,0,0,0,0,0,0,0,0,0), "s2",12,50,0,2,"s2","test","dc","",$c(0,0,0,0,0,0,0,0,0,0,0,0) ) }else{ s colinfo=$lb(3, "i1",4,10,0,2,"i1","test","dc","",$c(0,0,0,0,0,0,0,0,0,0,0,0), "i2",4,10,0,2,"i2","test","dc","",$c(0,0,0,0,0,0,0,0,0,0,0,0), "i3",4,10,0,2,"i3","test","dc","",$c(0,0,0,0,0,0,0,0,0,0,0,0) ) } s parminfo=$lb(1,12,50,0,2,"pCubeName",1) q $$$OK } /// d ##class(dc.test).Test() ClassMethod Test() { try{ s rs=##class(%SQL.Statement).%New() $$$ThrowOnError(rs.%PrepareClassQuery("dc.test","MyCustomQueryCube")) f i="a","b" d rs.%Execute(i).%Display() w !!,"==============" $$$ThrowOnError(rs.%Prepare("call dc.test_MultiRS(?)")) f i=0,1 d rs.%Execute(i).%Display() }catch(ex){ w "Error ", ex.DisplayString(),! } } } USER>d ##class(dc.test).Test() Dumping result #1 s1 s2 Name1_1 Name2_1 Name1_2 Name2_2 2 Rows(s) Affected Dumping result #1 i1 i2 i3 1 4 3 2 5 6 3 6 9 3 Rows(s) Affected ============== Dumping result #1 i1 i2 i3 1 4 3 2 5 6 3 6 9 3 Rows(s) Affected Dumping result #2 n +1 -2 3.1 4_4 4 Rows(s) Affected Dumping result #1 s1 s2 Name1_1 Name2_1 Name1_2 Name2_2 2 Rows(s) Affected
go to post Vitaliy Serdtsev · May 3, 2019 s delim = " ", abbrv = "" ... set abbrv = abbrv _ $e($PIECE(desc,delim,i),1,2) // But if I put w abbrv I can get "Resytorewipa"
go to post Vitaliy Serdtsev · May 3, 2019 Also I'm curious if we can set up and pass a JSON that easily too? Would be great. Certainly. Class dc.test Extends %RegisteredObject { ClassMethod MethodTest(args As %DynamicObject) { i $IsObject(args) { w args.%ToJSON(),! w:args.%IsDefined("arr") args.arr."2",! }else{ w "null",! } } ClassMethod Test() { ;d ##class(dc.test).Test() d ..MethodTest(), ..MethodTest({}), ..MethodTest({"arg1":($zts),"arg6":"hello","arr":["a",10,true,2.5674]}) } }Result: USER>d ##class(dc.test).Test() null {} {"arg1":"65136,19638.022","arg6":"hello","arr":["a",10,true,2.5674]} 1
go to post Vitaliy Serdtsev · Apr 24, 2019 First, should be so (AttachFile): s status=msg.AttachFile("F:\MyDir","myFirstFile.pdf",1,,.count) s status=msg.AttachFile("F:\MyDir","mySecondFile.pdf",1,,.count)Second, you did not specify the error text. Try the following simple MAC-example, replacing the values with your own: #include %systemInclude new try{ $$$AddAllRoleTemporaryInTry new $namespace set msg=##class(%Net.MailMessage).%New() set msg.Subject="Subject" set msg.From="from@domain" do msg.To.Insert("to@domain") do msg.TextData.Write("Hello!") $$$ThrowOnError(msg.AttachFile("F:\MyDir","myFirstFile.pdf")) $$$ThrowOnError(msg.AttachFile("F:\MyDir","mySecondFile.pdf")) set smtp=##class(%Net.SMTP).%New() set smtp.smtpserver="123.145.167.189" $$$ThrowOnError(smtp.Send(msg)) }catch(ex){ write "Error ", ex.DisplayString(),! }
go to post Vitaliy Serdtsev · Apr 23, 2019 s res=##class(%SQL.Statement).%ExecDirect(,$$$FormatText("CREATE TABLE %1 (TNAMESPACE CHAR(100),TINTERFACE CHAR(100))",$$$quote("xxxxx"_$USERNAME))) w res.%SQLCODE