Intersystems缓存:类中的<framestack>和<command />错误:如何解决和避免?

时间:2017-05-18 01:37:31

标签: intersystems-cache intersystems intersystems-cache-studio

我在 Intersystems缓存中有一个loadProgress: string = '';

  1. 根据用户调用
  2. class上写下记录
  3. globals进行迭代,并将结果放在globals
  4. 通过string
  5. 将所述结果写入记事本文件

    但是,部分代码始终返回FILE错误。

    在他们的文件中搜索显示:
    该例程对Do,For,Xecute,New或用户编写的函数进行了太多嵌套调用。

    如果您想知道为什么我使用违反SOLID的单个类,那是因为当我尝试在方法中通过<FRAMESTACK>调用其他方法时,我遇到了错误##class()。因此,我将代码放在我需要的方法中,并将它们混合在一个方法中。

    有没有办法在CLASS中正确调用类METHOD?

    关于FrameStack错误,究竟有多少是太多了?我怎么避免这个?

    编辑:按要求提供的代码

    <COMMAND>

    }

    这里,在制作全局变量的部分之后,我迭代了总记录数ClassMethod GetRRCDelToNP(DateFrom As %String, TimeFrom As %String, DateTo As %String, TimeTo As %String, Startparam As %String, Type As %String, Operator As %String, User As %String) As %String [ SqlProc ] { k ^IDXCMAWEB("ROADRECEIVAL",User) S RRCTR=0 n conwt Q:$G(DateFrom)="" "E:Please enter date time entry." Q:$G(TimeFrom)="" "E:Please enter date time entry." Q:$G(DateTo)="" "E:Please enter date time entry." Q:$G(TimeTo)="" "E:Please enter date entry." Q:$G(Type)="" "E:Please enter type entry." Q:$G(Operator)="" "E:Please enter operator entry." Q:$G(User)="" "E:Cannot process query. I dont know who you are." s (I,J,K,CN,CN1)="" s I=$ZDH(DateFrom,9) s J=$ZTH(TimeFrom) s TDT3=$ZDH(DateTo,9) s TTM3=$ZTH(TimeTo) Q:(TDT3<I) "E:Date time to cannot be greater than date time from." Q:(TDT3=I)&(TTM3<J) "E:Date time to cannot be greater than date time from." s MTY=$s(Type="optall":"",Type="optrec":"R",Type="optdel":"D") s OPR=$s(Operator="A":"",Operator="a":"",1:Operator) i OPR'="" S OPR=$tr(OPR,"abcdefghijklmnopqrstuvwxyz,","ABCDEFGHIJKLMNOPQRSTUVWXYZ|")_"|" s %id=User i K="" S CN="" loopi2 ;loopi if J="" s I=$O(^IDXLGE(I)) Q:(I="")!(+I>TDT3) loopj2 ;loopj if K="" s J=$O(^IDXLGE(I,J)) g loopi2:J="" if (I'="")&((I=TDT3)&(J>TTM3)) s J="",K="",CN="" g loopi2 loopk2 ;loopk if CN="" S K=$O(^IDXLGE(I,J,K)) g loopj2:K="" if "RD"'[K g loopk2 I $G(MTY)'="",MTY'[K g loopk2 if (I="")!(+I>TDT3) quit ;$G(I)_"/"_$G(J)_"/"_$G(K)_"/"_"0"_"/"_$G(^WK($J)) loopcn2 ;loopcn S CN=$O(^IDXLGE(I,J,K,CN)) g loopk2:CN="" S D=$G(^IDXLGE(I,J,K,CN)) S HIS=$P(D,"|"),MOV=$P(D,"|",2),GEN=$P(D,"|",3) g loopcn2:HIS=""!(MOV="")!(GEN="") S N=$G(^CNREC(CN,HIS,"MOVE",MOV)) S NB=$G(^CNREC(CN,HIS,"MOVEB",MOV)) I $P(N,"|",3)="CANCL" g loopcn2 S Z=$G(^CNREC(CN,HIS,"GEN",GEN)) I $P($G(^CNREC(CN,HIS,"GENB",GEN)),"|",3)["CSW" g loopcn2 g loopcn2:$P(Z,"|",9)="" I OPR'="",OPR'[($P(Z,"|",9)_"|") g loopcn2 I "56"[$E($P(Z,"|",2)) g loopcn2 S Q=$P(Z,"|"),VSC=$P(Z,"|",3) s VOY=$P(Z,"|",4) I $L($$^CMAUTH(%id,CN,VSC,VOY,$P(Z,"|",9))) s Error="" g loopcn2 S YEAR="" I VSC'="" D .S VCN=$P($G(^CDTAB("SEQN",VSC,VOY)),"|") .g loopcn2:VCN="" .S VN1=$G(^CDTAB("VOY",VSC,VCN,"1")) .S VN2=$G(^CDTAB("VOY",VSC,VCN,"2")) .S V=$S(Q="E":$P(VN1,"|"),Q="I":$P(VN1,"|",2),1:"UNK") .S YEAR=$p($zd($P($P(^CDTAB("VOY",VSC,VCN,1),"|",5),",",1)),"/",3) .S R=$P(VN2,"|",9) E S (VSC,V,R)="" g loopcn2:$E(R,1,3)="ATI"!($E(R,1,3)="BOC") S DATE=$zd(I,9) S ARR=$G(DATE)_" "_$zt(J,4) S Q=$S(Q="E":"Export",Q="I":"Import",Q="S":"Recirculation",1:"Unknown") S M=$P(Z,"|",17) s conwt=$p(Z,"|",18) i conwt'="" s conwt=conwt_" Tons" s othersealno=$P(Z,"|",15) s bookingseal=$P(Z,"|",5) s seal=$P(Z,"|",16) s plate=$P(N,"|",11) s trucker="" i plate'="" D .S truckercode=$P($G(^CDTAB("PLATE",plate)),"|",1) .i truckercode'="" S trucker=$TR($P($G(^CDTAB("CART",truckercode)),"|",1),"/","") S shipper="" I YEAR'="" D .S ivn=$G(^IXVH("R",YEAR,R)) .I ivn="" S ivn=$G(^IXVH("R",YEAR-1,R)) .I ivn'="" D ..S BLN=$O(^IXIFM(ivn,CN,"")) ..I BLN'="" S shipper=$TR($P(^BSIFM(ivn,BLN),"|",3),"/","") s dmg=$P(NB,"|",3) S CN1=CN1+1 S M=$S(M="F":"Full Container Load",M="L":"Less Container Load",M="E":"Empty",M="T":"Transhipment",1:"unknown") S K1=CN_"|"_$E($P(N,"|",22),2)_"|"_Q_"|"_M_"|"_$P(Z,"|",2) S K1=K1_"|"_$P(Z,"|",10)_"|"_$P(Z,"|",9)_"|"_VSC_"|"_V_"|"_R_"|"_ARR S K1=K1_"|"_conwt_"|"_$P(Z,"|",2)_"|"_HIS_"|"_GEN_"|"_CN1_"|"_othersealno_"|"_bookingseal_"|"_dmg_"|"_seal_"|"_plate_"|"_trucker_"|"_shipper i $P(K1,"|",2)'="" s $P(K1,"|",2)=$s($P(K1,"|",2)="R":"Received",$P(K1,"|",2)="D":"Delivered",1:$P(K1,"|",2)) S sz=$P(K1,"|",5) i sz'="" s sz=$e(sz,1,1) s $P(K1,"|",5)=$s(sz="0":"20'",sz="2":"20'",sz="4":"40'",sz="9":"45'",sz="L":"45'",sz="1":"10'") i $P(K1,"|",6)'="" s $P(K1,"|",6)=$p(^CDTAB("COMM",$P(K1,"|",6)),"|") i $P(K1,"|",7)'="" s $P(K1,"|",7)=$tr($p(^CDTAB("OPER",$P(K1,"|",7)),"|"),"/","") i $P(K1,"|",8)'="" s $P(K1,"|",8)=$tr($p(^CDTAB("VESS",$P(K1,"|",8)),"|"),"/","") S ^IDXCMAWEB("ROADRECEIVAL",User,RRCTR)=K1 S RRCTR=RRCTR+1 ;now holds the total number of GLOBALS s recctr=CN1 set getrows="" s NewI=I g loopcn2 ;THIS POINT WORKS AND CREATES THE GLOBALS ;####201694:2017-05-18 = GET THE DATA FROM THE GLOBALS JUST MADE ABOVE WITH THE loopcn2 S totrec="" S totrec=RRCTR-1 ;-1 so that the loop clearly shows all records ;totrec will now contain the total number of records. iterate on totrec S ctr=0 ;will contain the current record count S rsult="" ;will contain the total string result, to be written on the notepad Do { S data="" I $D(^IDXCMAWEB("ROADRECEIVAL",User,ctr)) D .S data=$G(^IDXCMAWEB("ROADRECEIVAL",User,ctr)) E D .S data="" S rsult=rsult_"|"_ctr_$P(data,"|",1) ;modify further. this will be the returned string S ctr=ctr+1 } WHILE ctr<=totrec ;Q rsult ;return the results... ;now, we write the results in a notepad file. ;writes the text file. OLD: S FILE="\\SOMELOC\PubShare\theFileToJSON.TXT" S FILE="\\SOMELOC\PubShare\theFileToJSON.TXT" O FILE:"WNS" U FILE S WriteToFile=rsult W rsult ;...we actually write the file? C FILE Q FILE ;display the file? ,将所述全局变量的一部分变成单个字符串。

    Globals正在成功,但没有创建文件。为什么是这样?运行时,它会将RRCTR称为错误

3 个答案:

答案 0 :(得分:4)

当您以递归方式调用代码时,通常会发生{p> <FRAMESTACK>。这不是一个好的编程实践,特别是如果你遇到堆栈溢出错误,你可以配置一个更大的堆栈,但我建议尝试重写你的代码而不是使用递归。

看起来您的<COMMAND>错误发生了,因为您混合了大括号&#34;在你的do..while循环结束时用&#34;做一个点&#34;句法。这不受支持,重写代码的这一部分到处使用大括号:

Do
{   
 S data=""
 I $D(^IDXCMAWEB("ROADRECEIVAL",User,ctr)) {
    S data=$G(^IDXCMAWEB("ROADRECEIVAL",User,ctr))
 } else {
    S data=""
 }

 S rsult=rsult_"|"_ctr_$P(data,"|",1) ;modify further. this will be the returned string

 S ctr=ctr+1
} WHILE ctr<=totrec

答案 1 :(得分:2)

尝试使用&#34;做## class(class).method&#34;而不是&#34;写## class(class).method)&#34;此外,它不是真正的缓存代码,它的Mumps代码和(恕我直言)旧遗产写得很糟糕。就个人而言,你应该重新编写(或支付顾问)

答案 2 :(得分:1)

我同意保罗的观点。使用Go命令'g'进行迭代,而不是例如'无论争论'是非常差的编程习惯。整个事情需要在没有任何Go(“g”)命令的情况下重写。