[REBOL] webbanner.r help Re:(2)
OK, so in the following function... make-banner: func [/ad adnumber /local url img alt] [ set [url img alt] skip banner-db either ad [ adnumber - 1 * 6 ][ random (length? banner-db) / 6 ] rejoin [{a href="} url {"IMG SRC="} img {" ALT="} alt {" target"_blank"/a}] ] ...how does adnumber get its value and what is the purpose of the adnumber word? you now have 18 entries in the database, six records of length 3 each, and not 36 entries. But when you call make-banner with the ad refinement, get adnumber - 1 * 6 is 6 - 1 * 6 = 30. No wonder you get none.
[REBOL] using print with CGI
I re-wrote Andrew Grossman's webbanner.r (I made it simpler for my simple mind) and I am able to get rebol on my local machine to print the HTML code for a linked image on the command line but I can't get my web server to output the HTML code. Here is the script... #!rebol -cs print "Content-Type: text/html^/" REBOL [ Title: "Banner Ad Randomizer" File: %webbanner.cgi Date: 16-Apr-2000 Author: "Ryan Christiansen" Purpose: { Generate HTML code that displays a linked banner advertisement } ] urls: [ "http://www.schonder.com" "http://www.schonder.com" "http://www.abisoft.com/BePlan/PurchaseBOSJ.html" "http://www.lebuzz.com/buzzcd_ad.html" "http://www.pushove.com/beos/" "http://www.bebits.com/app/867" ] imgs: [ "schonder.gif" "schnondersource.gif" "BePlan.gif" "buzzcd_anim.gif" "nvf.gif" "ImageProAd.gif" ] alts: [ "Papier-Schonder KG office supply and bookstore" "Papier-Schonder KG office supply and bookstore" "BePlan from AbiSoft" "BuzzCD - Hand-picked best BeOS software" "NVF: A Be-centric comic strip" "ImagePro displays, zooms, and re-sizes images" ] ad: random 6 url: pick urls ad img: pick imgs ad alt: pick alts ad bannerHTML: rejoin [{a href="} url {"IMG SRC="} img {" ALT="} alt {" target="_blank" border=0/a}] print bannerHTML *** I have also tried the following... bannerHTML: print rejoin [{a href="} url {"IMG SRC="} img {" ALT="} alt {" target="_blank" border=0/a}] do bannerHTML ... but the browser outputs "do bannerHTML"
[REBOL] Re: Parse Re:(3)
Hello [EMAIL PROTECTED]! On 16-Apr-00, you wrote: AOf course, this is a more accurate test: Aall [#"A" = C C = #"Z"] Whoops... Well, sometimes it's better to stay quiet... A;-) :-) (BTW, if the comparison between chars is case insensitive, it should be enough to convert them to integers first.) Regards, Gabriele. -- Gabriele Santilli [EMAIL PROTECTED] - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
[REBOL] using print with CGI Re:
Hi, not sure if it's the problem, but shouldn't REBOL header precede print "Content-Type: text/html^/"? Also, IMHO there should be a full path to REBOL executable after the "hash bang", not just #!rebol -cs -- Michal Kracik [EMAIL PROTECTED] wrote: I re-wrote Andrew Grossman's webbanner.r (I made it simpler for my simple mind) and I am able to get rebol on my local machine to print the HTML code for a linked image on the command line but I can't get my web server to output the HTML code. Here is the script... #!rebol -cs print "Content-Type: text/html^/" REBOL [ Title: "Banner Ad Randomizer" File: %webbanner.cgi Date: 16-Apr-2000 Author: "Ryan Christiansen" Purpose: { Generate HTML code that displays a linked banner advertisement } ] urls: [ "http://www.schonder.com" "http://www.schonder.com" "http://www.abisoft.com/BePlan/PurchaseBOSJ.html" "http://www.lebuzz.com/buzzcd_ad.html" "http://www.pushove.com/beos/" "http://www.bebits.com/app/867" ] imgs: [ "schonder.gif" "schnondersource.gif" "BePlan.gif" "buzzcd_anim.gif" "nvf.gif" "ImageProAd.gif" ] alts: [ "Papier-Schonder KG office supply and bookstore" "Papier-Schonder KG office supply and bookstore" "BePlan from AbiSoft" "BuzzCD - Hand-picked best BeOS software" "NVF: A Be-centric comic strip" "ImagePro displays, zooms, and re-sizes images" ] ad: random 6 url: pick urls ad img: pick imgs ad alt: pick alts ad bannerHTML: rejoin [{a href="} url {"IMG SRC="} img {" ALT="} alt {" target="_blank" border=0/a}] print bannerHTML *** I have also tried the following... bannerHTML: print rejoin [{a href="} url {"IMG SRC="} img {" ALT="} alt {" target="_blank" border=0/a}] do bannerHTML ... but the browser outputs "do bannerHTML"
[REBOL] webbanner.r help Re:(3)
Hi Ryan, you wrote: OK, so in the following function... make-banner: func [/ad adnumber /local url img alt] [ set [url img alt] skip banner-db either ad [ adnumber - 1 * 6 ][ random (length? banner-db) / 6 ] rejoin [{a href="} url {"IMG SRC="} img {" ALT="} alt {" target"_blank"/a}] ] ...how does adnumber get its value and what is the purpose of the adnumber word? Function specification: when you specify a refinement in a function - /ad - then you can associate an argument with that refinement - adnumber. The make-banner function can be called either without a refinement and without an argument, or with the refinement /ad, in which case you must supply an argument for adnumber. The argument adnumber is initialized to the value with which you call make-banner, when you call make-banner with the /ad refinement: make-banner ;- no refinement, no argument make-banner/ad 6 ;- with refinement, with argument The role of adnumber. The function subtracts 1 from the adnumber and mutliplies the result with 3 (not 6 as in your example!). The value 3 is the length of each record in the block. The adnumber which is passed to make-banner is index of the first field of the record. Since the function uses skip to locate the three fields it wants to use - url, img alt - you must subtract 1 from the index. If the function is called with the index 1, the first record in the block (consisting of three fields) has to be displayed. The skip function will skip (adnumber = ) 1 * 3 (= record length) = 3 fields. That would position you at the second record. So you subtract 1 (adnumber =) 1 - 1 * 3 (=record length) 1-1 * 3 = 0 * 3 = 0. You skip 0 fields and set [url img alt] will set the three local variables to the first three fields in the block. The url word will be set to the url of the site, the img will be set to the path of the image that is to be displayed, and will set to the string which is displayed while the image is being loaded, or continues to be displayed if loading the image fails. When you call make-banner/ad 2, you want to displaye the second record. 2 - 1 * 3 = 1 * 3 = 3 The skip function will skip 3 fields and s et will load the three local variables to the three fields beginning at the fourth field, which is the url of the second Web site, followed the image file's path, followed by the string that is displayed by the Web browser as the alt string. BTW, all arguments that precede any optional refinements are mandatory arguments, arguments that follow refinements are associated with their respective refinement, until another refinement is detected, or until the /local word is detected which introduces words that are local to the function. f: func [mandatory-arg-1 mandatory-arg-2 /refinement refinement-arg /local local-word] [ do-something-real-smart-here ] This function may be called with two arguments f arg-1 arg-2 or with two arguments, the refinement, and a third argument associated with the refinement: f/refinement mandator-arg-1 mandatatory-arg-2 refinement-arg Hope this helps, ;- Elan [: - )]
[REBOL] random not random
Thanks for the help so far. I have one last problem. The following script works fine now (having moved the Content-Type statement to just before the print output statement) except that it doesn't print a random banner like I expect it to. It always prints the 3rd banner, even though the pick number is set by using... ad: random 6 ...I tried giving "ad" a different value following the print statement, but it seems to have gotten caught up with the value "3" and I never see any other banner except the 3rd choice. The script should execute every time I reload the page, right? #!rebol -cs REBOL [ Title: "Banner Ad Randomizer" File: %webbanner.cgi Date: 16-Apr-2000 Author: "Ryan Christiansen" Purpose: { Generate HTML code that displays a linked banner advertisement } ] urls: [ "http://www.schonder.com" "http://www.schonder.com" "http://www.abisoft.com/BePlan/PurchaseBOSJ.html" "http://www.lebuzz.com/buzzcd_ad.html" "http://www.pushove.com/beos/" "http://www.bebits.com/app/867" ] imgs: [ "schonder.gif" "schnondersource.gif" "BePlan.gif" "buzzcd_anim.gif" "nvf.gif" "ImageProAd.gif" ] alts: [ "Papier-Schonder KG office supply and bookstore" "Papier-Schonder KG office supply and bookstore" "BePlan from AbiSoft" "BuzzCD - Hand-picked best BeOS software" "NVF: A Be-centric comic strip" "ImagePro displays, zooms, and re-sizes images" ] ad: random 6 url: pick urls ad img: pick imgs ad alt: pick alts ad print "Content-Type: text/html^/" print rejoin [{a href="} url {"IMG SRC="/graphics/bannerads/} img {" ALT="} alt {" target="_blank" border=0/a}]
[REBOL] random not random Re:
Hi, Yes, it is not random but "pseudorandom", it returns the same sequence every time REBOL is run. Try to seed it with current time before use: random/seed now ad: random 6 -- Michal Kracik [EMAIL PROTECTED] wrote: Thanks for the help so far. I have one last problem. The following script works fine now (having moved the Content-Type statement to just before the print output statement) except that it doesn't print a random banner like I expect it to. It always prints the 3rd banner, even though the pick number is set by using... ad: random 6 ...I tried giving "ad" a different value following the print statement, but it seems to have gotten caught up with the value "3" and I never see any other banner except the 3rd choice. The script should execute every time I reload the page, right? #!rebol -cs REBOL [ Title: "Banner Ad Randomizer" File: %webbanner.cgi Date: 16-Apr-2000 Author: "Ryan Christiansen" Purpose: { Generate HTML code that displays a linked banner advertisement } ] urls: [ "http://www.schonder.com" "http://www.schonder.com" "http://www.abisoft.com/BePlan/PurchaseBOSJ.html" "http://www.lebuzz.com/buzzcd_ad.html" "http://www.pushove.com/beos/" "http://www.bebits.com/app/867" ] imgs: [ "schonder.gif" "schnondersource.gif" "BePlan.gif" "buzzcd_anim.gif" "nvf.gif" "ImageProAd.gif" ] alts: [ "Papier-Schonder KG office supply and bookstore" "Papier-Schonder KG office supply and bookstore" "BePlan from AbiSoft" "BuzzCD - Hand-picked best BeOS software" "NVF: A Be-centric comic strip" "ImagePro displays, zooms, and re-sizes images" ] ad: random 6 url: pick urls ad img: pick imgs ad alt: pick alts ad print "Content-Type: text/html^/" print rejoin [{a href="} url {"IMG SRC="/graphics/bannerads/} img {" ALT="} alt {" target="_blank" border=0/a}]