Yuval Golan · Dec 13, 2023 go to post

Your problem might be the one I encountered - for the string "onenineight" the number is 18 and not 19

Yuval Golan · Dec 6, 2022 go to post

Maybe something like this:

zl YourRoutineName

S cmd=""

f i=1:1:4 s cmd=cmd_$t(func+i)_"  "

zr

w cmd //to see if it's ok

Yuval Golan · Jan 1, 2020 go to post

Well...my solutions are in COS.

Working on a bignum solution (also in COS) for the last code of part2 in day 22.

Yuval Golan · Dec 25, 2019 go to post

You can check my code at

https://github.com/uvg/AdventOfCode

Couldn't make day 18 and part 2 of day 25 (because of not completing day 18)

Also couldn't find a cos code for bignum so the last calculations of part2 in day22 were made in an external calculator

Yuval Golan · May 23, 2019 go to post

Maybe just a mistake in the production variable name:

set productionName = "MyApp.production"
if ##class(Ens.Config.Item).NameExists(produccionName,itemDelete, .idItem)
Yuval Golan · Dec 31, 2018 go to post

Run this code and check what's the best for you:

CHK ;set string="a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"set lfs=$listfromstring(string)set tags="x,d,blabla,m",tagl=$listfromstring(tags)set stringd=","_string_","kill arrstr for i=1:1:$length(string,",") set arrstr($piece(string,",",i))=ikill arrtag for i=1:1:$length(tags,",") set arrtag($piece(tags,",",i))=i;//$order the worstset hh=$zhorolog for i=1:1:1000000 for j=1:1:$listlength(tagl) set tag=$list(tagl,j) set hhh=$zhorologwrite !,"$ll&$li: ",$justify($fnumber(hhh-hh,"",6),10)set hh=$zhorolog for i=1:1:1000000 for j=1:1:$length(tags,",") set tag=$piece(tags,",",j) set hhh=$zhorologwrite !,"$l&$p: ",$justify($fnumber(hhh-hh,"",6),10)set hh=$zhorolog for i=1:1:1000000 set tag="" for  set tag=$order(arrtag(tag)) quit:tag=""  set hhh=$zhorologwrite !,"$o: ",$justify($fnumber(hhh-hh,"",6),10)//write !!!!set hh=$zhorolog for j=1:1:$length(tags,",") set tag=$piece(tags,",",j) for i=1:1:1000000 if $data(arrstr(tag)) set hhh=$zhorologwrite !,"$d: ",$justify($fnumber(hhh-hh,"",6),10)set hh=$zhorolog for j=1:1:$length(tags,",") set tag=$piece(tags,",",j),tagd=","_tag_"," for i=1:1:1000000 if stringd[(tagd) set hhh=$zhorologwrite !,"[: ",$justify($fnumber(hhh-hh,"",6),10)set hh=$zhorolog for j=1:1:$length(tags,",") set tag=$piece(tags,",",j),tagd=","_tag_"," for i=1:1:1000000 if $find(stringd,tagd) set hhh=$zhorologwrite !,"$f: ",$justify($fnumber(hhh-hh,"",6),10)set hh=$zhorolog for j=1:1:$length(tags,",") set tag=$piece(tags,",",j) for i=1:1:1000000 if $listfind(lfs,tag) set hhh=$zhorologwrite !,"$lf: ",$justify($fnumber(hhh-hh,"",6),10)set hh=$zhorolog for j=1:1:$length(tags,",") set tag=$piece(tags,",",j),tagd=","_tag_"," for i=1:1:1000000 if $match(stringd,".*"_tagd_"{1}.*") set hhh=$zhorologwrite !,"$match: ",$justify($fnumber(hhh-hh,"",6),10)quit
Yuval Golan · Nov 27, 2018 go to post

One can only hope that no one write like this.

Or something like this:

I S S S=I
Yuval Golan · May 1, 2018 go to post

Nice one, just notice that your util can copy properties between different types of objects.

Did you checked it with multi dim properties, relationships, arrays, lists, serials,  streams, calculated, etc.?

Notice that if obj1 and obj2 are of the same class then use %ConstructClone. It is part of the %Library.RegisteredObject class

http://docs.intersystems.com/latest/csp/docbook/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25sys&CLASSNAME=%25Library.RegisteredObject#METHOD_%ConstructClone

Yuval Golan · Apr 29, 2018 go to post

$GET(pDni)?8N in the GetLetter method where your input is 8 digits and the output is the corresponding letter.

In ValidateDni your input is 8 digits and one uppercase letter so there you should use $GET(pDni)?8N1U

So now the code will be something like this:

ClassMethod GetLetter(pDni As %String) As %String
{
    set correspondence = $LISTBUILD("T","R","W","A","G","M","Y","F","P","D","X","B","N","J","Z","S","Q","V","H","L","C","K","E")
    
    set letter = ""
    
    if ($get(pDni)?8N){
        set number = (pDni # 23)+1
        set letter = $LISTGET(correspondence,number)
    }
    
    quit letter
}
/// <br><b>0</b> Dni OK
/// <br><b>-1</b> Dni error

ClassMethod ValidateDni(pDni As %String) As %Integer
{

    set response = -1
    
    if ($get(pDni)?8N1U){
        //Get the numbers of Dni
        set auxNumber = $EXTRACT(pDni,1,8)
        
        //Get the letter of Dni
        set auxLetter = $EXTRACT(pDni,9,9)
        
        //Calculate the letter of the dni
        set calculatedLetter = ..GetLetter(auxNumber)
        
        if (auxLetter = calculatedLetter){
            set response = 0
        }        
    }
    
    quit response
}
Yuval Golan · Apr 26, 2018 go to post

I think that in GetLetter the condition should be if $get(pDni)?8n to validate that pDni contain 8 exactly 8 digits

And in ValidateDni the condition should be if $get(pDni)?8n1u to validate that pDni contains exactly 8 digits followd by an uppercase letter.

Also in ValidateDni instead of ##class(DKI.Common.Utils.Utilitades).GetLetter(auxNumber) you should do ..GetLetter(auxNumber) in this way when you put both methods in the same class the class name doesn't have to be DKI.Common.Utils.Utilitades

More about pattern matching can be found here:

https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KE…

And about arithmetic&logic precedence:

http://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls…

Yuval Golan · Apr 24, 2018 go to post

Using TO_DATE (?,'YYYYMMDD') in prepare

Executing as you said - working in the terminal, and also in the code, finally

Thank you very much

yesyesyes

Yuval Golan · Apr 24, 2018 go to post

I'm checking the status of prepare and there's no problem during the prepare, it's the execute that return the error.

copy+paste from the example:

status=obj.%Prepare(statement)

i status s result=obj.%Execute($zd($zdh(somedateYYYYMMDD,8),3),par2,par3,par4)

Yuval Golan · Apr 24, 2018 go to post

SQL shell is working (using to_date no matter if it's %Date or %String)

So what the sql shell and SMP are doing that i'm not doing in the code?

Yuval Golan · Apr 24, 2018 go to post

At the oracle db - the field type is DATE and no special format is specified for the field.

Yuval Golan · Apr 24, 2018 go to post

No problem in selecting from the table

Problems  only when trying to insert new data to the table.

I tried yyyy-mm-dd and $h (i tried $h only when it was defined as %Date letting the Cache auto translate using %Date.LogicalToOdbc method)

Yuval Golan · Apr 24, 2018 go to post

At the Caché side it was generated as %Date using the link table wizard, through the SMP it worked with to_date when it was %Date and worked also after i changed it to %String.

Through terminal couldn't make it work no mater what i tried, not when it is %Date and using $h without to_date nor when it is %String and translating the date to yyyy-mm-dd with or without to_date (at prepare or at execute).

I also tried using ##class(Package.SomeClassName).%New() and %Save()  and it also return ORA-01861 error ($h when %Date and yyyy-mm-dd when %String).

Also %String with %New/Save with "to_string ('"_FormattedDate_"','yyyy-mm-dd')" as the field value returned ORA-01858 error.

Don't know the table/field definition/format at the oracle db - hope to get this info soon.

Yuval Golan · Apr 23, 2018 go to post

Still not working in the code, at the SMP it worked in every mode Display/Logical/ODBC. isn't the mode affect only on select statements?
At the code i set the property back to %Date, and the sql statement and execute without the to_date, at the execute just converted to $h as you mentioned and i'm getting error [Oracle][ODBC][Ora]ORA-01861: literal does not match format string.

Yuval Golan · Apr 22, 2018 go to post

According to your code you know the different subscripts and want to continue on the same clientId and you only care for the first 4 subscripts, so try this (running only on the given clientid so no need to check it, and running only on the first 4 subscripts so no need to check if we are beyond the (or on the same) 4th subscript), haven't tested it!!:

    ; Get log for given 'clientid'
    ; 'maxlog' records max, starting from given 'date','dek','idx'
GetXLog(clientid,date,dek,idx,maxlog) public
{
    set:maxlog="" maxlog=400
    set counter=0
    ; ^cxlog("EFRW1000",20161219,2,1,"date")=20161219
    ;
    ;setting the subscripts for their previous subscripts so the next iteration will get to the values you asked for
    ;if you want to continue after idx and not to repeat idx then comment the next line
    set idx=$order(^cxlog(clientid,date,dek,idx),-1)
    set dek=$order(^cxlog(clientid,date,dek),-1)
    set date=$order(^cxlog(clientid,date),-1)
    for {
        quit:counter=maxlog
        set date=$order(^cxlog(clientid,date)) quit:date=""
        for {
            quit:counter=maxlog
            set dek=$order(^cxlog(clientid,date,dek)) quit:dek=""
            for { 
                quit:counter=maxlog
                set idx=$order(^cxlog(clientid,date,dek,idx)) quit:idx=""
                write idx,!
                set counter=counter+1
            }
        }
    }
    w !
}

Yuval Golan · Jan 17, 2018 go to post

I meant from the cache client "cube" I can't get to the System Management Portal of the cache server (the cache server isn't running the IIS server and the IIS is accessible only through https).

Another clarification: at the moment if I want to get to the SMP (System Management Portal) of this server than I chose the SMP in the cube (right click on the cache cube -> Remote Server Access -> Management Portal -> clicking on the server name I want to connect to) and after the internet browser is opened with the wrong url (http) I change it to https and its working.

Yuval Golan · Jan 17, 2018 go to post

If you meant that you want to get the day (name/value) from the date then try $zdate(datevalue,dayformat) where datevalue is in $h format and dayformat is 10 for number of day in week, 11 for short day name, 12 for full day name.

check out the docs about $zdate , $zdateh, $systm.sql.datepart for more info about working with dates.

Yuval Golan · Jun 26, 2017 go to post

Hi @Nikita Savchenko

Thanks for a full install info.

I'm using Cache for Windows (x86-64) 2013.1.1 (Build 501_1_13062) Sun Aug 11 2013 23:20:33 EDT

Step 1 and 2 are going fine, i'm able to downlad ver 2 beta8, and i'm able to import and compile it on the %SYS namespace.

At step 3 i'm getting the login page and after i authenticate i get the Cache WEB Terminal in the title but with an empty body.

At step 3 i used IE 11, using the debugger it throw the next error from terminal.js:

"{if("undefined"==typeof JSON)throw new Error("Browser does not support html5 local storage. Please, update your browser")}"

So i tried step 3 on chrome  and now it's better but i get the following error (It's displayed in the body):

"WebSocket connection error (ws://servername/%25WebTerminal.Engine.cls). Trying to connect again in 10 seconds...
WebSocket connection closed. Code 1006, reson: ." which came from terminal.js

And now finally step 3 is working - using chrome and using the port 57772 (instead of 80)  i'm getting the prompt to %SYS namespace.

Thank you very much.

Yuval Golan · Jun 26, 2017 go to post

So, returning to this...

What should i do in order to install WebTerminal-2.0.0-beta.7/beta.8 on a Cache 2013.1 server?
At what namespace should i import the xml?
Should i manualy set a web application? if so - what should i define?

Yuval Golan · Jun 25, 2017 go to post

The documentation say that ver 3 and 4 will run on Cache 2014.1+

And i need to run it on Cache 2013.1.

So, Will v4 work on Cache 2013.1?