Presentation is loading. Please wait.

Presentation is loading. Please wait.

©2003 Hal Helms, Inc. Variables The Tao that can be told is not the eternal Tao. The name that can be named is no t the eternal Name. —Lao-Tzu.

Similar presentations


Presentation on theme: "©2003 Hal Helms, Inc. Variables The Tao that can be told is not the eternal Tao. The name that can be named is no t the eternal Name. —Lao-Tzu."— Presentation transcript:

1 ©2003 Hal Helms, Inc. Variables The Tao that can be told is not the eternal Tao. The name that can be named is no t the eternal Name. —Lao-Tzu

2 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 2 Data types  Variables have a property called a data type that specifies t he type of data that a variable holds –integer –string –decimal number –boolean value –record set ds

3 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 3 Strong typing  Some languages require that you declare a variable's data type prior to using it –String state = "Indiana"; // Java  Once declared, a variable's data type cannot change –boolean state = true; // illegal!! –Such languages are called strongly-typed ds

4 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 4 Strong typing: pros & cons  Pros –allows compiler (most strongly-typed languages are also compiled languages) to optimize performance –enforced rigor helpful when dealing with large-scale or complex applications  Cons –slower development

5 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 5 Weak typing  Other languages do not require that you declare a variable' s data type prior to using it  Data types can change  Such languages are called weakly-typed ds

6 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 6 Weak typing: pros and cons  Pros –no compile cycle (most weakly typed languages are interpreted languages)  Cons –easier to make mistakes in overwriting variables –slower execution since all data typing must be done at run time –harder to maintain code

7 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 7 Compiled languages  Some languages have a separate compile cycle during whi ch several checks are made including checking variables are f or valid types, correct naming and scoping of variables, etc. –Java –C#  After the compile cycle is completed, the program can be r un  When the program runs, we are said to be in run time

8 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 8 Interpreted languages  Some languages have no separate compile cycle but inste ad do all checking at run time –ColdFusion –Smalltalk

9 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 9 ColdFusion?  ColdFusion is… –weakly-typed –interpreted

10 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 10 Data types can be simple…  String ‘Welcome to Programming Foundations’  Numeric 25 50.75  Date {ts '2001-03-30 17:45:43'}  Boolean TRUE FALSE ds

11 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 11 …or complex  Structure – collection of name/value pairs  Array – numbered collection of other data types (not name/value pairs)  Query result set – return by a  List – Pat, Wesley, Donna, Kathy, Michael, Jim ds

12 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 12 More on variables  Variables have two important properties –scope: where the variable can be accessed from –lifespan (or span): how long the variable lives

13 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 13 Scopes in ColdFusion  Variables that can be seen by the page that called them as well (including d files) are called local variables  Variables that can be seen by all pages (including custom t ags and d files) are called global variables ds

14 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 14 Lifespans in ColdFusion  Most variables live only for a single page request  Those that live across multiple page requests are called persistent Client Web server ColdFusion server Database server

15 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 15 Variable matrix ScopeSpan variables localpage request request globalpage request form globalpage request URL globalpage request attributes localpage request caller localpage request CGI globalpage request cookie globalpersistent session globalpersistent client globalpersistent application globalpersistent server globalpersistent ds

16 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 16 Creating/setting a variable  Method 1 (common)  Method 2 ds

17 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 17 Local scope examples * *Unscoped variables are part of the default “variables” local scope ds

18 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 18 Specifying different scopes same

19 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 19 Form variables  When a form is submitted through the post method, any f orm fields are placed into the form scope of the form processo r (the page set in the form's action property) and can be accessed by that page <input type="hidden" name="today" value="Monday"> …

20 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 20 URL variables  You can pass variables on a URL in a query string  The query string is created by appending a ? to the URL and then adding name=value pairs separated by an ampersan d  These variables are then accessible to the called page in the URL scope

21 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 21 Displaying variables  Wrap pound signs around a variable and set within tags Hello, there, #yourName#  You don't need to do this within CF tags and functions (usu ally)

22 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 22 The Evaluate() function  Use it when you want to force an evaluation of a name as a variable.  Example: –When you submit a form to a processing page, you get a variable called form.fieldlist, a list of the form fields…

23 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 23 Evaluate() #aFormField#  What will this produce?

24 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 24 Evaluate() #Evaluate(‘form.’ & aFormField)#  What will this produce?

25 ©2003 Hal Helms, Inc. Complex Variables A child of five would understand this. Send someone to fetch a child of five. —Groucho Marx

26 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 26 Complex data types in ColdFusio n  Structure –collection of name/value pairs  Array –numbered collection of data  Query result set –return by a  List –series of tokens and delimiters  Bob,Sue,Frank,Anne  21|257|TRUE|c:\cfusionmx\wwwroot\test

27 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 27 What is a structure?  Set of name/value pairs that all relate to a central topic or idea ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00

28 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 28 Why structures?  Organizes related data into a single variable that is sim pler to store and manipulate  Provides data encapsulation

29 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 29 Working with structures 1. aStructure.author  John Irving valuestructure-name ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 2. aStructure[‘author’]  John Irving keysvalues key

30 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 30 Structure limitations  Structures can hold as values… –simple values –arrays –structures –result sets –lists

31 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 31 Create a structure Method 1

32 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 32 Create a structure Method 2

33 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 33 Loop over a structure Method 1 #aProperty# is set to a #aBook[aProperty]#

34 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 34 Loop over a structure Method 2 #aProperty# is set to a #Evaluate('aBook.' & aProperty)#

35 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 35 By value  With most variables, a duplicate assignment creates a cop y of the value in a memory location  Changes to greeting will not affect myGreeting "Hello" greeting "Hello" myGreeting

36 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 36 By reference  With structures only, a duplicate assignment creates a poin ter to the same memory location  Changes to book will affect myBook structure book myGreet ing

37 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 37 What will Pavorotti be singing? Today, Mr. Pavarotti will perform "#concertChoice.work#"

38 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 38 Use Duplicate() for by value copie s Today, Mr. Pavarotti will perform "#concertChoice.work#"

39 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 39 Structure functions Duplicate() IsStruct() StructClear() StructCount() StructDelete() StructFind() StructInsert() StructIsEmpty() StructKeyArray() StructKeyExists() StructKeyList() StructNew() StructUpdate()

40 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 40 Duplicate() newBook.price  14.00 ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

41 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 41 IsStruct() IsStruct(Book)  TRUE IsStruct(FBrocks)  FALSE ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

42 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 42 StructClear() StructClear(Book) IsStruct(Book)  TRUE Book.title  error ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

43 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 43 StructCount() StructCount(Book)  6 ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

44 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 44 StructDelete() StructDelete(Book,‘title’)  ISBN0345417976 authorJohn Irving publisherBallantine Books formatPaperback price14.00 ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

45 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 45 StructFind() StructFind(Book,‘title’)  A Prayer for Owen Meany StructFind(Book,‘reserved’)  error ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

46 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 46 StructInsert() StructInsert(Book,‘reserved’,4)  (The fourth parameter for this function, “allowoverwrite” is optional and defaults to FALSE. This option determines whether StructInsert() should overwrite the value of an existing key value.) ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 reserved4 ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

47 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 47 StructIsEmpty() StructIsEmpty(Book)  FALSE StructIsEmpty(CD)  error ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

48 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 48 StructKeyArray() StructKeyArray(Book)  ISBNAUTHORFORMATPUBLISHERTITLEPRICE ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

49 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 49 StructKeyExists() StructKeyExists(Book,‘title’)  TRUE StructKeyExists(Book,‘reserved’)  FALSE StructKeyExists(Z,‘title’)  error ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

50 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 50 StructKeyList() StructKeyList(Book)  “AUTHOR,ISBN,FORMAT,PRICE,PUBLISHER,TITLE” ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

51 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 51 StructNew() StructIsEmpty(Book)  TRUE IsStruct(Book)  TRUE ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

52 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 52 StructUpdate() StructUpdate(Book,‘price’,16.95)  ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price16.95 ISBN0345417976 titleA Prayer for Owen Meany authorJohn Irving publisherBallantine Books formatPaperback price14.00 Book: a structure

53 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 53 Arrays  Definition: a numbered (or indexed) set of values in 1 t o 3 dimensions

54 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 54 Array limitations  Arrays can hold as values… –simple values –arrays –structures –result sets –lists

55 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 55 1-D Arrays  Think of as a single row in a spreadsheet 53625557 [1][2][3][4]

56 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 56 2-D Arrays  Think of as multiple rows in a spreadsheet 53625557 [1][2][3][4] 59485271 64655864 [1] [2] [3]

57 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 57 3-D Arrays  Think of as a spreadsheet cube 62655461 [1][2][3][4] 59485271 64655864 [1] [2] [3] 52596558 59485271 64655864 53625557 59485271 64655864 [1] [2] [3]

58 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 58 Refer to array elements  Use the array name followed by the proper index/es in square brackets 53625557 [1][2][3][4] onedee onedee[3]  55 53625557 [1][2][3][4] 59485271 64655864 [1] [2] [3] twodee twodee[3][4]  64

59 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 59 Create a 1-D array 53625557 onedee

60 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 60 Loop over 1-D array <cfloop from="1" to="#ArrayLen(aCart)#" index="aCol"> #aCart[aCol]#

61 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 61 Create a 2-D array 53625557 59485271 64655864 twodee

62 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 62 Loop over 2-D array <cfloop from="1" to="#ArrayLen(aCart)#" index="aRow"> <cfloop from="1" to="#ArrayLen(aCart[aRow])#" index="aCol"> #aCart[aRow][aCol]#

63 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 63 Unbalanced arrays  Arrays can be “unbalanced”—meaning the number of columns may vary from row to row.  This is a valid CF array: CF 1 Just for fun, write a loop that produces this array…

64 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 64 Things to look out for  It is easy to “walk off” the end of an array—especially unbalanced arrays.  Make sure the array index exists—or CF will throw an error. 21345 myArr

65 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 65 Array functions ArrayAppend() ArrayAvg() ArrayClear() ArrayDeleteAt() ArrayIsEmpty() ArrayLen() ArrayMax() ArrayMin() ArrayNew() ArrayPrepend() ArraySet() ArraySort() ArraySum() ArraySwap() ArrayToList()

66 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 66 Use array functions on 2-D arrays  Made to work on 1-D arrays  2-D arrays can be thought of as a series of stacked 1-D arrays 53625557 59485271 64655864 stacked 1-D arrays single 2-D array

67 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 67 Use array functions on 2-D arrays  If you want to use array functions on 2-D arrays, point at o ne of the stacked 1-D arrays by specifying which row you wan t the function to operate on  Example #ArraySum(twodee[3])# 53625557 59485271 64655864

68 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 68 ArrayAppend() A: 1-D array B: 2-D array ArrayAppend(A,‘x’)  ArrayAppend(B,‘x’)  ERROR ArrayAppend(B[2],‘x’)  1234 2468 36912 1234x 1234 2468 369 x

69 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 69 ArrayAvg() ArrayAvg(A)  2.5 ArrayAvg(B)  ERROR ArrayAvg(B[2])  5 A: 1-D array B: 2-D array 1234 2468 36912

70 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 70 ArrayClear() ArrayClear(A)  YES ArrayIsEmpty(A)  YES ArrayClear(B)  YES ArrayIsEmpty(B)  YES ArrayClear(B[2])  YES ArrayIsEmpty(B[2])  YES ArrayIsEmpty(B[3])  NO A: 1-D array B: 2-D array 1234 2468 36912

71 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 71 ArrayDeleteAt() ArrayDeleteAt(A,2)  ArrayDeleteAt(B,2)  ArrayDeleteAt(B[2],2)  A: 1-D array B: 2-D array 1234 2468 36912 1341234 369 1234 268 369

72 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 72 ArrayInsertAt() ArrayInsertAt(A,3,‘x’)  ArrayInsertAt(B,2,‘x’)  ERROR ArrayInsertAt(B[2],2,‘x’)  A: 1-D array B: 2-D array 1234 2468 36912 1234x1234 2468 369 x

73 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 73 ArrayIsEmpty() See ArrayClear() function A: 1-D array B: 2-D array 1234 2468 36912

74 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 74 ArrayMax() ArrayMax( A )  4 ArrayMax( B )  ERROR ArrayMax( B[2] )  8 A: 1-D array B: 2-D array 1234 2468 36912

75 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 75 ArrayMin() ArrayMin(A)  1 ArrayMin(B)  ERROR ArrayMin(B[2])  2 A: 1-D array B: 2-D array 1234 2468 36912

76 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 76 ArrayNew() A: 1-D array B: 2-D array 1234 2468 36912

77 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 77 ArrayPrepend() ArrayPrepend(A,‘x’)  ArrayPrepend(B,‘x’)  ERROR ArrayPrepend(B[2],‘x’)  A: 1-D array B: 2-D array 1234 2468 36912 1234x 1234 2468 369 x

78 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 78 ArrayResize() Resets an array to a specified minimum number. Used for performance gains on very large arrays

79 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 79 ArraySet()   ERROR  A: 1-D array B: 2-D array 1234 2468 36912 22222222

80 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 80 ArraySort() ArraySort(A,‘numeric’,‘desc')  ArraySort(B,‘numeric,‘desc’)  ERROR ArraySort(B[2],‘numeric,‘desc’)  A: 1-D array B: 2-D array 1234 2468 36912 4321 1234 8642 369

81 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 81 ArraySum() ArraySum(A)  10 ArraySum(B)  ERROR ArraySum(B[2])  20 A: 1-D array B: 2-D array 1234 2468 36912

82 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 82 ArraySwap() ArraySwap(A,3,2)  ArraySwap(B,3,2)  ArraySum(B[2],3,2)  A: 1-D array B: 2-D array 1234 2468 36912 13241234 369 2468 1234 2648 369

83 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 83 ArrayToList() ArrayToList(A)  “1,2,3,4” ArrayToList(B)  error ArrayToList(B[2],‘|’)  “2|4|6|8” A: 1-D array B: 2-D array 1234 2468 36912

84 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 84 Lists  Definition: a list is a string consisting of meaningful data (or tokens) separated by delimiters

85 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 85 Unlimited delimiters  Delimiters can be any single byte character a,b,c (comma is default delimiter) a|b|c myPage.cfm?a=1&b=17552&c=TRUE a b c a b c

86 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 86 List limitations  Lists can hold as values… –simple values –lists

87 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 87 Read a value from a list ListGetAt('a,b,c',2)  b

88 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 88 See if a value exists in a list ListFind(myList,2)  TRUE | FALSE ListFindNoCase(myList,2)  TRUE | FALSE

89 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 89 Set the value of a list element

90 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 90 Insert an element into a list

91 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 91 Delete an element from a list

92 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 92 Loop over a list #aListElement#

93 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 93 List functions ListLen() ListPrepend() ListQualify() ListRest() ListSetAt() ListSort() ListToArray() ListValueCount() ListValueCountNoCase() ListAppend() ListChangeDelims() ListContains() ListContainsNoCase() ListDeleteAt() ListFind() ListFindNoCase() ListFirst() ListGetAt() ListInsertAt() ListLast()

94 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 94 ListAppend() myNums  25,50,75 myNums  25,50,75,100

95 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 95 ListChangeDelims() myNums  25,50,75 myNums  25+50+75

96 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 96 ListContains() myWords  apple,baker,charlie ListContains(myWords,'BAKER',',')  0

97 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 97 ListContainsNoCase() myWords  apple,baker,charlie ListContainsNoCase(myWords,'BAKER',',')  2 ListContainsNoCase(myWords,'bak')  2 If you want to find elements (as opposed to sub-strings), use the ListFind() and ListFindNoCase() functions

98 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 98 ListDeleteAt() myNums  25,50,75 myNums  25,75

99 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 99 ListFind() myWords  apple,baker,charlie ListFind(myWords,'BAKER',',')  0 ListFind(myWords,'baker',',')  2 ListFind(myWords,'bak',',')  0

100 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 100 ListFindNoCase() myWords  apple,baker,charlie ListFind(myWords,'BAKER',',')  2 ListFind(myWords,'baker',',')  2 ListFind(myWords,'bak',',')  0

101 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 101 ListFirst() myWords  apple,baker,charlie ListFirst(myWords)  apple

102 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 102 ListGetAt() myWords  apple,baker,charlie ListGetAt(myWords,3)  charlie

103 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 103 ListInsertAt() myNums  25,50,75 myNums  25,37,50,75

104 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 104 ListLast() myWords  apple,baker,charlie ListLast(myWords,',')  charlie

105 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 105 ListLen() myWords  apple,baker,charlie ListLen(myWords,',')  3

106 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 106 ListPrepend() myNums  25,50,75 myNums  12,25,50,75

107 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 107 ListQualify() myWords  apple,baker,charlie myWords  'apple','baker','charlie'

108 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 108 ListRest() myWords  apple,baker,charlie ListRest(myWords,',')  baker,charlie

109 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 109 ListSetAt() myNums  25,50,75 myNums  25,50,100

110 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 110 ListSort() myNums  25,50,75 myNums  75,50,25 myWords  apple,baker,charlie myWords  charlie,baker, apple

111 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 111 ListToArray() myWords  apple,baker,charlie arr  applebakercharlie

112 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 112 ListValueCount() myWords  apple,baker,charlie ListValueCount(myWords,'charlie',',')  1 ListValueCount(myWords,'CHARLIE',',')  0

113 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 113 ListValueCountNoCase() myWords  apple,baker,charlie ListValueCount(myWords,'charlie',',')  1 ListValueCount(myWords,'CHARLIE',',')  1

114 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 114 Query Result Set  Definition: row(s) of values returned by an SQL query

115 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 115 Query a database …SQL Statement…

116 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 116 Query properties SELECT center_ID, name, city FROM Centers The columns returned are #myQ.columnList# I am now on row #currentRow#

117 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 117 Loop over a query  Use either | #column_name# or #column_name#

118 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 118 Get results of one column as a list  Use the ValueList() or QuotedValueList() function publishers  Techspedition,Techspedition,Prentice Hall,Addison-Wesl ey,Sams

119 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 119 Dereference a query value Your name is #UserInfo.firstName#

120 ©2003 Hal Helms, Inc. ColdFusion MX Foundations 120 Query functions IsQuery() QueryAddColumn() QueryAddRow() QueryNew() QuerySetCell() QuotedValueList() ValueList()


Download ppt "©2003 Hal Helms, Inc. Variables The Tao that can be told is not the eternal Tao. The name that can be named is no t the eternal Name. —Lao-Tzu."

Similar presentations


Ads by Google