BlitzPlus: Search Engine Tutorial (Google,Yahoo,Altavista & eBay)
by Tails

Who This Tutorial is Aimed At

Anyone who wishes to add a Search Bar onto a BlitzPlus interface using a web based search engine.

What Does This Tutorial Show

This tutorial will show you how to create windows, text fields, buttons and html view boxes and show you how to link between a BlitzPlus interface and a web based search engine like Google.

Step 1

First of all you will need to create a window and a text field box.



The above piece of code will first of all create a function named CreateMain - the aim of this fucntion is to create and display the interface.
Then it will create a window with the variable name Main, along with the window title, x&y position, size and style.

Created next is a textfield with variable name InputBox (this is the box the user will type their search request into)
After this is created the layout for the textfield is inputted (left,right,up,down - 1 = fixed, 0 = can freey move)

Step 2

Up next is how to create the search buttons along with the html view box.



The above code is the rest of the function code for the CreateMain function.
4 buttons are created, with variables names Search - Search 3. Each are the same button, just duplicated and positioned elsewhere with different text on it.
The text is relevant to what the button does when clicked.

A HTMLView is also created here (this is the area in which the websites will appear, so the x and y pos, and the size of the view box is required.
Once again we set up the gadget layout, this time it is the HTML view box, same rules apply as last time.

Then we must update out window menu - this is needed after any of the above commands have been executed in order for their effect to be realised.
Then we must end the function with the End Function command.

Step 3

Now we need to tell the program to run the above function and set up a loop so that the program stays running, until the window is closed.



The first line CreateMain() is how you tell the program to execute that particular function.
While WaitEvent()<>$803 means that this loop will continue to loop until the window is closed.
EvID=EventID() means that EvId is the variable name we chose for the EventID function which is a part of the BlitzPlus language.
EvData=EventData() means that EvData is the variable name we chose for the EventData function which is a part of the BlitzPlus language.
Select EvId means that we are creating a select structure (which means we can have different actions for different gadgets and events yet all under the same select structure which in this case is the EventID.
Case $1001 means a menu action (meaning we are checking for a menu action)
Case 2 means we are checking and selecting the actions when the Close menu is selected from the File menu.

PLEASE NOTE - The above source code is not complete and so will not work, variables names have been declared and a couple of menus have been made.
The full source code is available to download - Click Here.
The source code shown above is how to set up and implement a Web based search engine into a BlitzPlus interface yet obviously other bits of coding needs to be written in order for a BlitzPlus application to run

The next part is the action to be taken if the menu item is selected (in this case a confirm box appears)

Step 4

Next up we must set up the actions of our buttons we have just created.



EvID we will cover later on in the tutorial.
EventSource is the source of the event we are programming, in this case it is the first search button.
HTMLViewGo html means that we are going to visit a website in the html view box we created earlier with the variable name html.
The following code is how we implement a web based search engine into a BlitzPlus application (see Step 4)
The EndIf command is ending the if statement made earlier.

Step 5

In order to implement a web based search engine into a BlitzPlus application we need to know the URL of the search engine AFTER a user has searched for sometime using the search engines official website.

Simply proceed to the search engines website (ie - www.google.com) and type in anything in their search box and clock search.
Once the search is complete look into the Address Bar of your web browser and study the URL.


You will notice that within the long URL there will be the text in which you inputted in their search box.
This is where we want our text to be placed.

Then close it off with another ".
Then type +TextFieldText$(InputBox)+

The above code will place the text you inputed in the text field InputBox and place in AFTER the end of the website URL you just inputted.

However you only have HALF the needed URL for a search so now you go back to your website search and this time you copy the URL AFTER the text you inputted for your search, and paste it after the (InputBox)+ text
Remember to place the URL in between " " marks!

Step 6

Then repeat Step 4 but this time change Search to Search1 (etc) and change the URL parts to a different URL from a different search engine website.



the final piece of coding is the Wend which ends the while loop created earlier.

Conclusion

There you have it! A fully functional and customizable search engine within BlitzPlus using a web based search engine to do the searching for you!

Please download the full source code in order to see the application in action! - Click Here


For a printable copy of this article, please click HERE.


This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.