Return to main

Get a 60-day FREE trial!

See examples

How was this done?

How was this done?

Tech support

icon

Here's how this was done:

Most of the pages of this site were created with weber files. A weber file is a simple, extensible format for easily combining HTML and the power of WebBatch. In a weber file, the name of a WebBatch subroutine appears in {curly braces}. Everything else is standard HTML. Using the BinaryTag family of WebBatch operations, WebBatch scripts can be written to make quick work of processing the information within the {curly braces}.

To insert the random idea into the HTML text, we use this in the weber file:

    <BLOCKQUOTE>
    If you had WebBatch®, {randomideas}<P>
    </BLOCKQUOTE>
The WebBatch program "randomideas.web" uses a private "ini" file to store its list of ideas. When called without any parameters, randomideas.web simply picks one idea at random and inserts that into your HTML text. If called with a number for the parameter, it'll return a list of that many ideas (without duplicates). And if it's called with the parameter "all", randomideas.web will return the entire list.

Here's the source code for "randomideas.web":

; randomideas.web?howmany
;     if howmany='all' then returns <P>-delimited 
;     list of all ideas
;     if no params returns one idea at random
;     otherwise returns howmany (max 25 at once) 
;     unique random ideas (no dupes)
;
;     designed to be called from weber.web
;     so it assumes d=current directory



; ideas are stored in the 'ideas.ini' file
inifile=strcat(d,'ideas.ini')

; get the total number of ideas
ideacount=inireadpvt('poweredby','lastpoweredby',
                     '1',inifile)

; how many ideas we want is passed in param1
howmany=param1

defaultidea='you could write your own CGI scripts 
             instead of paying someone $125 an 
             hour to do it for you.'

; return all ideas if asked nicely
if howmany=='all'                                                       
      for y=1 to ideacount
            webout(strcat(inireadpvt('poweredby','x%y%',
                   defaultidea,inifile),'<P>'),1)
      next
      return
endif

; can't figure it out, just return 1 idea
if (!isnumber(howmany) || howmany==0) then howmany=1
      
; just one idea? pick one at random, 
; read it from the ini file, web it out
if (howmany==1)
      y=random(ideacount-1)+1
      webout(strcat(inireadpvt('poweredby','x%y%',
             defaultidea,inifile),'<P>'),1)
      return
endif

; max of 25 ideas at once
if (howmany>25) then howmany=25                                      

; start the idealist with a <P> and a CR
idealist=strcat('<P>',num2char(13))                               
numideas=0

; pick a list of ideas at random, with no duplicates
while numideas<howmany

:tryanother
      y=random(ideacount-1)+1
      
      ; get an idea from the file
      idea=strcat(inireadpvt('poweredby','x%y%',
                  defaultidea,inifile),'<P>')   
      
      ; already in the list? get another
      if itemlocate(idea,idealist,num2char(13))<>0 
         then goto tryanother 
            
      ; otherwise, add to list
      idealist=strcat(idealist,idea,num2char(13))                                               
      numideas=numideas+1
      
endwhile

webout(idealist,1)
return
Note: Some lines in this source code have been broken for improved readability.
Copyright ©1996-2023 by Island Lake Consulting LLC WebBatch is a trademark of Island Lake Consulting LLC. All other trademarks are the property of their respective owners.