Goodies to Go (tm)
November 11, 2002-- Newsletter #206

By Vince Barnes



Goodies to Go (tm)
November 11, 2002--Newsletter #206

This newsletter is part of the internet.com network.
http://www.internet.com
 


Featured this week:

* Goodies Thoughts  - A Smooth Operator
* Q & A Goodies
* News Goodies
* Feedback Goodies  
* And Remember This...

 


 

Goodies Announcement

Just in case you missed it before, the new Beyond HTML Goodies book is now available!

 

Go beyond the basics and learn how the pros add and use dynamic HTML features and advanced JavaScript techniques. Beyond HTML Goodies demonstrates dozens of new and different features readers can add to their existing Web pages using HTML and JavaScript. The book starts with simple text and image tips, such as adding a clock to a Web page or causing text to appear when the mouse moves over an image. It gradually builds to more complex tricks, including manipulating forms or working with cookies behind the scenes. Throughout the book, readers enjoy Joe's snappy style and "to the point" discussion of each "goody" in the book.

 

http://books.internet.com/books/0789727803

 

 

Goodies Thoughts - A Smooth Operator


There are many types of operators. There are those who drive cars, those who perform surgery, those who run casinos, and so on. We don't care about them, however (at least not for the purposes of this newsletter!) On the other hand, we care a lot about those that add or subtract things from each other, and in other ways manipulate one thing with another. I'm talking about the operators in programming languages; languages like Perl, VBScript and JavaScript; languages near and dear to a web developer's heart!

Since operators are so fundamental to the work of programming languages, it is important to understand the types of operator that there are, and their place in a language. Understanding fundamental aspects of language structure makes it simpler to get to know a language you are seeing for the first time. That being so, a little clarification couldn't hurt. I don't intend to provide a comprehensive list of either the types of operator or of the operators themselves, but rather to provide a basic understanding of the concepts involved.

In a computer language it's the operators that tell the computer what to do. If you want to add one to one to get a result, you would tell the computer "result equals one plus one". In this example there are two type of operator at work. "Plus" is an arithmetic operator that says to add the two numbers either side of itself together. "Equals" is an operator that says to assign the value of the answer to "result".

Not all types of operator are present, or implemented, in every language. Perl, for example, has a few special groups of operators that are peculiar to Perl. Common to most programming languages, and certainly to those that I have mentioned here, are arithmetic, assignment, relational and logical.

Arithmetic operators include the add, subtract, multiply and divide basic building blocks, along with exponentiation, modulus and increment. Hopefully, you are already familiar with the operation of the first four! It is worth noting that there are frequently variations on the add and subtract. In addition to addition, there is also the "Concatenate" operator. Though concatenate is usually referred to as a different operator type, namely a string operator, it is sometimes the same symbol as add (e.g. "+" in JavaScript). Using JavaScript for an example, -- result = 1 + 1 -- would yield a value of 2 in result, while -- result = "one " + "one" -- would yield a value of "one one" in result.

"Add" adds one number to another, meaning that is operates on two numbers, or has two operands. Operators with two operands are called "binary" operators. Those with one operand are called unary, and those with three are called ternary. I don't know of any operators with more than three operands, but they might exist in some language.

While subtract is a binary operator, there is also a unary variation. In its unary form, minus is used to define a negative number, "-1" for example. Exponentiation refers to raising a number to a power. For example (in Perl) 2**4 is equivalent to 2*2*2*2 which yields 16 (2 to the fourth power). Modulus (a.k.a. Modulo) returns the remainder after dividing the first operand by the second operand. For example -- result = 7 modulus 3 -- would give a value of 1 in result.

Assignment operands direct a value into a data item. If our examples above we have shown "equals" as an assignment operator. Most languages these days, including the three previously mentioned, assign from right to left. That is, in the arrangement "op1 = op2" the value already in op2 is assigned to op1, replacing its value. There are still some languages, however, that assign from left to right. Cobol is one such, as in "move op1 to op2" or "add 1 to 1 giving result". By the way, in case you think Cobol is dead, it's worth remembering that it is estimated that there are still more lines of Cobol code in use today than any other language. Of course, we don't really care very much because it's (probably) never used for web site development!

Relational operators compare one thing to another. "Equals" is also a relational operator, as in the JavaScript example -- if op1 == op2 -- where you notice that the language syntax calls for two "=" signs to distinguish it from its assignment cousin. "Greater than", "less than" and the negatives "not equal" (etc.), are all examples of relational operators. Some languages, including Perl, consider numeric and string relational operator to be different operator types.

Logical operators include "and", "or" and "not". These operators are used to combine other conditions in true/false tests. For an example in JavaScript -- if ((op1 == op2) && (op1 == op3)) -- there are two equality condition tests in the overall condition, joined by a logical "and". If both test evaluate true, the overall condition is true, if either or both evaluate false the overall condition is false. In a logical "or" the overall condition is true is either or both evaluate true, and false when both are false. Be careful with the (unary operator) logical "not"!! Sometimes it's simple to see what it means. For a JavaScript example -- if op1 != op2 -- clearly is looking for inequality between op1 and op2, but consider the Perl example -- $op1 = !$op2 -- where op1 will be assigned (the "=" assignment operator) a value of zero if op2 is either null or equal to zero. Trust me, it can get tricky! Negatives are like that! Consider: there's not no way to misunderstand this!! Beware also of the bitwise operators (another type) that also include an "and" an "or" (and a thing called an "exclusive or") and sometimes a "not". These fellas can also be tricky to understand and are beyond the scope of this little piece!

Hopefully, this explanation of this part of computer language structure will help you to operate on your own!


Thanks for Reading!
- Vince Barnes

Top

Q & A Goodies

Questions are taken from submissions to our Community Mentors. You can ask a Mentor a question by going to http://www.htmlgoodies.com/mentors/.



Q. But how do I make a link in one frame change both the main frame and the sidebar, each going to different pages?

A. There's a tutorial on just that subject:
http://www.htmlgoodies.com/tutors/2atonce.html




Q.
I want to place the copyright symbol into a message to be displayed. In HTML you can use ©. What can I use in JavaScript?

A. This is what I have done in the past: document.write("Copyright ) 2001 - 2002")




Q. I have downloaded a script that is basically a choice box with a description of the option selected below the choice box. My problem is that I want it to target a frame called "frame1" and Icant seem to find a way to fit that into the code. Any ideas??

A. Try changing your onClick event to this: onClick="parent.frame1.location=document.a294.a969.options
[document.a294.a969.selectedIndex].value"




Q. I have a website that can be viewed nicely in my resolution 1152 x 764 and I want to be able to do some HTML code that allows me to keep the page the same size on computers with all different resolutions so people out there can view my page the way I have built it.

A. You will have to build your content into a table and set the table for 790 x auto or such to accommodate the 800 x 600 window that is most common.
[You can't change the resolution of your visitor's screen -- Ed]


.

Q. I am trying to change the way my text is displayed on my documents. I understand the left, center and right alignments. What I am looking for is a command that allows me to space my text from the left border to the right border. In other words I want the left edge of my text to align left and the right edge of my text to align right. I have searched but come up empty handed so far.

A. Try adding align="justify" to the P tag.

 


 

 

 

Top

News Goodies


Smaller, Cheaper Pocket PCs on the Horizon
[November 11, 2002] Microsoft and Samsung today announced a concept design for 'light and thin' Pocket PCs that they say will greatly reduce costs and development time for manufacturers of the devices.'

Click here to read the article



AOL Goes After Small Business
[November 11, 2002] SOHOs (small office/home offices) remain the fastest-growing segment in the business world. AOL positions to offer them a ready-made network of marketing and branding services

Click here to read the article



Hollywood: Hooray for Broadband!
[November 11, 2002] Major film studios launch the beta of a download site where you can rent movies; the questions are how fast it will catch on and whether it can survive the attack of the Napster clones.

Click here to read the article
 



Gates To Lay Out Future of C++, C#
[November 8, 2002] At the OOPSLA 2002 conference in Seattle Friday, Microsoft Chairman Bill Gates will lay out the road map for the Visual C++ .NET and Visual C# .NET programming languages.

Click here to read the article




As the Bridex Worm Turns
[November 5, 2002] The Bridex e-mail worm targets a known vulnerability in Microsoft Windows: it's capable of spreading a variant of the active Funlove virus.

Click here to read the article

 

 


Top

Feedback Goodies



Did you ever wish your newsletter was an easy two way communications medium? Ploof! It now is!
If you would like to comment on the newsletter or expand/improve on something you have seen in here, you can now send your input to:

mailto:nlfeedback@htmlgoodies.com


We already receive a lot of email every day. This address will help us sort out those relating specifically to this newsletter from all the rest. When you send email to this address it may wind up being included in this section of the newsletter, to be shared with your fellow readers.


Many thanks to all who noticed that a US social Security number does indeed follow the format 999-99-9999 (three digits, hyphen, two digits, hyphen four digits) and not 99-999-9999 (two digits, hyphen, three digits, hyphen, four digits) as we said in the text. To the gentleman who modified the script to make it work, you might want to change it back since it was correct as written - only the text was wrong!

 

Top
And Remember This . . .


On this day in...

1918 World War Ends!
At the 11th hour on the 11th day of the 11th month of 1918, the Great War ended. The armistice was signed at 5:00 am on a train at Compihgne, France. Nine million soldiers were killed in that war. Another twenty-one million were injured. Germany, Russia, Austria-Hungary, France, and Great Britain each lost close to a million or more. World War I was known as the "war to end all wars" because of the great slaughter and destruction it caused. Unfortunately, the peace treaty that officially ended the conflict -- the Treaty of Versailles of 1919 -- forced punitive terms on Germany that destabilized Europe and laid the groundwork for World War II.


1997
Intel confirms bug
On this day in 1997, Intel confirmed that its Pentium chips contained a bug that hackers could exploit to crash computers, and the company released a fix by the end of the week. The first breed of Pentium chips, released in 1994, had been plagued by a bug that produced mathematical errors. After a public uproar, Intel agreed to replace those faulty chips with no questions asked


Thanks for reading Goodies to Go!

 




Archive Home Page.



Make a Comment

Loading Comments...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
  •  
  •  
  •  
Thanks for your registration, follow us on our social networks to keep up-to-date