Dataset Viewer (First 5GB)
Auto-converted to Parquet
content
stringlengths
27
653k
pred_label
stringclasses
2 values
pred_score_pos
float64
0.5
1
Drosophila Tufted Is a Gain-of-Function Allele of the Proneural Gene amos Eric C. Lai Tufted is a classical Drosophila mutant characterized by a large number of ectopic mechanosensory bristles on the dorsal mesothorax. Unlike other ectopic bristle mutants, Tufted is epistatic to achaete and scute, the proneural genes that normally control the development of these sensory organs. In this report, I present genetic and molecular evidence that Tufted is a gain-of-function allele of the proneural gene amos that ectopically activates mechanosensory neurogenesis. I also systematically examine the ability of the various proneural bHLH proteins to cross-activate each other and find that their ability to do so is in general relatively limited, despite their common ability to induce the formation of mechanosensory bristles. This phenomenon seems instead to be related to their shared ability to activate Asense and Senseless. ALTHOUGH the nervous system of the fruitfly is quite complex, it is also highly stereotyped. These characteristics make it an ideal experimental system for understanding basic principles of pattern formation. Accordingly, studies of how the Drosophila nervous system is assembled have occupied the collective efforts of hundreds of developmental geneticists over the decades. The pattern of sensory organs in both the embryo and the adult is prefigured by the spatially patterned expression and activity of the proneural genes, which encode basic helix-loop-helix (bHLH) transcriptional activators (reviewed by Bertrandet al. 2002). Proneural activity confers neural potential upon groups of adjacent cells referred to as proneural clusters (PNCs). Interactions among PNC cells restrict this potential to sensory organ precursor (SOP) cells; non-SOP cells of a PNC usually adopt a nonneuronal fate. This process is commonly referred to as “lateral inhibition” and is mediated by cell-cell signaling via the Notch receptor and the products of the neurogenic genes (reviewed by Artavanis-Tsakonaset al. 1999). Once stably specified, the SOP typically undergoes a fixed series of cell divisions to generate the different cells that make up a mature sensory organ, although nonclonally related cells are recruited into certain types of sensory organs. In the case of the mechanosensory bristles, divisions of the SOP generate five cells: a socket cell and shaft cell (which produce structures that are visible from the exterior) and a glial cell, sheath cell, and neuron (which lie beneath the cuticle; Ghoet al. 1999; Reddy and Rodrigues 1999). The glial cell subsequently undergoes programmed cell death, leaving four cells in the mature mechanosensory organ (Fichelson and Gho 2003). There are two subclasses of proneural bHLH proteins. The Ato class includes Atonal (Ato) and Absent solomultiple-dendritic (MD) neurons and olfactory sensilla (Amos); Ato controls the development of chordotonal organs, R8 photoreceptors, and a subset of olfactory sensilla (Jarman et al. 1993, 1994; Gupta and Rodrigues 1997) while Amos regulates the development of certain MD and olfactory neurons (Gouldinget al. 2000; Huanget al. 2000). Members of the ASC class are encoded by genes in the ac-sc complex (AS-C; Alonso and Cabrera 1988) and include Achaete (Ac), Scute (Sc), and Lethal of scute (L’sc). Ac and Sc are the proneural proteins for the adult mechanosensory bristles (García-Bellido 1979), while L’sc controls the development of the embryonic central nervous system and musculature (Martin-Bermudoet al. 1991; Carmenaet al. 1995). A fourth member of the AS-C, asense (ase), also encodes a protein with an ASC-class bHLH domain. It is not, however, a true proneural protein as it is expressed only by SOPs and not in PNCs; it is likely involved in sensory organ differentiation (Brandet al. 1993; Dominguez and Campuzano 1993). Another transcription factor expressed in SOPs is the zinc finger protein Senseless (Sens); it is involved in maintenance of proneural gene expression (Noloet al. 2000). Although expression of Ase and Sens is normally restricted to SOPs, both exhibit “proneural” activity in that they induce the formation of ectopic sensory organs when misexpressed. The mechanosensory bristles that cover the exterior of the fly can be observed in live individuals at low magnification; thus, mutations that affect their distribution are easily identified. Two general classes of mutants display extra bristles. Those that compromise lateral inhibition cause multiple SOPs to emerge from an individual PNC, leading to an increase in bristle density or the presence of tight bristle tufts lacking intervening epidermal cells (i.e., Bearded; Leviten and Posakony 1996). In this situation, extra sensory organs arise from the normal complement of proneural clusters. A second class of mutant displays sensory organs in wholly ectopic positions, although these are always separated by epidermal cells. This results from the generation of ectopic proneural clusters, from which singularized SOPs are chosen. Most of the phenotypically strong mutations in the latter class correspond to lesions in hairy (h) or extramacrochaetae (emc; Bridges and Morgan 1923; Moscoso del Prado and García-Bellido 1984). Both encode negative regulators of the proneural proteins: HAIRY is a bHLH protein that directly represses transcription of ac, while EMC is an HLH-only protein that binds to and inhibits the DNA-binding activity of proneural proteins (Van Doren et al. 1992, 1994; Ohsakoet al. 1994). A rarer set of mutants with ectopic PNCs has been designated Hairy-wing (Hw). Once thought to represent a distinct locus in the AS-C, Hw mutants are actually gain-of-function alleles of ac and sc that ectopically activate neurogenesis (Campuzanoet al. 1986; Balcellset al. 1988). Another mutant with a dramatic ectopic bristle phenotype is Tufted (Tft; Ritterhoff 1952). Surprisingly, it has been little studied since its discovery 50 years ago. In this report, I characterize the cellular basis of the Tft phenotype and show that it results from the establishment of ectopic proneural domains and selection of extra SOPs. Unexpectedly, Tft neither is dependent upon nor significantly cross-activates expression of Ac and Sc, indicating that it harbors proneural activity for mechanosensory organs. Consistent with this, I present genetic and molecular evidence that Tft is a gain-of-function allele of the proneural gene amos that ectopically activates mechanosensory neurogenesis. Misexpression of any of the proneural proteins can promote the development of mechanosensory organs, and I provide evidence that this is not generally due to promiscuous activation of Ac and Sc, but rather to induction of Ase and Sens. Drosophila stocks: All mutant alleles and transgenic stocks utilized in this study have been previously described: Tft1/SM-TM6B (Ritterhoff 1952), In(1)sc10-1/FM7 (García-Bellido and Santamaria 1978), isoRoi/CyO (Chanutet al. 2002), ato1/TM6B (Jarmanet al. 1994), UAS-ato (Jarmanet al. 1993), daKX136/SM-TM6B (Caudyet al. 1988), sensE2/TM6B and UAS-sens (Noloet al. 2000), ac 2.2-kb genomic transgene (Van Dorenet al. 1994), dpp40C6-Gal4/TM6C (Staehling-Hamptonet al. 1994), bxMS1096-Gal4 (Capdevila and Guerrero 1994), UAS-amos (Gouldinget al. 2000), UAS-sc (Chienet al. 1996), neurA101-lacZ/TM6B (Bellenet al. 1989), m4-lacZ (Bailey and Posakony 1995), hs-Gal4 (Brand and Perrimon 1993), Brd1/ TM6B (Leviten and Posakony 1996), and f, hs-flp; 101E-Gal4 (de Celis and Bray 1997). Cytology: Tft1/+ polytene chromosomes displayed a cytologically visible aberration at 36F-37A. The nature of the aberration was analyzed using a tiling set of 5-kb digoxigenin-labeled probes representing 100 kb of DNA from the 36F3-7 region. A contiguous set of probes hybridized to an additional band in the 37A region of the Tft1 chromosome, suggesting that the Tft1 aberration involves a duplication and translocation of material from 36F3-7 to 37A. The proximal limit was not determined, but extends a minimum of 75 kb upstream of amos. Two nonoverlapping probes 0-5 and 5-10 kb downstream of the amos start site both showed variable, but modest, amounts of duplicated signal. This suggests that the structure of this end of the aberration is complex, but terminates in the vicinity of amos. Immunofluorescence: Imaginal discs were processed for immunofluorescence as described previously (Lai and Rubin 2001). The following dilutions for antibodies were used in this study: rabbit α-Scute (1:200, gift of Hugo Bellen), mouse α-Achaete [1:100, Developmental Hybridoma Studies Bank (DHSB)], rabbit α-Asense (1:2500, gift of Yuh Nung Han), rabbit α-Amos (1:4000, gift of Andrew Jarman), rabbit α-Atonal (1:2000, gift of Andrew Jarman), guinea pig α-Senseless (1:5000, gift of Hugo Bellen), mouse α-Delta (1:100, DHSB), mouse α-E(spl)b323 (1:5, gift of Sarah Bray), mouse α-Hindsight (1:50, DHSB), mouse α-Cut (1:100, DHSB), mouse α-β-galactosidase (1:100, DHSB), rabbit α-β-galactosidase (1:5000, Cappel), and rabbit α-Neur (1:400; Laiet al. 2001). Phenotypic and cellular characterization of Tft: The Tft locus is defined by a single, viable mutant (Tft1) that displays a large number of ectopic mechanosensory bristles, particularly in the postalar, dorsocentral, and scutellar regions of the notum (Figure 1, A and B) (Arnheim 1967; Ritterhoff 1952). I analyzed the expression of several markers of the SOP fate in this mutant, including Hindsight (Hnt; Pickupet al. 2002), Senseless (Sens), neurA101-lacZ (A101), and Asense (Ase). I observed extra cells positive for each marker in the presumptive posterior notal region of Tft/+ wing imaginal discs (Figure 2, A-H, arrows), demonstrating that the Tft phenotype is due to ectopic adoption of the SOP fate. Ectopic SOPs appear to subsequently develop into normal sensory organs in Tft, since ectopic mechanosensory organs contain both sockets and shafts and have neurons that are functionally connected to the central nervous system (Ghysen and Richelle 1979). Ectopic bristle phenotypes can generally be classified according to whether they arise from ectopic proneural clusters or reflect a failure of lateral inhibition. The term bristle “tufting” is popularly used to refer specifically to a failure of lateral inhibition. Indeed, the presence of closely spaced or even adjacent bristles in Tft flies (Figure 1B) and the determination of SOPs adjacent to each other in Tft wing imaginal discs (Figure 2, E-H) together suggest a defect in lateral inhibition. However, the number of ectopic bristles in the Tft-affected region was significantly increased in Tft1/+; Brd1/+ double heterozygotes (Figure 1E), indicating that Tft bristles are still sensitive to lateral inhibition. In addition, many Tft bristles were seen at clearly ectopic locations, including the anterior-central portion of the scutellum (Figure 1, A and B) and the metathoracic notum (not shown). This suggested the existence of ectopic proneural domains, which are not characteristic of neurogenic mutants. Figure 1. —The Tft1 adult phenotype. Shown are scanning electron micrographs (SEMs) of thoraces from adult males of the following genotypes: (A) Canton-S, showing the wild-type pattern of mechanosensory bristles. Inset shows an anterior-central portion of the scutellum that normally lacks sensory organs. (B) Tft1/+, displaying many ectopic macrochaetae and microchaetae; inset shows microchaetae present on the scutellum. (C) sc10-1/Y fly is essentially devoid of mechanosensory organs. (D) sc10-1/Y; Tft1/+ shows ectopic sensory organs in the Tft-affected region. (E) Tft1/+; Brd1/+ shows enhancement of the Tft phenotype; Brd1 heterozygotes display only a few extra macrochaetae in the Tft-sensitive region (Leviten and Posakony 1996). (F) Tft1/dakx136 shows suppression of the Tft phenotype. I assessed the distribution of proneural clusters using a number of additional markers and observed both elevated and ectopic activity of E(spl)m4-lacZ (as marked by β-galactosidase; Figure 3, A and E, arrows) and expression of E(spl)bHLH proteins (as marked by the MAb323 antibody; Figure 3, B and F, arrows), indicating the presence of ectopic proneural clusters. Notably, these results also indicate that the Tft phenotype is not due to a failure to activate components of lateral inhibition. Surprisingly, I did not observe comparable ectopic expression of Sc and Ac (Figure 3, C, D, G, and H, arrows), the proneural proteins for the adult peripheral nervous system (PNS). Doubly stained preparations showed that ectopic SOPs (as marked by Sens) in the Tft background were not generally associated with corresponding proneural clusters of Ac expression, although Ac could sometimes be observed in ectopic SOPs (Figure 3, I and J). This contrasts with what has been shown for other ectopic bristle mutants such as hairy and extramacrochaetae, which are associated with ectopic clusters of proneural expression and/or activity (Skeath and Carroll 1991; Van Doren et al. 1992, 1994). In summary, Tft is an unusual extra-bristle mutant: It exhibits both ectopic proneural domains and some defect in lateral inhibition, and ectopic neurogenesis is not generally accompanied by corresponding Ac/Sc expression. Tufted harbors proneural activity for mechanosensory organs: Simultaneous inactivation of ac and sc, the proneural genes for the adult PNS, results in a nearly completely bald fly lacking most mechanosensory organs (sc10-1/Y, Figure 1C). The bald phenotype of sc10-1/Y is epistatic to that of most other ectopic bristle mutants, indicating the fundamental role for these genes in establishing adult peripheral neurogenesis. In contrast, the ectopic bristle phenotype of Tft was epistatic to sc10-1/Y (Figure 1D); similar findings have been noted previously (A. Garcia-Bellido, personal communication cited in Ghysen and Richelle 1979). The ability of Tft to bypass the requirement for Ac/Sc demonstrates that Tft harbors an independent proneural activity. In accord with this, ectopic expression of Sens and Hnt was specifically maintained in the Tft-affected region of sc10-1/Y; Tft/+ wing discs (Figure 2, I-L, arrows). Since neurogenic genes do not exhibit proneural activity, the name “Tufted” is somewhat of a misnomer. Figure 2. Tft causes ectopic adoption of the SOP fate in an ac/sc-independent manner. Shown are wing imaginal discs from Canton-S (A-D), Tft1/+ (E-H), sc10-1/Y (I and J), and sc10-1/Y; Tft1/+ (K and L). Ectopic cells express a broad range of markers of the SOP fate in the presumptive posterior notum and scutellum of Tft wing discs (arrows), including Hindsight (Hnt, A and E), Senseless (Sens, B and F), neurA101-lacZ stained for β-galactosidase (A101, C and G), and Asense (Ase, D and H). Ectopic SOPs develop independently of the normal proneural genes for the PNS. sc10-1/Y individuals lack most SOPs (compare brackets in B and J), with the exception of ato-dependent positions (e.g., I, asterisk); nonsensory aspects of Hnt expression [I, tracheal tubes (T)] or Sens expression [J, wing margin (WM)] are unaffected. In this background, Tft still generates ectopic SOPs (I-L, arrows), even though most other SOPs are still absent (L, bracket). I tested Tft for genetic interactions with other loci high in the regulatory hierarchy for peripheral neurogenesis. Genetic interactions were not observed with either ato or sens, nor was Tft enhanced by increasing ac dosage using an ac genomic transgene (data not shown). However, Tft was partially suppressed by removal of one copy of daughterless (da; Figure 1F), which encodes a bHLH heterodimeric partner for proneural bHLH proteins. In addition, Tft was previously reported to be suppressed by Df(1)260-1, a deficiency of the entire AS-C (A. Garcia-Bellido, personal communication cited in Campuzanoet al. 1985). These interactions suggest that the Tft phenotype might be due to altered bHLH activity. Tft is associated with an aberration at 36F-37A that results in misexpression of amos: Tft was previously mapped to ∼37A (FlyBase 1998) and shown to be reverted by deficiencies of this cytological region (Wrightet al. 1976), a genetic property consistent with it being a gain-of-function allele. Examination of polytene chromosomes revealed a complex aberration involving a duplication and translocation of sequences at 36F3-7 to 37A (Figure 4, A-D, asterisks; see also materials and methods and the Figure 4 legend for details of this analysis). I noted that the proneural bHLH-encoding gene amos is located at one end of the aberration (Figure 4A); amos is involved in the development of embryonic multiple-dendritic neurons and adult olfactory sensilla (Gouldinget al. 2000; Huanget al. 2000). Since directed misexpression of Amos results in the ectopic production of several types of sensilla, including mechanosensory organs, it was conceivable that Tft is due to misexpression of Amos. I tested this hypothesis by staining wild-type and Tft tissue for Amos, which is not normally expressed in the wing disc (Figure 4E). Ectopic Amos was indeed observed in the presumptive posterior notal region of the Tft wing disc (Figure 4F) as well as at the base of the haltere disc (data not shown). Consistent with the genetics of Tft, the domain of ectopic Amos was independent of ac/sc (Figure 4G) and included the precise region from which ectopic SOPs are determined in this mutant (Figure 4, H-J). The findings that Tft specifically misexpresses Amos and interacts genetically with da, which encodes a known heterodimeric partner of Amos (Gouldinget al. 2000; Huanget al. 2000), suggested that Amos is a primary contributor to the Tft phenotype. However, the Tft duplication extends a minumum of 75 kb upstream of amos and affects several additional genes (Figure 4A). In addition, previous reports have differed on the efficacy with which ectopic Amos induces the formation of mechanosensory organs (Gouldinget al. 2000; Huanget al. 2000). I therefore performed additional misexpression experiments to further substantiate the hypothesis that Tft is an allele of amos. Conditional misexpression of amos efficiently initiates peripheral neurogenesis and induces mechanosensory organ formation: Although prolonged misexpression of amos using drivers such as dpp-Gal4 and bxMS1096-Gal4 resulted in pupal lethality, I was able to characterize their disc phenotypes in detail using the PNC and SOP markers described earlier. Misexpression of Amos with either driver resulted in massive ectopic expression of proneural cluster markers such as Delta (Dl), E(spl)m4-lacZ, and E(spl)bHLHs (Figure 5, A-E, and data not shown); of SOP markers such as Hnt, Sens, Ase, and Neur (Figure 5, F-I, and data not shown); and also led to a significant increase in disc size. Induction of Cut by Amos (Figure 5J, arrow) served as an additional measure of the identity of many ectopic SOPs as precursors for external sensory organs (compare with wild type, inset to J) and contrasted with the activity of the related bHLH Ato, which instead represses Cut (Jarman and Ahmed 1998). Thus, ectopic Amos efficiently establishes new proneural domains and strongly induces external peripheral neurogenesis. Notably, the levels of ectopically produced proteins were generally far greater than those of the corresponding endogenous proteins, suggesting that the neuronal program was “super-activated” by Amos. In spite of this, Sc was only mildly misexpressed in response to Amos (Figure 7G), and ectopic Ac was observed essentially only in the presumptive notum posterior (Figure 7J). In fact, some aspects of Ac expression were somewhat suppressed by Amos. Taken together with the observations that the Tft phenotype does not involve Ac or Sc, I conclude that the neuronal program initiated by ectopic Amos is largely independent of the normal proneural genes for mechanosensory neurogenesis. Figure 3. —Upregulation and misexpression of downstream proneural cluster markers in Tft discs. Shown are wing imaginal discs from wild type (A-D) and Tft1/+ (E-J) stained for β-galactosidase (A and E), E(spl)bHLHs stained with Mab323 (B and F), Scute (Sc; C and G), Achaete (Ac; D and H), and Sens + Ac (I and J). Ectopic and increased levels of E(spl)m4 promoter activity (A and E, arrows) and E(spl)bHLH proteins (B and F, arrows) are observed in Tft tissue, whereas Sc (C and G) and Ac (D and H) expression is only mildly affected. Some ectopic cells that adopt a high level of Ac expression are seen in well-stained preparations. (I and J) Higher magnification view of the presumptive posterior notum of a Tft1/+ disc; double staining demonstrates that ectopic SOPs (as marked by Sens; I) are not associated with ectopic clusters of Ac expression, although ectopic Ac is seen in some SOPs (J). Unexpectedly, commitment to the SOP fate was not generally coincident with expression of Amos on a cell-by-cell basis, in spite of the ease with which Amos induced SOP-specific gene expression. I observed that both Hnt (Figure 5, K-M) and neurA101-lacZ (Figure 5, N-P) were expressed at low levels or not at all by Amos-expressing cells, while cells that accumulated high levels of these markers instead had low levels of or lacked Amos. The same observation applied to Tft tissue as well: Hnt-positive cells in the region displaying ectopic neurogenesis often did not express Amos (Figure 4, H-J). I attempted to assess the autonomy of clones of Amos-misexpressing cells using a FLP-out Gal4 strategy, but this typically resulted in bald patches in the adult, possibly due to toxicity of high and prolonged expression of Amos. However, in the small number of cases where ectopic bristles were formed, they were always Amos+, indicating that induction of sense organs by Amos is likely autonomous (Figure 6C). Consistent with this, Tft1 was likewise previously determined to be cell autonomous in tissue mosaics (Arnheim 1967). Therefore, the inverse relationship between expression of Amos and SOP markers appears to represent negative regulation of Amos in SOPs. dppGal4>UAS-amos pharate adults were occasionally recovered when they were reared at 18°; these individuals displayed a large number of ectopic mechanosensory organs (Figure 6, A and B). In fact, the ability of UAS-amos to generate ectopic mechanosensory organs with this driver was greater than that of other proneural genes, including UAS-ac, UAS-sc, and UAS-ato; only UAS-sens was on a par with UAS-amos in this regard (data not shown). The lethality of Amos misexpression was reduced by temporal restriction of expression using hs-Gal4 and a 6-min heat shock at 38°. As described previously, these animals displayed a variety of ectopic sense organs (Huanget al. 2000). However, I observed predominant induction of mechanosensory organs and campaniform sensilla (Figure 6, D and E). Thus, misexpression of Amos efficiently induced the development of mechanosensory organs, which is consistent with the Tft phenotype. Figure 4. Tft1 is associated with a duplication and translocation in the 36F-37A region that results in misexpression of the proneural gene amos. (A) Physical map of 100 kb from the 36F3-7 region used for cytological analysis of Tft1/+ polytene chromosomes; the map was modified from Gadfly output (Mungallet al. 2003). Selected hybridizations using the probes labeled “B,” “C,” and “D” are shown in B-D, respectively; the positions of 36E (arrowhead) and 37A (arrow) on the wild-type homolog are indicated. DNA from the region shaded yellow hybridized to an additional band in the vicinity of 37A, indicating that the Tft aberration involves a duplication and translocation of sequences from 36F3-7 to 37A. This is most clearly observed in exceptional chromosome figures where the homologs have separated (B); a second site of hybridization is seen on one of the two homologs (asterisks). The proximal limit of the aberration was not determined and lies to the left of the sequence analyzed here. The distal limit terminates in the vicinity of amos (in red), but its structure is complex. Both probe C (including the amos transcription unit) and a probe including the next distal 5 kb of sequence (not shown) showed modest evidence of duplication [C, asterisks designate full hybridization; (*) designates partial hybridization near 37A]. That adjacent but nonoverlapping probes showed this behavior suggests that the distal limit of the duplication does not break cleanly, but has one or more additional anomalies associated with it. The distal limit is therefore shaded in fading yellow. Probe D is distal to the duplicated region and hybridizes to a single band on each homolog (D, asterisks); aberrant pairing of the homologs at 37A is still observed. Amos is not expressed in the wild-type wing disc (E) but is ectopically expressed in Tft tissue in the presumptive posterior notal region (F, bracket) in an ac/sc-independent manner (G, bracket). Ectopic SOPs (as marked by Hnt) develop from the Amos-misexpressing region of Tft discs (H-J). Limited cross-activating potential of proneural proteins: Most proneural proteins display a significant amount of promiscuous activity when misexpressed, including a common ability to promote the development of mechanosensory organs. To assess whether this was generally attributable to cross-activation of proneural gene expression, I systematically evaluated the ability of proneural proteins (Ac, Sc, Ato, Amos, and Sens) to activate one another when misexpressed using dpp-Gal4 and appropriate UAS constructs. A subset of these data is shown in Figure 7; the results for Ato and Ac are not shown since their misexpression resulted in only very mild cross-activation, at best, of any of these markers when assayed at the third instar. As noted before, misexpression of Amos only mildly activates Sc (Figure 7G) and Ac (Figure 7J), even though it strongly induced Ase (Figure 7M) and Sens (Figure 7P). Interestingly, Amos also strongly induced Ato, although primarily only in the wing pouch region (Figure 7D, bracket). In contrast, neither Sc nor Sens detectably activated either Amos or Ato (Figure 7, B, C, E, and F). Only Sens induced an appreciable amount of ectopic Sc (Noloet al. 2000) and Ac (Figure 7, I and L), although this was mostly restricted to the dorsal wing pouch and notal regions of the disc. Since ectopic Sc did not generally induce Ac (Figure 7K; Gomez-Skarmetaet al. 1995), this might reflect independent cross-activation of Sc and Ac by Sens. Finally, all three of these proneural proteins could ectopically activate Ase and Sens (Figure 7, M-R), with their rank order of effectiveness being Amos > Sens > Sc. This correlated directly with their ability to activate neurA101-lacZ (Figure 7, S-U). Bearing in mind that one cannot infer direct regulatory relationships from these experiments, it appears that the ability of all of these proneural proteins to activate the mechanosensory organ is probably not due to activation of Ac/Sc, the normal proneural bHLHs for this process. Rather, it is correlated with their common ability to induce Ase and Sens. Figure 5. —Directed misexpression of Amos efficiently generates ectopic proneural clusters and SOPs for external sensory organs. Shown are discs from dppGal4>UAS-amos individuals, with the exception of B, which is wild type (wt). In general, the Amos-misexpressing discs are shown at a slightly lower magnification relative to the wild-type disc due to their overgrowth phenotype. Misexpression of Amos in a stripe along the anterior-posterior border (A) results in a similar stripe of ectopic proneural clusters, as marked by Delta (Dl, B and C), m4-lacZ (stained for β-galactosidase, D) and E(spl)bHLHs (E), as well as strong overcommitment to the SOP fate, as marked by Hnt (F), Sens (G), Ase (H), Neur (I), and Cut (J; dR, dorsal radius). Inset to J shows a wild-type dR stained for Cut for comparison; only a small number of cells are normally labeled. Wild-type expression patterns for all other markers are shown in Figures 2 and 3. (K-P) Amos is downregulated following adoption of the SOP fate. The same disc is doubly stained in A and F; the boxed region is shown at higher magnification in K-M. Note that a higher level of Hnt (green) is found in cells that do not express Amos (red). (N-P) Cells that strongly express Amos (red) express low levels of β-galactosidase (green) in the neurA101-lacZ background, while the cells that express the highest levels of β-galactosidase do not express Amos. amos activates ectopic mechanosensory neurogenesis in Tft: Although the normal function of amos is to initiate the development of certain embryonic multiple-dendritic neurons and adult olfactory sensilla (Gouldinget al. 2000; Huanget al. 2000), several lines of evidence suggest that it is also responsible for generating the dominant Tft phenotype, which consists of a large number of ectopic adult mechanosensory organs. Figure 6. —Adult phenotypes caused by misexpression of Amos. SEMs of (A) wild-type and (B) dpp-Gal4>UAS-amos nota are shown; many ectopic macrochaetae are seen in the latter. They generally die as pupae but occasionally survive to the late pharate adult stage; cuticle deformation is due to its dissection from the pupal case. (C) Phenotype of a small clone of Amos-expressing cells that have been marked with forked. Most such clones show only a bald patch; however, exceptional clones also show a tight cluster of forked bristles, suggesting that Amos induces sensory organs cell-autonomously. No instances of clusters of forked+ bristles were ever observed. (D) A proximal-central portion of a wild-type wing. The wing blade proper is devoid of mechanosensory bristles and has only a small number of campaniform sensilla associated with some of the veins (arrow). (E) hsGal4>UAS-amos fly that was exposed to a 6-min heat shock at the white prepupal stage; the wing is covered with several hundred ectopic mechanosensory and campaniform sensilla. First, Tft maps to the same cytological location as amos and is associated with a chromosomal duplication and translocation that affects amos. Second, Tft mutants ectopically express Amos in precisely the same region from which ectopic SOPs arise in this mutant. Third, Tft is sensitive to the dosage of da, which encodes an obligate bHLH cofactor for proneural proteins such as Amos. Consistent with this, da similarly suppresses Roi (caused by misexpression of amos; Chanutet al. 2002) and enhances the phenotype of amos deficiencies (Gouldinget al. 2000; Huanget al. 2000). Fourth, deliberate misexpression of Amos phenocopies Tft and very effectively generates ectopic mechanosensory organs (in addition to other types of sense organs). Although I cannot formally exclude the contribution of other genes affected by the aberration at 36F-37A, the collected observations strongly suggest that the Tft phenotype can be satisfactorily accounted for by the ectopic expression of Amos. It should be noted that Modolell and colleagues have come to similar conclusions regarding Tft and have also shown that Tft revertants no longer misexpress Amos and/or are hypomorphic for amos (Villa-Cuestaet al. 2003, accompanying article in this issue). Taken together, these observations strongly indicate that Tft is a gain-of-function allele of amos. The past year has witnessed not only the simultaneous and independent characterization of Tft (this work and Villa-Cuestaet al. 2003), but also the realization that the classical mutant Rough eye (Roi) is likewise a gain-of-function mutant of amos (Chanutet al. 2002). Therefore, this relatively recently identified gene, whose original characterization was also carried out simultaneously and independently by two laboratories (Gouldinget al. 2000; Huanget al. 2000), is affected by two completely distinct gain-of-function mutants. An even more stunning fact is that both Tft and Roi were first described in the same volume of the Drosophila Information Service in 1952 (Ives 1952; Ritterhoff 1952). The history of amos seems thus to be dominated by coincidences. Unusual features of mechanosensory neurogenesis induced by amos: A curious feature of ectopic peripheral neurogenesis induced by Tft or UAS-amos is that it very minimally involves Ac and Sc, the endogenous proneural proteins for this process. Tft is not suppressed by complete inactivation of these proneural genes and is not modified by an increase in ac dosage. In addition, Sc and Ac are minimally misexpressed in Tft or in directed Amos misexpression experiments, even though all other PNC and SOP markers tested are strongly induced under these conditions. The failure of Amos to induce Sc or Ac is especially surprising considering the fact that Sens is very strongly induced by Amos, and Sens can ectopically induce Sc and Ac (although only in a subset of disc cells). A possible explanation for this paradox is that the high levels of E(spl)bHLH proteins induced by Amos are responsible for repressing ac and sc (Van Dorenet al. 1994; Jimenez and Ish-Horowicz 1997), although it is also the case that Sens can induce E(spl) expression (Noloet al. 2000). Interestingly, expression of SOP markers such as Hnt and neurA101-lacZ was often inversely correlated with that of Amos on a cell-by-cell level, even though Amos very strongly induces their expression. Since the effects of Tft (Arnheim 1967) and Amos misexpression are autonomous, this probably does not represent nonautonomous induction or recruitment of SOPs, but rather negative regulation of Amos. This control seems unlikely to reside at the transcriptional level in our experiments involving the Gal4/UAS system, suggesting that Amos protein might be unstable in SOPs. amos mRNA is also apparently rapidly lost from olfactory SOPs (Gouldinget al. 2000), suggesting that amos is negatively regulated at multiple levels shortly after commitment to the SOP fate. This behavior seems to run counter to that of Ac and Sc, which accumulate to elevated levels in SOPs, but may be paralleled by Ato, which is downregulated in maturing chordotonal SOPs (zur Lage and Jarman 1999). More detailed studies are required to determine if there are distinct functional consequences of the apparently different regulation of Ato- and ASC-class proteins in SOPs, or if this reflects some trivial difference in the timing of the differentiation of these different SOPs. Figure 7. —Cross-regulatory capabilities of selected proteins with proneural activity. All discs contain dpp-Gal4 and UAS-amos (top row), UAS-sc (middle row), or UAS-sens (bottom row). For reference, the misexpressed protein of choice is visualized in A (Amos), H (Sc), and R (Sens); the wild-type expression patterns of most of these proteins are shown in Figures 2, 3, 4. Ectopic Amos activates Ato in the wing pouch region (D, bracket), very mildly activates Sc (G) and Ac (J), and leads to strong misexpression of Ase (M) and Sens (P). By contrast, neither Sc nor Sens activates Amos (B and C) or Ato (E and F) in the wing disc. Arrows in E and F point to normal endogenous Ato expression in the ventral radius (vR); these discs are identical to wild type with respect to expression of Ato (not shown). Sc negligibly activates Ac (K), while Sens activates both Sc (I) and Ac (L), although only in a subset of Sens-expressing cells. Both Sc and Sens can modestly activate Ase (N and O), and Sc misexpression also results in some ectopic Sens (Q). The proneural strength of these proteins can be rank ordered as Amos > Sens > Sc on the basis of their ability to activate neurA101-lacZ (S-U). This correlates directly with their ability to activate Ase and Sens (M-R) and with the strength of their corresponding adult phenotypes (not shown). D and J, E and K, and I and L are from doubly stained preparations; M and P are the same as Figure 5, G and H. The ability of Tft/amos to induce closely spaced or even adjacent SOPs and sensory organs suggests that it is able to at least partially overcome or bypass lateral inhibition. This is not simply due to disconnecting a proneural gene from its normal transcriptional control, at least in the case of the Gal4-UAS experiments, since misexpression of Ac or Sc by similar means results in ectopic, but spaced bristles. It is also not a consequence of a failure to activate lateral inhibition, since E(spl) bHLH expression is strongly induced by Amos. It may simply be the case that Amos’ unusually potent proneural activity overwhelms or is not very sensitive to lateral inhibition. Another possibility is that induction of exceptionally high levels of E(spl)m4 (and potentially other Brd family proteins) by Amos might interfere with lateral inhibition, an explanation that might underlie the strong genetic interaction between Tft and Brd. Deliberate misexpression of Brd family genes is known to compromise lateral inhibition (Levitenet al. 1997; Apidianakiset al. 1999; Lai et al. 2000a,b). Another explanation might lie in the difference between the types of sensory organs normally controlled by ASC and Ato-class proneural proteins. While single SOPs for mechanosensory organs are chosen from individual PNCs of ac- and sc-expressing cells, large numbers of SOPs for chordotonal and olfactory sensilla are instead continuously selected from individual zones of ato- or amos-expressing cells (zur Lage and Jarman 1999; Gouldinget al. 2000). It is conceivable that Ato-class proneural proteins possess an inherent ability to induce the formation of closely spaced sensory organs. Signaling via the epidermal growth factor receptor (EGFR) antagonizes N signaling during SOP determination, and the development of clustered chordotonal organs not only relies upon EGFR signaling but also is strongly correlated with localized expression of rhomboid and presence of dp-ERK (zur Lage and Jarman 1999; Culiet al. 2001). It will be interesting to determine if settings of Amos activity are similarly associated with EGFR signaling and if any mechanistic links can be established between expression of Ato-class proteins and activation of rhomboid transcription and/or phosphorylation of MAP kinase. Specificity of proneural activity: When misexpressed, proneural proteins often induce the ectopic differentiation of sensory structures whose development they do not normally control. For example, Sc can promote many aspects of eye development in the absence of Ato; Sc and Ato can weakly induce the differentiation of MD neurons; and Amos can promote the differentiation of chordotonal organs. Notably, all proneural proteins have the ability to promote the formation of mechanosensory organs (Jarmanet al. 1993; Hinzet al. 1994; Gouldinget al. 2000; Huanget al. 2000; Sunet al. 2000). Several mutually compatible explanations for their common ability to induce mechanosensory neurogenesis have been put forth. First, experiments with Da suggested that mechanosensory organs might represent a “default” output for neurogenesis. Since Da is the heterodimeric partner for all proneural bHLH proteins, it is not expected to exhibit a subtype specificity. Nevertheless, misexpression of Da induces only the development of external sensory organs (Jarman and Ahmed 1998). Second, most proneural proteins are known to exhibit a phase of transcriptional auto-activation (Martinez and Modolell 1991; Van Dorenet al. 1992; Culi and Modolell 1998; Sunet al. 1998). Although the binding specificities of the proneural proteins are distinct, particularly between the ASC and Ato subclasses, high levels of ectopic proteins could conceivably result in some direct cross-activation of ac/sc. Once initiated, auto-activation by Ac and/or Sc might then be responsible for subsequent mechanosensory organ formation. Third, it is known that the transcription factor Sens, which itself has inherent proneural activity, is downstream of both subfamilies of proneural proteins (Noloet al. 2000; Frankfortet al. 2001). Thus, it may be that the activation of a common downstream target by different proneural proteins could explain how they can all activate mechanosensory neurogenesis. My data do not speak to the first of these explanations. However, they do suggest that relatively little cross-activation occurs at the level of proneural bHLH gene expression. Although Amos is perhaps the strongest inducer of mechanosensory organs among proneural proteins it does not do so through induction of intermediary proneural clusters of Ac/Sc. Even Sc fails to significantly cross-activate Ac (Gomez-Skarmetaet al. 1995), although Sc and Ac have largely indistinguishable DNA-binding properties in vitro (Singsonet al. 1994). This is not to say that proneural proteins cannot influence each other’s expression, since ectopic Amos can strongly activate Ato in the pouch region of the wing disc and in the vicinity of the morphogenetic furrow of the developing eye disc (Chanutet al. 2002). This particular ability might reflect their related DNA-binding domains; however, it should be noted that Ato does not reciprocally activate Amos (data not shown). Ac, Sc, and Sens also fail to activate either Amos or Ato. So in general, there is limited promiscuity in cross-activation of proneural bHLH proteins. A common activity of Ato-class and ASC-class bHLH proteins is instead their ability to induce Ase and Sens expression; Sens also induces Ase. As misexpression of either Ase or Sens suffices to initiate mechanosensory organ development, their activation may be key to promiscuous induction of mechanosensory organs. In principle, initiation of an Ase/Da-Sens feedback loop might be responsible for triggering a mechanosensory-type developmental program. Consistent with this scenario, ase is required for ectopic neurogenesis in Tft although ac/sc are not (A. Garcia-Bellido, personal communication cited in Campuzanoet al. 1985; Villa-Cuestaet al. 2003), and Sens is strictly required for bristle formation by ectopic Sc (Noloet al. 2000). The precise contribution of ase to mechanosensory neurogenesis remains in question though, as it is not normally required for the development of most bristles. In addition, both L’sc and Sc can generate ectopic bristles in cells that carry a deletion of the AS-C (and thus lack ase; Hinzet al. 1994; Culi and Modolell 1998). It is conceivable that proneural proteins might generically substitute for ase in these experimental conditions. Dominant gain-of-function alleles in Drosophila: Although they arise infrequently, dominant gain-of-function alleles can produce dramatic phenotypes that are easily identified, even in the course of unrelated studies. This explains why they are generally among the oldest Drosophila mutants known (Lindsley and Zimm 1992). Although in some cases these mutants have been useful reagents for studying various developmental processes, in other cases, their effects are neomorphic and not informative of normal development. Perhaps for this reason, dominant gain-of-function mutants have generally been treated with suspicion or even de facto discrimination by Drosophila geneticists. Indeed, many “old” dominant mutants have escaped the attention of Drosophila developmental biologists, even though they often affect processes (such as wing, eye, and bristle development) that are otherwise the subject of intense scrutiny. This has remained true in spite of the fact that misexpression studies and systematic gain-of-function genetic screens have become de rigeur since the inception of the versatile Gal4/UAS system in the past decade (Brand and Perrimon 1993; Rørth 1996). Only very recent years have witnessed the molecular characterization of a number of classical dominant gain-of-function Drosophila mutants, including Rough eye (Chanutet al. 2002), Glazed (Brunneret al. 1999), Lyra (Noloet al. 2001), Drop (Mozer 2001), Beadex (Milánet al. 1998; Shoreshet al. 1998; Zenget al. 1998), and Scutoid (Fuseet al. 1999). In these examples, the mutant phenotype appears to be due to the misexpression of an important regulatory molecule (including transcription factors and a morphogen). Thus, while these mutations are all neomorphic, they are nonetheless useful in that they identify “interesting” genes. Many other commonly utilized dominant mutations—Curly, Tubby, Additional Veins, Blunt short bristle, and Plexate, for example—remain to be characterized. A cursory examination of the FlyBase archive reveals >50 other uncharacterized adult-dominant Drosophila mutants for which mutant stocks are publicly available; about one-half of these mutants have been extant for nearly 50 years or more (FlyBase 1998). Undoubtedly, this collection of mutants, once properly analyzed, will be found to affect many other interesting genes as well. The history of amos is particularly instructive in this context. Its recent discovery relied upon molecular approaches (degenerate PCR and two-hybrid screening) and specific genetic lesions in amos have yet to be described. Nevertheless, the existence of an amos-like function had been genetically inferred for many years, since certain neurons persist in embryos mutant for both the AS-C and ato, and much of the olfactory system develops independently of these proneural genes. Since the development of all of these neurons is still sensitive to manipulation of Da and/or EMC levels, this suggested the existence of an additional proneural bHLH. Loss of amos function produces phenotypes complementary to AS-C; ato mutants, suggesting it is the “missing” proneural gene (Gouldinget al. 2000; Huanget al. 2000). Had Roi and/or Tft been studied earlier, amos might have been discovered long ago. In this author’s opinion, the very history of amos justifies the study of other long-neglected dominant mutants. I thank Francoise Chanut, Adina Bailey, and Julia Serano for useful discussions of this work; Juan Modolell for communications regarding Tft prior to publication; and especially Todd Laverty for performing in situ hybridizations to polytene chromosomes. I also acknowledge the following for generous gifts of antibodies and fly stocks: Andrew Jarman, Yuh Nung Jan, Saray Bray, Hugo Bellen, Francoise Chanut, James Posakony, Jose de Celis, the Bloomington Stock Center, and the Developmental Hybridoma Studies Bank. I acknowledge the gracious support of Gerald Rubin and the Damon Runyon Cancer Research Foundation, DRG 1632. • Communicating editor: T. C. Kaufman • Received September 9, 2002. • Accepted January 8, 2003. View Abstract
__label__1
0.500169
Huntress #2 Review Huntress hates human traffickers. Like, really hates them. Paul Levitz and Marcus To continue Huntress' first New 52 adventure this month and once again deliver. Interestingly, their roles have somewhat reversed, with To's work being the star of the show while Levitz's script gets a little wobbly from time to time. To's flair for dynamic action, panel composition, and body language is fully present in issue #2, with the characters feeling lively and full of weight. While his facial expressions could use some work here, his overall knack for creating interesting pages and defined action sequences win out. Levitz delivers on the characterization of Helena, but the pacing of this issue holds it back. The jumps between scenes are quick and jarring, but after flipping the book shut, you'll be at a loss for what has actually progressed in this issue. That's not to say the plot is treading water, but there's never a sense that anything anyone says is actually building towards something bigger, other than the eventual confrontation that will happen two issues from now. The supporting cast and villains are left where they began in issue #1, but Huntress herself retains all the spark, snark and strength that Levitz gave her last time around. One other gripe I have, though small, is that characters speak in English that's supposedly translated from Italian, yet there are numerous instances where the dialog tosses in some Italian for good measure. As I said, it's a minor gripe but one of those nagging factors that will drive the more careful readers nuts. Huntress #2 is another decent win for female-led books in the New 52. If the coming issues can get the plot back on track and retain the same great characterization, this series could be a nice counterpoint to all of the critics pointing out the missteps with DC's other female characters. IGN Logo
__label__1
0.871144
Power Of Packaging In Consumer Choices January 7, 2014 Appearance Of Package Impacts Buying Decisions Of Consumers University of Miami Researchers from the University of Miami and California Institute of Technology show how the brain considers both visual cues and taste preferences when making everyday food choices When it comes to deciding what food to eat, one might expect that people's choices will be driven by past experience and personal preference, but how does the general appearance of the package impact buying decisions of consumers? Scientists believe colorful or otherwise noticeable food packages predispose where people look, how long they examine certain options and ultimately, influence which foods they choose, according to a new study published in the Proceedings of the National Academy of Sciences. "When choice options are presented simultaneously, eye movements are considered a good predictor of our economic decisions," says Milica Mormann, senior research scientist at the University of Miami School of Law and co-author of the study. "The big idea here is that perceptual processes happen in the brain in parallel with economic value computations and thus influence how economic decisions are made." "These findings can be applied to guide the design of choice environments, to 'nudge' people toward making optimal choices, be it selecting a healthy food option to eat or the best retirement plan to invest in," Mormann says. In the study, Mormann and researchers from the California Institute of Technology, Pasadena, CA asked participants to search for and choose a snack food item to eat -- such as M&Ms or Twix -- out of four simultaneously presented snack alternatives. Eye-tracking technology recorded what items people were looking at, in real time. Images of food items were also analyzed using novel neuro-computational simulation of human attentional processes to determine which items attract attention due to the color, brightness and other visual features of their packaging. The experiment showed that visual fixations are driven by a combination of visual attractiveness and preference information. In fact, the visual attractiveness of product packaging influences where people look in a ratio of 1:3 or 2:3 compared to consumer preferences. In other words, visual attractiveness has a smaller, but significant, influence than food preferences on consumer decisions. Importantly, these findings allowed the scientists to accurately predict eye-movement patterns and subsequent food choices using only the images of food items and participants' stated liking ratings of these food items. The accuracy of prediction was higher when both visual features and preferences are accounted for than when only the preference information, or asking people what they like, was considered. Most existing studies on how people make choices do not examine what is visually appealing but, instead, focus on what is economically attractive. A separate body of literature, dedicated to perceptual decision-making, examines what people perceive and pay attention to. The current study bridges these two research approaches to build a more comprehensive understanding of how people make everyday choices. "Surprisingly, the traditional research approach tends to ignore other, fundamental influences that could impact decision makers at the time of choice, such as how people perceive choice options and how much attention they allocate to different options," Mormann says. The new study makes an important observation: during the economic choice process the brain merges and reconciles competing types of inputs, including, but not limited to, the perceptual and taste preference information. On the Net:
__label__1
0.548965
39872274 vb-script Published on • Be the first to comment • Be the first to like this No Downloads Total Views On Slideshare From Embeds Number of Embeds Embeds 0 No embeds No notes for slide 39872274 vb-script 1. 1. AL A Quick Introduction RI to Programming TEA chapter covering the basics of VBScript is the best place to begin this book. This is because of the MAtype of language VBScript is and the kind of users the authors see turning to it. In this chapter, youget a crash course in programming basics. You might not need this chapter because you’ve come toVBScript with programming skills from another language (Visual Basic, Visual Basic .NET, C, C++,Delphi, C#) and are already both familiar with and comfortable using programming terminology. DIn that case, feel free to skip this chapter and move on to the next one. However, if you come froma non-programming background, then this chapter will give you the firm foundation you need to TEbegin using VBScript confidently.If you’re still reading, chances are you fall into one of three distinct categories: GH ❑ You’re a Network/Systems administrator who probably wants to use VBScript and the Windows Script Host or PowerShell to write logon scripts or to automate administration RI tasks. ❑ You might be a web designer who feels the need to branch out and increase your skill set, PY perhaps in order to do some ASP work. ❑ You’re interested in programming (possibly Visual Basic or Visual Basic .NET) and want to check it out before getting too deeply involved. COProgramming is a massive subject. Over the years countless volumes have been written about it,both in print and on the Internet. In this chapter, in a single paragraph, we might end up introduc-ing several unfamiliar concepts. We’ll be moving pretty fast, but if you read along carefully, tryingout your hand at the examples along the way, you’ll be just fine.Also, do bear in mind that there will be a lot that we don’t cover here, such as: ❑ Architecture ❑ System design ❑ Database design 2. 2. Chapter 1: A Quick Introduction to Programming ❑ Documenting code ❑ Advanced testing, debugging, and beta testing ❑ Rollout and support Think of this chapter as a brief introduction to the important building blocks of programming. It certainly won’t make you an expert programmer overnight, but it will hopefully give you the know-how you’ll need to get the most out of the rest of the book.Variables and Data Types In this section, you’ll quickly move through some of the most basic concepts of programming, in particular: ❑ Using variables ❑ Using comments ❑ Using built-in VBScript functions ❑ Understanding syntax issuesUsing Variables Quite simply, a variable is a place in the computer memory where your script holds a piece (or pieces) of information, or data. The data stored in a variable can be pretty much anything. It may be something simple, like a small number, like 4, something more complex, like a floating-point number such as 2.3, or a much bigger number like 981.12932134. Or it might not be a number at all and could be a word or a combination of letters and numbers. In fact, a variable can store pretty much anything you want it to store. Behind the scenes, the variable is a reserved section of the computer’s memory for storing data. Memory is temporary — things stored there are not stored permanently like they are when you use the hard drive. Because memory is a temporary storage area, and variables are stored in the computer’s memory, they are therefore also temporary. Your script will use variables to store data temporarily that the script needs to keep track of for later use. If your script needs to store that data permanently, it would store it in a file or database on the computer’s hard disk. To make it easier for the computer to keep track of the millions of bits of data that are stored in memory at any given moment, the memory is broken up into chunks. Each chunk is exactly the same size, and is given a unique address. Don’t worry about what the memory addresses are or how you use them because you won’t need to know any of that to use VBScript, but it is useful to know that a variable is a reserved set of one or more chunks. Also, different types of variables take up different amounts of memory. In your VBScript program, a variable usually begins its lifecycle by being declared (or dimensioned) before use.2 3. 3. Chapter 1: A Quick Introduction to Programming It is not required that you declare all of the variables you use. By default, VBScript allows you to use undeclared variables. However, it’s strongly recommended that you get into the good habit of declaring all of the variables you use in your scripts. Declaring variables before use makes code easier to read and to debug later. Just do it!By declaring variables you also give them a name in the process. Here’s an example of a variabledeclaration in VBScript. Dim YourNameBy doing this, you are in fact giving the computer an instruction to reserve some memory space for youand to name that chunk YourName. From now on, the computer (or, more accurately, the VBScriptengine) keeps track of that memory for you, and whenever you use the variable name YourName, it willknow what you’re talking about.Variables are essential to programming. Without them you have no way to hold all the data that yourscript will be handling. Every input into the script, output from the script, and process within the scriptuses variables. They are the computer’s equivalent of the sticky notes that you leave all over the placewith little bits of information on them. All the notes are important (otherwise why write them?) but theyare also temporary. Some might become permanent (so you take a phone number and write it down inyour address book or contact list), while others are thrown away after use (say, after reminding you to dosomething). This is how it works with variables, too. Some hold data that you might later want to keep,while others are just used for general housekeeping and are disposed of as soon as they’re used.In VBScript, whenever you have a piece of information that you need to work with, you declare a vari-able using the exact same syntax you saw a moment ago. At some point in your script, you’ll need to dosomething with the memory space you’ve allocated yourself (otherwise, what would be the point ofdeclaring it?). And what you do with a variable is place a value in it. This is called initializing the vari-able. Sometimes you initialize a variable with a default value. Other times, you might ask the user forsome information, and initialize the variable with whatever the user enters. Alternatively, you mightopen a database and use a previously stored value to initialize the variable. When we say database, we don’t necessarily mean an actual database but any store of data — it might be an Internet browser cookie or a text file that we get the data from. If you are dealing with small amounts of data a cookie or text file will suffice, but if you are dealing with a lot of data you need the performance and structure that a database offers.Initializing the variable gives you a starting point. After it has been initialized, you can begin making useof the variable in your script.Here’s a very simple VBScript example. Dim YourName ‘ Above we dimensioned the variable YourName = InputBox(“Hello! What is your name?”) ‘ Above we ask for the user’s name and initialize the variable MsgBox “Hello “ & YourName & “! Pleased to meet you.” ‘ Above we display a greeting containing the user’s nameRightly so, you’re now probably wondering what all this code means. Last time, you were showed oneline and now it’s grown to six. 3 4. 4. Chapter 1: A Quick Introduction to Programming All of the examples in this chapter are designed so that you can run them using the Windows Script Host (WSH). The WSH is a scripting host that allows you to run VBScript programs within Windows. WSH allows you to try out these example programs for yourself. You may already have WSH installed. To find out, type the previous example script into a text editor, save the file as TEST.VBS (it must have the .VBS extension, and not a .TXT), and double-click the file in Windows Explorer. If the script runs, then you’re all set. If Windows does not recognize the file, then you need to download and install WSH from http://msdn2.microsoft.com/en-us/library/ms950396.aspx.Using Comments You already know what the first line of code in the previous block does. It declares a variable for use called YourName. The second line in the code is a comment. In VBScript, any text preceded by the single quote character (‘) is treated as a comment, which means that the VBScript engine completely ignores the text, which begs the question why bother typing it in at all? It doesn’t contribute to the execution of the script, right? This is absolutely correct, but don’t forget one of the most important principles of programming: It is not just computers that may have to read script. It is equally important to write a script with human readers in mind as it is to write with the computer in mind. Of course, none of this means you should for one moment forget that when you write scripts, you must do so with the computer (or, more specifically, the script engine) in mind. If you don’t type the code cor- rectly (that is, if you don’t use the proper syntax), the script engine won’t be able to execute the script. However, once you’ve written some useful scripts, you’ll probably need to go back to make some changes to a script you wrote six months or a year ago. If you didn’t write that code with human readers, as well as computers, in mind it could be pretty difficult to figure out what you were thinking and how you decided to solve the problems at the time you wrote the script. Things can get worse. What happens when you or one of your coworkers has to make some changes to a script you wrote many months ago? If you did not write that script to be both readable and maintainable, others who use your code will encounter difficulties deciphering it — no matter how well written the actual computer part of the code is. Adding comments to your code is just one part of making sure code is clear and readable. There are many other things that you can do: ❑ Choose clear, meaningful variable names. ❑ Indent code for clarity. ❑ Make effective use of white space. ❑ Organize the code in a logical manner. All of these aid human-readability and are covered later, but clear, concise comments are by far the most important. However, too much of a good thing is never good and the same is true for comments. Over- burdening code with comments doesn’t help. Remember that if you are scripting for the Web that all the code, including the comments, are downloaded to the browser, so unnecessary comments may adversely affect download times. You learn about some good commenting principles later in this chapter, but for now just be aware of the fact that the comment in line 2 of the script is not really a good comment for everyday use. This is because, to any semi-experienced programmer, it is all too obvious that what you are doing is declaring4 5. 5. Chapter 1: A Quick Introduction to Programming the YourName variable on the code line above. However, throughout this book you’ll often see the code commented in a similar way. This is because the point of the code is to instruct the reader in how a par- ticular aspect of VBScript programming works, and the best way to do that is to add comments to the code directly. It removes ambiguity and keeps the code and comments together. Also worth noting is that comments don’t have to be on a separate line. Comments can also follow the code, like so: Dim YourName ‘ initialize the variable YourName = InputBox(“Hello! What is your name?”) ‘ ask for the user’s name MsgBox “Hello “ & YourName & “! Pleased to meet you.” ‘ display a greeting This works in theory but it isn’t as clear as keeping the comments on separate lines in the script.Using Built-in VBScript Functions OK, back to the script. Take a look at line 3. YourName = InputBox(“Hello! What is your name?”) Here you are doing two things at once. First, you’re initializing the variable. You could do it directly, like this: YourName = “Fred” However, the drawback with this is that you’re making the arbitrary decision that everyone is called Fred, which is ideal for some applications but not for others. If you wanted to assign a fixed value to a variable, such as a tax rate, this would be fine. Dim TaxRate TaxRate = 17.5 Because you want to do something that gives the user a choice, you should employ the use of a function, called InputBox. This function and all the others are discussed in later chapters, but for now all you need to know is that InputBox is used to display a message in a dialog box, and it waits for the user to input text or click a button. The InputBox generated is displayed in Figure 1-1. Figure 1-1 The clever bit is what happens to the text that the user types into the input box displayed — it is stored in the variable YourName. 5 6. 6. Chapter 1: A Quick Introduction to Programming Line 4 is another comment. Line 5 is more code. Now that you’ve initialized this variable, you’re going to do something useful with it. MsgBox is another built-in VBScript function that you will probably use a lot during the course of your VBScript programming. Using the MsgBox function is a good way to introduce the programming concept of passing function parameters, also known as arguments. Some functions don’t require you to pass parameters to them while others do. This is because some functions (take the Date function as an example — this returns the current date based on the system time) do not need any additional information from you in order to do their job. The MsgBox function, on the other hand, dis- plays a piece of information to the user in the form of a dialog box, such as the one shown in Figure 1-2. Figure 1-2 You have to pass MsgBox a parameter because on its own it doesn’t have anything useful to display (in fact, it will just bring up a blank pop-up box). The MsgBox function actually has several parameters, but for now you’re just going to look at one. All of the other parameters are optional parameters.Understanding Syntax Issues Take another look at line 5 and you’ll probably notice the ampersand (&). The ampersand is a VBScript operator, and is used to concatenate (join) pieces of text together. To concatenate simply means to “string together.” This text can take the form of either a literal or a variable. A literal is the opposite of a variable. A variable is so named because it is exactly that — a variable — and can change throughout the lifetime of the script (a script’s lifetime is the time from when it starts executing, to the time it stops). Unlike a variable, a literal cannot change during the lifetime of the script. Here is line 5 of the script again. MsgBox “Hello “& YourName & “! Pleased to meet you.” An operator is a symbol or a word that you use within your code that is usually used to change or test a value. Other operators include the standard mathematical operators (+, -, /, *), and the equals sign (=), which can actually be used in either a comparison or an assignment. So far, you’ve used the equals sign as an assignment operator. Later in this chapter you’ll find out more about operators. Now take a closer look at variables. Remember how we said that a variable is a piece of reserved memory? One question you might have is, How does the computer know how large to make that piece of memory? Well, again, in VBScript this isn’t something that you need to worry about and it is all handled automatically by the VBScript engine. You don’t have to worry in advance about how big or small you need to make a variable. You can even change your mind and the VBScript engine will dynamically change and reallocate the actual memory addresses that are used up by a variable. For example, take a quick look at this VBScript program.6 7. 7. Chapter 1: A Quick Introduction to Programming ‘ First declare the variable Dim SomeVariable ‘ Initialize it with a value SomeVariable = “Hello, World!” MsgBox SomeVariable ‘ Change the value of the variable to something larger SomeVariable = “Let’s take up more memory than the previous text” MsgBox SomeVariable ‘ Change the value again SomeVariable = “Bye!” MsgBox SomeVariableEach time the script engine comes across a variable, the engine assigns it the smallest chunk of memoryit needs. Initially the variable contains nothing at all so needs little space but as you initialize it with thestring “Hello, World!” the VBScript engine asks the computer for more memory to store the text. Butagain it asks for just what it needs and no more. (Memory is a precious thing and not to be wasted.)Next, when you assign more text to the same variable, the script engine must allocate even more mem-ory, which it again does automatically. Finally, when you assign the shorter string of text, the scriptengine reduces the size of the variable in memory to conserve memory.One final note about variables: Once you’ve assigned a value to a variable, you don’t have to throw itaway in order to assign something else to the variable as well. Take a look at this example. Dim SomeVariable SomeVariable = “Hello” MsgBox SomeVariable SomeVariable = SomeVariable & “, World!” MsgBox SomeVariable SomeVariable = SomeVariable & “ Goodbye!” MsgBox SomeVariableNotice how in this script, you each time keep adding the original value of the variable and adding someadditional text to it. You tell the script engine that this is what you want to do by also using the name of theSomeVariable variable on the right side of the equals sign, and then concatenating its existing value withan additional value using the ampersand (&) operator. Adding onto the original value works with num-bers, too (as opposed to numbers in strings) but you have to use the + operator instead of the & operator. Dim SomeNumber SomeNumber = 999 MsgBox SomeNumber SomeNumber = SomeNumber + 2 MsgBox SomeNumber SomeNumber = SomeNumber + 999 MsgBox SomeNumber 7 8. 8. Chapter 1: A Quick Introduction to Programming Here are the resulting message boxes generated by this code. The first is shown in Figure 1-3. Figure 1-3 The second message box is shown in Figure 1-4. Figure 1-4 The final message box is shown in Figure 1-5. Figure 1-58 9. 9. Chapter 1: A Quick Introduction to Programming You can store several different types of data in variables. These are called data types and so far you’ve seen two: ❑ String ❑ Integer You’ve also seen a single-precision floating-point number in the tax rate example. We’ll be covering all of them later on in the book. For now, just be aware that there are different data types and that they can be stored in variables.Flow Control When you run a script that you have written, the code executes in a certain order. This order of execution is also known as flow. In simple scripts such as the ones you looked at so far, the statements simply execute from the top down. The script engine starts with the first statement in the script, executes it, moves on to the next one, and then the next one, and so on until the script reaches the end. The execution occurs this way because the simple programs you’ve written so far do not contain any branching or looping code.Branching Take a look at a script that was used earlier. Dim YourName ‘Above we initialized the variable YourName = InputBox(“Hello! What is your name?”) ‘Above we ask for the user’s name and initialize the variable MsgBox “Hello “ & YourName & “! Pleased to meet you.” ‘Above we display a greeting containing the user’s name If you save this script in a file with a .vbs extension, and then execute it using the Windows Script Host, all of the statements will be executed in order from the first statement to the last. Note that it was previously mentioned that all of the statements will be executed. However, this isn’t what you always want. There is a technique that you can use to cause some statements to be executed, and some not, depending on certain conditions. This technique is called branching. VBScript supports a few different branching constructs, and they are covered in detail in Chapter 5, but here we only cover the simplest and most common one, which is the If...Else...End If construct. Take a look at this modified code example. 9 10. 10. Chapter 1: A Quick Introduction to Programming Dim YourName Dim Greeting YourName = InputBox(“Hello! What is your name?”) If YourName = “” Then Greeting = “OK. You don’t want to tell me your name.” Else Greeting = “Hello, “& YourName & “, great to meet you.” End If MsgBox Greeting Walking through the code, you do the following: 1. You declare the two variables that you are going to use: Dim YourName Dim Greeting YourName = InputBox(“Hello! What is your name?”) You ask the user for some input, again using the InputBox function. This function expects one required parameter, the prompt text (the text that appears on the input box). It can also accept several optional parameters. Here, you only use the one required parameter. Note that the parameter text that you passed “Hello! What is your name?” is displayed as a prompt for the dialog box. The InputBox function returns the value that the user types, if any. If the user does not type anything or clicks the Cancel button (both do the same thing), then InputBox returns a zero-length string, which is a strange kind of programming concept that basically means that it returns text that doesn’t actually contain any text. Your script stores the result of the InputBox function in the YourName variable. 2. You come to the actual loop you’re going to use: If YourName = “” Then Greeting = “OK. You don’t want to tell me your name.” Else Greeting = “Hello, “& YourName & “, great to meet you.” End If This code presents the VBScript engine with an option that is based on what the user typed (or didn’t type) into the input box. The first line tests the input from the user. It tests to see if the input that is stored in the variable YourName is a zero-length string. If it is, the next line of code is run and the variable Greeting is assigned a string. Figure 1-6 shows the message displayed if the user doesn’t type his or her name into the InputBox.10 11. 11. Chapter 1: A Quick Introduction to Programming Figure 1-6 3. What happens if the user does (as you expect) type something into the input box? Well, this is where the next line comes in. Else You can actually begin to read the code and in fact doing this helps it to make sense. What the whole loop actually means is that if the value of variable YourName is a zero-length string, then assign the variable Greeting with one value; however, if it contains something else, do some- thing else (assign Greeting a different value). This doesn’t protect your script from users enter- ing data like numbers of non-alphabet characters into the test box, although you could code for all these conditions if you wanted to. 4. The final line of the code uses the MsgBox function to display the value of the variable Greeting. Notice that both lines of code assign a value to the Greeting variable. However, only one of these lines will actually execute in any one running of the script. This is because the If...Else...End If block makes an either/or decision. Either a given condition is True, or it is False. There’s no way it can be neither (not a string that contains text nor a zero-length string) or both (a zero-length string that contains text). If it is True, then the script engine will execute the code between the If and Else statements. If it is False, then it will execute the code between the Else and End If statements.So, what the complete script does is test the input, and then executes different code, depending on theresult of that test, and hence the term branching. Using this technique allows your script to adapt to theunpredictable nature of the input. Compare the intelligent script to the following one, which looks prettylame. Dim YourName Dim Greeting YourName = InputBox(“Hello! What is your name?”) Greeting = “Hello, “& YourName & “, great to meet you.” MsgBox GreetingThis script is just plain dumb because it does not contain any branching logic to test the input; so whenthe user does something unpredictable, such as clicking the Cancel button, or not entering any name atall, the script does not have the ability to adapt. Compare this to your intelligent script, which is capableof adapting to the unpredictability of input by testing it with If...Else...End If branching. 11 12. 12. Chapter 1: A Quick Introduction to Programming Before you move on to looping, you should know a few other things about If...Else...End If: ❑ The block of code containing the If...Else...End If is known as a block of code. A block is a section of code that has a beginning and an end, and it usually contains keywords or state- ments at both the beginning and the end. In the case of If...Else...End If, the If statement marks the beginning of the block, while the End If marks the end of the block. The script engine requires these beginning and ending statements, and if you omit them, the script engine won’t understand your code and won’t allow your script to execute. Over the course of this book you will encounter many different types of code blocks in VBScript. To confuse matters, the term “block of code” is often used informally to describe any group of lines of code. As a rule, “block of code” will refer to lines of code that work together to achieve a result. ❑ Notice that the lines of code that are inside the block itself are indented by four spaces. This is an extremely important concept but not for the reason you might think. This indenting has nothing whatsoever to do with the script engine — it doesn’t care whether you add four spaces, 44 spaces, or none at all. This indenting is for the benefit of any humans who might be reading your code. For example, the following script is completely legal and will execute just fine: Dim YourName Dim Greeting YourName = InputBox(“Hello! What is your name?”) If YourName = “” Then Greeting = “OK. You don’t want to tell me your name.” Else Greeting = “Hello, “& YourName & “, great to meet you.” End If MsgBox Greeting However, this code is very difficult to read. As a general rule of thumb, you indent code by four spaces whenever a line or series of lines is subordinate to the lines above and below it. For ex- ample, the lines after the If clause and the Else clause belong inside the If...Else...End If block, so you indent them to visually suggest the code’s logical structure. Presentation, while having no bearing whatsoever on how the computer or script engine handles your code, is very important when it comes to how humans read it. You should be able to look at the code and get a sense for how it is organized and how it works. By seeing the indentations inside the If...Else...End If block, you can not only read the code, but also “see” the branching logic at that point in the code. Indenting is only one element of programming style, but learning and following proper style and layout is essential for any programmer who wants to be taken seriously. ❑ The Else part of the block is optional. Sometimes you want to test for a certain condition, and if that condition is True, execute some code, but if it’s False, there’s no code to execute. For example, you could add another If...End If block to your script.12 13. 13. Chapter 1: A Quick Introduction to ProgrammingDim YourNameDim GreetingYourName = InputBox(“Hello! What is your name?”)If YourName = “” Then Greeting = “OK. You don’t want to tell me your name.”Else Greeting = “Hello, “ & YourName & “, great to meet you.”End IfIf YourName = “Fred” Then Greeting = Greeting & “ Nice to see you Fred.”End IfMsgBox Greeting❑ The If...Else...End If block can be extended through the use of the ElseIf clause, and through nesting. Nesting is the technique of placing a block of code inside of another block of code of the same type. The following variation on your script illustrates both concepts:Dim YourNameDim GreetingYourName = InputBox(“Hello! What is your name?”)If YourName = “” Then Greeting = “OK. You don’t want to tell me your name.”ElseIf YourName = “abc” Then Greeting = “That’s not a real name.”ElseIf YourName = “xxx” Then Greeting = “That’s not a real name.”Else Greeting = “Hello, “& YourName & “, great to meet you.” If YourName = “Fred” Then Greeting = Greeting & “ Nice to see you Fred.” End IfEnd IfMsgBox Greeting Once again, seeing how the code has been indented helps you to identify which lines of code are subordinate to the lines above them. As code gets more and more complex, proper indenting of the code becomes vital as it will become harder to follow.❑ Even though the branching logic you are adding to the code tells the script to execute certain lines of code while not executing others, all the code must still be interpreted by the script engine (including the code that’s not executed). If any of the code that’s not executed contains any syntax errors, the script engine will still produce an error message to let you know. 13 14. 14. Chapter 1: A Quick Introduction to ProgrammingLooping Branching allows you to tell the script to execute some lines of code, but not others. Looping, on the other hand, allows you to tell the script to execute some lines of code over and over again. This is particularly useful in two situations: ❑ When you want to repeat a block of code until a condition is True or False ❑ When you want to repeat a block of code a finite number of times There are many different looping constructs, but this section focuses on only two of them: ❑ The basic Do...Loop While loop ❑ The basic For...Next loopUsing the Do…Loop While Loop This section takes a look at the Do...Loop While construct and how it can be used to repeatedly execute a block of code until a certain condition is met. Take a look at the following modification of the example script: Dim Greeting Dim YourName Dim TryAgain Do TryAgain = “No” YourName = InputBox(“Please enter your name:”) If YourName = “” Then MsgBox “You must enter your name to continue.” TryAgain = “Yes” Else Greeting = “Hello, “& YourName & “, great to meet you.” End If Loop While TryAgain = “Yes” MsgBox Greeting Notice the block of code that starts with the word Do and ends with the line that starts with the word Loop. The indentation should make this code block easy to identify. This is the definition of the loop. The code inside the loop will keep being executed until at the end of the loop the TryAgain variable equals “No”. The TryAgain variable controls the loop. The loop starts at the word Do. At the end of the loop, if the TryAgain variable equals “Yes”, then all the code, starting at the word Do, will execute again. Notice that the top of the loop initializes the TryAgain variable to “No”. It is absolutely essential that this initialization take place inside the loop (that is, between the Do and Loop statements). This way, the variable is reinitialized every time a loop occurs. If you didn’t do this, you would end up with what’s called an infinite loop. They are always bad. At best, the user is going to have to exit out of the program in an untimely (and inelegant) way because, as the name suggests, the loop is infinite. At worse, it can crash the system. You want neither and you want to try to avoid both in your code.14 15. 15. Chapter 1: A Quick Introduction to ProgrammingTake a look at why the TryAgain = “No” line is essential to preventing an infinite loop. Going throughthe script line by line: 1. This first line starts the loop. Do This tells the script engine that you are starting a block of code that will define a loop. The script engine will expect to find a loop statement somewhere further down in the script. This is similar to the If...End If code block because the script engine expects the block to be defined with beginning and ending statements. The Do statement on a line all by itself means that the loop will execute at least once. Even if the Loop While statement at the end of the block does not result in a loop around back to the Do line, the code inside this block will be executed at least one time. 2. Moving on to the second line of code, you initialize the “control” variable. It’s called the “con- trol” variable because it ultimately controls whether or not the code block loops around again. You want to initialize this variable to “No” so that, by default, the loop will not loop around again. Only if a certain condition is met inside the loop will you set TryAgain to “Yes”. This is yet another strategy in an ever-vigilant desire to expect the unexpected. Do TryAgain = “No” 3. The next line of code should look familiar. You use the InputBox function to ask the user to enter a name. You store the return value from the function in the YourName variable. Whatever the user types, unless they type nothing, will be stored in this variable. Put another way, the script receives some external input — and remember that we said input is always unpredictable: Do TryAgain = “No” YourName = InputBox(“Please enter your name:”) 4. In the next part of the code, you test the input. The line If YourName = “ “ Then tests to see if the user typed in their name (or at least some text). If they typed something in, the code immediately after the Else line will execute. If they didn’t type in anything (or if they clicked the Cancel button), then the YourName variable will be empty, and the code after the If line will execute instead: Do TryAgain = “No” YourName = InputBox(“Please enter your name:”) If YourName = “” Then MsgBox “You must enter your name to continue.” TryAgain = “Yes” Else Greeting = “Hello, “& YourName & “, great to meet you.” End If If the user didn’t type anything into the input box, you will display a message informing them that they have done something you didn’t want them to. You then set the TryAgain variable (the control variable) to “Yes” and send them around the loop once more and ask the users 15 16. 16. Chapter 1: A Quick Introduction to Programming for their name again (wherein this time they will hopefully type something into the input box). If the user did type in his or her name, then you initialize your familiar Greeting variable. Note that in this case, you do not change the value of the TryAgain variable. This is because there is no need to loop around again because the user has entered a name. The value of TryAgain is already equal to “No”, so there’s no need to change it. 5. In the next line of code, you encounter the end of the loop block. What this Loop line is essen- tially telling the script engine is “If the TryAgain variable equals “Yes” at this point, then go back up to the Do line and execute all that code over again.” If the user entered his or her name, then the TryAgain variable will be equal to “No”. Therefore, the code will not loop again, and will continue onto the last line: Do TryAgain = “No” YourName = InputBox(“Please enter your name:”) If YourName = “” Then MsgBox “You must enter your name to continue.” TryAgain = “Yes” Else Greeting = “Hello, “& YourName & “, great to meet you.” End If Loop While TryAgain = “Yes” MsgBox Greeting MsgBox Greeting If the user did not enter his or her name, then TryAgain would be equal to “Yes”, which would mean that the code would again jump back to the Do line. This is where the reinitialization of the TryAgain variable to “No” is essential because if it wasn’t done then there’s no way for TryAgain to ever equal anything but “Yes”. And if TryAgain always equals “Yes”, then the loop will keep going around and around forever. This results in total disaster for your script, and for the user.Using the For…Next Loop In this kind of loop, you don’t need to worry about infinite loops because the loop is predefined to execute only a certain number of times. Here’s a simple (if not very useful) example. Dim Counter MsgBox “Let’s count to ten. Ready?” For Counter = 1 to 10 MsgBox Counter Next MsgBox “Wasn’t that fun?” This loop is similar to the previous loop. The beginning loop block is defined by the For statement, and the end is defined by the Next statement. This loop is different because you can predetermine how many times it will run; in this case, it will go around exactly ten times. The line For Counter = 1 to 10 essentially tells the script engine, “Execute this block of code as many times as it takes to count from16 17. 17. Chapter 1: A Quick Introduction to Programming1 to 10, and use the Counter variable to keep track of your counting. When you’ve gone through thisloop ten times, stop looping and move on to the next bit of code.”Notice that every time the loop goes around (including the first time through), the Counter variableholds the value of the current count. The first time through, Counter equals 1, the second time throughit equals 2, and so on up to 10. It’s important to note that after the loop is finished, the value of theCounter variable will be 11, one number higher than the highest value in your For statement.The reason for this is that the Counter variable is incremented at the end of the loop, after which theFor statement tests the value of index to see if it is necessary to loop again.Giving you a meaningful example of how to make use of the For...Next loop isn’t easy because youhaven’t been exposed to much VBScript just yet, but here’s an example that shows you don’t need toknow how many times the loop needs to run before you run it. Dim Counter Dim WordLength Dim WordBuilder WordLength = Len(“VBScript is great!”) For Counter = 1 to WordLength MsgBox Mid(“VBScript is great!”, Counter, 1) WordBuilder = WordBuilder & Mid(“VBScript is great!”, Counter, 1) Next MsgBox WordBuilderFor example, the phrase “VBScript is great!” has exactly 18 letter spaces. If you first calculated thenumber of letters in the phrase, you could use that number to drive a For...Next loop. However, thiscode uses the VBScript Len() function to calculate the length of the phrase used. Inside the loop, it usesthe Mid() function to pull one letter out of the phrase one at a time and display them separately. Theposition of that letter is controlled by the counter variable, while the number of letters extracted isdefined by the length argument at the end. It also populates the WordBuilder variable with each loop,adding each new letter to the previous letter or letters, rebuilding the phrase.Here’s a variation of the last example: here giving the user the opportunity to type in a word or phrase to use,proving that there’s nothing up your sleeve when it comes to knowing how many times to loop the code. Dim Counter Dim WordLength Dim InputWord Dim WordBuilder InputWord = InputBox (“Type in a word or phrase to use”) WordLength = Len(InputWord) For Counter = 1 to WordLength MsgBox Mid(InputWord, Counter, 1) WordBuilder = WordBuilder & Mid(InputWord, Counter, 1) Next MsgBox WordBuilder & “ contains “& WordLength & “ characters.” 17 18. 18. Chapter 1: A Quick Introduction to Programming Figure 1-7 shows the final summary message generated by the code. Notice how well the information is integrated. Figure 1-7 Operators and Operator Precedence An operator acts on one or more operands when comparing, assigning, concatenating, calculating, and performing logical operations. Say you want to calculate the difference between two variables X and Y and save the result in variable Z. These variables are the operands and to find the difference you use the subtraction operator like this: Z = X - Y Here you use the assignment operator (=) to assign the difference between X and Y, which was found by using the subtraction operator (-). Operators are one of the single-most important parts of any programming language. Without them, you cannot assign values to variables or perform calculations or comparisons. In fact, you can’t do much at all. There are different types of operators and they each serve a specific purpose, as shown in the following table. Operator Purpose assignment (=) The most obvious and is simply used for assigning a value to a variable or property. arithmetic These are all used to calculate a numeric value, and are normally used in conjunction with the assignment operator and/or one of the comparison operators. concatenation These are used to concatenate (“join together”) two or more different expressions. comparison These are used for comparing variables and expressions against other variables, constants, or expressions. logical These are used for performing logical operations on expressions; all logical operators can also be used as bitwise operators. bitwise These are used for comparing binary values bit by bit; all bitwise operators can also be used as logical operators.18 19. 19. Chapter 1: A Quick Introduction to Programming When you have a situation where more than one operation occurs in an expression, the operations are normally performed from left to right. However, there are several rules. Operators from the arithmetic group are evaluated first, then concatenation, comparison, and finally logical operators. This is the set order in which operations occur (operators in brackets have the same precedence): ❑ ∩, −, (*, /), , Mod, (+, −) ❑ & ❑ =, <>, <, >, <=, >=, Is ❑ Not, And, Or, Xor, Eqv, Imp This order can be overridden by using parentheses. Operations in parentheses are evaluated before operations outside the parentheses, but inside the parentheses, the normal precedence rules still apply. Take a look at the following two statements: A = 5 + 6 * 7 + 8 A = (5 + 6) * (7 + 8) They look the same but they’re not. According to operator precedence, multiplication is performed before addition, so the top line gives A the value 55 (6 * 7 = 42 + 5 + 8 = 55). By adding parenthe- ses, you force the additions to be evaluated first and A becomes equal to 165.Organizing and Reusing Code So far, the scripts you’ve worked with have been fairly simple in structure. The code has been all together in one unit. You haven’t done anything all that complicated, so it’s easy to see all the code in just a few lines. The execution of the code is easy to follow because it starts at the top of the file, with the first line, and then continues downward until it reaches the last line. Sometimes, at certain points, choices redirect the code using branching, or sections of code are repeated using loops. However, when you come to writing a script that actually does something useful, your code is likely to get more complex. As you add more code to the script, it becomes harder to read in one chunk. If you print it on paper, your scripts will undoubtedly stretch across multiple pages. As the code becomes more complex, it’s easier for bugs and errors to creep in, and the poor layout of the code will make these harder to find and fix. The most common technique programmers use to manage complexity is called modularization. This is a big, fancy word, but the concept behind it is really quite simple. This section defines some terminology used when organizing and reusing code, and then discusses how to write your own procedures by turning code into a function. You then learn a few advantages of having procedures. 19 20. 20. Chapter 1: A Quick Introduction to ProgrammingModularization, Black Boxes,Procedures, and Subprocedures Modularization is the process of organizing your code into modules, which you can also think of as build- ing blocks. You can apply the principles of modularity to create your own personal set of programming building blocks, which you can then use to build programs that are more powerful, more reliable, easier to debug, and easier for you and your fellow programmers to maintain and reuse. When you take your code and divide it into modules, your ultimate goal is to create what are known as black boxes. A black box is any kind of device that has a simple, well-defined interface and that performs some discrete, well- defined function. A black box is so called because you don’t need to see what’s going on inside it. All you need to know is what it does, what its inputs are, and (sometimes) what its outputs are. A wristwatch is a good example of a black box. It has inputs (buttons) and outputs (time) and does a simple function well without you worrying about how the innards of the watch work in order to be able to tell the time. The most basic kind of black box programmers use to achieve modularity is the procedure. A procedure is a set of code that (ideally) performs a single function. Good examples of procedures are: ❑ Code that adds two numbers together ❑ Code that processes a string input ❑ Code that handles saving to a file Bad examples include: ❑ Code that takes an input, processes it, and also handles saving to a file ❑ Code that handles file access and database access You’ve been using procedures throughout this chapter, but they have been procedures that VBScript provides for you. Some of these procedures require input, some don’t. Some of these procedures return a value, some don’t. But all of the procedures you’ve used so far (MsgBox(), InputBox(), and so on) are black boxes. They perform one single well-defined function, and they perform it without you having to worry about how they perform their respective functions. In just a moment, you’ll see how to extend the VBScript language by writing your own procedures. Before you begin though, it’s time to get some of the terminology cleared up. Procedure is a generic term that describes either a function or a subprocedure. This chapter touched on some of this confusing termi- nology earlier, but a function is simply a procedure that returns a value. Len() is a function. You pass it some text, and it returns the number of characters in the string (or the number of bytes required to store a variable) back to you. Functions do not always require input, but they often do. A subprocedure is a procedure that does not return a value. You’ve been using MsgBox() as a subproce- dure. You pass it some text, and it displays a message on the screen comprising of that text. It does not return any kind of value to your code. All you need to know is that it did what you asked it to do. Just like functions, procedure may or may not require input.20 21. 21. Chapter 1: A Quick Introduction to ProgrammingTurning Code into a Function Some of the code that follows is from an example you used earlier in the chapter. Here’s how to turn code into a function. Function PromptUserName ‘ This Function prompts the user for his or her name. ‘ If the user enters nothing it returns a zero-length string. ‘ It incorporates various greetings depending on input by the user. Dim YourName Dim Greeting YourName = InputBox(“Hello! What is your name?”) If YourName = “” Then Greeting = “OK. You don’t want to tell me your name.” ElseIf YourName = “abc” Then Greeting = “That’s not a real name.” ElseIf YourName = “xxx” Then Greeting = “That’s not a real name.” Else Greeting = “Hello, “ & YourName & “, great to meet you.” If YourName = “Fred” Then Greeting = Greeting & “ Nice to see you Fred.” End If End If MsgBox Greeting PromptUserName = YourName End Function The first things to take note of in the code are the first and last lines. While not groundbreaking, these are what define a function. The first line defines the beginning of the function and gives it a name while the last line defines the end of the function. Based on the earlier discussion of code blocks, this should be a familiar convention by now. From this, you should begin to realize that a procedure is nothing but a special kind of code block. The code has to tell the script engine where it begins and where it ends. Notice also that you’ve given the function a clear, useful name that precisely describes what this function does. Giving your procedures good names is one of the keys to writing programs that are easy to read and maintain. Notice also how there’s a comment to the beginning of the procedure to describe only what it does, not how the function does what it does. The code that uses this function does not care how the function accomplishes its task; it only cares about inputs, outputs, and predictability. It is vitally important that you add clear, informative comments such as this to the beginning of your procedures, because they make it easy to determine what the function does. The comment also performs one other valuable ser- vice to you and any other developer who wants to call this function — it says that the function may return a zero-length string if the user does not enter his or her name. 21 22. 22. Chapter 1: A Quick Introduction to Programming Finally, notice how, in the second to last line, the function name PromptUserName is treated as if it were a variable. When you use functions (as opposed to subprocedures, which do not return a value), this is how you give the function its return value. In a sense, the function name itself is a variable within the procedure. Here is some code that uses the PromptUserName function. Dim Greeting Dim VisitorName VisitorName = PromptUserName If VisitorName <> “” Then Greeting = “Goodbye, “ & VisitorName & “. Nice to have met you.” Else Greeting = “I’m glad to have met you, but I wish I knew your name.” End If MsgBox Greeting If you are using Windows Script Host for this code, bear in mind that this code and the PromptUserName function itself must be in the same .vbs script file. Dim PartingGreeting Dim VisitorName VisitorName = PromptUserName If VisitorName <> “” Then PartingGreeting = “Goodbye, “ & VisitorName & “. Nice to have met you.” Else PartingGreeting = “I’m glad to have met you, but I wish I knew your name.” End If MsgBox PartingGreeting Function PromptUserName ‘ This Function prompts the user for his or her name. ‘ It incorporates various greetings depending on input by the user. Dim YourName Dim Greeting YourName = InputBox(“Hello! What is your name?”) If YourName = “” Then Greeting = “OK. You don’t want to tell me your name.” ElseIf YourName = “abc” Then Greeting = “That’s not a real name.” ElseIf YourName = “xxx” Then Greeting = “That’s not a real name.”22 23. 23. Chapter 1: A Quick Introduction to Programming Else Greeting = “Hello, “ & YourName & “, great to meet you.” If YourName = “Fred” Then Greeting = Greeting & “ Nice to see you Fred.” End If End If MsgBox Greeting PromptUserName = YourName End Function As you can see, calling the PromptUserName function is pretty straightforward. Once you have written a procedure, calling it is no different than calling a built-in VBScript procedure.Advantages to Using Procedures Procedures afford several key advantages that are beyond the scope of this discussion. However, here are a few of the most important ones: ❑ Code such as that put in the PromptUserName function can be thought of as “generic,” meaning that it can be applied to a variety of uses. Once you have created a discreet, well-defined, generic function such as PromptUserName, you are free to reuse it any time you want to prompt users for their name. Once you’ve written a well-tested procedure, you never have to write that code again. Any time you need it, you just call the procedure. This is known as code reuse. ❑ When you call a procedure to perform a task rather than writing the code in-line, it makes that code much easier to read and maintain. Increasing the readability, and therefore the manageability and maintainability, of your code is a good enough reason to break a block of code out into its own procedure. ❑ When code is isolated into its own procedure, it greatly reduces the effects of changes to that code. This goes back to the idea of the black box. As long as the procedure maintains its predictable inputs and outputs, changes to the code inside of a procedure are insulated from harming the code that calls the procedure. You can make significant changes to the procedure, but as long as the inputs and outputs are predictable and remain unchanged, the code will work just fine.Top-Down versus Event-Driven Before you leave this introduction to programming, it may be helpful to point out that you will encounter two different models of programming in this book: top-down and event-driven programs. The differences between the two have to do with the way you organize your code and how and when that code gets executed at runtime. As you get deeper into programming in general, and VBScript in particular, this will become clearer, so don’t be alarmed if it doesn’t completely sink in right now. 23 24. 24. Chapter 1: A Quick Introduction to ProgrammingUnderstanding Top-Down Programming So far in this chapter you’ve written very simple top-down style programs. The process is simple to follow: ❑ Write some code. ❑ Save the code in a script file. ❑ Use Windows Script Host to execute the script. ❑ The Script Host starts executing at the first line and continues to the last line. ❑ If a script file contains some procedure definitions (such as your PromptUserName function), then the Script Host only executes those procedures if some other code calls them. ❑ Once the Script Host reaches the last line of code, the lifetime of the script ends. Top-down programs are very useful for task-oriented scripts. For example, you might write a script to search your hard drive for all the files with the extension .htm and copy all the names and file locations to a file, formatted in HTML to act as a sitemap. Or you might write a script that gets executed every time Windows starts and which randomly chooses a different desktop wallpaper bitmap file for that session of Windows. Top-down programming is perfect for these kinds of scripts.Understanding Event-Driven Programming Event-driven code is different, and is useful in different contexts. As the name implies, event-driven code only gets executed when a certain event occurs. Until the event occurs, the code won’t get executed. If a given event does not occur during the lifetime of the script, the code associated with that event won’t be executed at all. If an event occurs, and there’s no code associated with that event, then the event is essentially ignored. Event-driven programming is the predominant paradigm in Windows programming. Most of the Windows programs you use every day were written in the event-driven model. This is because of the graphical nature of Windows programs. In a graphical user interface (GUI), you have all sorts of buttons, drop-down lists, fields in which to type text, and so on. For example, the word processor program Microsoft Word is totally jam-packed with these. Every time a user clicks a button, chooses an item in a list, or types some text into a field, an event is “raised” within the code. The person who wrote the pro- gram may or may not have decided to write code in response to that event. However, if the program is well written, an item such as a button for saving a file, which the user expects to have code behind it, will indeed have code behind it.How Top-Down and Event-Driven Work Together When a GUI-based program starts, there is almost always some top-down style code that executes first. This code might be used to read a setting stored in the registry, prompt the user for a name and pass- word, load a particular file at startup or prompt to take the user through setup if this is the first time the application has been run, and so on. Then a form typically comes up. The form contains all the menus, buttons, lists, and fields that make up the user interface of the program. At that point, the top-down style coding is done, and the program enters what is known as a wait state. No code is executing at this point and the program just waits for the user to do something. From here on, it’s pretty much all about events.24 25. 25. Chapter 1: A Quick Introduction to Programming When the user begins to do something, the program comes to life again. Suppose the user clicks a but- ton. The program raises the Click event for the button that the user clicked. The code attached to that event starts to execute, performs some operations, and when it’s finished, the program returns to its wait state. As far as VBScript is concerned, the event-driven model is used heavily in scripting for the Web. Scripts that run inside of HTML web pages are all based on events. One script may execute when the page is loaded, while another script might execute when the user clicks a link or graphic. These “mini scripts” are embedded in the HTML file, and are blocked out in a syntax very similar to the one you used to define the PromptUserName function in the previous section.An Event-Driven Code Example As you progress through the second half of this book, the finer points of event-driven programming will become much clearer to you. However, just so you can see an example at this point, type the following code into your text editor, save the file with a .HTM extension, and then load it into Internet Explorer 6 (if you are running Internet Explorer 6/7 and you are running this file off your desktop, you might have to dismiss some security warnings and allow ActiveX). <html> <head> <title>Simple VBScript Example</title> <script language=”vbscript”> Sub ButtonClicked window.alert(“You clicked on the button!”) End Sub </script> </head> <body> <button name=”Button1” type=”BUTTON” onclick=”ButtonClicked”> Click Me If You Can!!! </button> </body> </html> Figure 1-8 shows the result of clicking the button on the page. In this case it’s only a message box but it could be much more.Coding Guidelines It’s a really good idea to get into healthy programming habits right from the beginning. As you continue to hone your programming skills and possibly learn multiple languages, these habits will serve you well. Your programs will be easier for you and your fellow developers to read, understand, and modify, and they will also contain fewer bugs. When you first start writing code, you have to concentrate so hard on just getting the syntax correct for the computer that it may be easy for you to forget about all the things you need to do in order to make sure your code is human friendly as well. However, attentiveness early on will pay huge dividends in the long run. 25 26. 26. Chapter 1: A Quick Introduction to Programming Figure 1-8Expect the Unexpected Always remember that anything that can happen probably will happen. The idea here is to code defensively — preparing for the unexpected. You don’t need to become totally fixated on preparing for all contingencies and remote possibilities, but you can’t ignore them either. You especially have to worry about the unexpected when receiving input from the user, from a database, or from a file. Whenever you’re about to perform an action on something, ask yourself questions such as: ❑ What could go wrong here? ❑ What happens if the file is flagged read-only? ❑ What happens if the file isn’t there? ❑ What happens if the user doesn’t run the program from the right folder? ❑ What happens if the database table doesn’t have any records? ❑ What happens if the registry keys I was expecting aren’t there? ❑ What happens if the user doesn’t have the proper permission to carry out the operation? If you don’t know what might go wrong with a given operation, find out through research or trial and error. Get others to try out your code and get their feedback on how it worked for them, on their system configuration, and on their operating system. Don’t leave it up to your users to discover how well (or not) your script reacts to something unexpected. A huge part of properly preparing for the unexpected is the implementation of proper error handling, which is discussed in detail in Chapter 6.26 27. 27. Chapter 1: A Quick Introduction to ProgrammingAlways Favor the Explicit over the Implicit When you are writing code, constantly ask yourself: Is my intent clear to someone reading this code? Does the code speak for itself? Is there anything mysterious here? Are there any hidden meanings? Are the variable names too similar to be confusing? Even though something is obvious in your mind at the moment you are typing the code, it doesn’t mean it will be obvious to you six months or a year from now — or to someone else tomorrow. Always endeavor to make your code as self-documenting as possi- ble, and where you fall short of that goal (which even the best programmers do — self-documenting code can be an elusive goal), use good comments to make things clearer. Be wary of using too many generics in code, such as x, y, and z as variable names and Function1, Function2, and Function3 as function names. Instead, make them explicit. Use variable names such as UserName and TaxRate. When naming a variable, use a name that will make it clear what that variable is used for. Be careful using abbreviations. Don’t make variable names too short, but don’t make them too long either (10–16 characters is a good length, but ideal length is largely a matter of preference). Even though VBScript is not case-sensitive, use mixed case to make it easier to distinguish multiple words within the variable name (for example, UserName is easier to read than username). When naming procedures, try to choose a name that describes exactly what the procedure does. If the procedure is a function that returns a value, indicate what the return value is in the function name (for example, PromptUserName). Try to use good verb–noun combinations to describe first, what action the procedure performs, and second, what the action is performed on (for example, SearchFolders, MakeUniqueRegistryKey, or LoadSettings). Good procedure names tend to be longer than good variable names. Don’t go out of your way to make them longer, but don’t be afraid to either. Fifteen to thirty characters for a procedure name is perfectly acceptable (they can be a bit longer because you generally don’t type them nearly as much). If you are having trouble giving your procedure a good name, that might be an indication that the procedure is not narrow enough — a good procedure does one thing, and does it well. That said, if you are writing scripts for web pages to be downloaded to a user’s browser, it is sometimes necessary to use shorter variable and procedure names. Longer names mean larger files to download. Even if you sacrifice some readability to make the file smaller, you can still take time to create descriptive names. With web scripts, however, you may encounter instances where you don’t want the code to be clear and easy to understand (at least for others). You’ll look at techniques that you can employ to make scripts harder for “script snoopers” to follow while still allowing you to work with them and modify them later (see Chapter 17).Modularize Your Code into Procedures,Modules, Classes, and Components As you write code, you should constantly evaluate whether any given code block would be better if you moved it to its own function or subprocedure: ❑ Is the code rather complex? If so, break it into procedures. ❑ Are you using many Ands and Ors in an If...End If statement? Consider moving the evaluation to its own procedure. 27 28. 28. Chapter 1: A Quick Introduction to Programming ❑ Are you writing a block of code that you think you might need again in some other part of the script, or in another script? Move it to its own procedure. ❑ Are you writing some code that you think someone else might find useful? Move it. This isn’t a science and there are no hard and fast rules for code — after all, only you know what you want it to do. Only you know if parts are going to be reused later. Only you know how complex something will turn out. However, always keep an eye out for possible modularization.Use the “Hungarian” Variable Naming Convention You might hear programmers (especially C++ programmers) mention this quite a bit. While this is a bit out of scope of this introductory discussion, it is still worth mentioning nonetheless. The Hungarian naming convention involves giving variable names a prefix that indicates what the scope and data type of the variable are intended to be. So as not to confuse matters, the Hungarian convention was not used in this chapter, but you will find that most programmers prefer this convention. Properly used, it makes your programs much clearer and easier to write and read. See Chapter 3 for more on Hungarian notation variable prefixes. The standard prefixes for scope and data types are in Appendix B.Don’t Use One Variable for More Than One Job This is a big no-no and a common mistake of both beginner and experienced programmers alike (but the fact that experienced programmers might have a bad habit does not make it any less bad). Each variable in your script should have just one purpose. It might be very tempting to just declare a bunch of generic variables with fuzzy names at the beginning of your script, and then use them for multiple purposes throughout your script — but don’t do it. This is one of the best ways to introduce very strange, hard to track down bugs into your scripts. Giving a vari- able a good name that clearly defines its purpose will help prevent you from using it for multiple pur- poses. The moral here is that while reusing variables might seem like a total timesaver, it isn’t and can lead to hours of frustration and wasted time looking for the problem.Always Lay Out Your Code Properly Always remember that good code layout adds greatly to readability later. Don’t be tempted to save time early on by writing messy, hard to follow code because as sure as day turns to night, you will suffer if you do. Without reading a single word, you should be able to look at the indentations of the lines to see which ones are subordinate to others. Keep related code together by keeping them on consecutive lines. Also, don’t be frightened of white space in your code. Separate blocks of unrelated code by putting a blank line between them. Even though the script engine will let you, avoid putting multiple statements on the same line. Also, remember to use the line continuation character (_) to break long lines into multiple shorter lines. The importance of a clean layout that visually suggests the logic of the underlying code cannot be overemphasized.28 29. 29. Chapter 1: A Quick Introduction to ProgrammingUse Comments to Make Your Code More Clearand Readable, but Don’t Overuse Them When writing code, strive to make it as self-documenting as possible. You can do this by following the guidelines set out earlier. However, self-documenting code is hard to achieve and no one is capable of 100% self-documenting code. Everyone writes code that can benefit from a few little scribbles to serve as reminders in the margins. The coding equivalents of these scribbles are comments. But how can you tell a good comment from a bad comment? Generally speaking, a good comment operates at the level of intent. A good comment answers the questions: ❑ Where does this code block fit in with the overall script? ❑ Why did the programmer write this code? The answers to these questions fill in the blanks that can never be filled by even the best, most pedantic self-documenting code. Good comments are also generally “paragraph-level” comments. Your code should be clear enough that you do not need a comment for each and every line of code it contains, but a comment that quickly and clearly describes the purpose for a block of code allows a reader to scan through the comments rather than reading every line of code. The idea is to keep the person who might be reading your code from having to pore over every line to try and figure out why the code exists. Commenting every line (as you probably noticed with the earlier examples) makes the code hard to follow and breaks up the flow too much. Bad comments are generally redundant comments, meaning they repeat what the code itself already tells you. Try to make your code as clear as possible so that you don’t need to repeat yourself with comments. Redundant comments tend to add clutter and do more harm than good. Reading the code tells you the how; reading the comments should tell you the why. Finally, it’s a good idea to get into the habit of adding “tombstone” or “flower box” comments at the top of each script file, module, class, and procedure. These comments typically describe the purpose of the code, the date it was written, the original author, and a log of modifications. ‘ Kathie Kingsley-Hughes ‘ 22 Feb 2007 ‘ This script prompts the user for his or her name. ‘ It incorporates various greetings depending on input by the user. ‘ ‘ Added alternative greeting ‘ Changed variable names to make them more readableSummar y In this chapter you took a really fast-paced journey through the basics of programming. The authors tried to distill a whole subject (at least a book) into one chapter. You covered an awful lot of ground but also skimmed over or totally passed by a lot of stuff. However, the information in this chapter gave you the basics you need to get started programming with VBScript and the knowledge and confidence you need to talk about programming with other programmers in a language they understand. 29 30. 30. What Are VBScript Data Types? VBScript has only one data type called a Variant. A Variant is a special kind of data type that can containdifferent kinds of information, depending on how its used. Because Variant is the only data type in VBScript,its also the data type returned by all functions in VBScript. At its simplest, a Variant can contain either numeric or string information. A Variant behaves as a numberwhen you use it in a numeric context and as a string when you use it in a string context. That is, if youreworking with data that looks like numbers, VBScript assumes that it is numbers and does the thing that is mostappropriate for numbers. Similarly, if youre working with data that can only be string data, VBScript treats itas string data. Of course, you can always make numbers behave as strings by enclosing them in quotationmarks (" ").Variant Subtypes Beyond the simple numeric or string classifications, a Variant can make further distinctions about thespecific nature of numeric information. For example, you can have numeric information that represents a dateor a time. When used with other date or time data, the result is always expressed as a date or a time. Ofcourse, you can also have a rich variety of numeric information ranging in size from Boolean values to hugefloating-point numbers. These different categories of information that can be contained in a Variant are calledsubtypes. Most of the time, you can just put the kind of data you want in a Variant, and the Variant behaves ina way that is most appropriate for the data it contains. The following table shows the subtypes of data that a Variant can contain. Subtype Description Empty Variant is uninitialized. Value is 0 for numeric variables or a zero-length string ("") for stringvariables. Null Variant intentionally contains no valid data. Boolean Contains either True or False. Byte Contains integer in the range 0 to 255. Integer Contains integer in the range -32,768 to 32,767. Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807. Long Contains integer in the range -2,147,483,648 to 2,147,483,647. Single Contains a single-precision, floating-point number in the range -3.402823E38 to-1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values. Double Contains a double-precision, floating-point number in the range -1.79769313486232E308 to-4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 forpositive values. Date (Time) Contains a number that represents a date between January 1, 100 to December 31, 9999. String Contains a variable-length string that can be up to approximately 2 billion characters in length. Object Contains an object. Error Contains an error number. You can use conversion functions to convert data from one subtype to another. In addition, the VarTypefunction returns information about how your data is stored within a Variant.© 1997 Microsoft Corporation. All rights reserved. Terms of Use.
__label__1
0.509907
Early experiences matter: Lasting effect of concentrated disadvantage on children's language and cognitive outcomes ArticleinHealth & Place 16(2):371-80 · November 2009with31 Reads Impact Factor: 2.81 · DOI: 10.1016/j.healthplace.2009.11.009 · Source: PubMed A small but provocative literature suggests that neighbourhood socioeconomic conditions experienced by children early in life influence a variety of health and developmental outcomes later in life. We contribute to this literature by testing the degree to which neighbourhood socioeconomic conditions that children experience in Kindergarten influence their later language and cognitive outcomes in early adolescence, over and above current neighbourhood context and various child-level covariates including scores on a Kindergarten measure of school readiness. Cross-classified random effects modelling (CCREM) analyses were performed on a study population of 2648 urban children residing throughout the province of British Columbia, Canada, who were followed longitudinally from Kindergarten (age 5/6) to Grade 7 (age 12/13). Findings demonstrate that neighbourhood concentrated disadvantage experienced during Kindergarten has a durable, negative effect on children's reading comprehension outcomes seven years later-providing evidence that early social contextual experiences play a critical role in the lives of children. Possible explanations and future directions are discussed.
__label__1
0.999454
"P. 1\nThe Marxist-Leninist Publishing Field in Greece during the 60s-70sChristos Mais - MA Thesis\n(...TRUNCATED)
__label__1
0.802307
"Mystere pa21 Stereo Tube Power Amplifier\n\n\nDurob Audio is a company in the Netherlands that mark(...TRUNCATED)
__label__1
0.514612
"Scientists discover a new disease-causing bacterium in an immune-compromised patient\n\nResearchers(...TRUNCATED)
__label__1
0.998336
"Hawaii Travel pictures of the island of Hawaii - Hawaii Island - a report on Hawaii Islands - touri(...TRUNCATED)
__label__1
0.978741
"I agree with the above as to the engagement ring. It is a conditional gift. Marriage satisfied the (...TRUNCATED)
__label__1
0.506504
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
31