Upload
ese-ichekor
View
218
Download
1
Embed Size (px)
Citation preview
8/10/2019 PML intro
1/32
A query on usage in the field: how much do you use the $ comments (either $* or $(...$) )?
(For those of you at the ISI!s this is to do with "u#lished "%...)
I want to #e a#le to stri& comments when &u#lishing the "%' and am wondering ust howmuch trou#le to go to with wierdly nested and hidden comments (I will neer mangleanything' #ut might not stri& all the comments if you do really odd things)
I use the $* comments as much as &ossi#le. S&ecially #ecause I+m the ,ind of &erson who willwrite a macro and forget a#out it and - months later someone is as,ing me to add some newfunction to the macro. I try to add as much comments for my own &ersonal #enefit.If you are new to &ml and you want to ma,e life easier. I suggest you try to comment as muchas &ossi#le. Also' name you macros something that will ma,e since -months to een yearsfrom now. I hae s&end hours' days een months writing macros only to mis&lace them. y
adding as much comments' you are not only ma,ing your life easier #ut your em&loyeer aswell. !his go #ac, to the ISI! meeting.
/0ont....mate its sim&ly awesome.....ery useful...&lease ,ee& it u&....
I rec,on #etter add the A%"1A %23 command...where you can ta,e ur logs to a file and notflood ur command line :)
---------------------------------------------------------------------------------------------------------------------4es I agree.
5hen using the !rac,ing' you might want to use the al&ha log command first. !ry this.
Alpha log /C:/test.txt overy adding the oer' I am oerwriting any file with the name !est.t6t
!urn trace on$R6
!han' using the &ull downsModify > Name
!he modify name form will come u& and your command line filled with te6t.$R!o turn off the !race
Alpha log end!o end the log
2&en the .t6t file and chec, out some of the code. !hat is how I learn &ml' #y reading aea+scode.
/ust a note: 4ou are only allowed to hae one log file o&en at the time. Another o&tion will #eto use Al&ha Files. I+ll get to that later.
I ust found this and I wanted to &ass it on....noy
$78n9
; !racing to shell window (default)< ; !racing to requests window
8/10/2019 PML intro
2/32
= ; !racing of only in&ut lines e6ecuted> ; !racing of all in&ut lines- ; !racing without $ e6&resion (default off)< ; !racing includes line num#ers-= ; !racing of macro@function changes ; 3eneral Be#ugging< ; ca&ture trace in A%"1A %23
0an also do $17 at the command line to get all o&tions for $7
---------------------------------------------------------------------------------------------------------------------Cuote:
2riginally "osted #y Timharro!"A query on usage in the field: how much do you use the $ comments (either $* or $(...$) )?
(For those of you at the ISI!s this is to do with "u#lished "%...)
I want to #e a#le to stri& comments when &u#lishing the "%' and am wondering ust howmuch trou#le to go to with wierdly nested and hidden comments (I will neer mangle
anything' #ut might not stri& all the comments if you do really odd things)
1ello !im'
I use $( and $) for large #loc,s of comments or for quic, trou#le shooting. ut for indiiduallines of code @ comments' I will normally use DD #ecause I do not need to hold down the S1IF!,ey to get the DD to a&&ear (quic,er commenting for single lines).
From your &ersonal o&inion' is there a &reference #etween $* and DD ? Boes one singleDlinecommenting method wor, #etter than the other? /ust curious ...
1ae a lessed Bay
If I do not remem#er wrong' you cannot use DD for inline comments where you can use the $*synta6.
li,e:handle any$* !a,ing care of a &ro#lem. If I remem#er correctly you cannot do this with DDendhandle
I recall reading somewhere that DD can only #e used for commenting whole lines.
=====================================================================
Cuote:
2riginally "osted #y T#a!"If I do not remem#er wrong' you cannot use ++ for inline comments where you can use the $*
synta,.
yes that is the case.
Cuote:
2riginally "osted #y provers%:6From your &ersonal o&inion' is there a &reference #etween $* and ++ ? -oes one single+linecommenting method wor #etter than the other? /ust curious ...
8/10/2019 PML intro
3/32
at the start of the line they are treated identically' so no &reference
!his is the macro I am using to test comments so far D I hae lots more odd things to add
0ode:
$P this macro tests comments in various formats
$* $P this is an ordinary one-line comment$P this line is not a comment-- $P this is a new-style comment$P this line is not a comment either$( $P a short 'multi-line' comment $)$P I am not a comment - I am a free line!$($P a long multi-line comment$P yes, I mean it$)$P now to test some combinations$P start a new-style -- in the middle of a $P$P start an old-style $* in the middle of a line
$P embed a multi-line $(lie this$) in the middle of a line$P try hiding a multi-line with old-style$* $($P I wonder if this will come out$* $)$P try hiding a multi-line with new-style-- $($P I wonder if this will come out instead-- $)$ what about the end of a multiline"$($P this is within a multi-line$* $)
$P this is after a hidden closer
$P this is at the end
I didn+t ,now I could comment out &art of a line with the $*.
awesome
(#%)
!hat is the #eauty of using the $* comment synta6. 4ou canwrite them on the same line as the actual code.
1i gentlemen'
I am used to run a macro loaded with my faourite synonyms when I start "BS. So I tried touse the command $CS as I saw it in the first &ost. Eow I see in command window the list andI would li,e to get clear something.
http://www.pdmsworld.com/forum/showpost.php?p=4479&postcount=17http://www.pdmsworld.com/forum/showthread.php?t=1137&page=2#top%23tophttp://www.pdmsworld.com/forum/showpost.php?p=4479&postcount=178/10/2019 PML intro
4/32
!here are synonyms with $S #efore the synonym descri&tion. 6am&le :
$S AA ; add all within olu ce $S
!hen I hae here synonyms with $S (all my syns some more). 6am&le :
$S F3F ;new fla choo all new gas, choo all new fla choo all (short sequence for inserting &airof flanges)
And then finally there are some synonyms with $SG for running a macro. 6am&le :
$SG 0A%% ;$@H"BSGIH@BS@CGI@$S
I don+t understand the difference #etween $S' $S' $SG. Is it su&&osed to #e an argument?Are not arguments in general $n D without +S+? 5hat does it actually do? And why it says :
(=') 0": Illegal macro format
5hen I try to run the macro for myself (in this case : $@H"BSGIH@BS@CGI@$S )?
2ne question...
5hy J$*J and JDDJ are not equialent?
J$*J wor,s any &osition in the line' and JDDJ wor,s only at the #eggining of the line.
5hy AKKA designed the comment li,e that? Any reason?
"ossi#le to use $7L @FI%.name
8/10/2019 PML intro
5/32
&M' #asi!s &art ( )Creating an Array* + D
8/10/2019 PML intro
6/32
and so on.....
5hat is the difference #etween ty&e and ty&e
8/10/2019 PML intro
7/32
ar !-ae" ea#ate (-ae) /or a## /ro !Ppe"
!Ne0Po"to-" = !-ae".'orted-dce"()
!-ae"."ort()
ar !%o-e" ea#ate (-ae o/ %o-e) /or a## /ro !Ppe"
ar !p"pe" ea#ate (p"pe) /or a## /ro !Ppe"
ar !"pe" ea#ate ("pe) /or a## /ro !Ppe"
ar !"tat" ea#ate (:"tat") /or a## /ro !Ppe"
!%o-e".Re-dex(!Ne0Po"to-")
!p"pe".Re-dex(!Ne0Po"to-")
!"pe".Re-dex(!Ne0Po"to-")
!"tat".Re-dex(!Ne0Po"to-")
do !Ppe -dex !Ppe"
!record = !-ae"1!Ppe2 + |$!xTab| + !%o-e"1!Ppe2 + |$!xTab| + !p"pe"1!
Ppe2 + |$!xTab| + !"pe"1!Ppe2 + |$!xTab| + !"tat"1!Ppe2
!otpt.appe-d(!record)
e-ddo!/#e = object 34E(56P7M'"er68$!MyProj9Ppe4"t.txt*)
!/#e.0rte/#e(5OER;RTE*
$p
$p Macro /-"ed
Resulting sample output of PML report (623records:PPE ,ONE P'PEC 'PEC :'T&TU'
>?@A7?BD?A???FDAGHADDD? >PPA?BDDDAB? >???FDAGH =D>D ?
>?@AR?BIDDIA??DFAR >PPA?BDDDA34&RE >???FDAGH =D>D ?
>?@AR?BIDDA??DFAR >PPA?BDDDA34&RE >???FDAGH =D>D ?
>?D@AK?BIDD?A??FDAG?ADDD?A? >PPA?BDDDA34&RE >??FDAG? =D>D ?
>?D@AK?BIDDIA??FDAG?ADDD?A? >PPA?BDDDA34&RE >??FDAG? =D>D ?
>?D@AK?BIDA??FDAG?ADDD? >PPA?BDDDA34&RE >??FDAG? =D>D ?
>?D@AK?BIDLA??FDAG?ADDD? >PPA?BDDDA34&RE >??FDAG? =D>D ?
PML2 with code for selected pipeattribute output:!Project = CURRENT PROJECT
!MyProj = !Project.code()
$p
$p Project: $!MyProj
$p
!T0#d = ||
!xTab = | |
8/10/2019 PML intro
8/32
!otpt = object &RR&()
!xRec = |*PPE| + |$!xTab| + |,ONE| + |$!xTab| + |P'PEC| + |$!xTab| + |
'PEC| + |$!xTab| + |:'T&TU'*|
!otpt.appe-d($!xRec)
!Co##ect = object CO44ECTON()
!Co##ect."cope(;OR47)
!Co##ect.type(5PPE*)
!Co##ect.expre""o-(object EPRE''ON(5'UK'TR(N&ME
8/10/2019 PML intro
9/32
>?@AR?BIDDA??DFAR >PPA?BDDDA34&RE >???FDAGH U-"et ?
>?D@AK?BIDD?A??FDAG?ADDD?A? >PPA?BDDDA34&RE >??FDAG? U-"et ?
>?D@AK?BIDDIA??FDAG?ADDD?A? >PPA?BDDDA34&RE >??FDAG? U-"et ?
>?D@AK?BIDA??FDAG?ADDD? >PPA?BDDDA34&RE >??FDAG? U-"et ?
>?D@AK?BIDLA??FDAG?ADDD? >PPA?BDDDA34&RE >??FDAG? U-"et ?
8/10/2019 PML intro
10/32
&M' #asi!s &art % )Creating a 'oop* + D
8/10/2019 PML intro
11/32
$" $0ollQ$6R has the wrong 3ty&enddo
or
Bo 6 alues 0oll$" $6 has the wrong 3ty&e
nddo
4es !han, you #hnst. ee& them coming.
5hen you use the:
9o ,x indi!es ,CollT is still a num#er
ut when you use:
9o ,x val8es ,Coll6 is now the item or an element
ore e6am&les' this is a request #y ?@6&9M
. 1ow can we assign alues to elements using "%...e.g. If you hae to assign &s&ec @A!2 A%% "I" 5I!1 27 SIN
First' 4ou hae to do a collection for all "i&e with #ore eq . Again' citte has a greatthread on collections going on.
ar ,&B&4 C2'' A'' )&B&4* BTD )&ARAM0 2E CATR4E 2E &C2 4F GG* E2R $,,C4
9o ,x indi!es ,&B&4
$,&B&4$,x0&&4C /A%GGDandle Any $H hy did B add a Dandle the pipe !o8ld of een !laim or lo!"ed this
8/10/2019 PML intro
12/32
Are you going to e6amine 2/0!S' es&ecially the 02%%0!I2E 2/0!. And the use of thiso#ect? %i,e you &ointed out in your thread' the other collections thread e6&lores multi&leways to create the collection using #oth "% and "%
8/10/2019 PML intro
13/32
Ee6t' notice I as,ed for the p ore' this guarantees me that I will add an element with atleast one side of it matching my criteria' I could add more criteria to guarantee that I getanything that has as a #ore' &' &< ' & etc. ut #y as,ing for catalogue &arameters' I+massuming that my catalogue administrator hasn+t done anything silly with the first &arameter.An eent that has undone me in the &ast.
Also' to clean it u& a #it' you don+t need the $0' ust 0 will do.
!i&: on anything that has a S"7 with a 0A!7F' the 0A!7F is also aaila#le for query fromthat element. So instead of 0A!7F of S"7' (I would not say S"02' as that is an element'and not a reference)' you could ust call the 0A!7F' it is a &seudo attri#ute.
I+e heard some really good things a#out you cont
8/10/2019 PML intro
14/32
EewEame ; M.efore(+"7+) +"7%I+ $* 5ill ta,e current name M' stri& off "7' andadd "7%I7ename $EewEame$& $M renamed to $EewEame $*/ust "rints the old and new to command linendBo
ndFunction
0an #e done in one row...
Cuote:
2riginally "osted #y ?@6&9M-o y indices "0123"01234y5.-#ref().3ame 6 "01234y5.-#ref().3ame.0e&lace(7+"07'7+"0%I7)8andle any$& rror on $&r9one4$y5nd8andlenddo
3uyM than,M a #unch.....
V!#ac,tried ur code and it wor,s #eautiful.....
Vccottoni+ll also try urs and see how it goes....ust wondering wats the diff #@w
atch and atch5Bo alues and Bo Indices
Cuote:
2riginally "osted #y ?@6&9M
ust wondering wats the diff #w
atch and atch;-o alues and -o Indices
atch(EA 2F N2E' WA0W)EC()$*If somewhere in the name of the Mone the letters A0 a&&ear then this e6&ression is !rueatch(EA 2F N2E' WA0W)C()
$*If the letters A0 does not a&&ear then the e6&ression is !rue
atchw(EA 2F N2E' W*A0W)$*%et say the name is /(%+A#C' then this e6&ression is !rue$*%et say the name is /A#C+(%' then this e6&ression is False. It wor,s li,e windows search.In order to ma,e this e6&ression true' it would hae to read li,e this.atch5(EA 2F N2E' W*A0*W)
$* 0oll is an arrayBo 6 alues coll
8/10/2019 PML intro
15/32
$T $* in this case' T is a reference num#er
Bo 6 indice coll$T $* in this case' T is a num#er ('
8/10/2019 PML intro
16/32
0ould anyone tell me if i+m correct on my assum&tions..
!o #rea, down the first line...
ar 0oll D this defines a local o#ect of this name
coll D is this a commmand to ma,e a collection ?
$0 D this is a glo#al o#ect of this name
$" $0ollQ$6R has the wrong 3ty&e D what do the square #rac,ets do QR ?
!han,s for the hel&...Eeil
0oll is array of sections+s and gensecs+s names whose gty&e not equal gty&e of catref. It iscollection from current element ($0).0oll D you are right' this is command to ma,e collection and to store it in array 0oll.
$0 gies reference num#er of 0.$" $0ollQ$6R D in QR num#er of array+s element is indicates' in this case $6 is num#er ofcurrent cycle of the loo&.
Alright' Sorry I hae #een gone for so long' I hae #een e6tremely #usy li,e eeryone else inthe "BS community.
1ere is a small sim&le macro to using a do loo&.
ulti&le co&y command for draft
0ode:
0e>ne unction !!9ultioy()
!& urrent &essionIf !&59odule()52.('06+') hen return2nddo
!element !!ce0o ew $!2lement5ye coy rev =n I0 ? ;andle +ny refresh
return 2nd;andle2nddo
2ndunction
1elloIm a new#ie and Im trying to ma,e a loo& that collects the names of all sheets in a s&ecific
8/10/2019 PML intro
17/32
regi and writes them to a logfile. 0an any#ody tell me what im doing wrong?
@"I"%A42G!@
ar sheename collect all S1 for 73I
File ; o#ect file(+0:@"[email protected]+)
Array ; o#ect Array()
ar sheename collect all S1 for 73Ido i IEBT sheenameKA7 EA$Array.A&&end($K)
enddoFile.writefile(+oerwrite+'Array)
!he array dont seem to #e accessi#le inside the do loo&
0hange J $Array.A&&end($K)J to JArray.A&&end(K)J and you should #e 2.
!han,s for the quic, res&onse. ut it didnt wor,. Cuite confusing with all the $ . !his is mycode at the moment2E7727 02E!IEG
@"I"%A42G!@
File ; o#ect file(+0:@"[email protected]+)Array ; o#ect Array()
ar sheename collect all S1 for 73Ido i IEBT sheename
KA7 EAArray.A&&end(K)enddoFile.writefile(+oerwrite+'Array)
Slight modification then. 0hange your doDloo& to this:do i IEBT sheenamename ; nameArray.A&&end(name)enddo
than"sI than, for all this ,ind of &osts' #ecause i+m getting startiing in "% and it+s ery usefull toget this info...
Cuote:
2riginally "osted #y ditG(lt!hans for the quic res&onse. 23!I3
http://www.pdmsworld.com/forum/showthread.php?p=13237#post132378/10/2019 PML intro
18/32
"I"%A@2!
File 6 o#ect file(7>:"lotsnames.log7)Array 6 o#ect Array()
ar sheename collect all S8 for 0Ido i I3-B sheenameCA0 D 3AArray.A&&end(CD)enddoFile.writefile(7oerwrite7'Array)
unless I am ery much mista,en (and I could #e) as you haent naigated to the sheet namethe ar name will always #e the same."ersonally I would do it this way (its a #it more "%< li,e as well)
0oll ; collectallfor(+shee+'++'ce) D assuming you are at the 7egiBo A indices 0ollArray.a&&end(0ollQ$AR.name)
*and of course at this &oint I cant recall if itsR.name)orR.name()) D old age
nddo
that way you dont naigate (as you dont need to)
File.writefile(+oerwrite+'Array)
att
u are not missta,ing. Ie added another row to the code $S1EAQ$iR.I must say your solution loo,s #etter #ut mine wor,s.!han,s anyway
h%%2 K742E
B1m Daving tro8le
8/10/2019 PML intro
19/32
so' this is su&&osed a multifunction macro :D)
this is my code (#ased on what+s e6&osed here)
Cuote:
$* "7!EB 1A07 GEA A072 CG 0AI GE A!7IG!2 A !2B2S %2S %E!2S
$* $ B% 0G77E! %E!.$*$* $ ; !I"2 B %E!2S E %2S CG A"%I0A %A A072$* $< ; A!7IG!2$* $ ; KA%27 B% A!7IG!2 FIEA%$*
$* 07A GE A77A4 J02%00I2EJ CG 702%0!A !2B2S %2S$* A73GE!2S $ "A7A % 0.$*DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD$* mAS AE A77A4 J02%00I2EJ AEB 02%%0! A%% !1 $ IE !1 0KA7 02%00I2E 02%% A%% $ F27 $0
$* A%A0EA E y %2S IEBI0S B J02%00I2EJ 4 3E7A GE %22"
$*DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD$* AS A %22"B2 4 IEBI0S 02%00I2E
$*$02%00I2EQ$4R
$* 0AIA % A!7IG!2 $< 4 % ASI3EA % KA%27 $$*DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD$* 01AE3S !1 A!!7IG! $ 5I!1 !1 E5 KA%G $$< $
$* 02E!72% B 7727S'$*DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
$* 02E!72% 77271AEB% AE4
$* GS!7A GE ESA/ B 7727 E %A %IEA B 02AEB2S$"7727 2E $02%00I2EQ$4R
EB1AEB%
EBB2
i 1AK !7IB 5I!1 !1 A%!7EA!IKS !1A! 42G S125 17 %I
Cuote:
$* "7!EB 1A07 GEA A072 CG 0AI GE A!7IG!2 A !2B2S %2S %E!2S$* $ B% 0G77E! %E!.$*$* $ ; !I"2 B %E!2S E %2S CG A"%I0A %A A072$* $< ; A!7IG!2$* $ ; KA%27 B% A!7IG!2 FIEA%
8/10/2019 PML intro
20/32
$*
02%00I2E ; 02%%0!A%%F27(+$+'++'0)
$* A%A0EA E y %2S IEBI0S B J02%00I2EJB2 4 IEBI0S 02%00I2E
$* S SI!GA E % %E!2 CG S BSA 0AIA702%00I2EQ4R.$< ; $
$* 02E!72% B 7727S'1AEB% AE4
$* GS!7A GE ESA/ B 7727 E %A %IEA B 02AEB2S$"7727 2E $02%00I2EQ$4R
EB1AEB%
EBB2
G! I! BIBE+! 527... I !1IE !1A! IS 0AGS !1 0 IS A F75 AEB !1 SE!E0 J02%00I2EQ4R.$< ; $J !74 !2 01AE3 !1 A!!7IG! !2 !1 F75 IES!AB 2F !1S0!E (I 1AK "72KB 5I!1 J02%00I2EQ4R./GS% ; !2SJ !22)... am I right?
52G%B 42G 1%" ' "%AS?
0hristiansen'
try this....
0ode:
!+6I@72 $A
!=
8/10/2019 PML intro
21/32
!+6I@72 '$A'
it wor,s...
the final &rogram isCuote:
A!!7IG! ; +$
8/10/2019 PML intro
22/32
!=
8/10/2019 PML intro
23/32
1) Pipe form macro
These file contain pipe form which will create a pipe as per project set-up (admin have to define)
& simultaneously set attributes :lsize duty :lproc :lsno Pspec Ispec Tspec :Areacode :lsuf :Isoref:Mtoref :Mtodrwg :Mtoarea
As per project philosophy
Procedure:
Go to respective zone clic !new pipe"button then feed the value & then apply
#f insulation or tracin$ spec if not defined in line number don"t leave blan put !unset"
& if insulation or tracin$ spec is defined put spec name followin$ forward slash !%"
or e'$'
T*T T+, A./
8/10/2019 PML intro
24/32
8/10/2019 PML intro
25/32
&M' #asi!s &art I )4xpressions and BE statements*
5ell' I hae coed Arrays and %oo&s. Eow I want to start getting in to e6&ressions and Ifstatements.
efore we get started writing our own e6&ressions. I remem#er when I was first learninge6&ressions' I turn to the manuals. If you hae a chance' &lease chec, it out. ut' since I,now most &eo&le don+t really o&en the manual' I+m going to &ost the &art on e6&ressions.
we need to ,now some 2&erator:
. #ra!"ets )*(. H /%. J +I. 4F N4F 'T '4 34 3TK. N2T6. AN9?. 2R
Eow' when writing an e6&ression' thin, #ac, to high school math or een middle schoolmath when you learn how to sole nested e6&ressions.)I H )&24R)&ARA0 (* J &24R)&ARA(0 (* *
4ou hae seeral different ty&es of e6&ressions:
'ogi!al expressions
"BS attri#utes
%ogical constants
TRUE, ON, YESfor true
FALSE, OFF, NOfor false
%ogical 2&erators0on&arator o&erators (EQ, NEQ, LT, GT, LEQ, GEQ)oolean o&erators (NOT, AND, OR)
%ogical functions
AB7F
BFIEB' GEBFIEB07A!
B%!B"!4
A!015I%B2BIFIB
GES!K%23I0A%
'ogi!al array expressions
"BS attri#utes
Ex: XLEN YLEN POHE POSITION ORIENTATION
!he ,eyword "I('=
8/10/2019 PML intro
26/32
+ Add
- Subtr!t" #u$t%&$'
D%%d*
Eumeric functionI+m not going to list all of them #ut some of them are:
AS, AOS, ASIN, ATAN, SIN, OS, TAN, #ATH, #AX, SQRT
Real expressionsS** .u/*r%! 0u.t%1.2
Real array expressions
Text expressions
A te6t string
"BS attri#utes
!e6t o&erators
!e6t fuctions
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYYYYYYYYYY
2,' lets start creating some If statements using some of this e6&ressions. !his is an e6am&leI li,e to use a lot.5hen users descoer that they can create sctns using synta6' sometimes they forget tochange all the attri#utes. 2ne of those attri#utes will #e the 3!4". So a sim&le e6&ressionwill #e:
,Catref - 3type of Catref,!tn - 3type of !tn
Bf ),Catref ne7 ,!tn* Then
3type $,CatrefDandle any $H B try to add a handle any
8/10/2019 PML intro
27/32
I tend not to use the ce as you hae to naigate to it within "BS' I find it safer to createsay an array of items (which will #e d#refs) then query or assign accordingly e.g.
$* assign some aria#lesFile ; o#ect file(+H&dmsuserH@[email protected]+)Array ; o#ect Array()
$* collect some items0oll ; collectallfor(+el#o+'++'world)
$* action the collectionBo A indices 0ollIf (0ollQ$AR.catref.u&case() ne +TTTT+) then$" we missed this one DD $0ollQ$ARArray.a&&ned(0ollQ$AR.name)lsesome other actionndifndoo
$* see if we found any data errors' if so out&ut to a file and adise userIf (Array.siMe() gt )thne$" we hae an out &ut error@log fileFile.writefile(+oerwrite+'Array)lse$" it all went wellndif
$* get user to ac,nowledge the macro has finishedAlert.message(+4ou hae now finished+)
1ello'I+m a new "BS@"% user' I+m ust learning.0an any#ody hel& me in macro writing?I would li,e to ma,e a macro in "%' which is counts the ales and el#ows in a current siteand write the result in a file.
I try to ma,e it since two days' #ut it isn+t wor,s."lease hel& me' if you can ...
I+d use the in#uilt JcollectJ function
Kale ; collectallfor(+al+'++'ce) DDD ce ;;9 ce' in this case the site you want to collectales froml#ow ; collectallfor(+el#o+'++'ce) DDD ce ;;9 ce' in this case the site you want to collectel#ows fromKaleSiMe ; Kale.siMe()l#owSiMe ; .......
Bo the same for other com&onents then create an arrayItemsQR ; (+num#er of ales + U KaleSiMe)ItemsQ
8/10/2019 PML intro
28/32
If you want to do it for a num#er of sites then collect the sites into an arraye.g. Sites ; collectallfor(+site+'++'world)
and create a do loo&
Bo A indices Sites
$SitesQ$AR8the do the collection a#oe98write to the file D File.writefile(+a&&end+'Items)nddo
ut why not ust use the 7e&orts facility.
Cuote:
2riginally "osted #y !sig8s=!han you att
(I can do it with re&ort facilities' #ut I7d lie to learn the "% &rogramming)
!hans again
%Eri
Seems fair. In the File.writefile() &art you hae the o&tion to either +oerwrite+ or +a&&end+. If Iwas using a B2 loo& I would delete the file first (File.deletefile() ) #efore I started the B2loo&' that way you ,now you are starting with a clea# file.In the 0ollectallfor(...) funcntion' you hae three o&tions' the first is a String and you su&&ly
what you are loo,ing for' teh second is a conditional string i.e. if you only want the first stringto match an attri#ute' the third is a d#ref' so ce or world wor, (or any other d#ref aria#le)
If I wanted el#ows from sites that were &i&ing site I would set all my FGE0 attrri#utes on the"i&ing sites to "I" and then collect in this wayls ; collectallfor(+el#o+'+Func of site eq W"I"W+'5orld)
att
"lease #e noted that 02770! o#ect' 0ollect() function' 0ollectAllFor() function' 0ollectAll5ithin() function' 0ollectem#ers2f() function' are not real #uilt ino#ect@functionAll those are defined #y "%< macro using JKA7IA% KA7EA 02%%0! ZZZJ command.!hose consumes more &rocessing time for conerting search result from String to B7ef.
If you are familier with JKA7 KA7EA 02%%0! ZZZJ and JKA7 KA7EA KA%GA!ZZZJ'and some sort o&eration' I don+t see any #enefit to use those o#ects@functions.
Eote that "%< style couldn+t #e always good
Sorry to say that I+m ha&&y with "%< and don+t really see to much of this &rocessing time. Ido some heay collections and I really don+t see a #ig &roccess time' not at lease something tocom&lain a#out. If I use &ml collecting var ,!oll !oll' the collection is a string and I reallydon+t want to #e conerting or adding e6tra lines to conert it into a d#ref()' the smaller themacro' the easier to understand. !hat+s the way I see it.
I agree'ar coll collect all ( %2 ) for 0 (or name of element research)'
http://www.pdmsworld.com/forum/showthread.php?p=11336#post113368/10/2019 PML intro
29/32
and ne6t:ar collname eal name for all from coll(for ealuate name of all of &reious list)
5hy not0 ; o#ect collection)*
0.sco&e(ce)0.filter( o#ect T"7SSI2E( +true+ )0.ty&e(+%2+)Eames ; o#ect A77A4()B#refs ; 0.results()do B#ref alues B#refsEames.a&&end(B#ref.flnm)enddo
Few more lines #ut much #etter code
I agree that "%< style is good for &eo&les who already familier with the other &rogramminglanguage' and I ,now that it is mandatory to ,now "%< with "BS < .net &rogramming.
If eery#ody satisfy with current condition' it is fine.ut' I #eliee that if no#ody com&lain a#out #ad thing with "BS' it will neer #e im&roed.
ery#ody should ,now that if the "BS user is waiting for sec. macro &rocessing time' he
will do nothing' ust wait for the o&eration is done.4ou+ll see what will ha&&en if this o&eration is iterrated many times ' done #y many &eo&les'eery day.
Anyway' now we hae "BS
8/10/2019 PML intro
30/32
ar for W for ceWendifar com& collect all #ran mem with ty&e neq WIES!W and ty&e neq WFI%!W $for $* 7emoeinstrument and S" itemar ty&e eal ty&e for all from com&ar or eal or for all from com&
ar dt6r eal dt6r for all from com&ar sort sort ty&e ciascii or numeric dt6r ciasciiar out&ut a&&end W!4"'"27'B!T7Wdo i indices sortar out&ut a&&end W$ty&eQ$iR'$orQ$iR'$dt6rQ$iRWenddofile ; o#ect file(Wc:[tem&[list.t6tW) $*this is "%< style' this is useful.file.writefile(W2K7W'out&ut)DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD5ith "% style' no need to declare aria#le ty&e.!he Jar 8ar9 ealuate 8attri#ute9J does not wor, if the 7AE has #ad S"7F.(In the real &roect o&eration' often we see &i&ing com&onents which looses S"7F.)so I modified the code li,eP (try to use more "%< command in here)DDDDDDDDDDDDDDDD
ty&e ; o#ect array()#ore ; o#ect array()dt6r ; o#ect array()if ce.ty&e eq W527%W thenfor ; WWelsefor ; W for ceW
endifar com& collect all #ran mem $fordo alues com&$if #adref(ce.s&ref) then$" $ has #ad S"7F $* 5e can+t use J write +te6t+ J command in tty mode. !his is why Iuse this.
s,i&endifty&e.a&&end(ce.ty&e)ore ; ce.ore $* this line may #e wrong.. could #e ce.#oreQR?#ore.a&&end(ore.real().string()) $*4ou+ll ,now why we need this.dt6r.a&&end(ce.s&ref.detre.rte6t) $* does this wor,???enddoar sort sort ty&e ciascii #ore numeric dt6r ciascii $* all the sort ,ey alue must #e stringty&e.out&utQR ; W!4"'"27'B!T7W *$ &ut first array element instead of declare this as arrayo#ectdo i indices sortout&ut.a&&end(ty&eQiR U W'W U orQiR U W'W Udt6rQiR)enddo
file ; o#ect file(Wc:[tem&[list.t6tW)file.writefile(W2K7W'out&ut)DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEot so good code' #ut more &ractical than the first e6am&le... I didn+t test the a#oe macroyet' cause I+m in home.
I still hae no good idea to use .sortedindices() method for an array aria#les which containsmi6ed sort ,ey ty&e' I mean string' real' and so on.
Anyway' wait for "BS
8/10/2019 PML intro
31/32
D=D
8/10/2019 PML intro
32/32
So when we see defined@undefind' set@unset condition with aria#le?
"lease try to co&y the attri#ute alue to your aria#le' and use the function@method a#oe.I recommend you to use Jaria#le ; Qattri#ute nameRJ command to get what ty&e of o#ectwill #e loaded to your aria#le. if we use Jar aria#le Qattri#ute nameRJ command' we alwaysget string alue' and this will #e the same alue as we see #y JC Qattri#ute nameRJ (Qattri#ute
nameR can #e J"2SI!I2EJ' J27IE!A!I2EJ' JFGE0!I2EJ' etc.
"lease #e noted that the Jem&tyJ te6t string and JunsetJ alue is different.Jem&tyJ te6t string will #e recogniMed as JsetJ alue.
Also #etter to test the B search command result.