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}.

There are two things that change every time you load the main page for the WebBatch site: the random stripe, and the random idea.

To make the random stripe, we created 29 separate background GIF images, named "bg-1.gif", etc. Then we used a weber file to get WebBatch to pick one at random, like this:

    <HTML>
    <HEAD>
    <TITLE>Powered by WebBatch</TITLE>
    </HEAD>
    <BODY BACKGROUND="bg-{random?29}.gif">
The {random?29} tells the server to run a WebBatch program called "random.web", and pass the number 29 to it. The program uses WebBatch's "webout()" command to insert the random number into the HTML text.

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

    if param0==0
       webout(0,0)
    else
       webout(random(param1-1)+1,0)
    endif
    return
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. It's a little more complicated than "random.web", as it can accept several different parameters. But when called without any parameters, "randomideas" simply picks one idea at random and inserts that into your HTML text.

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-2017 by Island Lake Consulting LLC WebBatch is a trademark of Island Lake Consulting LLC. All other trademarks are the property of their respective owners.