Download as pdf
Download as pdf
You are on page 1of 12
58 O & » Semone BY nen neonn In this chapter, important VBScript commands fr programming with CATSeip ae liste Abs sa function tha returns the aac alu of «nome (amaun Example! Wo2Ase _Aseis funtion that returs the numerical ANS character code al ofthe ist sharatr inating, Example: Ho. Boolean ‘Boolean is variable ype tat can make vals “rus” or “als” Boanye [Byte isa vaiable ype with amgeof"0"t0°255- o.5cBoot (Book sa fnetion tat churns the rest of gical fest of “Boolean variable pe Example: MH o.cnyte (cayte sa nein tha retur number ouverte to the"Bye arable type Decal pols are rounded the decimal point sequal oo." it is rounded tothe nearest eer number. Example: sm ‘CDate a fueton that transfers an expression int the datetime format with he "Dato" variable ‘ype. The expression mist correspond tothe national convention Ihe expression sa number, the integer part oa dates converte into the factional part of tie. Fone EOae (Capresstol) A fate moscn (CDbLisa function that eras a number converted to the“Doubie” vaviable yp, Fone €001 «(umber Ae eae sampler Hooch ‘Chris function thn converts number toa character ofthe ANSI carat code Examples MH oa0cint (Cts nction hat ems mb converted othe “tees” variale ype. Decimal ples re rounded Ihe decimal point sequal o“0.5itis rounded tothe nearest ever number. Example! MW o.rcing (CLngie funtion that returns «number convert tothe “Lang” variable ype, Dacia ples are mde Ifthe decimal pont is equal 109." it is rounded tothe nearest even number. fone Einar) a8 Long Example: ‘Const declares variable a constant.The following code's asigment values reported a an ror inthe mero. Examples Moascos (Coss tion that calculates the easine ofan ange. The results btveen tneeeued in nan, nd "2 The angle enc Cos (ante) Ae Svble) te Butte Example: Mi oagcsng (Sings fietion that retusa number converted tothe “Single sible type ene CSnp (mbar) Ae Stage Example! Moascstr (Cstris function that converts an expression tothe “Sings pe. Fone EStr ({EaprestenD) As String Example: WH o.6Date ate function tht either designates the “DateTime variable ype (eg, iH /o8/2002 12:94:58 or returns the arent date ofthe operting stem, bee (en Ne) He ate Examples MoayDay Pay isa fnetion that ers the dae as an intezr. Ho. Dim ‘im declares one or more varies Section 18.2), Whether sie funetion or subatine, the Ascaraton x only ali in the statement where trees. Ifthe decaaton made inthe ead ofa rnc. it ali forall fnetions ad sbrotines. Examples Hos9 ding, ‘im () dates viable oct eld (Secon 18.2. The nds i dimension with counting stated at “0 The amenson oa ea ean be changed ina macro wih the ReDim statement Seton 997. Examples 0.20 Double Doubles te vase type for foating plat double precsion, ‘Do-Untldeserbes «Hop with an ni eonaion (Seton 1.9.9) 0.22 Do-White Do-Whiledescibesa loop wi an inp condition (Section 19. Ho. Empty "Empty san uninitaieieatifier or the contents ofa variable ste Scion 98). Mocatnd End maths the nd of faction, subroutine, oop or branch Moas ke Eris an obj thats autora availabe ino aco a ives information about the eror tats ofthe mero, The objet used i conjunction withthe satement On Eeror Resume Next Seton 959. ntzes the abst MH o.20 Exit itis statu that prematurely terminates function, subroutine, loop, brane, oarEp ‘Bxp funtion tha sedate tos power ofa” Example! Moasrix -Fixis auction hat returns the integer portion ofa nue (se Setin 9.3). The decimal places are truest enc Fin (timber) Ae osha) Ae Integer Example! 0.20 ForNext For-Nex deseries an incrementing lop (Section 19.) 9.90 Funetion ‘anetion marks the begining oa function Seton 18.3) Hogi tour Hours function that prints the hour ofa time as aninteger, Example! Mo. 1F Then Hse eTen-Hlse describes araneh Setion L931). 5.33 Inputtion Inpatiox i fusion for test at (Setion 2.2) Inte unetion that determines the postion ofa sbseing “Pan the string “All” The optional prameter“Stat” an be spect, starting rom whieh characteris being compare Example: {Intisafeneton that returns the tee portion of munber (ae Seton 9:28). The etonal part of postive numbers ranated, A negative mnber is rounded othe nearest whole mune. Example: 9.96 Imeger Integer isthe variable type for an integer M ogrisbate IsDate sa function that checks whether an expression isthe “Date-Tine” variable type, The rater "Expresson” ean be the Date" “Sing salable ype, fone Labete (Cbepressfon]) Ae Botean Example: Hogs isEmpty ‘IsEmpty ia function that checks wheter a arabes indie, The faeton returns “Tru ifthe ‘ariableas not et been assigned a va (ee Seton 639) fone Letty (QYarablel se Example! 9.9 IsNull [sNullis funtion that checks whether a variable contains an invalid vale, The function seturs True" ifthe contents of arable ae" (Seton 95). enc tart (hai Ne) As Benton Example: [eNumerici «function tat checks whether «chaste rings number. The fnetionretums “Tre ifthe att expression second asa number fone Latnerte {Stren As String) Az Been Example: WH o.a1Join Joins ution that converts the contents of one-dimensional ancy toString” variable yp. The optional parameter“Doimiter defines character to be witten between each alco he eld ‘ariables I the parameters omitted, a space sted as a delinter, Fone doin (Feld) As Strings (Ue iiter As Strtg]) As Stina Example! WM o.g2case ‘Lease sa function tat converts rng into a sting consisting of lowers eters, fone Lcae ((trta] Az Strog) Ae Stesen Example: Moa ten ‘Lets fneton that retusa specified number of characters fom thee side of tring Fone Left (String) As String, (ber Ae sample! Woasten ‘Lens function hat prints the number of charatersin a sting Fone tan (Sting Ae String) As Tateger Examples Boas tog {Logica function that dotersines the natural gait ofa nub, Anaturl logarithm se base bes Fase Lop {tater} se abt) As bnbte Examples MH o.go Long, {Longisa variable ype foram integer bat hasan increase range of ales Mor Ltvim ‘:rvam ia rneion hat creates a tng tat nes no spaces a he beginning ofthe stan Fone Ue (tring) As String) As Steen Example: ‘Mid sa function that reads a specified numberof hart from astrng “Star™indiats the Postion ofthe fist character. "Leng isthe umber of character ed, incloding te start characte. Fone Wis (Stina) As String. (Start. Lena As Integer) Ao String ‘Minute isa fonction that prints the inate of ie san integer. ene Wine (CHM As bate) as tage Example: 0.50 Mod ‘Mod isan operntor that determines the mods. The moda isthe reminder of mn ntege vin M1 5.51Month, ‘Month ie function that retuns the month ofa date san age. enc Wonth (Cate) Ae ete) As Inteper xample: MH o.52 Msetox ‘MsgBox isa function for text output (Seton 2, MossNow [Now ia fnetion tht stra the cure dat a neo th operating ste, MosaNutt N Ivan dentitier forthe inva content of valable (Ge Section 9.9) ‘Tho On Error Resume Next stems tls the mato to pass runtime eror and jump tothe next instruction, Not: this ttementi ony valid forts respective funtion or subroutine The Ere object (Section 9.25 responds to runtime ezrin the mero. Example: 6.56 Randomize “The Randomize statement inline the rom nuniber generator ee Section 9.60). BW o7Repim. ‘ReDim statenent that esis varie fl to one dtenson (8 Seton 99). sample: M1 os8 Rem ‘Res marks comment ine Re an abbreviation forthe apostrophe character (ae Seton 182). 5.59 Right [Rights function that returns espace numberof characters frm height side of string. Fone High (CString) Ae String, amber] Ae Tatgerd Ae Se Example: 5.60 Rad ‘dis fonction that returns random value btn 0" nls) and 1" (ecsve) Inthe ead ofamacrothat uses the Rnd faction, use the Randomize statement ojntlz the random number generator though the syste lok (Seton 9.50). MH o.1RTHin, [ren isfueton tat rete string that has no spaces atthe end ofthe sting Fone Mee (Ctr) A String) Ae Steen Fxample! 6.62 Second Secondisa faction hat pins the second of time a an integer. Fone Second (Time As Date) As tener Example: 0.09 Select Case Select Case ntvates branch tha separates mutple Bock of statements Section 1.9), MH o.645et Set iret the detnton ofan objet (Section 18.2) MH o.5sin Sin sa funeton hn cleats the sine of on angle. The rest isbeteen ‘neasued in eins, end "1"The angles enc Sin (Cte) As Sobled As Dosbte Example: 0.06 sinsle Single arable ype fo sting point sing reson WH o.678en Sg function hat deters the sgn ofa number The fuetion can take the values," "0 an "the mumiber sega the unetion value ls." the number aero the vale 0. Example: W o.08sqr ‘See fetion that determines the square rot of wumbe. enc Sar (Chanter) As Double Example! 0.60 StrReverse SteReverse sa faneion that reverses the sequence of carters in sting anc Steavere (tring) As String Ay Sting Example! Bozo string Strings variable ype fo mocisub Sul mari the beginning of subroutine (Seton 83,2) oretan ‘Tan sa faton that calults the tangent ofan ange The angles measured ans Examples Mors Time “Times function hat eur the current tine of he operatingsystem. Example: Mor4Timer “Timer is fnetion ht prints the be of seconds tht hve apd from dit (perting syste tne). This nein en be stopped with maeeo times. Example: BW orsTime' “TimeValue isa function that ners time from string oF extracts a proportion © tins from | date Utapression) As tate Examples “Trims funtion that cents string that has no spaces at the beginning or end of thet, Example: Mocrucase {Weave funtion hat converts sting into sting consisting of uppercase eters. Example: Mora Year ‘Yeni function that returns the year of date a an inte fone Year (ste) he ate) Ae Integer Example! oF tyne emote ey Findansnerson teyormaser something ne Subserbe toda. See ington

You might also like