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))=i
kill arrtag for i=1:1:$length(tags,",") set arrtag($piece(tags,",",i))=i
;
//$order the worst
set hh=$zhorolog for i=1:1:1000000 for j=1:1:$listlength(tagl) set tag=$list(tagl,j) set hhh=$zhorolog
write !,"$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=$zhorolog
write !,"$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=$zhorolog
write !,"$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=$zhorolog
write !,"$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=$zhorolog
write !,"[: ",$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=$zhorolog
write !,"$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=$zhorolog
write !,"$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=$zhorolog
write !,"$match: ",$justify($fnumber(hhh-hh,"",6),10)
quit
$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
}
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
go to post
Your problem might be the one I encountered - for the string "onenineight" the number is 18 and not 19
go to post
Hi Mark,
Is your AOC2022 repo public or private?
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
go to post
Trying to publish to https://test.pm.community.intersystems.com and getting Publish FAILURE
ERROR! Publishing module, something went wrong.
I have done the following:
repo -n registry -r -url https://test.pm.community.intersystems.com -user test -pass PassWord42
load C:\where\my\code\is
list
publish my-zpm-package
and received the error
What am I doing wrong?
go to post
Thank you @Evgeny Shvarov
Now with classes, you can find them on
https://github.com/uvg/AdventOfCodeUvg/tree/master/2021/CLS
go to post
Repository (for all years) can be found here: https://github.com/uvg/AdventOfCodeUvg
COS Code for 2021 : https://github.com/uvg/AdventOfCodeUvg/tree/master/2021/COS
ObjectScript quality status: https://community.objectscriptquality.com/dashboard?id=intersystems_iris_community%2FAdventOfCodeUvg
go to post
https://github.com/uvg/AdventOfCode/tree/master/2020/COS
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.
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
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)
go to post
Run this code and check what's the best for you:
go to post
One can only hope that no one write like this.
Or something like this:
I S S S=I
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
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:
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?KEY...
And about arithmetic&logic precedence:
http://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?...
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
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)
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?
go to post
At the oracle db - the field type is DATE and no special format is specified for the field.
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)