Re: Req: Array Tags Explained, simple and clear

This WebDNA talk-list message is from

2004


It keeps the original formatting.
numero = 55144
interpreted = N
texte = Hi Palle, Arrays can be used to store any kind of data. It may be data you've returned from a database search or form variables from user input, or stuff you make up on the fly, whatever you want to stuff into your array. Arrays are (normally) used to store related or lists of data. For example when you pass variables from one html document to another you are actually passing name-value pairs in a list, kind of an array. ?cart=123&user=bob you might think of it as an array(2,2) where array(1,1) = cart, array(1,2) = 123, array(2,1) = user and array(2,2) = bob. In the "Top Selling Books" example you could simply return the results of a WebDNA search if all you wanted to do was list them once, but what if you wanted to do a lot of other operations on the same "list" you wouldn't want to do a new search for each operation. You need to store that information somewhere. Working with an array is much easier than working with a long list of named variables like [book1], [book2], ... [book200]. Most importantly, (and the most powerful thing about arrays), you may not know what information is going to be in that list of books or even how many books are going to be listed. Suppose the user chooses x number of his "favorite" books? What then? Using named variables you'd have to know before hand how many book he was going to choose. It would quickly turn into an unmanageable programming nightmare without arrays. Searching simply returns some data that you are looking for. Once you have that data you'll want to store it somewhere so that you can work with it. Depending on what kind of data you have and what you want to do with it will determine whether you store it in arrays or variables. What exactly are you hoping that Array functions will do for your forum? Hope this helps, MK On Thursday, January 1, 2004, at 11:01 AM, Palle Bo Nielsen wrote: > Hi Marc, > > Thanks a lot for spending some time trying to explain the Array tags > for me. > > I have a couple of questions before I might get (understand) it ;) > > So what your are telling me is that the Array function is mostly, if > not only, used when working with template variables, or? > > Your "top selling books" example. Let's say your have a database of > 10.000 books in your WebDNA database, with 10.000 names and 10.000 > NumSold fields. Why just not do a normal Search and Sort to see the > top 4 selling books? How does the Array tag come handy here? > > I really need to see the difference in using a normal Search and Sort > function compared to the Array function... I'm just a bit confused > here... and really need to learn the Array function. > > Currently I have a quite large Forum system build up using WebDNA and > I hope that the Array function will give me some new possibilities > towards performance and functionality. > > Hope to hear from you soon again. > > Palle > > > > On 31/12-2003, at 19.28, Marc Kaiwi wrote: > >> You're right, the online docs for [ARRAYGET] are very confusing, for >> example I don't understand if you can simply call an array variable >> name [MyArray(1,2)] outside the [ARRAYGET] context or what the syntax >> is? >> >> Anyway, arrays are really useful and easy to understand once you get >> the hang of it. I don't have WebDNA 5 so this code won't work as >> displayed but hopefully I can express the concept of using a simple >> array in a practical way. >> >> At some point in your programming career you're going to find >> yourself using lots of variables like: [book1], [book2], [book3], >> [book4], ... etc,. This is a good sign that it might be easier to use >> an array. >> >> For example, we'll assume you have a "list" of your 4 current top >> selling books and the number of books sold for each. You might make >> assignments like this: >> [TEXT] book1=John[/TEXT] >> [TEXT] book2=Mark[/TEXT] >> [TEXT] book3=Matthew[/TEXT] >> [TEXT] book4=Luke[/TEXT] >> And then >> [TEXT] book1_NumSold=50[/TEXT] >> [TEXT] book2_NumSold=40[/TEXT] >> [TEXT] book3_NumSold=30[/TEXT] >> [TEXT] book4_NumSold=12[/TEXT] >> >> In this case you would access these values using: >> Our top selling book is [Books1] it has sold [book1_NumSold] copies! >> >> Or you could set up an array with these same values: >> >> [ARRAYSET NAME=Books&DIM=4,2] [/arrayset] --> creates an empty two >> dimensional array (think of it as a table) that looks like this: >> [1][2][3][4] >> [1] 0 0 0 0 >> [2]  0 0 0 0 >> >> [ARRAYSET NAME= Books] >> (1,1)=John&(2,1)=Mark&(3,1)=Matthew&(4,1)=Luke&(1,2)=50&(2,2)=40&(3,2) >> =30&(4,2)=12 >> [/ARRAYSET] >> >> Now you have an array that looks like this: >> [1][2][3][4] >> [1]JohnMarkMatthewLuke >> [2] 50403012 >> >> So that you can access these values using the array's variable name >> (again, I don't have v5 so I'm not sure of the syntax here): >> >> Our top selling book is [Books(1,1)] it has sold [Books(1,2)] copies! >> >> And the best part is that using arrays makes it easy to loop through >> and list all of the books: >> >> [loop start=1&end=4] >> Our number [index] selling book is [Books([index],1)], it has sold >> [Books([index],2)] copies! >> [/loop] >> >> Kind of a simple and silly example but I hope this helps a little. : >> c) >> >> Good luck! >> >> MK >> >> On Tuesday, December 30, 2003, at 11:00 AM, Palle Bo Nielsen wrote: >> >>> ... Anyway - more important. I have run through the WebDNALab >>> tutorial and it just ain't good enough for me. I need a real world >>> example doing some real stuff - not just numbers and letters. >>> >>> Anyone willing to spend some time trying to explain the Array tags >>> using a real world example? >>> >>> PowerPalle >>> >> >> Signed: Marc Kaiwi >> >> >> ------------------------------------------------------------- >> This message is sent to you because you are subscribed to >> the mailing list . >> To unsubscribe, E-mail to: >> To switch to the DIGEST mode, E-mail to >> >> Web Archive of this list is at: http://webdna.smithmicro.com/ >> >> > > -- > Venlig hilsen > Palle B. Nielsen (PowerPalle) > http://www.macnyt.dk/ > > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://webdna.smithmicro.com/ > > Signed: Marc Kaiwi ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Req: Array Tags Explained, simple and clear ( Donovan Brooke 2004)
  2. Re: Req: Array Tags Explained, simple and clear ( Donovan Brooke 2004)
  3. Re: Req: Array Tags Explained, simple and clear ( "Nitai @ ComputerOil" 2004)
  4. Re: Req: Array Tags Explained, simple and clear ( Palle Bo Nielsen 2004)
  5. Re: Req: Array Tags Explained, simple and clear ( Palle Bo Nielsen 2004)
  6. Re: Req: Array Tags Explained, simple and clear ( "Nitai @ ComputerOil" 2004)
  7. Re: Req: Array Tags Explained, simple and clear ( "Nitai @ ComputerOil" 2004)
  8. Re: Req: Array Tags Explained, simple and clear ( Donovan Brooke 2004)
  9. Re: Req: Array Tags Explained, simple and clear ( Marc Kaiwi 2004)
  10. Re: Req: Array Tags Explained, simple and clear ( Palle Bo Nielsen 2004)
  11. Re: Req: Array Tags Explained, simple and clear ( Marc Kaiwi 2003)
  12. Re: Req: Array Tags Explained, simple and clear ( "Nitai @ ComputerOil" 2003)
  13. Re: Req: Array Tags Explained, simple and clear ( Palle Bo Nielsen 2003)
  14. Re: Req: Array Tags Explained, simple and clear ( "Scott Anderson" 2003)
  15. Re: Req: Array Tags Explained, simple and clear ( Palle Bo Nielsen 2003)
  16. Re: Req: Array Tags Explained, simple and clear ( Phillip Bonesteele 2003)
  17. Re: Req: Array Tags Explained, simple and clear ( Donovan Brooke 2003)
  18. Req: Array Tags Explained, simple and clear ( Palle Bo Nielsen 2003)
Hi Palle, Arrays can be used to store any kind of data. It may be data you've returned from a database search or form variables from user input, or stuff you make up on the fly, whatever you want to stuff into your array. Arrays are (normally) used to store related or lists of data. For example when you pass variables from one html document to another you are actually passing name-value pairs in a list, kind of an array. ?cart=123&user=bob you might think of it as an array(2,2) where array(1,1) = cart, array(1,2) = 123, array(2,1) = user and array(2,2) = bob. In the "Top Selling Books" example you could simply return the results of a WebDNA search if all you wanted to do was list them once, but what if you wanted to do a lot of other operations on the same "list" you wouldn't want to do a new search for each operation. You need to store that information somewhere. Working with an array is much easier than working with a long list of named variables like [book1], [book2], ... [book200]. Most importantly, (and the most powerful thing about arrays), you may not know what information is going to be in that list of books or even how many books are going to be listed. Suppose the user chooses x number of his "favorite" books? What then? Using named variables you'd have to know before hand how many book he was going to choose. It would quickly turn into an unmanageable programming nightmare without arrays. Searching simply returns some data that you are looking for. Once you have that data you'll want to store it somewhere so that you can work with it. Depending on what kind of data you have and what you want to do with it will determine whether you store it in arrays or variables. What exactly are you hoping that Array functions will do for your forum? Hope this helps, MK On Thursday, January 1, 2004, at 11:01 AM, Palle Bo Nielsen wrote: > Hi Marc, > > Thanks a lot for spending some time trying to explain the Array tags > for me. > > I have a couple of questions before I might get (understand) it ;) > > So what your are telling me is that the Array function is mostly, if > not only, used when working with template variables, or? > > Your "top selling books" example. Let's say your have a database of > 10.000 books in your WebDNA database, with 10.000 names and 10.000 > NumSold fields. Why just not do a normal Search and Sort to see the > top 4 selling books? How does the Array tag come handy here? > > I really need to see the difference in using a normal Search and Sort > function compared to the Array function... I'm just a bit confused > here... and really need to learn the Array function. > > Currently I have a quite large Forum system build up using WebDNA and > I hope that the Array function will give me some new possibilities > towards performance and functionality. > > Hope to hear from you soon again. > > Palle > > > > On 31/12-2003, at 19.28, Marc Kaiwi wrote: > >> You're right, the online docs for [ARRAYGET] are very confusing, for >> example I don't understand if you can simply call an array variable >> name [MyArray(1,2)] outside the [ARRAYGET] context or what the syntax >> is? >> >> Anyway, arrays are really useful and easy to understand once you get >> the hang of it. I don't have WebDNA 5 so this code won't work as >> displayed but hopefully I can express the concept of using a simple >> array in a practical way. >> >> At some point in your programming career you're going to find >> yourself using lots of variables like: [book1], [book2], [book3], >> [book4], ... etc,. This is a good sign that it might be easier to use >> an array. >> >> For example, we'll assume you have a "list" of your 4 current top >> selling books and the number of books sold for each. You might make >> assignments like this: >> [text] book1=John[/TEXT] >> [text] book2=Mark[/TEXT] >> [text] book3=Matthew[/TEXT] >> [text] book4=Luke[/TEXT] >> And then >> [text] book1_NumSold=50[/TEXT] >> [text] book2_NumSold=40[/TEXT] >> [text] book3_NumSold=30[/TEXT] >> [text] book4_NumSold=12[/TEXT] >> >> In this case you would access these values using: >> Our top selling book is [Books1] it has sold [book1_NumSold] copies! >> >> Or you could set up an array with these same values: >> >> [ARRAYSET NAME=Books&DIM=4,2] [/arrayset] --> creates an empty two >> dimensional array (think of it as a table) that looks like this: >> [1][2][3][4] >> [1] 0 0 0 0 >> [2]  0 0 0 0 >> >> [ARRAYSET NAME= Books] >> (1,1)=John&(2,1)=Mark&(3,1)=Matthew&(4,1)=Luke&(1,2)=50&(2,2)=40&(3,2) >> =30&(4,2)=12 >> [/ARRAYSET] >> >> Now you have an array that looks like this: >> [1][2][3][4] >> [1]JohnMarkMatthewLuke >> [2] 50403012 >> >> So that you can access these values using the array's variable name >> (again, I don't have v5 so I'm not sure of the syntax here): >> >> Our top selling book is [Books(1,1)] it has sold [Books(1,2)] copies! >> >> And the best part is that using arrays makes it easy to loop through >> and list all of the books: >> >> [loop start=1&end=4] >> Our number [index] selling book is [Books([index],1)], it has sold >> [Books([index],2)] copies! >> [/loop] >> >> Kind of a simple and silly example but I hope this helps a little. : >> c) >> >> Good luck! >> >> MK >> >> On Tuesday, December 30, 2003, at 11:00 AM, Palle Bo Nielsen wrote: >> >>> ... Anyway - more important. I have run through the WebDNALab >>> tutorial and it just ain't good enough for me. I need a real world >>> example doing some real stuff - not just numbers and letters. >>> >>> Anyone willing to spend some time trying to explain the Array tags >>> using a real world example? >>> >>> PowerPalle >>> >> >> Signed: Marc Kaiwi >> >> >> ------------------------------------------------------------- >> This message is sent to you because you are subscribed to >> the mailing list . >> To unsubscribe, E-mail to: >> To switch to the DIGEST mode, E-mail to >> >> Web Archive of this list is at: http://webdna.smithmicro.com/ >> >> > > -- > Venlig hilsen > Palle B. Nielsen (PowerPalle) > http://www.macnyt.dk/ > > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://webdna.smithmicro.com/ > > Signed: Marc Kaiwi ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Marc Kaiwi

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

problems with 2 tags shakur (1997) [WebDNA] Don't change [ipaddress] ... (2015) Adding insurance to an order, round 2 (2003) emailer on Windows Beta 18 (1997) [isfile] ? (1997) emailer (1997) Nested tags count question (1997) WebCat2.0 [format thousands .0f] no go (1997) greater than or equal to (1997) [lookup] vs. [search] (1998) Cool new site (1996) Comments in db? (1997) [append] problem (1997) WebCat2b13MacPlugin - nested [xxx] contexts (1997) Re2: Calculating multiple shipping... (1997) Practice runs ? (1997) webcat- multiple selection in input field (1997) RE:It just Does't add up!!! (1997) WebCat2: Items xx to xx shown, etc. (1997) Summing Fields (1998)