text stringlengths 454 608k | url stringlengths 17 896 | dump stringclasses 91
values | source stringclasses 1
value | word_count int64 101 114k | flesch_reading_ease float64 50 104 |
|---|---|---|---|---|---|
Tk_SetAppName - Set the name of an application for ``send'' commands
#include <tk.h>
CONST char *
Tk_SetAppName(tkwin, name)
Tk_Window tkwin (in) Token for window in application. Used
only to select a particular application.
CONST char *name (in) Name under which to register the appli-
c applica-
tion on the display, then a new name will be generated by appending ``
#2'' to name; if this name is also in use, the number will be incre-
mented until an unused name is found. The return value from the proce-
dure is a pointer to the name actually used.
If the application already has a name when Tk_SetAppName is called,
then the new name replaces the old name.
Tk_SetAppName also adds a send command to the application's inter-
preter, inacces-
sible via send. The application can be made accessible again by call-
ing Tk_SetAppName.
Tk_SetAppName is called automatically by Tk_Init, so applications don't
normally need to call it explicitly.
The command tk appname provides Tcl-level access to the functionality
of Tk_SetAppName.
application, name, register, send command | http://www.syzdek.net/~syzdek/docs/man/.shtml/man3/SetAppName.3.html | crawl-003 | refinedweb | 176 | 55.74 |
On Mon, Sep 23, 2013 at 8:17 AM, Zero Piraeus <z at etiol.net> wrote: > On Mon, Sep 23, 2013 at 09:45:46AM -0400, Chris Lambacher wrote: > > [...] The exact use case is in Django templates where a value comes > > from the database. If you want to compare you either have to use > > __class__ which I would say is a code smell, or you have > > to provide the Enum class. > > I'm having a hard time seeing why the latter is problematic, I must > admit (certainly no more so than the "Alice in Wonderland" side effects > previously described). > > > [...] An example of how this will be used in practice is: > > > > {% if object.state == object.state.completed %} > > some html > > {% endif %} > > The names used slightly obscure the weirdness of it, but what you're > really saying there is: > > if my_state == my_state.another_state > > ... which feels more like a code smell to me than > > {% if object.state == State.completed %} > some html > {% endif %} > > That's quite intelligible, and doesn't require anyone to know that an > Enum member's siblings can, in your proposal, be accessed directly via > dot notation (an unintuitive state of affairs, to me at least). > Right. The OP is just concerned that (because these are Django templates) he will have to pass in the 'State' class as a separate template parameter for this to work. But to me that's a problem with Django, and not something for which the Enum type should bend over backwards to cover up for. Given that it's a Djano weakness, IMO the __class__ solution is reasonable enough, although in theory it would allow having object.state be something of the wrong class that happens to have a 'completed' attribute -- that would be a bug of a different color, though. :-) -- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <> | https://mail.python.org/pipermail/python-dev/2013-September/128913.html | CC-MAIN-2021-04 | refinedweb | 309 | 68.81 |
Working with XML in Managed C++;} };
You mark the class with the Serializable element. Only public variables can be serialized like this, and the class must have a default constructor. Once you've complied with those restrictions, life gets pretty simple. Here's how to dump out the object to a file: bongPosted by Capoustaits on 06/24/2013 03:30am
This is why it is necessary to get support from lead to of center, there is one glaring ingredient that is missing; seeds. - - [marijuana. [url= ]pax vaporzer[/url] Marijuana treatment is efficient, without a doubt, and it is confirmed to supply great results in patients with cancer, glaucoma, people with out with urine, hair, blood, sweat, or saliva. The nurses reaction skill the or for a long change the cover his $20 a day drug an alcohol habit.Reply
vaporizer attachmentsPosted by Attanoboollef on 02/07/2013 05:31pm
The government could put these growing officers conclude whether or not their child is abusing drugs. My guess, and my students tend to agree, is use is Allow steroids yourself to get totally prepared to quit smoking. Therefore, if you intend to have successful marijuana do Long-term marijuana I urge you to seek help immediately. Interestingly enough, there are ZERO reported Cannabis patients patients may a certified, licensed dispensary. Right After You've Made comply considered of law, hang the the owners, simply the salaries that are set. This is just one of the reasons why they are normally medicine of the new age, which is medical marijuana. Medical marijuana is one of the usually consider and law means of control as any other cures that physicians write out. For now, a lot of Californians 19 vowed How as of K2 how factors in identified or a major bud harvests because they are the only ones that can. There are too many also medical marijuana Bobby like medical play to research well on medicinal extreme hallucinogens, cocaine, the 6. However, it's highly unlikely that any person would that better / find out reputed of is in the views of many on drug topics. [url=]Pax Vaporizer[/url] The best options to pick and mix are almost vigorously a every smaller, many took (MS) determining the quality of the plant. You can find networks much like the Cannabis Medical time wanted to smoke a joint, it being million the to or taking with your health. Alas, the failure of such an initiative this past November seeds may the better to talk to them openly and honestly. However, it may be illegal, are for in base simple place order in California indicates we are not that far along yet.Reply
vaporizer no2Posted by Attanoboollef on 02/07/2013 02:09am
Smoking marijuana and cigarettes may change the the it them and seeds are very in establishing a dispensary. - Growing one's own medication: Another way to obtain to allow they ate the picture one to skills, and judgment and distort perception. In order to obtain an Arizona marijuana medical not of information understand if not to heal, to make a person more comfortable. [url=]Pax Vaporizer[/url] This article discusses some simple States, there is no reason why especially ones not included in the authorizing legislation or approved by voters..Reply
MFC dll and c++.net studio 2008 problemPosted by ATX on 10/21/2008 05:04pm
I have read this article and several others which suggest this code snippet should compile, yet it fails to compile in my dll project. The problems start when I add the using and namespace directives. The compiler complains about adding /clr and that results in having to shutoff other switches it claims are incompatible with managed code. When I make these changes, the code still does not compile as the compiler now complains about indirection errors. Why won't this code snippet compile in my DLL?Reply | http://www.codeguru.com/columns/kate/article.php/c6579/Working-with-XML-in-Managed-C.htm | CC-MAIN-2015-06 | refinedweb | 653 | 58.82 |
My First contribution to Wikipedia, Hell Yeah!
Today, I was studying sorting algorithms, and I found this strange comb sort algorithm. This algorithm seems to not be so popular as bubble sort or quick sort, but I liked it.
Its page at wikipedia didn't have a ruby example, so I wrote one, I hope that could be helpful.
def comb_sort(list) shrink_factor = 1.247330950103979 gap = list.size swapped = true until (gap == 1) && !swapped gap = gap / shrink_factor gap = 1 if gap < 1 i = 0 swapped = false until (i + gap) >= list.size if list[i] > list[i + gap] list[i], list[i + gap] = list[i + gap], list[i] swapped = true end i = i + 1 end end list end | https://coderwall.com/p/noaf3q/comb-sort | CC-MAIN-2019-22 | refinedweb | 117 | 84.88 |
#include <wx/scopedptr.h>
This is a simple scoped smart pointer implementation that is similar to the Boost smart pointers (see) but rewritten to use macros instead.
Since wxWidgets 2.9.0 there is also a templated version of this class with the same name. See wxScopedPtr<T>.
A smart pointer holds a pointer to an object. The memory used by the object is deleted when the smart pointer goes out of scope. This class is different from the
std::auto_ptr<> in so far as it doesn't provide copy constructor nor assignment operator. This limits what you can do with it but is much less surprising than the "destructive copy" behaviour of the standard class.
Example:
Below is an example of using a wxWidgets scoped smart pointer and pointer array.
To declare the smart pointer class
CLASSNAME containing pointer to a (possibly incomplete) type
TYPE you should use
And later, when
TYPE is fully defined, you must also use
to implement the scoped pointer class.
The first argument of these macro is the pointer type, the second is the name of the new smart pointer class being created. Below we will use wxScopedPtr to represent the scoped pointer class, but the user may create the class with any legal name.
Alternatively, if you don't have to separate the point of declaration and definition of this class and if you accept the standard naming convention, that is that the scoped pointer for the class
Foo is called
FooPtr, you can use a single macro which replaces two macros above:
Once again, in this cass
CLASSNAME will be
TYPEPtr.
Creates the smart pointer with the given pointer or none if NULL.
On compilers that support it, this uses the explicit keyword.
Destructor frees the pointer help by this object if it is not NULL.
This operator gets the pointer stored in the smart pointer or returns NULL if there is none.
This operator works like the standard C++ pointer operator to return the object being pointed to by the pointer.
If the internal pointer is NULL this method will cause an assert in debug mode.
Smart pointer member access.
Returns pointer to its object.
If the internal pointer is NULL this method will cause an assert in debug mode.
Returns the currently hold pointer and resets the smart pointer object to NULL.
Deletes the currently held pointer and sets it to p or to NULL if no arguments are specified.
Swap the pointer inside the smart pointer with other.
The pointer being swapped must be of the same type (hence the same class name). | https://docs.wxwidgets.org/3.0/classwx_scoped_ptr.html | CC-MAIN-2018-51 | refinedweb | 434 | 71.14 |
Udo Stenzel wrote: > Juan Carlos Arevalo Baeza wrote: > >> myParser :: Parser () >> myParser = >> do string "Hello" >> optional (string ", world!") >> >> It makes no sense for myParser to generate any values, especially not >> the result from the optional statement, so it is set to return (). >> > > Don't you think this will interfere somehow with type inference? With type inference? No, why? I mean... specifying the type of a function (as is recommended practice in multiple places) places a hard-point in the type system. It is even sometimes critical to make the types of a program totally predictable (or decidable), as when it's needed to resolve the the monomorphism restriction. Therefore, the language/compiler can do things to types at those hard points. If, say, the compiler needs to match some expression with "IO ()" (or else it'll throw an error), and it infers "IO String", it can unambiguously resolve it by adding the ">> return ()". In my opinion, this would make the program better by removing chaff. In the function above, the "string" statement returns a value which is ignored because it is in the middle of a do-notation sequence. The second statement, after my proposed change, also returns a value. But this value currently cannot be ignored like the others in the do-sequence, even though it could without ambiguity of any kind. If I hadn't specified the type of "myParser", it would have gotten the inferred type "Parser (Maybe String)". But I should be able to specify the more general one "Parser ()" because that change is decidable. In some conceptual way, this is no different than this: max :: Int -> Int -> Int max a b = if a > b then a else b In this case, I've forced the type of the function to be more restrictive (and definitely different) than what it would have had if the type signature weren't there. > I > wouldn't like a function that might decide to throw away its result if > (erroneously) used in a context that wouldn't need it. I also think > almost every function has a sensible result, and written with the right > combinator, can return it without too much hassle. So I'd probably > write: > > yourParser :: Parser String > yourParser = liftM2 (++) (string "Hello") > (option "" (string ", world!") > Personally, that style is way too functional (and a bit lisp-ish) for me. I prefer just using: yourParser :: Parser String yourParser = do helloResult <- string "Hello" worldResult <- option "" $ string ", world!" return $ helloResult ++ worldResult But that's just a matter of style. In this case, that might even be a reasonable thing to do, returning this value from this function. But sometimes isn't. Sometimes, dropping results is the right thing to do. > I also find it very convenient to have a combinator that does a bind and > return the unmodified result of the first computation. With that you > get: > > (*>) :: Monad m => m a -> m b -> m a > m *> n = do a <- m ; n ; return a > > ourParser :: Parser String > ourParser = string "Hello" *> optional (string ", world!") > So you do drop returned values now and then? But with that function you lose out on the do-notation convenience. > Therefore, implicit (return ()) is selsdom useful, has the potential to > cause annoying silent failures and is generally not worth the hassle. > Useful? No more than the do-notation. They are both conveniences. No more than the "liftM2" function you used above: that's another convenience. All languages are full of conveniences that are not strictly necessary. Annoying silent failures? No more than the ">>" monad combinator. >> Another case where I encounter this is with the "when" function: >> >> myParser2 :: Bool -> Parser () >> myParser2 all = >> do string "Hello" >> when all $ >> do string ", world" >> string "!" >> > > A better fix would be more flexible when: > > when :: Monad m => Bool -> m a -> m (Maybe a) > when True m = Just `liftM` m > when False _ = return Nothing > > ...which is quite similar to the proposed change to Parsec's 'optional'. > I'd support both. > I like that. >> It resembles a lot the >> automatic conversions that C++ does. >> > > I'm more reminded of Perl... > I don't know perl :) Thanx! JCAB | http://www.haskell.org/pipermail/haskell-cafe/2006-February/014517.html | CC-MAIN-2014-42 | refinedweb | 681 | 64.41 |
Streams Fundamentals
Introduction
To support file processing, the .NET Framework provides the System.IO
namespace that contains many different classes to handle almost any type of file
operation you may need to perform. The parent class of file processing is Stream. With Stream, you can store data
to a stream or you can retrieve data from a stream.
Stream is an abstract class, which means that you cannot use it to declare a
variable in your
application.
As an abstract class, Stream is used as the parent of the
classes that actually implement the necessary operations. You will usually use a
combination of classes to perform a typical. Most classes used to create a stream as we will learn later can
take a string that represents the name of the file.
The File's Path
If you declare a string variable as done above and use it as
the name of the file, the file will be created in
the same be made of
the name folders must be separated by backslashes.
When providing a path to the file, if the drive you specify
doesn't exist or cannot be read, the compiler would consider that the file doesn't exist. If you provide a folder that doesn't exist in the drive, the
compiler would consider that the file doesn't exist. This also means that the
compiler will not create the folder(s) (the .NET Framework provides all means to
create a folder but you must ask the compiler to create it simply specifying a
folder that doesn't exist will not automatically create it, even if you are
creating a new file). the file exists, otherwise the compiler will not be able to open a file it
cannot find.
To check the existence of a file, the File class provides
the Exists() method. Its syntax is:
Public Shared Function Exists(ByVal path As String) As Boolean
If you provide only the name of the file, the compiler would
check it in the folder of the application. If you provide the path to the file, the
compiler would check its drive, its folder(s) and the file itself. In both
cases, if the file exists, the method returns true. If the compiler cannot find
the file, the method returns false. It's important to know that if you provided
a complete path to the file, any slight mistake in the path such as one
backslash instead of two or a misspelling somewhere, would produce a false result.
Access to a File
In order to perform an operation on a file, you must specify
to the operating system how to proceed. One of the options you have is to
indicate the type of access that will be granted on the file. This access is
specified using the FileAccess enumerator. The members of the FileAccess
enumerator are:
File Sharing
In standalone workstations, one person is usually able to
access and open a file then perform the necessary operations on it. In networked
computers, you may create a file that different people can access at the same
time or you may make one file access another file to retrieve information. For
example, suppose you create an application for a fast food restaurant that has
two or more connected workstations and all workstations save their customers
orders to a common file. In this case, you must make sure that any of the
computers can access the file to save an order. An employee from one of these
workstations must also be able to open the file to retrieve a customer order for
any necessary reason. You can also create a situation where one file holds an
inventory of the items of a store and another file holds the customers orders.
Obviously one file would depend on another. Based on this, when an operation
must be performed on a file, you may have to specify how a file can be shared.
This is done through the FileShare enumerator.
The values of the FileShare enumerator are:
The Mode of a File
Besides the access to the file, another option you will most
likely specify to the operating system is referred to as the mode of a file. It
is specified through the FileMode enumerator. The members of the FileMode
Enumerator are: | http://functionx.com/vbnet/fileprocessing/Lesson02.htm | CC-MAIN-2019-22 | refinedweb | 717 | 60.04 |
Breaking news from around the world
Get the Bing + MSN extension
We are planning to store user data in cosmos DB, but after we add nuget Microsoft.Azure.DocumentDB in a test UWP app, it reports an error: error CS0234: The type or namespace name 'Azure' does not exist in the
namespace 'Microsoft' (are you missing an assembly reference?). The same nuget package cloud be use and work well in console application.
The version that we currently using is Microsoft.Azure.DocumentDB 2.2.1,
Tuesday, December 25, 2018 (12/25/2018).
You may say that I could reference the dll in "packages" folder, I have tried it but also get error:
Hi William,
That is correct, your are using a .NETFramework library item and not a .NETCore library item. Please see the following NuGet page for dependency information related to this: Microsoft.Azure.DocumentDB
Please take a look at Microsoft.Azure.DocumentDB.Core as this is what you are looking to use for .NETCore based projects with Cosmos DB SQL API.
Regards,
Mike
Got it, thanks Mike. | https://social.msdn.microsoft.com/Forums/windowsapps/en-US/a687ce3b-f0d6-41b9-866a-bc802383ed6a/uwp-cant-add-reference-microsoftazuredocumentdb?forum=azurecosmosdb | CC-MAIN-2019-51 | refinedweb | 178 | 67.04 |
%load_ext autoreload %autoreload 2 %matplotlib inline %config InlineBackend.figure_format = 'retina'
Writing linear models with
stax
In this notebook, I'll show the code for how to use JAX's
stax submodule to write arbitrary models.
Prerequisites
I'm assuming you have read through the
jax-programming.ipynb notebook, as well as the
tutorial.ipynb notebook.
The main
tutorial.ipynb notebook gives you a general introduction to differential programming using
grad, while the
jax-programming.ipynb notebook gives you a flavour of the other four main JAX idioms:
vmap,
lax.scan,
random.PRNGKey, and
jit.
What is
stax?
Most deep learning libraries use objects as the data structure for a neural network layer.
As such, the tunable parameters of the layer, for example
w and
b for a linear ("dense") layer
are class attributes associated with the forward function.
In some sense, because a neural network layer is nothing more than a math function,
specifying the layer in terms of a function might also make sense.
stax, then, is a new take on writing neural network models using pure functions rather than objects.
How does
stax work?
The way that
stax layers work is as follows.
Every neural network layer is nothing more than a math function with a "forward" pass.
Neural network models typically have their parameters
initialized into the right shapes using random number generators.
Put these two together, and we have a pair of functions that specify a layer:
- An
init_funfunction, that initializes parameters into the correct shapes, and
- An
apply_funfunction, that applies the specified math transformations onto incoming data, using parameters of the correct shape.
Example: Linear layer
Let's see an example of this in action, by studying the implementation of the linear ("dense") layer in
stax
from jax.experimental import stax
stax.Dense??
As you can see, the
apply_fun specifies the linear transformation.
It accepts a parameter called
params,
which gets tuple-unpacked into the appropriate
W and
b.
Notice how the
params argument matches up with the second output of
init_fun!
The
init_fun always accepts an
rng parameter, which is returned from JAX's
jax.random.PRNGKey().
It also accepts an
input_shape parameter,
which specifies what the elementary shape of one sample of data is.
So if your entire dataset is of shape
(n_samples, n_columns),
then you would put in
(n_columns,) inside there,
as you would want to ignore the sample dimension,
thus allowing us to take advantage of
vmap to map our model function
over each and every i.i.d. sample in our dataset.
The
init_fun also returns the
output_shape,
which is used later when we chain layers together.
Let's see how we can use the Dense layer to specify a linear regression model.
Create the initialization and application function pairs
Firstly, we create the
init_fun and
apply_fun pair:
init_fun, apply_fun = stax.Dense(1)
Initialize the parameters
Now, let's initialize parameters using the
init_fun.
Let's assume that we have data that is of 4 columns only.
from jax import random, numpy as np key = random.PRNGKey(42) output_shape, params_initial = init_fun(key, input_shape=(4,))
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
params_initial
(DeviceArray([[ 0.43186307], [ 0.9563157 ], [ 0.9000483 ], [-0.32341173]], dtype=float32), DeviceArray([0.01369469], dtype=float32))
Apply parameters and data through function
We'll create some randomly generated data.
X = random.normal(key, shape=(200, 4)) X[0:5], X.shape
(DeviceArray([[ 0.03751167, 0.8777058 , -1.2008178 , -1.3824965 ], [-0.37519178, 1.5957882 , -1.5086783 , -0.75612265], [-0.51650995, -1.056697 , 0.99382603, -0.3520223 ], [-1.4446373 , -0.51537496, 0.30910558, -0.31770143], [ 0.9590066 , -0.6170032 , -0.37160665, -0.7339001 ]], dtype=float32), (200, 4))
Here's some
y_true values that I've snuck in.
y_true = np.dot(X, np.array([1, 2, 3, 4])) + 5 y_true = y_true.reshape(-1, 1) y_true[0:5], y_true.shape
(DeviceArray([[-2.3395162 ], [ 0.26585913], [ 3.9434848 ], [ 2.1811237 ], [ 0.6745796 ]], dtype=float32), (200, 1))
Now, we'll pass data through the linear model!
apply_fun??
from jax import vmap from functools import partial y_pred = vmap(partial(apply_fun, params_initial))(X) y_pred[0:5], y_pred.shape
(DeviceArray([[ 0.23557997], [ 0.26439613], [-0.21156326], [-0.72209364], [-0.2593076 ]], dtype=float32), (200, 1))
Voilà! We have a simple linear model implemented just like that.
Optimization
Next question: how do we optimize the parameters using JAX?
Instead of writing a training loop on our own, we can take advantage of JAX's optimizers, which are also written in a functional paradigm!
JAX's optimizers are constructed as a "triplet" set of functions:
init: Takes
paramsand initializes them in as a
state, which is structured in a fashion that
updatecan operate on.
update: Takes in
i,
g, and
state, which respectively are:
i: The current loop iteration
g: Gradients calculated from
grad!
state: The current state of the parameters.
get_params: Takes in the
stateat a given point, and returns the parameters structured correctly.
from jax import jit, grad from jax.experimental.optimizers import adam init, update, get_params = adam(step_size=1e-1) update = jit(update) get_params = jit(get_params)
Loss Function
We're still missing a piece here, that is the loss function. For illustration purposes, let's use the mean squared error.
def mseloss(params, model, x, y_true): y_preds = vmap(partial(model, params))(x) return np.mean(np.power(y_preds - y_true, 2)) dmseloss = grad(mseloss)
"Step" portion of update loop
Now, we're going to define the "step" portion of the update loop.
from dl_workshop.stax_models import step step??
JIT compilation
Because it takes so many parameters (in order to remain pure, and not rely on notebook state),
we're going to bind some of them using
functools.partial.
I'm also going to show you what happens when we JIT-compile vs. don't JIT-compile the function.
step_partial = partial(step, get_params=get_params, dlossfunc=dmseloss, update=update, model=apply_fun, x=X, y_true=y_true) step_partial_jit = jit(step_partial)
Explicit loops
Firstly, let's see what kind of code we'd write if we did write the loop explicitly.
from time import time start = time() state = init(params_initial) for i in range(1000): params = get_params(state) g = dmseloss(params, apply_fun, X, y_true) state = update(i, g, state) end = time() print(end - start)
6.063878536224365
Partialled out loop step
Now, let's run the loop with the partialled out function.
start = time() state = init(params_initial) for i in range(1000): state = step_partial(i, state) end = time() print(end - start)
5.8399598598480225
JIT-compiled loop!
This is much cleaner of a loop, but we did have to do some work up-front.
What happens if we now use the JIT-ed function?
start = time() state = init(params_initial) for i in range(1000): state = step_partial_jit(i, state) end = time() print(end - start)
0.16867327690124512
Whoa, holy smokes, that's fast! At least 10X faster using JIT-compilation.
lax.scan loop
Now we'll use some JAX trickery ot write a training loop without ever writing a for-loop.
from dl_workshop.stax_models import make_scannable_step make_scannable_step??
from jax import lax scannable_step = make_scannable_step(step_partial_jit) start = time() initial_state = init(params_initial) final_state, states_history = lax.scan(scannable_step, initial_state, np.arange(1000)) end = time() print(end - start)
0.23279523849487305
get_params(final_state)
(DeviceArray([[1. ], [2.0000002], [3. ], [3.9999995]], dtype=float32), DeviceArray([5.0000005], dtype=float32))
vmap-ed training loop over multiple starting points
Now, we're going to do the ultimate: we'll create at least 100 different parameter initializations and run our training loop over each of them.
from dl_workshop.stax_models import make_training_start make_training_start??
from jax import lax train_linear = make_training_start(partial(init_fun, input_shape=(-1, 4)), init, scannable_step, 1000) start = time() N_INITIALIZATIONS = 100 initialization_keys = random.split(key, N_INITIALIZATIONS) final_states, states_histories = vmap(train_linear)(initialization_keys) end = time() print(end - start)
1.7054486274719238
w_final, b_final = vmap(get_params)(final_states) w_final.squeeze()[0:5]
DeviceArray([[1.0000002, 2. , 2.9999998, 4.0000005], [1.0000001, 2. , 3. , 4.0000005], [1.0000002, 2. , 3. , 4.000001 ], [1.0000001, 2. , 3. , 3.9999998], [1.0000001, 2. , 3.0000002, 4. ]], dtype=float32)
b_final.squeeze()[0:5]
DeviceArray([5.000001, 5.000001, 5.000001, 5.000001, 5.000001], dtype=float32)
Looks like we were also able to run the whole optimization pretty fast, and recover the correct parameters over multiple training starts.
JIT-compiled training loop
What happens if we JIT-compile the vmapped initialization?
start = time() N_INITIALIZATIONS = 100 initialization_keys = random.split(key, N_INITIALIZATIONS) train_linear_jit = jit(train_linear) final_states, states_histories = vmap(train_linear_jit)(initialization_keys) vmap(get_params)(final_states) # this line exists to just block the computation until it completes. end = time() print(end - start)
1.4674859046936035
HOOOOOLY SMOKES! Did you see that? With JIT-compilation, we essentially took the training time down to be identical to training on one starting point. Naturally, I don't expect this result to hold 100% of the time, but it's pretty darn rad to see that live.
The craziest piece here is that we could
vmap our training loop over multiple starting points and get massive speedups there. | https://ericmjl.github.io/dl-workshop/03-stax/01-linear.html | CC-MAIN-2022-33 | refinedweb | 1,493 | 58.08 |
I guess this is more of a physics question then a java question but i figured there would be a lot of smart people on this forum so here goes:
(ignore the mouse listener stuff i was just starting to mess with it)(ignore the mouse listener stuff i was just starting to mess with it)Code :
import java.applet.*; import java.awt.*; import javax.swing.*; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.awt.geom.*; import java.util.concurrent.*; import java.lang.reflect.Array; import java.util.ArrayList; import java.awt.event.*; public class point extends Ellipse2D.Float implements MouseListener{ double y_speed; double x_speed; int gravity = 2; private int d; private int width = Particle.WIDTH; private int height = Particle.HEIGHT; private ArrayList<point> points; // make particles randomly in screen ------V public point(int diameter, ArrayList<point> points){ super((int) (Math.random() * (Particle.WIDTH - 20) + 1), (int) (Math.random() * (Particle.HEIGHT - 20) + 1), diameter, diameter); this.d = diameter; this.x_speed = (int)(Math.random()* 10 + 1); this.y_speed = (int)(Math.random()* 10 + 1); this.points=points; } public void move (){ Rectangle2D r = new Rectangle2D.Float(super.x, super.y, d+1, d+1); // collision loop -------V for (point p : points){ if (p != this && p.intersects(r)){ double txspeed = x_speed; double tyspeed = y_speed; [COLOR="Red"]// need stuff in HERE!!!![/COLOR] } } // movement stuff ------V if (super.x < 0){ super.x = 0; x_speed = Math.abs(x_speed)/2; } else if (super.x > width - d){ super.x = width-d; x_speed = -Math.abs(x_speed)/2; } if (super.y < 0){ super.y = 0; y_speed = Math.abs(y_speed)/2; } else if (super.y > height - d){ super.y = height-d; y_speed = -Math.abs(x_speed)/2; } if (x_speed>5){ x_speed--; } if (x_speed<5){ x_speed++; } if (y_speed>5){ y_speed--; } if (y_speed<5){ y_speed++; } y_speed+=gravity; y_speed*=0.99; x_speed*=0.99; super.x+=x_speed; super.y+=y_speed; } @Override public void mouseClicked(MouseEvent e) { for (point p : points){ x_speed=x_speed+e.getX(); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } }
I've been trying to get the particles in my simulation to collide, and yes, i know several methods of detecting collisions but i figured checking for rectangle intersection would be the quickest to code. Now what I am wondering is what mathematically i can do when a collision is detected to keep the particles out of other particles rectangles in a stable manner. (no explosive flying particles going 1,000,000 miles an hour) I've been trying to figure this out for days and i feel really dumb that after watching ton of tutorials and stuff the best i have got to work is a spastic blob of dots... thanks for any help given.
ALSO if you need the other classes for some reason you can but the collision things all that really matters. :-/ | http://www.javaprogrammingforums.com/%20whats-wrong-my-code/7181-particle-collisions-printingthethread.html | CC-MAIN-2014-15 | refinedweb | 497 | 60.31 |
How to always call a class method, forcefully, on return in python
I have a
ReportEntry class
class ReportEntry(object): def __init__(self): # Many attributes defined here ... # Lot many setattr/getattr here def validate(self): # Lot of validation code in here return self
Multiple other classes maintain
has-a relation with
ReportEntry class
class A(object): def test1(self): t1 = ReportEntry() # Assign the attribute values to t1 return t1.validate() def test2(self): t2 = ReportEntry() # Assign the attribute values to t2 return t2.validate()
And there are multiple such classes as A.
I need to enforce each
ReportEntry class instance to call
validate() on
return or maybe just before
return.
Basically, no instance of
ReportEntry should escape validation since the final report generation will fail if something is missing.
How may I achieve that ?
You can write a class decorator:
import inspect def validate_entries(cls): def validator(fnc): # this is a function decorator ... def wrapper(*args, **kwargs): rval = fnc(*args, **kwargs) if isinstance(rval, ReportEntry): # print('validating') return rval.validate() return rval return wrapper for name, f in inspect.getmembers(cls, predicate=inspect.isfunction): setattr(cls, name, validator(f)) # .. that we apply to all functions return cls
Now you can define all
A-like classes:
@validate_entries class A(object): # ...
This will validate any
ReportEntry that is returned by any of
A's methods.
Python's Instance, Class, and Static Methods Demystified – Real , class MyClass: def method(self): return 'instance method called', self @classmethod def Here's what happens when we call an instance method: Notice how Python automatically passes the class as the first argument to the function when The classmethod () method returns a class method for the given function. The syntax of classmethod () method is: classmethod () is considered un-Pythonic so in newer Python versions, you can use the @classmethod decorator for classmethod definition. @classmethod def func (cls, args)
One approach that I could think of is to define
__enter__ and
__exit__ methods where
validate is called upon
__exit__ in
ReportEntry
class ReportEntry(object): def __enter__(self): return self def __init__(self): # Many attributes defined here ... # Lot many setattr/getattr here def validate(self): # Lot of validation code in here return self def __exit__(self, a,b,c): self.validate() return True # And then use it as with ReportEntry() as report: ...
But again, this will be enforced only when used
with ReportEntry() as report:
2. Built-in Functions, Note that classes are callable (calling a class returns a new instance); instances are If object is not an object of the given type, the function always returns false. by file, but if the flush keyword argument is true, the stream is forcibly flushed. :
There are two ways I can think about to go about this. I cannot say more without knowing more implementation details:
Decorate your methods: Where every return instance is run through the decorator function. You may want to put this as a stand-alone function or part of a class depending on your specific use case.
def validate(func): return func().validate() class A(object): @validate def test1(self): t1 = ReportEntry() # Assign the attribute values to t1 return t1 @validate def test2(self): t2 = ReportEntry() # Assign the attribute values to t2 return t2
Updating the __setattr__ and decorate your class:
def always_validate(cls): # save the old set attribute method old_setattr = getattr(cls, '__setattr__', None) def __setattr__(self, name, value): # set the attribute validate(name, value) old_setattr(self, name, value) cls.__setattr__ = __setattr__ return cls
and then you could decorate your ReportEntry:
@alway_validate class ReportEntry(object): ...
Built-in Functions, Note that classes are callable (calling a class returns a new instance); instances This is always the dictionary of the current module (inside a function or method, by file, but if the flush keyword argument is true, the stream is forcibly flushed. Instance, Class, and Static Methods — An Overview Let’s begin by writing a (Python 3) class that contains simple examples for all three method types: class MyClass : def method ( self ): return 'instance method called' , self @classmethod def classmethod ( cls ): return 'class method called' , cls @staticmethod def staticmethod (): return
9. Classes, __doc__ is also a valid attribute, returning the docstring belonging to the The instantiation operation (“calling” a class object) creates an empty object. __init__() method, class instantiation automatically invokes __init__() ** * The methods that are test scenarios start with test_ to help python discover them easily. In Python, there are two ways of defining static methods within a class. In this tutorial we will learn about the class __del__ method in Python. b import classa class classb: def method_1(): = classa() a.
Python - Call function from another function, When the called function completes its execution and returns then the calling function is popped from the Python code to demonstrate calling parent class..
Is it possible to call constructor and destructor explicitly , C · C++ · Java · Python · C# · Javascript · JQuery · SQL · PHP · Scala · Perl Constructor is a special member function that is automatically called by Test(); // Explicit call to constructor. Test t; // local object. t.~Test(); // Explicit call to destructor. return 0;. } Dr. Bjarne: No. temporary objects of the class types are useful.. | http://thetopsites.net/article/54167069.shtml | CC-MAIN-2020-34 | refinedweb | 852 | 50.77 |
is it possible to build a engine in monogameGL and then include it as a reference to a .net framework console app?
this is the project I want to use as a framework
I also tried creating a .Net Framework Library project and referencing MonoGame.Framework, however it seems I can't access the xna namespace when I do that and I don't even know if its cross platform..
A console app is just another project nearly empty in this case so ya i suppose you could just add in everything you need to you'll end up with a monogame project with the application output type already set to console.
If you want a console window for your monogame project though there is a much easier way.
In Visual Studio click Project click the drop down and look forProperties at the bottomOn the left side of the window that opens there is a list click Applicationin that window you will see a drop down box labeled Outputclick it and select -> Consolerun your project and you have a console window in addition to your monogame window.(you can then print to it as expected with Console.WriteLine(" hello world ");
If you want to hide the monogame window completely i couldn't help with that.
thankyou.I actually made it a class library, but the project that references it doesn't recognize its there
does anybody know how to fix this?the targeted .net framework are the same.
Did you add a reference to the class library you created in your project? Putting the using directive at the top of your file won't count for much if the project itself deosn't have a reference to your compiled library dll.
ya i did. its included as a reference | http://community.monogame.net/t/question-about-using-monogamegl-project-as-library-for-console-app/11598 | CC-MAIN-2019-26 | refinedweb | 299 | 70.23 |
From: Gavin Lambert (boost_at_[hidden])
Date: 2019-07-17 23:23:49
On 17/07/2019 23:03, JH wrote:
>>?
Calling close() in the destructor of the class that the handlers are
defined on is rarely the correct choice.
If you're not using shared_ptr, then you've called close() too late --
there is still an outstanding async operation but you're in the process
of deleting the object that will be called when that (later) completes,
meaning that you have a dangling pointer and will be accessing deleted
memory later.
If you are using shared_ptr, then the close() in the destructor is
(mostly) pointless, because the destructor won't get called until all
the pending operations are already ended, which *usually* means that
something else has already called close() first. (Although you have to
be a little careful of loopholes, such as when your async_read handler
doesn't start a new read, either due to error or exception. Still, as
long as you're holding the socket by value and you don't have any
pending async operations on it, it's safe to just let the socket be
destroyed without explicitly close()ing it.)
So yes, you should be calling close() from some other method. This
might be an explicit disconnection operation, or following a failed read
operation, or in the destructor of some other class that is different
from the shared_ptr used for the operations themselves.
A useful trick is to implement the pimpl idiom using a shared_ptr --
your 'outer' public class can call close() in its destructor because the
shared_ptr is to the 'inner' private class instead. Just avoid calling
"out" from the inner class to the outer class in handlers, because the
inner class will have a longer lifetime than the outer class.
>)
No, not even slightly. Have a look at the example code included with Asio.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk | https://lists.boost.org/Archives/boost/2019/07/246614.php | CC-MAIN-2020-24 | refinedweb | 334 | 68.7 |
I've been using
os.rename to move files in Python. However, it appears that this fails if you try to move files between one mountpoint and another (on Linux).
Is there a Python library or function to move files between mountpoints, similar to
mv on Linux?
This is a common caveat with
os.rename. The higher level
shutil module and it's
move method works around this for you by using
os.rename() or
shutil.copy2() as appropriate.
One thing to keep in mind is that this loses the atomic guarantee that
os.rename has if it isn't on the same filesystem.
See
You can use
mv using subprocess
from subprocess import check_call check_call(["mv","src","dest"]) | http://www.dlxedu.com/askdetail/3/8d4a5c3f048200269a8691a83f295b2a.html | CC-MAIN-2018-30 | refinedweb | 119 | 69.99 |
- MVC
- Entity Framework
- LINQ
- Web Services
- ADO.NET
- Servers
- Client-Side Technologies
- Concepts
- Development
- Visual Studio
- References
- About
- References
Programming Paradigms
Programming Paradigms
Language Integrated Query (LINQ) extends the data querying capabilities of programming languages and provides a common way to access data from various sources (databases, XML, collections, etc.). LINQ was released as part of .NET 3.5 (11/19/2007) and ports also exist for various non-.NET languages such as Java, PHP, JavaScript, and ActionScript. LINQ consists of two types of syntax: Query Syntax (resembling SQL) and Method Syntax (allows method chaining). LINQ makes use of lambda expressions, anonymous types, and object initializers.
LINQ
LINQ includes over 50 query operators for functions such as filtering, grouping, aggregations, partitioning, and projection. LINQ makes heavy use of generic interfaces and extension methods to provide these functions. For example, LINQ contains the ISequence<T> which hides the data source, which could be a database, file, or in-memory collection). While interfaces work well for hiding the data source, it requires full implementation of all its method signatures. So adding a new method breaks an existing application which uses the interface. To prevent this Microsoft introduced Extension Methods which allows methods to be created, and used, as if belong to an existing type, but in reality they are static methods which belong to a different type.
Extension Methods are static methods in static classes which allow the extension of any type (e.g. can even extend sealed classes). However through the use of the this keyword, the extension methods appear as if they are an instance method of the type. For example, the following static method determines the number of days until the end of the year.
Adding the this keyword in the parameter list, before the type it is modifying, makes it an extension method which now appears in intellisense as if it were an instance method on the type. It can now be invoked in the same way as instance methods of the type.
Extensions methods are a compiler trick which makes the method appear in intellisense and allows the static method be be invoked the same way as an instance method.
Adding this Keyword to Make an Extension Method
Below is another example of an extension method. This extension method returns on the words from an IEnumerable which contain more than one vowel.
Extension Method Returning Words With More Thane One Vowel
All the LINQ methods are defined as extension methods in the System.Linq namespace. By using the free standalone .NET decompiler dotPeek from JetBrains, you can view the definitions of the LINQ methods (see image below). LINQ methods work with the Enumerable class which implements the IEnumerable<TSource> generic interface. The TSource defines the WHERE the data is coming from, but the programmer must specify HOW the data is to be manipulated. The HOW to define the data is passed to the LINQ method as a delegate (i.e. pointer to a method). The shorthand way of defining delegates inline, know as Lambda Expressions, is frequently used in LINQ methods to define HOW the data is to be manipulated.
Note: As Bill Wagner points out, IEnumerable is not a collection. Bill uses his deck of cards analogy to illustrate that IEnumerable is a sequence, i.e. you get one card at a time as opposed to getting the entire deck at once. This is very significant when working with large data sets. So the LINQ methods are not returning a set of values, but instead are returning the next value in a sequence of values. See
JetBrains dotPeek Showing LINQ Classes
Lambda Expressions
The following code rewrites the example above to use a delegate to pass into the extension method a method which determines if an item from the enumeration contains only a single vowel. That is the "ContainsVowels" method returns true if the input string contains just a single vowel.
The delegate allows different methods to be passed into the extension method which can vary the logic used to select an item from the enumeration. As shown in the code below, the "ContainH" method is now passed into the extension method to search for words which contains an "H", instead of searching for words which contain a vowel.
Instead of passing in the method signature, an anonymous delegate could be used as shown in the code below.
The anonymous delegate in the above code can be replaced with the lambda expression as shown in the code below on line 14.
Func, Action, and Expressions
Func is a generic type which encapsulates delegates, i.e. encapsulates callable code. Func takes 1 to 16 generic parameters with the last parameter indicating the return type and the other parameters indicating the input types. For example a function which calculates the volume of an object could be coded as:
Action is similar to func ad it defines callable code. Except Action does not return a value; An example of an action is:
With Func the delegate definition is no longer needed. The code below shows how the delegate definition can be eliminated when Func is used.
When LINQ operators are used against data which is not in memory, which may be out of process, perhaps even on another machine, such as when running against a database server or a web service ... they are wrapped in expressions to create an Expression Tree. Expression trees were created to make the task of converting code, such as query expressions, into a string which is passed to some other process for execution. When a LINQ expression is executed against a database, such as Oracle, it is Oracle which provides the code to translate the LINQ into SQL to execute against the database. With the LINQ expression represented by an expression tree, Oracle can accept and interpret the LINQ expression and determine the best way to convert it into SQL that the Oracle database understands.
LINQ to Objects returns IENumerable, while LINQ to SQL, or LINQ to Entities, returns IQueryable. IQueryable makes use of expression trees (to run the LINQ query on a remote source), while LINQ to Objects typically do not because they run the LINQ query against objects in memory.
Expression trees represent code in a tree-like data structure. This allows dynamic modification of executable code and is used to execute LINQ queries against databases. Expression trees are also used by the Dynamic Language Runtime (DLR) to create dynamic objects which can be used together with static objects. This enables dynamic features in statically typed languages, such as C# and VB. For example C# and VB use dynamic objects for HTML, DOM, and reflection.
Expression Tree Viewer in Visual Studio
Dynamic Language Runtime
The Dynamic Language Runtime (DLR) runs on top of the Common Language Runtime (CLR) and supports dynamic language features. The DLR was incorporated into .NET 4.0 in April 2010. The DLR allows .NET to support dynamic languages such as IronPython and IronRuby. It also allows statically-typed languages, such as C# and VB to support dynamic features. Note, the DLR is similar in concept to Sun Microsystems' Da Vinci Machine project which extended the Java Virtual Machine to support dynamic languages.
Dynamic Language Runtime
Typically languages are divided into one of two categories: Static (C/C++, Java, C#, F#, Haskell) or Dynamic (JavaScript, Ruby, Python, PHP, Perl). But sometimes the distinction is blurred as some languages, such as C#, support both features. Typically dynamic language allow you to modify types and code at runtime. Dynamic languages do not have a pre-runtime compiler phase so type checking is performed when the program runs, if at all. In a Static languages are strongly typed so you can not perform operations, such as assign a string value to an integer, or dynamically change the definition of a class, as these will perform compiler errors. However in a dynamic language, such as Ruby, these operations are allowed.
Static type checking finds typing errors early, at compile time, instead of later at run time. However this does pose some limitations upon the language, which forces the use of reflection to perform some operations. Before the DLR, it was difficult for .NET languages to interoperate with dynamic languages or COM objects (the dominate Microsoft component technology prior to .NET). An example of this difficulty was evident when programming with COM components to automate Microsoft Word or Excel.
In C# 4.0 the dynamic keyword was introduced for typing variables. When the C# compiler sees a dynamically typed variable, it turns off all compile time checks for that variable. Any operations performed on a dynamically typed variable are resolved at run time. Some times dynamics can eliminate the need for type casting or use of reflection (e.g. GetMember(), GetMethod(), GetProperty()). For example if you do not know the type of an object, but you know the name of its method you wish to invoke, you can use reflection, as shown below. Or more simply you can eliminate the reflection code when using dynamic, also shown below.
Calling Method on Unknown Type using Reflection vs Dynamic
Dynamic can be used to interoperate with COM objects, as show in the code below which creates and populates an Excel spreadsheet:
Using dynamic to Create and Populate an Excel Spreadsheet
Func Examples
Declare a Func variable and assign it a lambda expression.
Example Usage of a Func Variable
Example of a Func used to create a predicate (function which returns a boolean). The predicate is used to select particular strings and is used with a static method to filter an enumeration of strings.
Func used to create a predicate, used with static method to filter an enumeration of strings.
References
- Expression Trees (C#) - MSDN Programming Concepts (C#)
- Dynamic Language Runtime Overview - MSDN Dynamic Programming
- Extension Methods - MSDN C# Programming Guide
- Lambda Expressions - MSDN C# Programming Guide
- Basic LINQ Query Operations - MSDN C# Programming Guide
- Func - MSDN C# Programming Guide
- Action - MSDN C# Programming Guide
- IQueryable - MSDN C# Programming Guide
- IEnumerable - MSDN C# Programming Guide | http://www.kcshadow.net/aspnet/?q=programmingparadigms | CC-MAIN-2018-22 | refinedweb | 1,678 | 52.8 |
Method overloading
Posted on March 1st, 2001. It’s a lot like writing prose – the goal is to communicate with your readers.
You refer to all objects and methods by using names. Well-chosen names make it easier for you and others to understand your code.
A problem arises when mapping the concept of nuance in human language onto a programming language. Often, the same word expresses a number of different meanings – it’s overloaded. This is useful, especially when it comes to trivial differences. You say “wash the shirt,” “wash the car,” and “wash the dog.” It would be silly to be forced to say, “shirtWash the shirt,” “carWash the car,” and “dogWash the dog” just so the listener doesn’t need to make any distinction about the action performed. Most human languages are redundant, so even if you miss a few words, you can still determine the meaning. We don’t need unique identifiers – we can deduce meaning from context.
Most programming languages (C in particular) require you to have a unique identifier for each function. So you could not have one function called print( ) for printing integers and another called print( ) for printing floats – each function requires a unique name.
In Java, and by reading information from a file. You need two constructors, one that takes no arguments ordinary methods:
//: Overloading.java // Demonstration of both constructor // and ordinary method overloading. import java.util.*; class Tree { int height; Tree() { prt("Planting a seedling"); height = 0; } Tree(int i) { prt("Creating new Tree that is " + i + " feet tall"); height = i; } void info() { prt("Tree is " + height + " feet tall"); } void info(String s) { prt(s + ": Tree is " + height + " feet tall"); } static void prt(String s) { System.out.println(s); } } public class Overloading { public static void main(String[] args) { for(int i = 0; i < 5; i++) { Tree t = new Tree(i); t.info(); t.info("overloaded method"); } // Overloaded constructor: new Tree(); } } ///:~
A Tree object can be created either as a seedling, with no argument, or as a plant grown in a nursery, with an existing height. To support this, there are two constructors, one that takes no arguments (we call constructors that take no arguments default constructors [17]) and one that takes the existing height.
You might also want to call the info( ) method in more than one way. For example, with a String argument if you have an extra message you want printed, and without if you have nothing more to say. It would seem strange to give two separate names to what is obviously the same concept. Fortunately, method overloading allows you to use the same name for both.
Distinguishing overloaded methods
If the methods have the same name, how can Java know which method you mean? There is sufficient to distinguish two methods: (Although you don’t normally want to take this approach, as it produces difficult-to-maintain code.)
//: OverloadingOrder.java // Overloading based on the order of // the arguments. public class OverloadingOrder { static void print(String s, int i) { System.out.println( "String: " + s + ", int: " + i); } static void print(int i, String s) { System.out.println( "int: " + i + ", String: " + s); } public static void main(String[] args) { print("String first", 11); print(99, "Int first"); } } ///:~
The two print( ) methods have identical arguments, but the order is different, and that’s what makes them distinct.
Overloading with primitives
Primitives can be automatically promoted from a smaller type to a larger one and this can be slightly confusing in combination with overloading. The following example demonstrates what happens when a primitive is handed to an overloaded method:
//: PrimitiveOverloading.java // Promotion of primitives and overloading public class PrimitiveOverloading { // boolean can't be automatically converted2(double x) { prt("f2(double)"); } void f3(short x) { prt("f3(short)"); } void f3(int x) { prt("f3(int)"); } void f3(long x) { prt("f3(long)"); } void f3(float x) { prt("f3(float)"); } void f3(double x) { prt("f3(double)"); } void f4(int x) { prt("f4(int)"); } void f4(long x) { prt("f4(long)"); } void f4(float x) { prt("f4(float)"); } void f4(double x) { prt("f4(double)"); } void f5(long x) { prt("f5(long)"); } void f5(float x) { prt("f5(float)"); } void f5(double x) { prt("f5(double)"); } void f6(float x) { prt("f6(float)"); } void f6(double x) { prt("f6(double)"); } void f7(double x) { prt("f7(double)"); } void testConstVal() { prt("Testing with 5"); f1(5);f2(5);f3(5);f4(5);f5(5);f6(5);f7(5); } void testChar() { char x = 'x'; prt("char argument:"); f1(x);f2(x);f3(x);f4(x);f5(x);f6(x);f7(x); } void testByte() { byte x = 0; prt("byte argument:"); f1(x);f2(x);f3(x);f4(x);f5(x);f6(x);f7(x); } void testShort() { short x = 0; prt("short argument:"); f1(x);f2(x);f3(x);f4(x);f5(x);f6(x);f7(x); } void testInt() { int x = 0; prt("int argument:"); f1(x);f2(x);f3(x);f4(x);f5(x);f6(x);f7(x); } void testLong() { long x = 0; prt("long argument:"); f1(x);f2(x);f3(x);f4(x);f5(x);f6(x);f7(x); } void testFloat() { float x = 0; prt("float argument:"); f1(x);f2(x);f3(x);f4(x);f5(x);f6(x);f7(x); } void testDouble() { double x = 0; prt((); } } ///:~
If you view the output of this program, you’ll doesn’t find an exact char match, it is promoted to int.
What happens if your argument is bigger than the argument expected by the overloaded method? A modification of the above program gives the answer:
//: Demotion.java // Demotion of primitives and overloading public class Demotion {(char x) { prt("f2(char)"); }3(char x) { prt("f3(char)"); } void f3(byte x) { prt("f3(byte)"); } void f3(short x) { prt("f3(short)"); } void f3(int x) { prt("f3(int)"); } void f3(long x) { prt("f3(long)"); } void f4(char x) { prt("f4(char)"); } void f4(byte x) { prt("f4(byte)"); } void f4(short x) { prt("f4(short)"); } void f4(int x) { prt("f4(int)"); } void f5(char x) { prt("f5(char)"); } void f5(byte x) { prt("f5(byte)"); } void f5(short x) { prt("f5(short)"); } void f6(char x) { prt("f6(char)"); } void f6(byte x) { prt("f6(byte)"); } void f7(char x) { prt("f7(char)"); } void testDouble() { double x = 0; prt("double argument:"); f1(x);f2((float)x);f3((long)x);f4((int)x); f5((short)x);f6((byte)x);f7((char)x); } public static void main(String[] args) { Demotion p = new Demotion(); p.testDouble(); } } ///:~
Here, the methods take narrower primitive values. If your argument is wider then you must cast to the necessary type using the type name in parentheses. If you don’t do this, the compiler will issue an error message.
You should be aware that this is a narrowing conversion, which means you might lose information during the cast. This is why the compiler forces you to do it – to flag the narrowing conversion.
Overloading on return values call a method and ignore the return value; this is often referred to as calling a method for its side effect since you don’t.
Default constructors
As mentioned previously, a default constructor is one without arguments, used to create a “vanilla object.” If you create a class that has no constructors, the compiler will automatically create a default constructor for you. For example:
//: Bush { Bush(int i) {} Bush(double d) {} }
Now if you say:
new Bush();
the compiler will complain that it cannot find a constructor that matches. It’s as if when you don’t put in any constructors, the compiler says “You are bound to need some constructor, so let me make one for you.” But if you write a constructor, the compiler says “You’ve written a constructor so you know what you’re doing; if you didn’t put in a default it’s because you meant to leave it out.”
The this keyword
If you have two objects of the same type called a and b, you might wonder how it is that you can call a method f( ) for both those objects:
class Banana { void f(int i) { /* ... */ } } Banana a = new Banana(), b = new Banana(); a.f(1); b.f(2);
If there’s only one method called f( ), how can that method know whether it’s being called for the object a or b?
To allow you to write the code in a convenient object-oriented syntax in which you “send a message to an object,” the compiler does some undercover work for you. There’s a secret first argument passed to the method f( ), and that argument is the handle to the object that’s being manipulated. So the two method calls above become something like:
Banana.f(a,1); Banana.f(b,2);
This is internal and you can’t write these expressions and get the compiler to accept them, but it gives you an idea of what’s happening.
Suppose you’re inside a method and you’d like to get the handle to the current object. Since that handle is passed secretly by the compiler, there’s no identifier for it. However, for this purpose there’s a keyword: this. The this keyword – which can be used only inside a method – produces the handle to the object the method has been called for. You can treat this handle just like any other object handle. Keep in mind that if you’re calling a method of your class from within another method of your class, you don’t need to use this; you simply call the method. The current this handle handle to the current object. For example, it’s often used in return statements when you want to return the handle to the current object:
//: Leaf.java // Simple use of the "this" keyword public class Leaf { private int i = 0; Leaf increment() { i++; return this; } void print() { System.out.println("i = " + i); } public static void main(String[] args) { Leaf x = new Leaf(); x.increment().increment().increment().print(); } } ///:~
Because increment( ) returns the handle to the current object via the this keyword, multiple operations can easily be performed on the same object.Calling constructors from constructors
When you write several constructors for a class, there are times when you’d like to call one constructor from another to avoid duplicating code. You can do this using the this keyword.
Normally, when you say this, it is in the sense of “this object” or “the current object,” and by itself it produces the handle to the current object. In a constructor, the this keyword takes on a different meaning when you give it an argument list: it makes an explicit call to the constructor that matches that argument list. Thus you have a straightforward way to call other constructors:
//: Flower.java // Calling constructors with "this" public class Flower { private int petalCount = 0; private(); } } ///:~
The constructor Flower(String s, int petals) shows that, while you can call one constructor using this, you cannot call two. In addition, the constructor call must be the first thing you do or you’ll get a compiler error message.
This example also shows another way you’ll see this used. Since the name of the argument s and the name of the member data s are the same, there’s an ambiguity. You can resolve it by saying this.s to refer to the member data. You’ll often see this form used in Java code, and it’s used in numerous places in this book.
In print( ) you can see that the compiler won’t let you call a constructor from inside any method other than a constructor.The meaning of static
With the this keyword in mind, you can more fully understand what it means to make a method static. It means that there is no this for that particular method. You cannot call non- static methods from inside static methods [18] (although the reverse is possible), and you can call a static method for the class itself, without any object. In fact, that’s primarily what a static method is for. It’s as if you’re creating the equivalent of a global function (from C). Except global functions are not permitted in Java, and putting the static method inside a class allows it access to other static methods and to static fields.
Some people argue that static methods are not object-oriented since they do have the semantics of a global function; with a static method you don’t send a message to an object, since there.”
[17] In some of the Java literature from Sun they instead refer to these with the clumsy but descriptive name “no-arg constructors.” The term “default constructor” has been in use for many years and so I will use that.
[18] The one case in which this is possible occurs if you pass a handle to an object into the static method. Then, via the handle (which is now effectively this), you can call non- static methods and access non- static fields. But typically if you want to do something like this you’ll just make an ordinary, non- static method.
There are no comments yet. Be the first to comment! | http://www.codeguru.com/java/tij/tij0050.shtml | CC-MAIN-2015-06 | refinedweb | 2,209 | 59.13 |
We Maps, using Angular UI Bootstrap, and uploading files to services such as FilePicker.io.
Building an AngularJS app with ECMAScript 2015 (the latest version of JavaScript) is a very different experience than building AngularJS apps with the old version of JavaScript. For example, you use JavaScript classes to implement controllers and services. And, you perform dependency injection by taking advantage of class constructors.
For example, here’s how you can create an AngularJS controller that retrieves a list of movies from the server and exposes the movies with a public field named movies:
namespace MyApp.Controllers { class MoviesController { public movies; constructor(private $http: ng.IHttpService) { this.$http.get('/api/movies') .then((response) => { this.movies = response.data; }) .catch((response) => { console.error('Could not retrieve movies.'); }); } } angular.module("MyApp").controller('MoviesController', MoviesController); }
Notice that the list of movies is retrieved in the JavaScript class constructor. You have access to the $http service through constructor dependency injection.
Notice, furthermore, that the code above uses fat arrows (lambdas) instead of anonymous functions.
And, here is how you would display the list of movies in an AngularJS view by taking advantage of Controller As syntax:
<!DOCTYPE html> <html xmlns="" ng- <head> <title>My App</title> </head> <body ng- <ul> <li ng- {{movie.title}} </li> </ul> <script src="/Scripts/angular.min.js"></script> <script src="/ngApp/app.js"></script> <script src="/ngApp/controllers.js"></script> </body> </html>
In the view above, the ng-repeat directive is used to iterate through each of the movies exposed by the MoviesController and display each movie in a bulleted list.
I find the ECMAScript 2015 way of working with AngularJS much more natural than the older JavaScript way.
Student Progress
At the end of the week, students tackled a large JavaScript+AngularJS project. They worked together to build an interactive Car Dealership application. In order to build the application, they needed to use client-side routing, interact with a REST service using a $route factory, and perform filtering and sorting.
Students took turns building the application in the front of the room. I was super proud of the fact that they managed to build the entire app on their own (okay, maybe they had one or two hints from the instructors).
I keep forgetting that the students have only two weeks of experience using JavaScript (ECMAScript 2015) and AngularJS. These guys have been working hard on their labs each night and it definitely shows in their progress.
Next Week
Next week we shift from the client-side to the server-side. Students have a single week to learn C#. We focus all week on building console apps. We want the students to get fluent with C# before they start building ASP.NET applications.
I have confidence in these guys. Now that they are comfortable writing code with ECMAScript 2015 – and they have already become familiar with classes, interfaces, arrow functions, and dependency injection – they should find C# very familiar.
Learn More
If you want to sign up for our next Seattle boot camp then register here.
Discussion | https://stephenwalther.com/archive/2015/11/23/typescript-asp-net-web-api-angularjs-bootcamp-week-2 | CC-MAIN-2021-31 | refinedweb | 508 | 56.15 |
I was able to reduce my temps by 10-14C with same performance (FPS) in WoW and Fallout 4 by using Global WattMan in Radeon Settings.
I selected to "Auto undervolt GPU" and then started a game. Played for 45 minutes and peak temp was 76C with average around 74C.
This morning in the same game/environment my temps hit 86C on average and higher depending on the game.
I will continue to cautiously tweak the settings but depending on your card, your mileage may vary.
This is my first AMD card in 7 years, I want to make it work but I am very new to the Radeon software.
If you have advice please share.
Thank you!
def tweak your fan curve, amd has it set pretty high at stock and therefore loud. also you should undervolt it yourself, most forms of software auto overclocking/even undervolting is just terrible. just set the core clock where you want it or leave it at stock 2100 and then start dropping the mv down about 40mv's or so at a time and run a benchmark like unigine heaven to make sure its stable and then go again. ive seen some guys posting that there getting in the mid 900mv range give or take. | https://community.amd.com/thread/241207 | CC-MAIN-2020-45 | refinedweb | 213 | 77.57 |
Here are some notes on getting and learning Python.
Getting:
For Windows: The Enthought Python Distribution is free for “educational users at degree-granting institutions”. It includes numpy, scipy, and matplotlib. Go to the Enthought Download Page and get it if you are eligible. Install it by double-clicking and then clicking ‘Ok’ until it stops asking for approval. Then download and install the PyMC windows installer from the PyMC Downloads Page. Alternative approach: get packages you need individually here.
For Ubuntu or Debian: Type the following into a terminal:
sudo apt-get install ipython python-setuptools python-dev python-nose python-tk python-numpy python-matplotlib python-scipy python-networkx gfortran libatlas-base-dev sudo easy_install pymc
Testing:
Type
ipython --pylab to start interactive python, or find the icon in the start menu. To make PyMC run its self-tests, do this:
import numpy numpy.test() import pymc pymc.test()
Hmm, my PyMC doesn’t have any tests…
Learning
:
To quickly get going in Python read this and this:
If you have used Matlab before then skim this:
Other resources:
9 responses to “Python/PyMC Setup”
More resources:
Other resources that I’ve found useful:
SciPy 2010 intro tutorial slides:
A Primer on Scientific Programming with Python:
Book:
Slides (the page is in Norwegian, but the slides aka ‘foils’ are in English):
Learn Python the Hard Way
Programming for Scientists
Python and a number of other wonderful things for scientists to know about software engineering:
I tried the instructions you gave for pymc installation, and easy_install failed with “No module named numpy.distutils.misc_util”. But when I tried pip, it worked fine.
Thanks for this fix, Gary. Scientific python packaging has shifted since I wrote these notes. I think pip is generally preferred to easy_install now. Also, I’ve had great results with anaconda lately.
To install on 64-bit windows 8.1, I’ve had success with this:
Can Python has any editor like Rstudio? I want install it to ubuntu. Please guide me
There is something called spyder that people are excited about, but I do everything with an IPython Notebook these days | https://healthyalgorithms.com/about/pythonpymc-setup/ | CC-MAIN-2016-30 | refinedweb | 356 | 63.09 |
My system: Python 2.4.4; py2exe 0.6.5; Win2000SP4
I want to use simultaneous 'packages' and 'excludes' option,
but have error.
To reproduce problem:
* in the main directory create directory named 'dir'
* inside 'dir' directory create 3 valid or empty files:
'__init__.py', 'foo.py', 'bar.py'
* in the main directory create setup.py with content below:
========================================================
from distutils.core import setup
import py2exe
setup(name = 'test',
options = {"py2exe": {"packages": ['dir'],
"excludes": ["dir.bar"]}},
)
========================================================
Run 'python setup.py py2exe' and got error:
running py2exe
creating C:\temp\1\build
creating C:\temp\1\build\bdist.win32
creating C:\temp\1\build\bdist.win32\winexe
creating C:\temp\1\build\bdist.win32\winexe\collect-2.4
creating C:\temp\1\build\bdist.win32\winexe\bundle-2.4
creating C:\temp\1\build\bdist.win32\winexe\temp
creating C:\temp\1\dist
*** searching for required modules ***
Traceback (most recent call last):
File "C:\temp\1\setup.py", line 5, in ?
options = {"py2exe": {"packages": ['dir'],
File "E:\Python24\lib\distutils\core.py", line 149, in setup
dist.run_commands()
File "E:\Python24\lib\distutils\dist.py", line 946, in run_commands
self.run_command(cmd)
File "E:\Python24\lib\distutils\dist.py", line 966, in run_command
cmd_obj.run()
File "E:\Python24\lib\site-packages\py2exe\build_exe.py", line 218, in run
self._run()
File "E:\Python24\lib\site-packages\py2exe\build_exe.py", line 269, in _run
self.find_needed_modules(mf, required_files, required_modules)
File "E:\Python24\lib\site-packages\py2exe\build_exe.py", line 1217, in find_needed_modules
mf.import_hook(package, None, ["*"])
File "E:\Python24\lib\site-packages\py2exe\mf.py", line 649, in import_hook
return Base.import_hook(self,name,caller,fromlist)
File "E:\Python24\lib\site-packages\py2exe\mf.py", line 135, in import_hook
self.ensure_fromlist(m, fromlist)
File "E:\Python24\lib\site-packages\py2exe\mf.py", line 208, in ensure_fromlist
self.ensure_fromlist(m, all, 1)
File "E:\Python24\lib\site-packages\py2exe\mf.py", line 213, in ensure_fromlist
raise ImportError, "No module named " + subname
ImportError: No module named dir.bar
If I remove 'excludes' option from 'setup.py' then all works OK.
Note: if I run python and try to import module manually then it works OK:
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import dir.bar
>>> dir.bar
<module 'dir.bar' from 'dir\bar.py'>
Is it a known bug? What a workaround for this situation?
Alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla -
iD8DBQFFkA0jzYr338mxwCURAuXxAJ9bPS1kidFrkdaL2HImrV1I1CxLQwCeOcQC
yWzRCRkJyKL4NyShRotX3Oc=
=SIdm
-----END PGP SIGNATURE-----
Alexander Belchenko wrote:
> My system: Python 2.4.4; py2exe 0.6.5; Win2000SP4
>=20
> I want to use simultaneous 'packages' and 'excludes' option,
> but have error.
...
> create setup.py with content below:
> distutils.core import setup
> import py2exe
>=20
> setup(name =3D 'test',
> options =3D {"py2exe": {"packages": ['dir'],
> "excludes": ["dir would say that it's a bug that it raises an exception, but I'm not
sure if the correct behavior would be to include dir.bar or exclude it.
If you were to specify a module in both "includes" and "excludes" then
"includes" takes precedence. The "packages" option can be seen as
another form of "includes" and for consistency it would make sense to
have it take priority. But I can see an argument for it being a bit of a
special case in that you only implicitly requested the inclusion of
dir.bar. It also seems like a pretty rare edge case. If I see this come
up repeatedly with a consistent desired behavior then I might be
inclined to go a certain way. I'll also defer to Thomas if he feels one
way or the other is clearly better.
For now, my suggestion would be to monkeypatch it to get the behavior
you desire. I'm assuming you want it excluded, in which case you could
put something like this just before your setup() call:
from py2exe.mf import ModuleFinder
def ensure_fromlist(self, m, fromlist, recursive=3D0):
self.msg(4, "ensure_fromlist", m, fromlist, recursive)
for sub in fromlist:
if sub =3D=3D "*":
if not recursive:
all =3D self.find_all_submodules(m)
if all:
self.ensure_fromlist(m, all, 1)
elif not hasattr(m, sub):
subname =3D "%s.%s" % (m.__name__, sub)
if subname not in self.excludes:
submod =3D self.import_module(sub, subname, m)
if not submod:
raise ImportError, "No module named " + subname
ModuleFinder.ensure_fromlist =3D ensure_fromlist
This simply replaces the method where the exception is occurring with a
new version with one additional line ("if subname not in
self.excludes:"). As with monkeypatching in general... this can be
fragile in the face of new versions with subtle failures. I've tested
the above with version 0.6.6 which will be released any minute now...
Jimmy
I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details | https://sourceforge.net/p/py2exe/mailman/message/6938936/ | CC-MAIN-2016-40 | refinedweb | 846 | 54.08 |
Getting Started
At the start of every guizero program, choose the widgets you need from the guizero library and import them:
from guizero import App, PushButton, Slider
You only need to import each widget once, and then you can use it in your program as many times as you like.
Hello World
All guizero projects begin with a main window which is called an
App. At the end of every guizero program you must tell the program to display the app you have just created.
Let's create an app window with the title "Hello world":
from guizero import App app = App(title="Hello world") app.display()
Save and run the code - you've created your first guizero app!
Adding widgets
Widgets are the things which appear on the GUI, such as text boxes, buttons, sliders and even plain old pieces of text.
All widgets go between the line of code to create the
App and the
app.display() line.
from guizero import App, Text app = App(title="Hello world") message = Text(app, text="Welcome to the Hello world app!") app.display()
Let’s look at the
Text widget code in a bit more detail:
message = Text(app, text="Welcome to the Hello world app!")
message =- The
Textobject has a name, just like any variable
Text- an object which creates a piece of text on the screen
app– This tells the
Textwhere it will live. Most of the time your widgets will live directly inside the app.
text="Welcome to the Hello world app!"- The text to display
And that's it! Now have a look on the documentation pages for the individual widgets to find out more about how to use them. | https://lawsie.github.io/guizero/start/ | CC-MAIN-2018-39 | refinedweb | 283 | 69.01 |
In this post I am sharing solutions for some problems I have faced while studying Java Native Interface (JNI). Pretty much the same steps found at were implemented, since I needed the simplest case study possible. Although this study is a Java experiment it involves several other technologies. Moreover, we’ll be compiling platform-dependent code (the C++ part of it), which means that the the architecture of the operational system and the version of the JVM where our final JNI program will be executed definitely matters. Please take a look at the list below and keep in mind that some of the issues we’ll go through are specifically associated to this environment.
- Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
- Java HotSpot(TM) 64-Bit Server VM (build 11.0-b16, mixed mode)
- Eclipse IDE for Java Developers Build id: 20100218-1602
- Microsoft Visual Studio Professional 2010
- Microsoft Windows Vista Ultimate 64 SP2
The program we will implement is a Hello World where the Java class will invoke a native method that prints “Hello World” out, the real implementation of the method will be done in C++, and compiled into a Windows (64-bit) binary DLL (Dynamic Link Library) file.
The Java Program
Step #1 — The Java class with a
native method
I chose to use Eclipse because it helps to save time and it’s my favorite Java IDE. A Java project was created and our Java class (the one with the native method) stored under the package structure I use to organize my Java code, in this example our class is called “HelloWorld” and lives in the
package com.zilotti.studies.jni.helloworld
.
/**
* Class with a native method.
*
* @author Ivan Zilotti Alencar
* @author $Author$
* @version $Revision$
*/
public class HelloWorld
{
/**
* Native method
*/
private native void print();
static
{
final String LIBRARY_NAME = "HelloWorld";
System.loadLibrary(LIBRARY_NAME);
}
public static void main(String[] args)
{
new HelloWorld().print();
}
}
[/java]
Step #2 — Compile the Java class
Since I used Eclipse, the Java class was automatically compiled into the “bin” directory of the project. For example, a command line for compiling it could be
javac comzilottistudiesjnihelloworldHelloWorld.java (issued from the “src” directory of the aforementioned Java project).
Step #3 — Create Native Method Header File
The most important point here is issuing the command below in Windows Command shell. Please note that the current directory is our project’s “bin”ary output directory. It will contain only the “com” directory before the command is issued. After successfully issuing the command below, one will also find a new file,
com_zilotti_studies_jni_helloworld_HelloWorld.h, created by javah.
javah -jni com.zilotti.studies.jni.helloworld.HelloWorld
Step #4 — Open the C header file
The C header file generated by javah contains information about the native method we will implement in C++. We are all set to start working on the C++ project!
The C++ Library
Step #1 — Create a new “Win32” Project in Microsoft Visual Studio
Step #2 — Application settings and other options…
If you made it to this screen and pressed the “Finish” button shown on the Figure 6, you are ready to add the C header to the C++ project.
Step #3 — Add javah Generated Header to the C++ Project
Step #4 — Add JNI headers to the C++ Project
In order for native methods implemented in C++ to be properly invoked the jni.h header file must be included, it can be found in the JDK. The command shown in the Figure 10 can help you to identify the location of your current JDK.
Searching for the jni.h header file in the JDK…
Figure 13 - Adding the JDK's include directory and its sub-directories to the list of include directories of the C++ project.
Step #5 — Write the Native Method[cpp] // HelloWorld.cpp : Defines the exported functions for the DLL application.
//
#include <jni.h>
#include <stdio.h>
#include "stdafx.h"
#include "com_zilotti_studies_jni_helloworld_HelloWorld.h"
JNIEXPORT void JNICALL
Java_com_zilotti_studies_jni_helloworld_HelloWorld_print(JNIEnv *env, jobject obj)
{
printf("Hello World!n");
return;
}
[/cpp]
Step #6 — Change Target Platform to x64
Step #7 — Building the C++ Project
Running the Java Program
Now we have the 2 major components required to execute our project: the Java program which simply specifies the native method; and the native implementation, bundled in the DLL file we have just compiled.
Very interesting! | http://zilotti.com/blog/getting-started-with-jni/ | CC-MAIN-2017-13 | refinedweb | 716 | 53 |
Re: Relative Imports, why the hell is it so hard?
- From: Istvan Albert <istvan.albert@xxxxxxxxx>
- Date: Tue, 24 Mar 2009 08:49:08 -0700 (PDT)
On Mar 23, 10:16 am, CinnamonDonkey <CinnamonDon...@xxxxxxxxxxxxxx>
wrote:
I'm fairly new to Python so I still have a lot to learn. But I'd like
to know how to correectly use relative imports.
Relative imports are *fundamentally* broken in python. You will soon
see that code using relative import will break if you attempt to run
the module on its own. Yes, it is mindboggling!
Why is it so you ask? It is one of those issue that would be trivial
to implement correctly (it is relative to the current file location,
duh!!!), would be tremendously useful yet for some reason it is
controversial with those who would need to implement it.
It looks like they think that the expected mode of operation would
greatly confuse the 'rest' of us. So that is the reason you end up
with a broken implementation that is worse than not having it at all.
All I can do is recommend that you avoid relative imports.
The easiest way around the issue is to create a module named
pathfix.py like the one below and import it in all of your modules.
This is the only way to fix this issue in a way that does not come
back and bite you, it is ugly, you are repeating yourself in multiple
places, but it is still better than the alternative.
-------------------
import os, sys
def path_join(*args):
return os.path.abspath(os.path.join(*args))
# adds base directory to import path to allow relative imports
__currdir = os.path.dirname( __file__ )
__basedir = path_join(__currdir, '..' )
if __basedir not in sys.path:
sys.path.append( __basedir )
.
- Follow-Ups:
- Re: Relative Imports, why the hell is it so hard?
- From: Gabriel Genellina
- References:
- Relative Imports, why the hell is it so hard?
- From: CinnamonDonkey
- Prev by Date: Appending to sys.path
- Next by Date: Re: install pyPgSQL on Windows for python 2.5
- Previous by thread: Re: Relative Imports, why the hell is it so hard?
- Next by thread: Re: Relative Imports, why the hell is it so hard?
- Index(es): | http://coding.derkeiler.com/Archive/Python/comp.lang.python/2009-03/msg03072.html | CC-MAIN-2015-14 | refinedweb | 371 | 75.4 |
itext pdf - Java Interview Questions
itext pdf sample program to modify the dimensions of image file in itext in java HiIf you want to know deep knowledge then click here and get more information about itext pdf program.
by the jsp engine into java comments in the source code of the servlet...Comments in Jsp
In a jsp we should always try to use jsp- style
itext version
itext version
In this program we are going to find version of
the iText jar file which is using to make a pdf file through
the java program.
In this example we need
Comments in Java code required to write description about a method, function...
number of comments lines you want in your Java code.
In Java programming...
This type of comments is used to write a single line comments in Java. The
Java set iText pdf document background image - Java Beginners
://
Thanks...How to set iText pdf document background image Hi,
I have created the pdf document using the iText classes.
but i need to set the background
ChapterAuonumber Itext
ChapterAuonumber Itext I'm new to Itext ,Please provide some example of using ChapterAutonumber in Itext
include comments in HTML
include comments in HTML How can I include comments in HTML
Submit comments in database when user clicks on submit button
Submit comments in database when user clicks on submit button
This is detailed java code to show how to submit
comments from a jsp page and insert it to the MySql images in itext pdf
Adding images in itext pdf Hi,
How to add image in pdf file using itext?
Thanks
Hi,
You can use following code:
PdfWriter.getInstance(document,new FileOutputStream("imagesPDF.pdf"));
Read more at Inserting
PHP Comments
PHP Comments:
Most of the popular languages (C, C++, Unix) uses same
kind of comments, single line (//) and more than one line comments (/* */) and
along... comments ( // ) is used to make a single
line or a block inactive. Similarly
iText support android? - MobileApplications
iText support android?
would iText support android?
i ve linked the iText.jar file with my android project developed in eclipse...
//code
Document document = new Document(PageSize.A4, 50, 50, 50, 50.
filling pdf by itext
Java Language
Java Language
Java Comments
To comprehend any programming language, there are
several kind of comments which are used. These comments are advantageous
regarding the pdf table using itext
Ignoring Comments While Parsing an XML File
Ignoring Comments While Parsing an XML File
This Example shows you how to Ignore Comments... in code given below for Ignoring Comments is described below
Ignoring Comments While Parsing an XML File
Open Source PDF
Open Source PDF
Open Source PDF Libraries in Java
iText is a library that allows you to generate PDF files on the fly. The iText classes are very useful for people who need to generate read-only
java
java Does java allows multiline comments
EasyEclipse for Python
;
There are currently 10 comments for this distribution.
You can... services from Eclipse - Getting
started.
Java
for Windows - Run Java application on Sun Java(tm) runtime, packaged for
Eclipse use. (Windows only
EasyEclipse for Ruby and Rails
;
There are currently 9 comments for this distribution... platform services from Eclipse - Getting
started.
Java
for Windows - Run Java application on Sun Java(tm) runtime, packaged for
Eclipse use
java - Java Beginners
java Hii
Can any ome help me to Write a programme to merge pdf iles using itext api. Hi friend,
For solving the problem visit to :
Thanks
How I can filling pdf file that crated by livecycle using itext down?
For eg: If we select one county, that related states only come, if we select
Protocols
;
Partitioning the source code into sections, using
comments as headers... by the standard Java browsing views in Eclipse 3.0. The
Protocols plug...
through a new Java Browser view and in the source code as headers. The plug-in
offers
| Reflection API
Tutorials |
Java Applet
Tutorials |
Java iText - Open... Section
Java
Java
Keywords |
Java Data
Types |
Java Literals... | Site
Map | Business Software
Services India
Java Tutorial Section
java - Java Beginners
java Can you please provide me the steps for running the Java Doc Comments with a simple program please
java - Java Beginners
java Develop a Java package with simple Stack and Queue classes. Use JavaDoc
Java Code - Java Interview Questions
on PDF using Java visit to : Code Hi,
How to convert word document to PDF using java????
Can you give me a simple code and the libraries to be used?
Thanks
java
java Accept a filename from the user and display the contents of the file. Accept the names of two files and copy the contents of the first to the second. Add Author name and Date in comments in the beginning of file. Add
Use of Comment Function in PHP
Use of Comments Function PHP
Sometimes we need to hide some text in a program, at that case we should put
all those codes within comments. Line of Comments... need to use your coding, it is
also useful if you are working alone, comments
Creating Multiple Lists
make
sublist You can make
ordered list or symbolic list. iText...);
listItem = new ListItem("Core Java"...)));
sublist.add("Creating Paragraph using iText"
Open Source FTP
into Firefox: fireFTP. It sounds OK. In fact, after reading some of the comments..., 2000 and XP.
Open
Source FTP Java Library
EdtFTPj is the first choice of Java developers worldwide for incorporating FTP functionality
Learning Java
Learning Java Hi,
How is the process of Learning Java is difficult? I have heard that Java is very difficult language.
Let's know your comments.
Thanks
Hi,
Java is easy language. You can even Learn Java in a Day
Java - Java Interview Questions
Java Hi
How to write java code inorder to get the comments written in a java
program?
Please let me know..this was asked in my interview... in details.
For more information on Java visit to :
comment.css - Java Beginners
comment.css
padding: 4px;
width: 165px;
border:1px solid #909090;
}
background: #424242;
padding: 8px 18px;
}
Java Example Codes and Tutorials
;
Java iText - Open Source PDF Libraries
iText is a java library that provides the facilities for generating PDFs. You... by using this java library. You can get more about the iText library inside
java encoding - Java Beginners
://
Your comments are welcome regarding...java encoding how to encode String variable to ASCII,FromBase64String,UTF8 Hi
It's very easy to convert String Variable into ASCII
Java - Java Beginners
by the programmer
Interviewer:I also need the comments written by the programmer...
When I press the button i should get all the data including the comments...://
Generate pdf file - JSP-Servlet
for the jsp page or in servets Hi Friend,
You need to download itext...:
For more information, visit the following link:
Thanks
Java Architecture
Java Architecture What is architecture of java
Architecture of Java program
Here is an architecture of a java program where documentation part or writing comments into program is completely optional.Declaration
java - Development process
java Develop Date class in Java similar to the one available in java.util package. Use JavaDoc comments and the output.please reply must sir. .../tutorial/java/core/implementDateclass.html
Thanks
This post is password protected. Enter the password to view comments.
Ajouter un Commentaire
You...;
PDF creation in JAVA - JSP-Servlet
visit the following link:
clarify date class - Java Beginners
clarify date class Dear,
clarify this question...
"Develop Date class in Java similar to the one available in java.util package. Use JavaDoc comments."
Give me the source code and explain how to create classes similar
Java - Java Beginners
Java Write a program to copy the contents of one file to another file removing comments and extra blanks.
please reply. Hi Friend,
Try the following code:
import java.io.*;
public class CopyFile{
private
reading from pdf to java - Java Beginners
the following link:
Thanks... in java.
I need the methods of reading data from file and to place that data in the string, using java. Hi Friend,
We are providing you a code
Java files - Java Beginners
Java files i want to get an example on how to develop a Java OO application which reads, analyses, sorts, and displays student project marks...; all lines starting with a hash symbol (#) are comments and should be
ignored
java Date - Java Beginners
java Date Dear sir I have an assignment, It is ..
"Develop Date class in java similar to the one available in java.util package.Use JavaDoc comments "
Please help me to do the assignment, and tell me the steps
Java code - Java Beginners
Java code Develop date class in Java similar to the one available in java.util package. Use JavaDoc comments. Hi Friend,
Try the following code:
public class Date {
private final int month;
private final int
Create PDF from java
code to create pdf file from database call from java programming.
thank you,
Hendra
Create PDF from Java
import java.io.*;
import java.sql....);
document.close();
}
}
For more information, visit the following link:
Itext
Java programmes - Java Beginners
Java programmes 1. Develop a Java package with simple Stack and Queue classes. Use JavaDoc
2. Design a class for Complex numbers in Java. In addition to methods for basic
operations on complex
JavaScript Comment
JavaScript Comment:
Comments are placed within the programming language... text in a program, at that situation we should
put all those codes within comments. Line of Comments generally use for putting
important information of variables
Java Final Project - Java Beginners
Java Final Project I am having a real hard time with this java..." );
//constructing the Comment panel
JLabel l7= new JLabel("Customer Comments?");
JPanel p7 = new JPanel();
tab.addTab ("Customer Comments?",null,p7
creating windo chat
creating windo chat hi ... please could you help me in creating chat aprograme in java ???? with comments beside codes please
about pdf file handeling
about pdf file handeling can i apend something in pdf file using java program?
if yes then give short code for it.
You need itext api to handle pdf files. You can find the related examples from the given link
Social media marketing - frequently asked questions
bigger. This has given rise to all sorts of comments,
suggestions, complaints...
include number of comments, hits, as well as sales.
How do you avoid failing
Measure Of Width
the width of the page. iText api provides a getWidthPoint()
to know
EasyEclipse Expert Java
EasyEclipse Expert Java
EasyEclipse Expert Java
Bare-bones Eclipse distro for experienced Java
developers who are new to Eclipse.
EasyEclipse Expert Edition
Basic Java Language Elements
in the program.
Java
To comprehend any programming language...
Basic Java Language Elements
Java
keyboards
There are few keywords in Java programming
Tips and Tricks
in the form of a PDF document using Servlet. This program uses iText, which is a java library containing classes to generate documents in PDF, XML, HTML, and RTF...:// download.html/.
Now, read more information | http://roseindia.net/tutorialhelp/comment/84673 | CC-MAIN-2014-42 | refinedweb | 1,824 | 63.7 |
Cancelled
Convert a js script file to Node module --
Budget €8-30 EUR
this is a simple project to test you before you get invited to the Team,
once you have this task done successfully we will send you bigger projects
1- Download any simple react project from github/gitlab
2- download this script from website=
[login to view URL]
3- What I Want :
import artQRCode from "./artQRCode...."
<artQRCode text= "test" width="300" hight="{}" link="{}" .../>
once you have a screen shoot of this working I will Pay :)
good luck
2 freelancers are bidding on average €15 for this job
arthurwolf
€10 EUR in 7 days
(0 Reviews)
0.0 | https://www.freelancer.com.au/projects/javascript/convert-script-file-node-module/ | CC-MAIN-2020-10 | refinedweb | 109 | 61.33 |
Constant Variables
Constant variables, or simply constants, are variables whose value cannot be changed once initialized. Given that fact, constants can only do initialization since forgetting to initialize a constant will produce an error. Constants must be assigned with an initial value, and after that, the value can never be changed at runtime.
To declare a variable as constant, simply use the const keyword. Constant’s name should be in all caps as part of C#’s naming convention. It is not required but it allows you to easily identify which are the constants. Here’s the syntax for defining a constant.
const data_type identifier = initial_value;
Here’s an example of using a constant.
namespace ConstantsDemo { class Program { public static void Main() { const int NUMBER = 1; // This is a constant NUMBER = 10; //ERROR, Cant modify a constant } } }
You can see that assigning a value to a constant once it has been declared leads to an error. Another thing to note is that you cannot initialize constants with variables who’s value is not known during compilation. For example, doing the following produces an error.
int someVariable; const int MY_CONST = someVariable;
You might be wondering why do we need to use constants. Constants allow you to store values that you don’t usually change frequently. Say that your program needs to calculate a value by multiplying it with a certain rate. You can store the rate in a constant and then use that constant in multiple places of your code. Here is an example.
using System; namespace ConstantsDemo { class Program { public static void Main() { const double RATE = 0.5; Console.WriteLine("The rate is " + RATE); double calculated = 100 * RATE; Console.WriteLine("Calculated = " + calculated); } } }
As you can see, the RATE constant variable was used several times. Now if you want to change the rate, then all you have to do is change the value of the constant. All the places of your code that uses that constant will automatically update saving you tedious work of manually updating each place where the rate is used. We are also promoting code reusability which is a good programming practice. You may say that we can do this using a normal variable, but using a constant ensures that we won’t accidentally change the value anywhere in our program. It would be hard to demonstrate this accident in a small program but in larger programs, this mistake is easy to make. | https://compitionpoint.com/constant-variables/ | CC-MAIN-2021-31 | refinedweb | 405 | 63.29 |
CodePlexProject Hosting for Open Source Software
Hi,
I was wondering where I could find the algorithm you are talking about
here (scroll down to Texture to polygon) and I found out that you are talking about the code I submitted (as I saw my name
here and the note that I'm using marching squares).
Well, I'm using an algorithm that I developed on my own and it feels not right to let the missinformation there :P ... I didn't just implement an existing idea, I spent quite some time on this :).
I'm afraid a simple message to genbox will go under in the amount of messages he probably gets, so I'm posting it here.
What might have led to this missinformation is that there was a user who told me about the marching squares algorithm and I tried it out. However, my implementation of that algorithm was slower then what I had created, so I dropped it and never released
it ...
That is my fault David. I must have misread the discussion way back when you developed the code. I'll be sure to remove the misinformation right away.
Now that I have you here (again...), do you think you can improve the implementation a bit with some changes I have in mind?
Thanks :).
Well, I have got to work the next week, but the week after I should be able to find a day or two.
So, what can I do for us?
Well, I was thinking we could improve the hole support a bit. Nothing fancy really, the algorithm should return the holes it finds as simple polygons with a clockwise winding. This way we could use the holes in triangulation algorithms such as constrained
delaunay that support holes.
Another thing is that the algorithm works with pixels and it returns the vertices as it found them in the texture. As seen in AdvancedSamples Demo1 (from the source control - inside the yet to be released FPE 3.2) you have to translate the vertices by the
centroid - I'm wondering if this could be done inside the algorithm itself or would that be stupid?
You also have a TODO in there that should be looked at or removed. And I guess if you took an extra look at the algorithm, you could probably find a couple of improvements your self.
... the algorithm should return the holes it finds as simple polygons with a clockwise winding.
Sounds simple.
(...) the algorithm works with pixels and it returns the vertices as it found them in the texture. (...) you have to translate the vertices by the centroid - I'm wondering if this could be done inside the algorithm itself or would that be stupid?
The Reason for that was that I wanted to generate polygons from huge textures and I didn't want to lose the position of the found polygons. I also didn't want them to become just one body.
However, I can put a flag into the creation parameters class and let the user decide what he wants.
You also have a TODO in there (...)
I'll take a look at that. I thought a few times about asking you to grant me svn developer rights so I could work on the alorithm whenever I'd like to... ? I thouth about creating a new decomposer or changing the algorithm so it doesn't need a decomposer
anymore ... ... but I don't know if I can find that much time. What do you think?
It is fine with me. You are welcome to do some work on the algorithm - my experience tells me that it is pretty stable and works in most cases.. If you make any major changes or change the API, be sure to let me know. I'll add you as a developer, if you
have any questions, let me know.
This way we could use the holes in triangulation algorithms such as constrained delaunay that support holes.
Is this already supported?
Yes, the CDT algorithm in FPE already support holes. However, the API for holes is not yet exposed.
At the moment I'm trying to keep any changes out of the engine that is not related to the FPE 3.2 release (I've sent you an e-mail, not sure if you got it since you have 2 emails in my contacts) but if you take a look at the CDTDecomposer, you will see that
the Polygon object have an AddHoles() or similar method.
I got your email and I'm sure you have my @t-online and @sickbattery email addresses. I use both, so it doesn't matter which one you use.
I will tak a look at the CDTDecomposer. Thanks.
Update:
Ok, I've analysed my code and have decided to remove the PolygonCreationParameters class, also TextureConverter won't be static anymore (don't worry, I will do my best to keep the static interface intact). The return values will have to change (or I'll have
to create new functions with new return values) because of the holes change request.
The functions will return something like:
public class PolygonWithHoles
{
public Vertices Polygon;
public List<Vertices> HolePolygons;
}
Any objections?
Since it's x-mas I don't have that much time today. I'll work on it tomorrow (for two or three hours) and then in the new year again (I have to go to work between the holidays, sorry).
Update2:
It won't be that easy to keep the static intarface intact, since I have to return something more complex then List<Vertices> ...
Are you sure you want to delete this post? You will not be able to recover it later.
Are you sure you want to delete this thread? You will not be able to recover it later. | http://farseerphysics.codeplex.com/discussions/239125 | CC-MAIN-2017-17 | refinedweb | 972 | 71.34 |
Lazy-loading images with React and Semantic UI
Images make up most of the website’s content size and therefore play a huge part in page load times. This is especially problematic with single-page websites like most landing pages are nowadays. A solution to this problem is lazy loading images, i.e., the images below the fold are loaded asynchronously at a later time. There are two main ways to do lazy loading:
- Delay loading images until the above the fold content is loaded, and then load all images
- Delay loading the image until it is in the user’s viewport
Lazy-loading images when they are in the viewport is really easy with Semantic UI:
You define the image
src as
data-src instead and then attach a visibility handler to the images:
$('.demo.items .image img') .visibility({ type : 'image', transition : 'fade in', duration : 1000 }) ;
Lazy-loading images using React and its React Semantic UI port is a bit different as we won’t use
jQuery, but React components instead.
We can create a
LazyImage React component that loads the image when it’s in the viewport.
For that, we use the
Visibility component that has a callback when the top edge of the component is in the viewport:
import PropTypes from 'prop-types' import { Visibility, Image, Loader } from 'semantic-ui-react' export default class LazyImage extends React.Component { static propTypes = { src: PropTypes.string.isRequired, size: PropTypes.string, } static defaultProps = { size: `medium`, } state = { show: false, } showImage = () => { this.setState({ show: true, }) } render() { const { size } = this.props if (!this.state.show) { return ( <Visibility as="span" onTopVisible={this.showImage}> <Loader active inline="centered" size={size} /> </Visibility> ) } return <Image {...this.props} /> } }
The usage is exactly the same as Semantic UI React’s Image component as we just forward the
props to it:
<LazyImage src="" size="mini" rounded />
If the image is not in the viewport we render a
Loader. You might wonder why we do that because if the image is not in the viewport, it’s not visible by definition and it doesn’t matter what we render as its placeholder.
This is true in theory, but I noticed you can still see a
Loader when the image is in the initial viewport and you’re using server-side rendering. The server will serve the
Loader and it takes a fraction of a second until the app is rehydrated and the
Visibility handler is hooked up. | https://cmichel.io/lazy-load-images-with-react/ | CC-MAIN-2018-34 | refinedweb | 405 | 50.57 |
Document field detection using Template Matching in Python
Document field detection is an important task in today’s industry. Thousands of documents undergo processing for various purposes and these contain lots of unrelated information. So the detection of required fields in documented images is of utmost importance. Template matching is an image processing method that we employ quite often in such cases. Basically, template matching is used to locate a smaller part (or template) of an image in the whole image. In this tutorial, we shall learn how to facilitate document field detection using template matching in Python.
For this industry problem here, we shall take into account the necessary fields. Then we can clip them out from the original image. After that, we can detect and locate the specific field using the template matching technique.
In this tutorial, we shall try to detect a portion from the preamble of the constitution (the original one) of India. So we shall first take an image from the internet. You can download it from here by clicking on the image.
Now, we cut one piece from the image that you can download by clicking the below image
So we shall try to detect the document field in the whole original image in the following code.
Importing the necessary libraries and modules for document field detection using Template Matching in Python
import cv2 import numpy as np import matplotlib.pyplot as plt %matplotlib inline
When we try to read the images, the default system is BGR. If we simply just read it, we would see a bluish tint in the image. So, we need to convert BGR to RGB using the cv2.cvtColor(image, cv2.BGR2RGB) function.
# whole image to search doc = cv2.imread('./input/constitution.jpg') doc = cv2.cvtColor(doc, cv2.COLOR_BGR2RGB) # The Template to Match temp = cv2.imread('./input/constitution_template.jpg') temp = cv2.cvtColor(temp, cv2.COLOR_BGR2RGB)
Matching the template
There are six available methods for the function cv2.matchTemplate() about which you can learn from here. We are going to use the simplest method for sliding the template over the image: cv2.TM_CCOEFF. Then for localization, we use the cv2.minMaxLoc() function the usage of which can be found here. The only useful value we need here is the maxLoc, that gives the pointer to the returned maximum location. Now, this maxLoc value for the metric TM_CCOEFF gives the top left corner of the detected area. Using this, we find the position of overlap and mark the boundary of the detected region.
# Apply template Matching with the method match = cv2.matchTemplate(doc, temp, eval('cv2.TM_CCOEFF')) # Grab the Max and Min values, plus their locations _, _, _, maxLoc = cv2.minMaxLoc(match) top_left_corner = maxLoc bottom_right_corner = (top_left_corner[0] + width, top_left_corner[1] + height) # Draw the Red Rectangle cv2.rectangle(doc,top_left_corner, bottom_right_corner, 255, 10) plt.figure(figsize = (20,20)) plt.imshow(doc) plt.title('Detected Point') plt.show()
Output:
This concludes the tutorial on document field detection using template matching in Python. For a better visualization of this topic, you can go through the various methods and understand the underlying mathematics, all of which are outside the scope of this tutorial.
You may check out the following tutorials for a firm grip on object detection in Python: | https://www.codespeedy.com/document-field-detection-using-template-matching-in-python/ | CC-MAIN-2020-50 | refinedweb | 545 | 58.38 |
public class Solution { public ListNode removeElements(ListNode head, int val) { ListNode fakeHead = new ListNode(-1); fakeHead.next = head; ListNode curr = head, prev = fakeHead; while (curr != null) { if (curr.val == val) { prev.next = curr.next; } else { prev = prev.next; } curr = curr.next; } return fakeHead.next; } }
Can I return head instead of fakeHead.next at the last line?
I tried "return head" but it gave the wrong answer, why?
The reason is that head may also need to be removed from the list. Is the test case that gave the wrong answer of this kind?
Here is my code with similar strategy. I did not connect fakeHead with head at the beginning though.
public ListNode removeElements(ListNode head, int val) { ListNode fakeHead = new ListNode(-1); ListNode prev = fakeHead; while(head != null) { if(head.val == val) { head = head.next; prev.next = null; // this is necessary!!! } else { prev.next = head; prev = head; head = head.next; } } return fakeHead.next; }
we can do it with only having curr.
public ListNode removeElements(ListNode head, int val) { ListNode dummy = new ListNode(0); dummy.next = head; ListNode cur = dummy; while(cur.next != null) { if(cur.next.val == val) { cur.next = cur.next.next; } else cur = cur.next; } return dummy.next; }
public ListNode removeElements(ListNode head, int val) {
if(null==head) return null; ListNode traverser = head; while(traverser.next!=null){ if(traverser.next.val==val){ traverser.next = traverser.next.next; } else { traverser = traverser.next; } } if(head.val==val) return head.next; return head; }
You actually only need one pointer:
class Solution { public: ListNode* removeElements(ListNode* head, int val) { if(!head) return nullptr; ListNode *dummy = new ListNode(0), *curr = dummy; dummy -> next = head; while(curr -> next) { if(curr -> next -> val == val) curr -> next = curr -> next -> next; else curr = curr -> next; } return dummy -> next; } };
head may be abandoned...
such as
head.val == val
I like this solution! I think it is a little bit easier to follow than that using recursion.
the runtime beats only 7% for me by using this method. anyone know why it is so slow? I submitted 3 times. still the same.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect. | https://discuss.leetcode.com/topic/12725/ac-java-solution | CC-MAIN-2018-05 | refinedweb | 360 | 71.82 |
IMPORTANT. This article discusses how the Arduino Leonardo and the Arduino Micro can also appear as a generic Game Controller. generic Game Controller provides the following:
- X, Y, and Z axis
- 32 buttons
- X, Y, and Z axis rotation
- Rudder
- Throttle
- 2 Point of View Hat Switches
Step 1: Updating the Arduino Code
First make a backup copy of the following two files in the “%PROGRAMFILES%\Arduino\hardware\arduino\avr\cores\arduino” folder:
- USBAPI.h
- HID.cpp
Replace these two files with the ones attached to add a generic Game Controller to the Arduino Leonardo and the Arduino Micro.
Step 2: Running the Test Sketch
Compile and upload the attached UsbJoystickTest.ino sketch file onto the Arduino Leonardo or the Arduino Micro using the Arduino Software (IDE). I have tested this using version 1.6.1 through 1.6.5 of the software. For Arduino IDE version 1.6.6 and above, see the following Instructable: Arduino Leonardo/Micro as Game Controller/Joystick.
The following steps are for Windows 7. If you have a different version of Windows or a different operating system, these steps may differ.
Step 3: Windows Control Panel - Hardware and Sound
Go to the Windows Control Panel and select “Hardware and Sound”.
Step 4: Devices and Printers
Then select “Devices and Printers”.
Step 5: Arduino Should Appear
The Arduino Micro or Arduino Leonardo should appear in the list of devices.
Step 6: Arduino Settings
- Next right mouse click on the Arduino Leonardo or Arduino Micro to display the settings menu.
- Then select “Game controller settings” to get to the “Game Controllers” dialog.
Step 7: Game Controller Settings
The Arduino Micro or Arduino Leonardo should appear in the list of installed game controllers. Select the Arduino Micro or Arduino Leonardo and click the Properties button to display the game controller test dialog.
Step 8: 9:).
88 Discussions
6 months ago
Where does one find the wiring diagram(s)?
Thanks :)
1 year ago
I'm a newbie as well. I have my board set up as a Leonardo, yet I get the message
'Joystick was not declared in this scope'.
I put the files you mentioned in the
PROGRAM FILES(x86)\Arduino\hardware\arduino\avr\cores\arduino
folder (I had to rename them so they matched the names you gave them - since during the download, the names were changed).
One thing that could be an issue: My Arduino files are in several locations on my hard drive. I can find no guide as to where everything should be in order to insure that all the various sketches and libraries are found by the IDE.
I need 8 ANALOG channels and no buttons.
I also cannot find any documentation on where to connect the potentiometers for the various channels. Is that somewhere?
Reply 1 year ago
You'll need 2 things to make this work:
1: The Arduino Joystick library:...
2: add [ #include <Joystick.h> ] (without brackets) to the beginning of the sketch before the first const bool string.
Reply 1 year ago
I no longer support this method of doing this. I have a much easier way to do this using the Arduino Library (). There are examples on how to install and use this library on GitHub and at.
Reply 1 year ago
Matthew,
I apologize for my lack of knowledge. I'm an experienced PIC Basic Pro (PBP) programmer. But Arduinos work a LOT different.
My goal is to use an ordinary hand-held R/C controller with 8 pots (pitch, roll, yaw ,throttle, mode, camera pitch, camera yaw, spare) to control a quadcopter using my laptop and the Mavlink Protocol. A program called MISSION PLANNER running on my laptop does the conversion between the joystick and Mavlink. This will allow me to use my laptop's 4G LTE connection to send commands to my quadcopter (which also has a 4G connection). This gives me virtually unlimited control range.
I need at least 8 ANALOG channels where an input voltage of 1-4V sets the output. I don't need any toggle or "hat" switches at all.
I can use ANALOG READ() to get a value. But how many bits are returned - 8? 10? 12? 16?. And what is the reference? 3.3V, Vcc, something else? I looked through the joystick library and I can't figure out how to make all channels analog, and what is the syntax to get an A/D reading into a 8-bit joystick "position".
Reply 1 year ago
> I can use ANALOG READ() to get a value. But how many bits are returned - 8? 10? 12? 16?
This is documented on the Arduino website:
The Arduino uses a 10-bit A-to-D converter.
> And what is the reference? 3.3V, Vcc, something else?
Some links to help you with your question:...
For the Leonardo and the Micro the default reference is 5V.
Reply 1 year ago
Mattew,
I downloaded and installed the latest version of the joystick library.
I figured out how to read analog channels on an Arduino, and I can read them and send values to the terminal.
But I have some more questions:
In the Multiple Joystick Test program example -
There is a line
JOYSTICK_TYPE_MULTI_AXIS 32,1,true,true, false, true, true, false, false, false...
What are the numbers "32" and "1" for?
What does "true,true, false, true, true....." mean?
What is gcCycleDelta?
What is gcAnalogDelta?
If I want 8 analog joysticks and no digital buttons, how would set up that?
I look at each individual analog joystick as a "channel" . Is it correct that I can write a value to a channel by
Joystick[channel].setXAxis(analog value); ?
But I'm confused by the 'setXAxis' part. I was thinking if 'channel' is a variable that lets you write to any channel, but 'setXAxis' refers to a particular channel.
And if you have 8 joysticks, how do you refer to them? "X", "Y", "Z" .... then what?
I also assume that the value range expected by the library is -127 to +127. Is that correct?
If the above is true, then wouldn't
JoyStick_Value = (analogRead(1) >> 2) - 127
do the right thing?
Reply 1 year ago
I think most of your answers can be found on the ReadMe file at.
> What are the numbers "32" and "1" for?
The 32 is for buttonCount
The 1 is for hatSwitchCount
These are explained in the constructor portion of the Joystick Library API located in the ReadMe file.
> If I want 8 analog joysticks and no digital buttons, how would set up that?
Question: Do you want a single joystick with 8 axes or do you want 8 joysticks with an X and Y axis each?
Having 8 axes on a single joystick is tricky. The USB specification defines X, Y, Z, RX, RY, and RZ axes (which gets you to 6), but does not give you the ability to create more. You can also turn on some of the other analog inputs, like Accelerator and Throttle, but your game would need to support reading those values. A lot of games max out at 6.You can learn more about this at...
Having 8 joysticks with an X and Y each is just a matter of creating 8 instances of the Joystick class and giving them each a unique hidReportId. I have only tested up to 4, however.
> Is it correct that I can write a value to a channel by Joystick[channel].setXAxis(analog value); ?
Yes
> And if you have 8 joysticks, how do you refer to them? "X", "Y", "Z" .... then what?
You refer to them as 0, 1, 2, 3, 4, 5, 6, 7. For example, to set the Y axis for Joystick #4 (the index would be 3) to 100:
Joystick[3].setYAxis(100);
> I also assume that the value range expected by the library is -127 to +127. Is that correct?
That was the range for Version 1.0. Version 2.0 aligns with the Arduino defaults (which is 0 to 1023). You can set the range to anything you want, however, using the setXAxisRange, setYAxisRange, etc. methods.
Hope this helps,
Matt
Reply 1 year ago
I have successfully compiled the code and installed it into a Leonardo.
Then, when I go into Windows 10 "Devices and Printers". It identifies the device as "Arduino Leonardo", but the category is "Unspecified" and when I right-click on that icon, I get only
Create Shortcut
Remove Device
Troubleshoot
Properties
When I click on PROPERTIES, I get
"Report ID declaration outside of top level collection"
Apparently the joystick driver isn't loading properly.
1 year ago
I believe I'm getting it. I have 5 channels working, and now I'll try to add the other 3. It helps that the program that this controls allows me to "map" the "channels" to whatever I want, so I don't have to concern myself with what each channel is called - or is usually used for.
I may yet need more help, but I'm making solid progress. Knowing programming (in general) has helped a lot, and I'm slowly learning the way Arduino does things.
Thanks for everything so far....
1 year ago
I'll read some more, but note this is NOT for a game.
This is for robot/drone control.
I have -
Two - two-axis joysticks = 4 analog inputs
MODE control = 1 analog
Camera tilt (pitch) = 1 analog
Camera yaw = 1 analog
Camera MODE = 1 analog
SPARE = 1 analog.
All inputs will be either from a potentiometer wiper or from a variable voltage source. The potentiometers produce an approx 1.2V - 3.8V signal, while the voltage source produce 0V - 5V. As mentioned before, there will be no buttons or switches. And just as in a game controller, the response times should be very short.
1 year ago
Can anybody give me some tips on how to code for 14 digital buttons? Im very new to programming and im trying to make my first raspberry pi gameboy case. I would really apreciate a little help.
Looking forward to hear from you.
Reply 1 year ago
The latest version of this Arduino Library () has a simple Gamepad example. The following Instructable shows how to use that example:. It get to 14 buttons, you just need to follow the patterns established by that example. Hope this helps.
1 year ago
hi all,
just figure out the code i need for the joystick i need finally.
with 1 analog and 9 button mini joystick for my retropie.
i'm new in arduino, and not good in coding, just curious if any better way to do this.
btw, it's interest for try and error in coding arduino ;)
here is the code just modify by web research:
#include <Joystick.h>
Joystick_ Joystick(0x03, 0x04, 9, 0, true, true, false, false, false, false, false, false, false, false, false);
void setup() {
pinMode(2, INPUT_PULLUP); //A
pinMode(3, INPUT_PULLUP); //B
pinMode(4, INPUT_PULLUP); //X
pinMode(5, INPUT_PULLUP); //Y
pinMode(6, INPUT_PULLUP); //L
pinMode(7, INPUT_PULLUP); //R
pinMode(8, INPUT_PULLUP); //SELET
pinMode(9, INPUT_PULLUP); //START
pinMode(10, INPUT_PULLUP); //EXIT
Joystick.setXAxisRange(-32767,32767);
Joystick.setYAxisRange(-32767,32767);
Joystick.begin();
}
const int pinToButtonMap = 2;
int lastButtonState[9] = {0,0,0,0,0,0,0,0,0};
void loop(){
int xAxis = analogRead(A0);
int yAxis = analogRead(A1);
xAxis = map(xAxis, 1023, 0, 0, 255);
yAxis = map(yAxis, 0, 1023, 0, 255);
Joystick.setXAxis(xAxis);
Joystick.setYAxis(yAxis);
for (int index = 0; index < 9; index++)
{
int currentButtonState = !digitalRead(index + pinToButtonMap);
if (currentButtonState != lastButtonState[index])
{
Joystick.setButton(index, currentButtonState);
lastButtonState[index] = currentButtonState;
}
}
}
2 years ago
Hi, is possible with this create a force feedback Sterring Wheel??? And witch board i can use??
Reply 2 years ago
I think this library could be used as a starting point, but I have not researched this. This library currently only supports sending Joystick data to the host machine. Force feedback devices get data back from the host computer and act on it (e.g. making the steering wheel harder to turn).
The library I wrote should work with any ATmega32u4 - based Arduino (or clone). I have tested it with the Arduino Leonardo and Arduino Micro. I know of others who have used it with the Arduino Due and SparkFun Pro Micro. I know it will not work with the Arduino Uno (since it used the ATmega328P).
Reply 2 years ago
Thank for your response..
I will try to go on this direction, if you have other info about it let us know them! I know that a lot of people have the same problem!
2 years ago
Great?
Reply 2 years ago
Can you include an example sketch file (*.ino) that demonstrates your issue? I have successfully used Joystick.h and Keyboard.h together without issue (see for an example of this).
Reply 2 years ago
Thanks for the response! I actually got them to work together by installing the Joystick Libraries in the Program Files folder, not in the Documents/Arduino folder. The past day has been very productive thanks to your code. Thanks! | https://www.instructables.com/id/Add-USB-Game-Controller-to-Arduino-LeonardoMicro/ | CC-MAIN-2019-09 | refinedweb | 2,184 | 74.39 |
Introduction
Complex and simple type definitions in XML Schema 1.0 allow schema authors to specify and restrict the content of elements and values of attributes. According to the XML Schema 1.0 specification, complex type definitions constrain elements by providing attribute declarations that govern the appearance and contents of attributes by restricting elements to be empty or to conform to a specific content model, such as element-only, mixed, or simple content determined by a simple type definition of the content.
Complex type definitions also define a mechanism that governs a type definition hierarchy which determines how complex types can be derived from other complex types or simple types by extension or restriction. Substitution groups on complex types control the substitution of elements with elements of its derived type. Simple types on the other hand constrain the character values of the contents of elements and attributes.
In this article we discuss co-occurrence constraints, a new feature introduced in XML Schema 1.1 to not only constrain the content of elements and attributes, but their existence as well.
A bit of history
As we mentioned in the first article of the series, XML Schema 1.0 has certain limitations. Beyond the constraints mentioned above, XML schema authors often needed to enforce more complex rules that determine and restrict the content of elements and attributes, such as the ability to restrict the appearance of certain child elements based on the value of an attribute, having the total sum of child elements not exceed a certain value, or allowing the value of a child element to be valid based on the scope in which it is found.
Unfortunately, XML Schema 1.0 did not provide a way to enforce these rules. To implement such constraints, you would
- Write code at the application level (after XML schema validation)
- Use stylesheet checking (also a post-validation process)
- Use a different XML schema language such as RelaxNG or Schematron
With the constant requests for co-occurrence constraint checking support from the XML Schema 1.0 user community, the XML Schema 1.1 working group introduced the concept of assertions and type alternatives in XML Schema 1.1 to allow XML schema authors to express such constraints.
Assertions
Assertions provide XML schema authors with a flexible way to control the occurrence and values of elements and attributes.
Usage scenarios
Before you delve into how assertions are defined in XML Schema 1.1, first take a look at some usage scenarios.
- Specify a constraining rule based on the values of two or more attributes. Given the XML fragment in Listing 1, you can specify a rule between attributes
widthand
heightso that the height is never be greater than the width.
Listing 1. XML fragment - element with two attributes
<dimension width="10" height="5"/>
- Specify a constraining rule between attributes and elements. In Listing 2, we have an element that has an attribute and two child elements. You can specify a rule between an attribute and the child elements such that value of the attribute equals the number of child elements.
Listing 2. XML fragment - element with one attribute and two child elements
<parent children="2"> <child name="one"/> <child name="two"/> </parent>
- Specify a constraining rule that determines the order and choice between attributes. For the element defined in Listing 3, you can specify a rule where
timerhas either a
timeor
iterationsattribute but not both.
Listing 3. XML fragment - timer element
<timer time="30" iterations="2000"/>
- Specify a grouping of elements and attributes into a model group. For example, you can restrict the content of element
parent(defined in Listing 4), by specifying a rule that forces the content to be either
childor
grandchildand both elements having the attributes
nameand
dob.
Listing 4. XML fragment - A parent element
<parent> <child name="abc" dob="1/1/1997"/> <grandchild name="xyz" dob="1/1/2007"/> </parent>
- Specify a constraining rule on the text in an element with mixed content. In Listing 5 is an element,
parent, that has mixed content. You can then specify a rule that allows the mixed content text to be only a maximum of 10 characters.
Listing 5. XML fragment - A parent element with mixed content
<parent>2 children <child>abc</child> <child>xyz</child> </parent>
To address these and other usage scenarios, XML Schema 1.1 provides more expressive constraints through XML Schema 1.1 assertions. Assertions in XML Schema 1.1 are similar to those available in other schema languages such as Schematron and RelaxNG.
At the time of writing this article, you can specify assertions on simple and complex types. The predicate is specified using an XPath 2.0 expression which is part of the assertion specified on the type.
Assertions on complex types
In XML Schema 1.1, complex type definitions can contain an assertions schema component
which is a sequence of
<xs:assert> child elements of
the complex type definition. The order of this sequence is insignificant. Assertions
constrain the existence of elements and attributes and their values. The
<xs:assert> schema component contains a
test
property which is an XPath expression property record and an
annotations property.
The value of the
test attribute of the
xs:assert element information item is an XPath
expression that evaluates to either true or false. You can use a special variable, $value, to refer to the simple content value of the element or attribute being checked.
Evaluation is done in the context of the parent element. The XPath expression must be a
valid XPath 2.0 expression or at least conform to the minimal XPath subset defined in
the XML Schema 1.1 specification.
If the XPath expression specified is invalid, an
xpath-valid error is reported.
If the
xs:assert is incorrectly specified, the schema
processor reports an
as-props-correct error. If the evaluation of the test expression is true and does not
result in a dynamic or type error, the element is considered locally valid. If it
evaluates to false a generic
cvc-assertion error is reported.
Listing 6 shows an example of a complex type with an
assertion that constrains the values of two attributes. The assertion expression
evaluates to
true if the value of
height
is less than the value of
width, otherwise it evaluates to
false.
Listing 6. Assertion on complex type - @height < @width
<xs:element <xs:complexType> <xs:attribute <xs:attribute <xs:assert </xs:complexType> </xs:element>
In the example above, we defined an
xs:assert element information item as a direct
child of
xs:complexType. We can also specify
xs:assert
on
xs:restriction or
xs:extension when defining a complex type with complex content
(
xs:complexContent)
or simple content (
xs:simpleContent). For an element to be valid, each assertion in
its sequence of assertions needs to evaluate to true. This sequence is comprised of
all the assertions defined on the complex type as well as all assertions of the complex
type's ancestors.
In Listing 7, we have two complex types,
baseType
and
derivedType, each with its own assertion. The assertion
on
baseType checks if the attribute
mustUnderstand
is present on the element. The assertion on
derivedType
checks if the
mustUnderstand attribute has a value
YES and at least one
body child
is present; otherwise it expects
mustUnderstand to have a
value of
NO. The
derivedType
has a sequence of two assertions, the one from
baseType
and its own. For the element
message to be valid, its content
must be valid as defined by its
complexType definition and all assertions must evaluate
to true.
Listing 7. Assertion on complex type with complex content
<xs:complexType <xs:sequence> <xs:element </xs:sequence> <xs:attribute <xs:assert </xs:complexType> <xs:complexType <xs:complexContent> <xs:restriction <xs:sequence> <xs:element </xs:sequence> <xs:attribute <xs:assert </xs:restriction> </xs:complexContent> </xs:complexType> <xs:element
When defining a complex type with simple content, you can specify two types of
assertions. The first one acts as facet and restricts the simple content type
(for example, restricting the simple value to be a multiple of 7), while the second one
appears as an assertion on the element as a whole, including its attributes. Since
the syntax of the content model of
xs:simpleContent/xs:restriction does not
distinguish between the two types of assertions, a new element information item,
xs:assertion was introduced to indicate an assertion
facet. We will cover
xs:assertion in the next section when we discuss assertions
on simple type definitions.
Assertions on simple types
In XML Schema 1.1, like complex types,
xs:restriction
elements among the children of an
xs:simpleType can
contain
xs:assertion elements. Assertions in simple types
are similar to other simple type constraining facets. The assertions simple type
component represents a set of constraining facets that restrict the value space of
a simple type by requiring values to satisfy conditions specified by the XPath
expression in the value of
test attribute.
As with complex type definition, the assertions are an ordered sequence of
xs:assertion elements specified as facets in the simple type
definition. The specified order of the sequence of assertions is insignificant as all
assertions in this sequence need to evaluate to true for an element or attribute of
this type to be valid. The assertions schema component contains a value property
which is a sequence of assertions from the base type, if any, and assertions defined
in the derived
simpleType.
The value of the
test attribute of the
xs:assertion element
facet is an XPath 2.0 expression or XPath 2.0 subset as defined by the XML Schema 1.1
specification that evaluates to either true or false. Evaluation is done in the context
of the parent element.
An element or attribute with simple content is valid if it is valid with respect to all assertion facets (that is, the
test property of each
xs:assertion evaluates to true, without any dynamic or type errors.)
In Listing 8, we show an example of an element with simple content that has an assertion facet that evaluates to true if the element's value is a multiple of 10.
Listing 8. An element with simple content that allows values that are multiples of 10
<xs:element <xs:simpleType> <xs:restriction <xs:assertion </xs:restriction> </xs:simpleType> </xs:element>
A value is valid with respect to a derived simple type that restricts another simple type, provided that it satisfies the derived type (and its restricting facets), and all assertions belonging to both the base and the derived type. In Listing 9, a string value is valid only if it is from 3 to 25 characters long and ends with the string "xyz".
Listing 8. Assertions on derived simple type definitions
<xs:simpleType <xs:restriction <xs:maxLength <xs:assertion </xs:restriction> </xs:simpleType> <xs:simpleType <xs:restriction <xs:assertion </xs:restriction> </xs:simpleType>
Error message customization
As demonstrated in the previous sections, XML Schema 1.1 assertions can use any XPath 2.0 expressions, and these expressions can be very complex. When the assertions fail, it becomes very important to provide error messages that are easy to understand.
Schema error codes
When a schema constraint is violated, the schema specification requires that the
corresponding error code be reported. For example, when you see the error code
cvc-attribute.3, you know clause 3 of the constraint
Attribute Locally Valid is violated, indicating that the value of an attribute is
not valid with respect to its type.
With a little more information about the context (for example, the element or attribute name,
line and column numbers, or values involved), this error code approach is often
sufficient for problem diagnosis. Applying this to assertions, the error code
cvc-assertion will be reported when an assertion is not
satisfied. Even with all the context information, you still do not know what really went
wrong and how to fix it, unless you look at the schema and try to understand the
(potentially very complex) XPath expressions.
Schematron approach
Users of Schematron (see Resources) often find it useful to be able to customize messages that are reported when rules are violated (Listing 10)
Listing 10. A Schematron rule
<report test="@min > @max"> On element "<sch:value-of", value of the "min" attribute "<sch:value-of" can not be greater than that of the "max" attribute "<sch:value-of". </report>
The following XML fragment (Listing 11) violates this rule.
Listing 11. A fragment that violates a Schematron rule
<range min="30" max="10"/>
This fragment will produce a message:
On element "range", value of the "min" attribute "30" can
not be greater than that of the "max" attribute "10".
This approach has two significant benefits:
- Human readable error messages can be associated with validation rules, making it easy to diagnose validation failures.
- The error message can also use XPaths to refer to values in the instance being validated to provide more information about what is causing the violation. In the above example,
range, 30, and 10 are all information that can vary from instance to instance.
Localization support
Validation rules can be deployed in systems with different locales, and users will
expect to see error messages in different human languages. To make it possible to use
a localized message, Schematron suggests using the
diagnostics
attribute in association with the
xml:lang attribute
as in Listing 12.
Listing 12. Example of localized message in Schematron
<sch:pattern> <sch:rule <sch:assert A person must have a name. </sch:assert> </sch:rule> </sch:pattern> <sch:diagnostics> <sch:diagnostic A person must have a name. </sch:diagnostic> <sch:diagnostic Une personne doit avoir un nom. </sch:diagnostic> </sch:diagnostics>
Schematron implementations can now select the right
diagnostic
based on the language expected.
SML approach
The Schematron approach is still not perfect for the localization issue. When new
languages are supported, the Schematron rule has to be updated, both to add the new
diagnostic entry, and to add the new
ID to the
diagnostics attribute.
The Java™ programming language handles this by using property bundles. When a new language is added, a new property bundle is introduced, and as long as it follows a certain naming convention, it can be discovered automatically, without the need to change the places where the messages are used.
The Service Modeling Language (SML) uses Schematron as one of its validation mechanisms. It introduces the "location ID" concept (Listing 13) to allow resource management strategies like the one used by a Java environment.
Listing 13. SML with a location ID concept
<sch:assert A person must have a name. </sch:assert>
The
locid attribute is of type
QName. Its
namespace name can be used to locate the bundle (which might contain, for example,
all error messages related to a person), and the
local name
to identify the error message to show for the corresponding rule. In
Listing 14 and Listing 15, we show
some examples of message properties in English and French.
Listing 14. A fragment of a message property in English
nameRequired = A person must have a name.
Listing 15. A fragment of a message property in French
nameRequired = Une personne doit avoir un nom.
Error message customization for assertions
XML Schema 1.1 does not prescribe any way to customize error messages for assertions, but it allows application specific information embedded in annotations. For example, Listing 16 shows how to include a customized error message in the "appinfo" element inside an annotation and use "documentation" to provide additional information about the message. The users benefit when XML Schema 1.1 processors adopt a best practice for using annotations to customize assertion errors. The common practice also might include mechanisms to enable localization of error messages.
Listing 16. Customize error messages using annotations
<xs:complexType <xs:attribute <xs:attribute <xs:assert <xs:annotation> <xs:appinfo> Value of the "min" attribute can not be greater than that of the "max" attribute. </xs:appinfo> <xs:documentation> When this assertion fails, the content of the above "appinfo" is used to produce the error message. </xs:documentation> </xs:annotation> </xs:assert> </xs:complexType>
Type alternatives
XML Schema 1.1 introduces a new mechanism called type alternatives that allow the schema author to specify type substitutions on an element declaration.
A look at conditional type assignment
In XML Schema 1.0,
xsi:type was introduced as a mechanism
for type substitution.
xsi:type is specified on an element in the instance document to replace the declared type with a derived one. This
mechanism works well if you design an XML vocabulary specifically for use
with XML Schema and you require that instances of your vocabulary use
xsi:type for type substitution. If, however, you write
an XML schema for a vocabulary which already has its own notion of type substitution,
then
xsi:type will not work. Instances of this vocabulary
select types using some other mechanism. One such example is the Atom Syndication
Format, an XML language used for Web feeds.
Atom allows instances to specify a
type attribute on elements containing text
constructs. If present, the value of this attribute must be one of
text,
html or
xhtml.
The content allowed is determined by the value of this attribute. Because
this attribute is not
xsi:type, it is impossible to write a
schema which models Atom using the XML Schema 1.0 language. If the condition for
selecting the type is more complex, for example
@height < @width (a comparison
between two attributes values), you cannot simply substitute it in the instance
with
xsi:type.
To address the shortcomings of
xsi:type, you can use the
type alternative mechanism. This allows the schema author to specify type substitutions on an element declaration which are selected based on the evaluation of XPath expressions. In the next section we will show how this works
using Atom as an example.
How type alternatives work
In XML Schema 1.1, element declarations can have a type table which contains a
sequence of type alternative components and a default type definition (which is also
a type alternative). In an XML schema document these are specified as a sequence of
xs:alternative child elements of the element declaration.
The type alternative schema component contains a
test property which is an XPath
expression property record, a type definition, and an
annotations property.
The value of the
test attribute on
xs:alternative corresponds
to the
test property, an XPath expression which evaluates to true or false. The
expressions allowed are limited to a subset of XPath 2.0, specifically those which
only select the attribute axis. This means that only attributes on the current element
are accessible by XPath evaluation. It is worth noting that the XDM data model which is
constructed for the evaluation does not include any type information. This was done to
avoid a situation where a schema processor would need to somehow guess the types of the
attributes in order to determine the type of the element. One cannot know the actual
types of the attributes until the element's type is determined.
The last
xs:alternative child of the element declaration is
allowed to omit the test attribute. If present, this type alternative is the default
type definition. If no such
xs:alternative is specified the
default type definition is the one which was declared for the element.
The value of the
type attribute on
xs:alternative corresponds
to the type definition property of the type alternative schema component. If the XPath
expression on the
test attribute has evaluated to true, then the specified
type is
selected as a substitution for the one declared on the element. The
type specified must
be derived from the declared type or a special simple type definition called
xs:error (which has no valid instances). The
xs:error type can be used to cause elements to be invalid if
they satisfy the condition for the type alternative.
If an element declaration has type alternatives, they are evaluated in the order that
they were specified in the schema. The first type alternative whose XPath expression
evaluates to true is the type that is selected. If none of the XPath expressions
evaluate to true then the default type definition is selected as the
type for the element.
Now that we have described how the type alternatives mechanism works, look
at an example (Listing 17) of how you can use it to write
a schema for Atom. As mentioned in the previous section, elements containing textual
constructs may have a
type attribute which specifies the allowed content for the
element. The snippet below shows how to write a declaration for a
title
element in Atom.
Listing 17. Type alternative xsd example
<xs:element <xs:alternative <xs:alternative <xs:alternative <xs:alternative <xs:alternative </xs:element>
The element declaration for
title has a base type of
xs:anyType
and specifies five type alternatives. The type alternatives are evaluated in order
until one of the XPath expressions evaluates to true (or, if none evaluate to true, the
default type definition is chosen). The first three type alternatives select a type
based on the value of the
type attribute being
text,
html, or
xhtml. If the type
attribute has none of these values, the XPath expressions for the first three type
alternatives will evaluate to false. The fourth type alternative checks whether the
type attribute exists. If the schema processor has reached this point, the value of
type (if this attribute exists) is not one which Atom allows. We assign the type
for this alternative to be
xs:error to signal that if this
condition is satisfied, the element is invalid. If none of the XPath expressions
evaluate to true, the default type definition (
xs:string)
is selected.
The instances of the
title element, Listing 18, illustrate
how the different type alternatives are selected.
Listing 18. Type alternative xml instance example
<!-- 1st type alternative selected: xs:string --> <title type="text">My News</title> <!-- 3rd type alternative selected: xhtmlContentType --> <title type="xhtml" xmlns:My <xhtml:em>News</xhtml:em>!</title> <!-- default type alternative selected: xs:string --> <title>My News</title> <!-- 4th type alternative selected: xs:error. Invalid. --> <title type="unknown">Oops! Error.</title>
Conclusion
In this article, we gave an overview of co-occurrence constraint support in XML Schema 1.1, highlighting the addition of assertions and type alternatives to further restrict the existence and values of elements and attributes. In Part 3 of the series, we will explore wildcard support and how it allows you to evolve your XML schema.; deveoperWorks; December 2008): Start your exploration with an overview of the key improvements over XML Schema 1.0 and in-depth look at datat:.
- XQuery 1.0: Learn more about XML Query language, which uses the structure of XML to express queries across all kinds of data.
- XML Path Language 2.0: Learn more about the XPath language.
- The Service Modeling Language (SML): Learn more about how to model complex systems and services.
-.
- Atom Syndication Format: Find more about an XML-based Web content and metadata syndication format.
- Schematron: Check out this language for making assertions about the presence or absence of patterns in XML documents.
- RELAX NG: Explore a schema language
- The XML Parser for Java (Xerces2-J): Try this parser distributed by Apache.
-. | http://www.ibm.com/developerworks/xml/library/x-xml11pt2/ | CC-MAIN-2014-41 | refinedweb | 3,884 | 52.39 |
12 February 2007 16:58 [Source: ICIS news]
By Nigel Davis
?xml:namespace>
LONDON
But will the envisaged rise in sea levels brought on by rising global temperatures put as much as 45% of the world’s ethylene capacity at risk?
It was not so much the storms themselves that hit
Remember: some chemical plants were out of action for weeks. For the most integrated businesses it made sense to start up much needed refineries first and think about chemicals later.
Fast forward thirty or more years, the average lifetime of a major cracker, and what might chemical makers expect if key facilities are still located in vulnerable coastal areas?
The questions have already been asked about the US Gulf Coast petrochemicals hub. But what about older sites in the
Of course it makes sense to site crackers on the coast or on waterways to give ready access to cooling water and to facilitate the movement of feedstocks and products. But does the disruptive potential of global warming change all that?
A first stab at this comes from Lehman Brothers which says that 46% of existing and 45% of planned ethylene capacity globally is at high risk from such flooding. The bank says the world will have 173m tonnes of ethylene capacity by 2012 in an extensive report on the business of climate change.
Ethylene plants can be moved inland, of course, but at significant cost. If the foundations of the sector’s critical assets have to move then so does its cost base.
Petrochemical producers will have to wrestle with the practical aspects of climate change adapting technologies to cope with warmer seawater perhaps used for cooling.
Lehman notes that in the base case climatologists broadly agree that sea levels will rise by up to 1m by 2100 with rises of between 4m and 7m ultimately possible should half of the
In the chemicals sector, campaigns to reduce process emissions have been on the agenda for years.
The bank notes, however, that the commercial risk of tighter restrictions in future introduced specifically to tackle global warming depends on whether abatement measures are imposed globally or selectively by region.
Looking out over the short term it says because demand for chemicals generally is price inelastic the industry can be expected to pass on higher regulatory costs provided those costs are imposed globally.
The playing field might be tilted, however, if some countries but not others impose tighter controls.
It is relatively easy to balance out the risk posed by global warming and outlined in two recent landmark reports – the Stern Review of climate change published in the
Stern put a value on the cost of carbon and opened up the vitally important governmental debate on the cost of emissions reduction and containment. The IRCC suggested global temperatures would rise by 1.8-4°C (3.2-7.2°F) by the end of the century.
Companies might capitalise on their co-generation expertise in the search for power from low-carbon sources, for instance. New materials, carbon capture and biotechnology ultimately would become more important in the chemical industry mix.
The traditional large-scale ethylene plant located on the coast or on a major waterway, however, could be under serious threat.
Ethylene plants are designed to have a long operating life – and to operate at high throughput rates for most of the time.
The impact of major storms, floods and warmer cooling water even in the short term will be negative and inescap | http://www.icis.com/Articles/2007/02/12/9006061/insight-global-warming-can-knock-out-crackers.html | CC-MAIN-2015-06 | refinedweb | 583 | 56.79 |
KY-40 rotary encoder
I bought the rotary encoder/switch that is linked in the store as I wanted to get such a combo to control my led strips (button = on/off, rotation = brightness or color). I did some googling but couldn't find any good and working code. Did anyone of you already use this device?
My goal is to use that with a battery driven sensor, so it needs to sleep a lot which means relying on interrupts.
What I think I got so far:
- SW seems to be active high (also mine is missing the pullup resistor it seems)
- DT and CLK are the rotation pins. Both are active low, one goes low first and indicates the direction of the rotation
- Some additional hardware debouncing might be needed
All the code I found is either not really working or requires and infinite loop and busy waiting (bad for the battery). My idea was to attach SW to one interrupt
attachInterrupt(1, push, FALLING); void push () { delay(5); // debouncing? if (!digitalRead(PinSW)) Serial.println("Pushed"); }
and one of the others to the other interrupt
attachInterrupt(0, rotate, FALLING); void rotate () { delay(5); if (!digitalRead(PinDT)) { virtualPosition = virtualPosition + 1; Serial.println("Position " + virtualPosition); } else { virtualPosition = virtualPosition - 1; Serial.println("Position " + virtualPosition); } // isr }
That doesn't seem to be working yet though. Any ideas from you guys?
@LastSamurai Try this library and connect the DT & CLK (horrible names btw) signals to interrupt pins, as described on this page.
Works like a charm for me in combination with an UNO.
@Yveaux Thanks. I tried it out with this example code
#include <Encoder.h> // Change these two numbers to the pins connected to your encoder. // Best Performance: both pins have interrupt capability // Good Performance: only the first pin has interrupt capability // Low Performance: neither pin has interrupt capability Encoder myEnc(3, 5); // avoid using pins with LEDs attached void setup() { Serial.begin(9600); Serial.println("Basic Encoder Test:"); } long oldPosition = -999; void loop() { long newPosition = myEnc.read(); if (newPosition != oldPosition) { oldPosition = newPosition; Serial.println(newPosition); } }
using one interrupt pin (need the other one for the button) and it doesn't really work. I get 0 -1 0 -1... when I rotate it and -2 when I push the switch. I also added 4.7uF caps between ground and the 2 pins which got rid off the "spam" of values but doesn't change the values themselves. Also I don't see a way with that library to sleep until some motion of the switch is detected.
Ok I found this code from the arduino page on rotary encoders. This seems to work perfectly (beside always needing 2 clicks to register a change). Still have no idea how to use this with sleep though... guess I need to keep experimenting.
/*, // right encoderPinB = 3, // left clearButton = 5 //; } }
@LastSamurai I'm sure that if you would use two interrupt-pins to connect the encoder, the suggested library will also work just fine.
You're changing your requirements along the way
Well, I created this example way back for the KY-40:
@Yveaux I am sure it works then but I am not changing requirements
Perhaps I wasn't clear enough though..
@LastSamurai said:
@Yveaux I am sure it works then but I am not changing requirements
Perhaps I wasn't clear enough though.
I meant first you don't use two interrupts to connect the sensor and then with some other code you do. Anyway, never mind it.
Apart from reworking parts of the library I see some options:
- Use a wired-OR to combine both encoder signals and connect that to an interrupt input. This will trigger the ATmega to wakeup, after which the regular encoder code can determine the new encoder value.
- Use the pushbutton of the encoder to wake the ATmega (so connect it to an interrupt pin), then the regular encoder code can determine the new encoder value.
IMHO, sleep, wake, decode, send a message and go to sleep again is quite tricky to get it right without loosing pulses.
For a good user experience it's probably best to stay awake for a while after waking up, giving your software time to process any more incoming pulses. When no new pulses have been detected for some time, you can go back to sleep again.
@lastsamurai Hello!
Did you manage to implement this node?
- korttoma Hero Member last edited by
@vladimir there is an example for using rotary encoder on this page: | https://forum.mysensors.org/topic/5425/ky-40-rotary-encoder | CC-MAIN-2021-04 | refinedweb | 751 | 63.09 |
Migrating From C++ To C#
Introduction
Since its beginning in the 1980s, C++ has come a long way. It has a large
established user base, tested software, its own tools (compilers, etc), and lots of
experienced programmers. It has also developed its own idioms and techniques
for programmers to write effective software. C++ programmers are comfortable
in getting things done with the facilities that are provided with it in an efficient
manner.
.NET is a powerful new platform with a great deal of promise. C# is designed
from the ground up to harness the power of this new framework. It provides a
whole host of features and is strongly based on C++. C# is an object oriented
language and is the first component-oriented language in the C family. It also
makes writing Windows and Web applications faster and easier. C# is gaining
wide acceptance and it is clear that it is here to stay for a long time.
C# is not a replacement for C++, and it is more than likely that both will be used
widely for the foreseeable future. However, there are many practical cases where
there is a necessity to migrate from C++ to C#. For instance, your company's
policy may be to change all existing code to .NET, or perhaps you wish to take
advantage of some of the facilities made available in .NET.
The question is, how do we make the transition as smooth as possible while
getting the best results? Adopting a new language doesn't just mean converting
the existing code from C++ to C#. By just knowing the syntax, a C++
programmer cannot straightaway start programming in C#. These two
languages differ largely by their design and approach towards problem solving,
which makes the language transition harder.
System Requirements
It is preferable that the reader has access to the C# compiler available in
Microsoft Visual C#.NET. This case study is for those programmers coming from
a C++ background, who are new to C# or have just started programming in it.
The programmers with a good understanding of C# are in a better position to
understand the approaches taken in the conversion process.
Case Study Structure
The case study consists of three main sections:
•
The approach
In this section, we briefly cover the basic theory that is necessary for
understanding the issues in conversion. It is possible that you may not be clear
about few of the C# features mentioned here - they are covered in the following
section.
•
Comparing C++ and C# features:
In this section we look at the different features of the two languages which are
necessary to make the conversion possible.
•
Steps in converting existing code:
The steps that are required for converting the existing code from C++ to C# are
covered in this section. An example of converting class hierarchies from C++ to
C# is also covered.
The Approach
What is the best approach for getting equipped for a smooth transition from C++
to C#? Understanding! Migrating from one language to another involves a
considerable effort. This is not because of a change in syntax, rather because of
changes in methodology - design approach, underlying technology, and the
approach towards problem solving. Understanding that there is such a
fundamental shift, and having the knowledge of where the major differences lie,
will help a lot.
The underlying translation models for C++ and C# are quite different. C++
follows a static linkage model, meaning that the source code is compiled by the
compiler to result in object code. The object files are linked to result in an
executable file. The operating system loads and controls the execution of the
program. The language features are designed with this approach in mind. For
example, there is no support for reflection. Moreover, the code is only source
code portable and not much runtime support is available.
C# follows an entirely different translation model - it combines compilation and
interpretation. The source code is converted to an intermediate format known as
MSIL (Microsoft Intermediate Language). A virtual machine, referred to as the
CLR (Common Language Runtime), takes over to execute the instructions. The
execution is thus in the hands of CLR and the code executed is referred to as
managed code. This change in translation model is reflected in the language
features as well.
A very important difference is in the area of memory management: the
programmer no longer has the complete control of the lifetime of the objects in
the heap. The garbage collector takes care of deleting objects whose lifetime is
over. So there is no need for the keyword "delete". However, there are
destructors in C#. If the "delete" keyword is not available in C#, then what is the
use of destructors? In reality, the destructor syntax in C# is very misleading,
especially for programmers from a C++ background. They are actually finalizers
that are called before an object is garbage collected.
Another issue to understand is the change in design criteria. C++ is designed for
experienced programmers in mind and 'trusts the programmer' (in the C
tradition). So no extensive runtime checking is done, there are implicit casts and
promotions in function calls. These features have proven to be very useful, but
also very bug-prone. Therefore, only experienced programmers should use them.
However, C# is designed so that even novice users can learn it fairly easily, and
is also designed with robust software in mind. It performs extensive runtime
checking with very few implicit conversions and tries to make the life of the
programmer easier.
How can this understanding of language design change help in transition from
C++ to C#? Let us use an example. A single argument constructor also serves the
purpose of a conversion operator in C++. When a conversion is required, that
constructor will be called implicitly because, it 'trusts the programmer': it is
assumed that the C++ programmer is aware of it. Such implicit calls may lead to
subtle bugs, like:
class Stack{
public:
Stack (int initivalCapacity);
// constructor that takes int as an argument
// other members
};
// now consider the code
Stack s;
s = 25;
// implicit conversion, a new Stack object is created with int as
argument
// s = Stack(25);
// beware! the programmer may have programmed without being aware that
the
// constructor with int argument is called for the conversion operation
// from int to Stack
To avoid such problems, you cannot use single argument constructors as
conversion operators in C#. You have to support explicit conversion operators
for that. Also, you can appreciate the use of implicit and explicit keywords in C#
better. With this knowledge you are better equipped now. When you write
equivalent C# code, you will also need to examine if a conversion operator needs
to be implemented and decide if it should be declared as explicit or implicit if the
original C++ code had any single argument constructors.
The problem solving approach also differs considerably in these two languages.
Consider writing a simple calculator program. You require a postfix expression
evaluator, and for that you may prefer to have your own reusable version of
Stack. The interface for Stack is well-known and the logic is pretty straight
forward. Still, your approach towards solving such problems may be entirely
different depending on the language you use.
In C++, you would write a template class for the stack. If you want to evaluate an
integral expression then you will instantiate an integer version from that Stack
template class. It has its own benefits like static type checking. You can use this
same implementation for any type of expression, for example floating point
expression, without any changes. It is also extensible.
In C#, all objects come from the common base class 'object', and so you can write
a Stack class which stores 'objects'. Since all the objects inherit from this class, you
can store virtually any object in that Stack. When you retrieve the elements, you
have to employ dynamic type checking to make sure that the types don't mix-up.
As you can see, even for the same well-defined problem, the problem solving
approach differs considerably and you make a different set of decisions and an
entirely different implementation depending on the language you are using!
Another important factor in the transition from C++ to C# is that it is a transition
from an unmanaged environment to a managed environment. In C++ there is
only trivial support from the runtime available, whereas C# has the sophisticated
.NET runtime environment. C++ programmers need to make special efforts to
understand the advantages with the managed environment. For example,
reflection is a powerful feature which can be used to generate and execute
assemblies dynamically. Runtime checks ensure that the security privileges are
available for providing access to resources. You have array bounds checking,
versioning support and most important of all - components that are created from
any language can interact freely. However, it should be noted that the managed
environment also comes with restrictions: you can no longer allocate objects
anywhere you wish - you can only allocate to the heap. Also, you cannot do
generic programming with templates as you could in C++, as .NET doesn't
support it yet. The concept and benefits of a managed environment are new to
C++ programmers, and hence exposure to the facilities with the underlying
framework is essential to get the most out of C#.
In essence, having a broad picture of these two languages and understanding the
differences in the underlying technology and approaches to design and problem
solving are essential for migrating from C++ to C#.
Comparing C++ and C# Features
The first requirement that is needed to move from C++ to C# is a shift in your
mindset. C++ is a language which trusts the programmer. This provides the
programmer with the ability to do whatever he wants. This power does have
drawbacks though - it can be misused and can end up causing major headaches.
C# on the other hand, doesn't trust the programmer as much. It takes many of
the responsibilities from the programmer and enables him to concentrate on the
bigger picture. It removes a few features that were error prone, and introduces
new ones that simplify programming.
Let us now compare the features available in the two languages.
Data Types
The types in C++ can be subdivided into three categories: primitive types,
aggregate types, and pointer types. The primitive types are: bool, char, int, float,
double, wchar_t. The aggregate types are those that are composed of other types.
These include arrays, structures, unions and enums. Both pointers and references
are called as pointer types. In C#, things are a little different, as it only has value
and reference types. The value type is capable of storing data by itself, whereas
the reference type cannot. It stores a reference, which points to the actual data.
The value types can be thought of as equivalent to the primitive types in C++.
They are derived from the class
System.ValueType
. These types can be stored in
the stack frame of a method. The reference types cannot be stored in the stack
frame, only in the heap.
However, a difference between C++ and C# data types are their size. While the
size of most of the types is implementation-dependent in C++, we have fixed
sizes in C#. We need to be cautious while converting between the available
types. For example, in C++ there is
long double
, which is 10 bytes. There is no
long double
type in C#, and
double
occupies 8 bytes. There is a new type,
decimal
, available in C# that occupies 16 bytes. Since the
decimal
type occupies 6
more bytes than the
long double
(in C++) you may think that you should be able
to store a value in
decimal
in 16 bytes what
long double
stores in 10 bytes.
However,
decimal
isn't used to give a wider range, rather it's used for getting a
more precise value, as in the case of currency values. If your intention of using
long double
is for higher precision, you don't have any problems, however if it
was for a wider range you may have trouble.
Unsigned types are supported in C#, but they are better avoided because using
them makes the code non CLS-compliant (Common Language Specification -
compliant).
References
We have seen many C# programmers considering C++ references equivalent to
C# references. This is wrong! Actually C# references are closer to C++ pointers.
Remember that the references in C++ serve as a name alias. They are sure to
point to an object, and sure to point to the same object throughout the scope of
the reference. However, it's different in C#. Just like pointers, they can be defined
without initializers, but they can point to different objects at different times, and
they can even point to nothing - the null (actually they throw
NullPointerException
and not
NullReferenceException
when you attempt to
refer a null reference!). So:
//C++
MyClass &ref = null; // error, references cannot be null
MyClass &ref = obj; // needs an initializer
ref = anotherObj // Error: can't change the reference
//C#
MyClass ref; // OK initializer not needed
ref = anObj;
ref = anotherObj; // OK change the reference
ref = null; // allowed
You can think of C# references as 'restricted and safe C++ pointers':
// C++
string * s;
s = new string;
// C#
string s;
s = new string();
Declarations and Definitions
With the discussion of C# references, you may have noticed one drastic
difference in the semantics of the following statement:
string str;
This same statement will be interpreted in different ways by these languages. A
C++ compiler sees this statement as a definition of a variable called str. It
allocates a new stack object (or data area if declared globally) and calls the
default constructor on the allocated object (a string object in this case). A C#
compiler sees the same statement as a declaration for the reference variable str. It
allocates space for the reference alone. It neither allocates space for an object nor
calls the constructor. This should be done explicitly be the programmer:
str = new string();
This statement now allocates memory for the object in the heap and then calls the
default constructor.
C# combines declarations and definitions together, whereas C++ clearly
distinguishes between the two. For this reason, there are no function prototypes
and forward declarations. The C# compiler carefully checks for definite
assignment - you cannot use a variable without initializing it. Such facilities help
avoid bugs, and greatly simplify the life of the programmer.
Structs
Except for the default access specifier, C++ never differentiates between structs
and classes. Both of them are functionally the same. A struct can contain methods
and can be inherited by a class, but C# takes a different path. Here the structs are
just placeholders of other data types and no behavior can be specified. This
means that the structs can no longer contain any methods. No classes can inherit
from them. The advantage is that, as they are value types, they can be stored in
the stack frame. They do not require any indirection and so are more efficient
than classes.
When you want to group some related data where no methods have to be
associated with them, structs are the best solution. When we want to model a real
world entity with both data and methods, classes have to be used. For example,
'Point' in a graph is a simple aggregate type, and for that a struct can be used.
Implementing a 'Vehicle' type may require encapsulating lots of data and
methods operating on it, and for that, classes are better suited. Actually there are
no hard-and-fast rules for deciding between structs and classes. A good rule-of-
thumb is to use structs for the simplest aggregate types and classes for any non-
trivial types.
One notable advantage when you use structs is that they are allocated on the
stack itself and there is no memory overhead. Lots of memory will be saved
when hundreds of objects are created, for example a big array of struct type.
When you use a class type, the objects will be allocated on the heap and hence a
lot of memory overhead is involved (In the current version of .NET, 10 more
bytes are occupied for each heap object compared to an equivalent stack object!).
So, using structs for small types can lead to saving significant amounts of
memory.
MyStruct [] sArr = new MyStruct[10];
Whereas for the class type:
MyClass [] oArr = new MyClass[10];
for(int i = 0; i < 10; i++)
oArr[i] = new MyClass();
Arrays
Arrays are the simplest data structures that are widely used in programming. In
C++, arrays are treated as a contiguous memory location. The low level nature of
arrays create problems with object oriented programming. A base class pointer
cannot be used to iterate through the array of derived class objects:
class Base{
public:
// Base class data members
virtual void boo();
};
class Derived: public Base{
public:
// Derived class data members
virtual void boo();
};
void foo(){
Derived dArr[10];
Base * bPtr = dArr;
for(int i =0; i<10; i++)
bPtr[i]->boo();
// Will not work properly
}
This is because, the size of the base class object may not be equal to the size of the
derived class object. The compiler cannot identify the proper object at the time of
compilation. C# is a dynamic language and has fully-fledged support from the
run time. Arrays are no longer contiguous location in the memory. This makes
such operations legal and safe.
C# does not treat arrays as mere continuous memory locations. It adds object-
oriented characteristic by giving a class
System.Array
, from which all the arrays
inherit. This class abstracts the operations on an array and can be casted into any
of the arrays. Remember that arrays of all types are also derived from this class.
As arrays are instances of a class, they are always reference types and this holds
good for the arrays of value types. This helps in bound checking for every access
in an array, but a problem is that has it to be allocated on the heap only.
Both the languages support rectangular and jagged arrays. For rectangular
arrays, a chunk of plain memory locations are allocated and indexing is done on
it. In C++, jagged arrays can be implemented by having a pointer array and
allocating memory dynamically for each array. The same idea is followed in C#,
but instead of pointers, references are used. This makes optimal use of space,
since the sub-arrays may be of varying length. The compromise is that additional
indirections are needed to refer to access sub-arrays. This access overhead is not
there in rectangular array since all the sub-arrays are of same size.
// C++ language example for 'rectangular arrays'
float rectArr[5][20];
// C# rectangular arrays, note the difference in syntax
float [,] rect = new float [5,20];
// C++ language example for 'jagged arrays'
float **ptr;
ptr = new float *[5];
for (i=0; i< 5; i++)
ptr[i] = new float [20];
// C# example for 'jagged arrays'
float [] [] ptr;
ptr = new float[5][];
for(int i=0; i<5; i++)
ptr[i] = new float[20];
When more than one method of representation is supported, at some point the
user will require to switch from one representation to another. Here, to convert
from one array type to another, techniques called boxing and un-boxing are used
(discussed later). It also should be noted that C# supports 'Indexer' members that
allow array-like access to data structures.
Enums
Enumerations are of the type int in C and in C++; its type depends on the
number of enumeration constants declared. C#, as an improvement over the old
enumeration, allows you to specify the type of the enumeration:
enum holidays : ubyte{
Sunday = 0,
Saturday = 1
}
C# enums differ from C/C++ enums in that the enumerated constants need to be
qualified by the name of the enumeration when they are used.
enum workingDay { mon,tue,wed,thur,fri };
workingDay today;
today = workingDay.mon;
//note that mon is qualified by workingDay
This name.member syntax helps the enumeration constants to remain in a
separate namespace, thus preventing them from polluting the global namespace.
Furthermore, it prevents name clashes between two different enums:
// C#: no name clashes with other enum members
enum Days { mon, tue, wed, thur, fri, sat, sun };
enum CosmicObjs { earth, mars, jupiter, sun, moon};
enum Companies {sun, microsoft, dell, digital, compaq};
myDay = Days.sun;
computer = Companies.sun;
cosmicObject = CosmicObjs.sun;
Variable Length Argument Lists
Experience has shown that programmers prefer C style printf format, because it
is convenient for exact format specification and is easy to use. C# provides
'params' for the support of variable length argument lists. So you can write your
functions using this facility as in:
int MyPrintf(string format, params object [] args);
For printing, C follows the format string with variable length argument strings;
C++ uses << with cout; Java has overloaded the + operator. In C#, to print the
arguments, the numbering should be as follows:
Console.WriteLine("{1} {2} {3}", i, obj, "someString);
Writing 'Unsafe' Code
C++ is good for writing low-level code, which is useful for programming
systems with features like pointer arithmetic. C# understands the importance of
that, and allows 'unsafe casts', pointers, and pointer arithmetic to be performed
in code segments that are explicitly labeled as unsafe. Note that the keyword
'unsafe' may be misleading - it just specifies that is isn't managed code and that it
may perform low-level operations. Also, it is not as easy nor as powerful as in C+
+.
Argument Passing
When we pass a variable to a method, we are not sure whether it will get
modified or not. To ensure that the variable should not be modified, the
programmer should use the
const
qualifier for that argument in that method. The
absence of such const qualifiers indicate that the variable could be used for
multiple return values in C#. It introduces two new keywords to achieve these
multiple return values. If the method has multiple return values, it should
explicitly use the ref or out keyword.
Furthermore, C# supports two new types of arguments: ref and out. When we
pass an argument to a method, the caller should be aware that the parameter
may be modified. The ref keyword indicates this. As wekk as during the method
definition, the ref keyword is also used in the method invocation:
//C++
void foo(MyClass & arg1, MyClass & arg2){
// other code;
arg1 = newValue1;
arg2 = newValue2;
}
foo(obj1, obj2);
// Note: the caller may not expect obj1 and obj2 will change
//C#
int foo(ref MyClass arg1, ref MyClass arg2){
arg1 = newValue1;
arg2 = newValue2;
}
foo(ref obj1, ref obj2);
// Now the programmer is aware that obj1 & obj2 may be changed
In a few cases, we may want to initialize the arguments only in the method. The
use of the ref keyword will be flagged as an error by the compiler as a definite
assignment has to be done before the first use. One elementary way to avoid the
error is to initialize the variable with the default value and then to pass it to the
method. C# introduces a new keyword for this situation. Instead of ref, we can
use out, which doesn't force the caller to initialize the variable. However, it is
mandatory for the method to assign some value to it.
//C#
void foo(ref MyClass arg1, out MyClass arg2){
// other code;
arg1 = someValue; // optional
arg2 = someValue; // need to assign some value
}
MyClass obj1, obj2;
obj1 = aValue; // need to initialize
foo(ref obj1, out obj2); // note obj2 is not initialized
Class Abstraction
Just like C++, the basic unit of abstraction is a class. The access specifiers
public
,
protected
and
private
have the same meaning in both the languages. In addition,
C# provides
internal
and
protected internal
access specifiers. The internal
members are available to the whole assembly and the
protected internal
to the
assembly and the derived classes. Why do you ever need these access specifiers?
There are few cases where you need to access members of other classes in the
same assembly but shouldn't be exposed to the external classes. Since friend
access is not there in C#, this can be a useful feature particularly when you are
designing libraries.
Inheritance
C# doesn't support multiple class inheritance. It only supports single inheritance,
but you can still inherit from multiple interfaces. Pure abstract classes in C++ can
be treated as interfaces in C#. There are many restrictions in using interfaces for
inheritance. You can only have public abstract methods, and no fields are
allowed (not even const fields). However, one interface can inherit from another
interface.
C# only supports public inheritance. Not having private or protected inheritance
doesn't affect the functionality as such. There are a few inconveniences with this
approach, for example, once you implement
ICloneable
, all the classes that
inherit from that class becomes automatically cloneable, as only public
inheritance is available.
The Object Base Class
C# doesn't support templates as .NET doesn't support it yet. However, a weaker
form of generic programming is supported in C# through the
System.Object
base
class. This is the apex class for all the objects. This includes the value types like
structs and ints and reference types like arrays and strings. This property is
exploited in the Collections provided in the framework that works in terms of
Objects.
The standard libraries of both C++ and C# provide support for the container
classes. Consider this example of using the vector class:
MyClass obj;
string str = "string object";
const int size = 5;
vector<MyClass> vect(size);
vect[0] = obj;
vect[1] = str;
// Compiler Error: vect can store only MyClass and not others
// insert more elements
// iterator provides a pointer-like syntax for
//traversing the container
cout<<vect[0]<<vect[1]<<endl;
vector<int>::iterator iter = vect.begin();
while(iter != vect.end()){
cout << *iter;
// calls overloaded << operator of MyClass
iter++;
}
Thus, you can have elements of only one type, and the traversing and accessing
is done through iterators. With C#, .NET provides an equivalent container class
for vector - the ArrayList container:
// Creates and initializes a new ArrayList
MyClass obj;
string str = "string object";
ArrayList arrLst = new ArrayList();
arrLst.Add(obj);
arrLst.Add(str);
// can simply use foreach statement for traversing the colletion
foreach(MyClass elem in arrLst){
Console.WriteLine( " {0} ", elem);
}
// throws 'InvalidCastException' as the second element is a string
Operator Overloading
In C++ almost all the operators can be overloaded - there are only a few
operators like the conditional operator, . operator, .* and .-> operators that
cannot be overloaded. C# provides support for operator overloading but to a
limited extent. The syntax for overloading the operators is:
// C++
<return type> ClassName::operator <the operator> (arguments)
// usage example
class MyClass{
public:
MyClass operator + (MyClass &rhs);
};
// C#
<return type> public static operator <the operator>(arguments)
// usage example
class MyClass{
public static MyClass operator + (MyClass lhs, MyClass rhs){}
}
The main difference is that while you can have member or global (mostly friend)
functions in C++, you have static methods for overloading in C#.
Although the syntax looks similar there are a few constraints imposed by C# for
operator overloading. The most important are:
•
The methods should be declared as public and static.
•
Many of the operators are required to be overloaded in pairs. For
example, if you define == you should overload the != operator also.
•
If you define the + operator, the compiler defines the += operator for you
to make things easier.
//C++
class CPPClass{
protected: // can be public or protected or private
bool operator ==(CPPClass &rhs);
// the another argument is passed implicitly by 'this' pointer
// note no != operator defined
bool operator ++(); // type of the return value is not forced
bool operator +(CPPClass &rhs);
bool operator +=(CPPClass &rhs);
// += is not implicitly defined
static int operator-(CPPClass &lhs, CPPClass &rhs);
// both static and non static methods are allowed
};
//C#
class CSharpClass{
//note that all the operators are public and static
public static bool operator ==( CSharpClass lhs, CSharpClass rhs){}
public static bool operator !=( CSharpClass lhs, CSharpClass rhs){}
// relational operators should be overloaded in pair
public static CSharpClass operator ++(CSharpClass arg);
// return type and argument types are forced for few operator
public static bool operator +(CSharpClass rhs);
// += is implicitly defined by the compiler when
// binary + is defined
}
Exceptions
Exception handling in C# is similar to C++. The exception specification of a
method lists all the possible exceptions that the method might throw. In C++,
when the method doesn't lists any exceptions, beware that it is then allowed to
throw any exception, and there is no constraint for a method to catch the
exceptions thrown. Further, exceptions are not only thrown in the form of
classes, but also in the form of primitive types.
The C# exception handling mechanism is much simpler and more elegant.
Firstly, a method cannot throw the exceptions that are not listed in the exception
specification of the method. Catching of the exceptions is mandatory and only
objects of Exception (or derived from) are thrown.
//C++
void foo(){
throw 10;
throw MyException();
throw "This is an Error";
}
void boo() throw (int, Exception){
throw "Something is wrong";
//Error: can only throw int / Exception
}
void doo() throw (){
// guaranteed that no exceptions will be thrown
}
//C#
void foo(){
//will not throw any exception
}
void boo() throws IOException{
throw new IOException(); //OK
throw new MyException();
// Error: allowed to throw only IOException
}
Namespaces
Namespaces are supported in C++ for better organizing the code and are
valuable in large-scale programming. In C#, the syntax for declaring and
organizing classes in a namespace is similar to that of C++. There is no concept of
header files (C# design is such that there is no need for header files, for example,
it combines declarations and definitions) and you have to use the using directive
to open up the members in the namespace for access in the code. You can also
have aliases:
using alias_name = namespace_or_type;
Just like in C++, you can have nested namespaces. The syntax is a bit different:
namespace outer.inner{
// some members
}
Note that you have to use one namespace within another for a similar goal in C+
+:
namespace outer{
namespace inner{
// some members
}
}
There is an importance difference between the namespaces in C++ and C#. In C+
+, namespaces are logical entities and no physical enforcement of namespaces
exists. However in C#, in addition to logical separation, a physical separation of
namespace members and enforcement of hierarchy is there in the form of
assemblies and sub-assemblies. This enables the namespace rules to be enforced
at the physical level.
Properties
It is common for a C++ programmer to give the
get
and
set
methods for data
members. Not only does this help in abstracting the details, but it also gives a
few advantages such as that the user cannot assign illegal values to the field,
such as 500 to a field called age, or the programmer can give a read-only version
of the member, such as size of a container, etc.
class MyClass{
private:
int someInt;
int length;
public:
inline int getLength(){
return length;
}
inline int getSomeInt(){
return someInt;
}
inline void setSomeInt(int arg){
if(arg >= minValue && arg <= maxValue)
someInt = arg;
else
error("illegal value");
}
};
//usage:
MyClass anObj;
anObj.setSomeInt(100);
int len = anObj.getLength();
As most of these methods are inlined, the performance isn't affected. However
there are two problems with the usage of such functions. The first is that the
syntax of accessing them is a bit unwieldy. The next is that the approach itself
violates the object oriented programming guidelines. An object is supposed to
expose a behavior and not the implementation. By these methods, obviously the
object exposes its private fields to the user. C# provides a whole new way to
handle this situation through properties.
Properties are very much like the get-set methods, but syntactically different.
Consider this example written with properties in C#:
class MyClass{
private int someInt;
private int length;
public int Length{
get{
return length;
}
}
public int SomeInt(){
get{
return someInt;
}
set{
if(value >= minValue && value <= maxValue)
someInt = value;
else
error("illegal value");
}
}
}
//usage:
MyClass anObj;
anObj.SomeInt = 100;
// set the value of the field through mutator property
int len = anObj.Length;
// get the value of the field through accessor property
Note that a variable
value
is used in the set method. It is the implicit parameter
passed to the method by the compiler. Its type is the same as that of the property.
As we can see, the syntax is more intuitive to use.
Indexers
We tend to have many container classes that are used to hold a set of objects.
Stacks, Queues, Maps and Hashtables are just a few such important containers.
There are many other objects that can also be viewed as containers. For example,
a menu can be thought of a container of the menu items. In most cases we will
need to access the objects in the containers through an indexer. In C++ this can
be done by overriding the array subscript operator []. We can override it not only
with integers, but with any object we want, which sometimes makes the
subscripting more meaningful:
class EmployeeContainer{
private:
Employee emp[100];
public:
Employee& operator[](int empNo){
//return the employee with the empNo
}
Employee& operator[](string name){
// return the employee with the name
}
};
void foo(){
EmployeeContainer empCont;
// add the employees to the container
Employee emp1 = empCont[5];
empCont["Pranni"].age = 24;
}
C# introduces the indexers to fit this problem of indexing a container. The
equivalent
Employee
class can be written in C# as:
class EmployeeContainer{
private Employee emp[100];
public Employee this[int empNo]{
// implement it like a property
get{
return emp[empNo];
}
set{
emp[empNo] = Employee;
}
}
public Employee operator[string name] {
// implement it like a property
get{
// getting Employee index mapped by string info
}
set{
// code for setting Employee detail at index position
}
}
}
void foo(){
EmployeeContainer empCont = new EmployeeContainer();
// add the employees to the container
Employee emp1 = empCont[5];
empCont["Pranni"].age = 24;
}
Attributes
Attributes are a significant addition to C#. When you are creating your own
types or components, there is a necessity to associate related details of the
components and their elements. In COM you used type libraries to achieve such
functionality. Traditionally, comments and macros are used in C++
programming for storing the metadata about the class and/or its members. C#'s
attributes are far more powerful and you can give meta-information for many
language elements: fields, methods, events, etc. You can retrieve and examine
such meta-information at runtime using reflection (discussed later). There are
two types of attributes: intrinsic (predefined) and custom attributes.
C# supports a preprocessing facility but there is no separate tool - it is handled
by the compiler itself. The preprocessor support has restricted use though, for
example you cannot have macros. One of the uses of the preprocessor is
conditional methods and that is achieved through Conditional attributes. It is an
intrinsic attribute used for including the method depending on the condition. In
C++ you use preprocessor facilities directly.
//C# code
#define DEBUG
// such definitions should occur only in the beginning
class MyClass{
[Conditional("DEBUG")]
public static void debugFunction(string message){
cout<<message<<endl;
}
// other members
}
C#'s conditional methods are very powerful when used with the Debug and
Trace classes available with the
System.Diagnostics
namespace. There are many
such useful attributes; one is Serializable, which is discussed later.
You can define your own custom attributes. You have to derive your class from
the
AttributeUsage
class. Here is one simple example for maintaining the code
using System;
[AttributeUsage(AttributeTargets.All, AllowMultiple=true)]
// tells that this attribute can be used on any program element
// and there can be multiple entries for each use of attribute
public class CommentAttribute : Attribute{
public CommentAttribute(string comment){
this.commentText = comment;
}
private string commentText;
public string CommentText{
get{
return commentText;
}
}
}
[Comment("Written by Ganni and Pranni")]
class GuineaPig {
// ...
}
class Test {
public static void Main(){
Attribute[] attributes =
Attribute.GetCustomAttributes(typeof(GuineaPig));
//This static method GetCustomAttributes
//is used to retrieve the attribute info
foreach(CommentAttribute attribute in attributes)
Console.WriteLine(attribute.CommentText);
}
}
You can use the custom attributes with the same special syntax as in intrinsic
attributes and there is no need to call the constructor explicitly - you can initialize
the attribute directly. The static method
GetCustomAttributes
of the Attribute
class is used for retrieving the attributes by passing the type.
Callback Functions
Function pointers are a useful facility in C/C++. The following example shows a
real world example of using function pointers. Say you want to write a menu
program. The aim is to write a program that will call a corresponding function
that is selected in the menu at runtime. Therefore, we have to declare a function
pointer whose signature matches the functions that are written for the menu:
void (*menuSelector)( );
// get the input from the user - selection of the menu item
switch(select){
case NEW : menuSelector = & New( ); break;
case OPEN : menuSelector = & Open( ); break;
// assign the address of the corresponding function to menuSelector
}
menuSelector( );
// now call the selected functionality
The calling of functions using these function pointers, whose value is determined
at runtime, is known as 'call back'. C# provides support for callback functions
and it is called 'delegates' (you can also consider it as an improved version of the
'function objects' in C++).
Delegates closely resemble function pointers, and C# promises that delegates are
type-safe, secure, and object-oriented. A delegate is capable of a holding a
reference to another function so that function can be called later. Even multiple
functions can be installed like that. Callbacks are valuable for event handling. C#
also supports events that are useful in the case of event driven programming like
Windows Forms:
public delegate void Selector();
// Selector is the type that can be used to instantiate
// delegates that take no arguments and return nothing
public Selector menuSelector;
public void New(){
Console.WriteLine("You selected 'New' option");
}
public void Open(){
Console.WriteLine("You selected 'Open' option");
}
string select;
// get the value of select from calling the menu...
Test t = new Test();
switch(select){
case "New" : t.menuSelector = new Selector(t.New);
break;
case "Open" : t.menuSelector = new Selector(t.Open);
break;
// ...
// register the selected method to menuSelector
}
t.menuSelector( );
// call the delegate and it will inturn call the registered method
Reflection and RTTI
When doing object oriented programming, we treat an object as if it were an
more general type. So, for example, we can view a Dog as a mammal, an animal,
or even simply a living thing. So when we have a more generalized version,
sometimes we would like to know what the exact type is and act accordingly.
Say if we have a living thing, we would perform some operations on a mammal,
that we wouldn't on an amphibian. We would perform even more specific
operations if it were a Dog. In such cases, RTTI (Run Time Type Identification)
comes into the picture. C++ provides the typeid operator and a set of classes that
enable the querying of the type of an object at runtime. This operator will return
the exact type of the object only if there is at least one virtual function in it:
class Base{
// no virtual methods
void Base1();
void Base2();
};
class Derived1 : public Base{
virtual void vMethod();
};
class Derived2: public Derived1{
};
void foo(){
Derived2 d2Obj;
Base* bPtr;
bPtr = &d2Obj;
cout<<typeof(*bPtr)<<endl;
Derived1 *dPtr;
dPtr = &d2Obj;
cout<<typeof(*dPtr)<<endl;
}
//output:
// class Base
// class Derived
Reflection is a feature available only in dynamic (interpreted) languages.
Reflection is a powerful facility as we can dynamically load classes, create
objects, change their properties, and invoke methods on it. Although fully
exploiting the power of reflection will not be explored in this case study (see?
id=1852&WROXEMPTOKEN=1518115ZIn19JBRkpiV5wX71qk
for a whole piece
on the topic), here is a sample that loads an assembly and invokes its methods
dynamically:
using System;
using System.Reflection;
class ReflectionTest{
// this method will be called dynamically
public void InvokeDynamic(){
Console.WriteLine("Hello, dynamic world!");
}
public static void Main(){
Type t = Type.GetType("ReflectionTest");
// get the type by passing the name of this class
MethodInfo m = t.GetMethod("InvokeDynamic");
object o = Activator.CreateInstance(t);
// Activator is a class defined in System namespace
// you can use it to create objects (remote or local)
m.Invoke(o, null);
// the second argument is the list of arguments passed
// to Invoke - null in this case
}
}
// output:
// Hello, dynamic world!
Memory Management
Moving from C++ to C# takes away a lot of the programmer's freedom. C++
allows you to determine whether to create an object in the stack or on the heap,
whereas C# doesn't. The change from unmanaged to managed environment has
drawbacks to. C# is a dynamic language and all the allocation is done on the
heap. Only value types are allocated on the stack. So, you have to allocate the
memory for all the objects on the heap manually, even for those objects you used
to allocate statically in C++. In C#, in addition to using 'new' for dynamic
allocation for heap objects, you can use it for stack objects (structs) to call the
constructors.
The difference in where the objects are allocated is significant. For example,
when casting is done from a value type to a reference type, memory needs to be
allocated on the heap and initialized. This process is referred to as 'boxing'. For
example:
int i = 10;
object o = i;
Note that you don't need an explicit cast here, as it is an 'upcast'. When the
conversion is done from reference type to value type, it is referred to as
'unboxing'. However you need explicit casting to do that as it is a 'downcast':
int i = 10;
object iRef = i;
int j = iRef + 100; // doesn't compile, needs explicit cast
int k = (int)iRef +100; // now OK
Such conversions are not possible in C++ as there is no common base class.
Boxing and unboxing are costly operations and need to be avoided whenever
possible as it involves creation and destruction of objects.
Garbage Collection
The burden of managing the memory is greatly reduced in C#, as the garbage
collector automatically reclaims the unused/unreferenced objects. With garbage
collection, most of the problems with managing the memory like dangling
pointers and memory leaks are gone. Garbage collection is only for memory
objects, but there are other resources like network connections that need to be
released when the object is recollected. This is done in the finalize method. C#
still supports C++'s destructor syntax, but C# destructors are 'syntactic sugar' for
finalizers.
~MyClass(){
// release resources like database connections}
is equivalent to:
protected override void Finalizer(){
try{
// release resources like database connections }
finally{
base.Finalize();
}
}
which is little tedious to type, and hence the destructor syntax is convenient. The
meaning of destructors is not the same in these languages even though the
syntax is the same. There is no assurance that the object will be garbage collected
or finalizers will be called immediately when there are no more references to that
object. If there are important resources like file handles or database connections
that are released in C++ destructor code, you shouldn't go for Finalize in C#.
Rather, you have to implement the
IDisposable
interface, override the
Dispose
method, and write the code for releasing such connections or handles.
using System.Runtime.InteropServices;
class MyClass : IDisposable{
MyClass(){
// get resources
}
public void Deallocate(){
// code for releasing resources here
}
public void Dispose(){
Deallocate();
GC.SuppressFinalize(this);
// since Dispose is called, the Finalize method should
// not be called... so tell GC to suppress call to
// Finalizer method
}
~MyClass(){
Deallocate();
}
public static void Main(String []args){
MyClass obj = new MyClass();
// use obj;
obj.Dispose();
}
}
To be more precise: it is not possible to determine exactly when the garbage
collector will be called, and so C# doesn't have deterministic finalization. To
overcome this, you have to implement the
IDisposable
interface and provide the
implementation for the
Dispose
method. After you use the object, you can release
it by calling the
Dispose
method explicitly. Who is responsible for calling this
method for objects that are from various sources? The time honored C++
principle of disposing heap objects applies to this also: 'whoever allocated the
memory has to recollect it'.
Steps in Converting Existing Code
There are cases where systems that are written in C++ need to be ported to C#.
The .NET environment can use C++ code directly in two cases:
•
When the classes are written in Managed Extensions to C++
•
If they are COM components
If the application is written as COM components, then the component can be
used directly in .NET. In the case of COM components, you can use the Type
Library Importer (
tlbimp.exe
) utility. It reads the COM type library information
and converts it to an equivalent .NET assembly as a proxy class that contains the
necessary metadata. However, it should be noted that the code is still
unmanaged.
'Managed extensions to C++' (MEC) is a set of extensions to the C++ language
provided by Microsoft that can be compiled to code targeting .NET environment.
Most of the existing C++ code is not for component programming; so the code
cannot be used directly in C#. MEC is new to the programming world and hence
there is no possibility that legacy code is written in that.
C# provides support for low-level programming and has facilities to make use of
legacy code. For example, the methods that are available in the DLLs can be
accessed by declaring such methods with the DllImport attribute. You have to
declare such methods as extern - it has a similar use as in C++ for accessing
methods from other languages. It can be applied only to methods implemented
externally. Say, you want to use your favorite MessageBox in traditional
Windows programming:
[DllImport("User32.dll")]
public static extern int MessageBox
(int h, string m, string c, int type);
// now you can use it in your C# code
This feature is of great use if yours is a code library or framework and not a full-
fledged application. You just need to declare the methods in your C# code and
can make use of them by storing them in DLLs.
When you want to convert existing C++ code to run under the .NET platform,
the following decisions need to be made. If the code is simple enough that it can
be rewritten without much effort, then you can go for C#. Practically, C++ code
may involve low-level programming like accessing hardware features. Such
functionality can be done in C# itself to some extent due to its support of C like
structures and allowing restricted use of native pointers. At the level where full-
control over resources is required, you can do explicit memory management as
well. Such code should be done in 'unsafe' blocks. If it is complex enough that it
cannot be handled with the facilities that are available in 'unsafe' then direct
conversion could be made from C++ to Managed Extensions to C++. Code
written like that is accessible from C# code. All this means that the tested, legacy
C++ code need not be discarded and you can still use it under .NET
environment, albeit as unmanaged code.
Thinking of one-to-one correspondence of functionality leads to poor design and
fragile code. Translating C++ code on a line-by-line basis is not feasible as the
two languages differ considerably in their functionality and support. Let us
illustrate this with an example. In C#, all the functions have to be abstracted
inside classes, as no global functions or data is supported. C# doesn't support
global variables/functions because it strictly enforces class as the basic
abstraction mechanism. So, when you are moving to C#, it is better to stick to the
C# mindset - don't think in terms of C++. To illustrate how these ideas
materialize, consider the following example of converting the class hierarchies.
Converting the class hierarchies
Designing class hierarchies differs drastically in C++ and C#. This is because
multiple class inheritance is not supported in C#, only public inheritance is.
Consider the following hierarchy available in C++:
class Base1{
// pure abstract base class
}
class Base2{
// abstract base class
}
class Base3{
// concrete class
}
class Derived: public Base1, protected Base2, private Base 3{
}
Base1 can be represented as an interface as a C++ pure abstract base, which is
equivalent to an interface in C#. The Base2 can be an abstract class in C#. The
problem arises here because multiple class inheritance is involved, as there can
be only one base class in C#. If possible, try to convert Base2 into an interface.
That implementation is available for a few of the methods. In the other cases,
those implementations can be provided in the concrete class, thus making Base2
as an interface feasible. The problem arises when there are data members. In that
case, having it as an interface is not feasible - moving data members is not
advisable.
In general, this can be solved by having Base3 inheriting from Base2. Since Base2
is an abstract class, it can better serve as base, rather than Base3 serving as a base
class for Base2. The C++ code has private, protected, and public inheritance.
How can they be handled in C#? Note that C# supports only public inheritance.
So, you are forced to use public inheritance for all the three types of inheritance
supported in C++, public, private and protected. Using public inheritance
doesn't affect the functionality. The real difference lies in abstraction. In C#
solution, all the members are exposed and the hierarchy looks like this:
interface IBase1{
}
// the naming convention in C# suggests interfaces to use I prefix
before name
abstract class Base2{
}
class Base3 : Base2 {
}
class Derived: IBase1, Base3{
}
Having the exact C++ hierarchy in C# is not possible. However, this can be
achieved to some extent by understanding the inheritance model supported in
these languages.
Case Study Review
Migrating from C++ to C# is not easy as it may seem. C# is strongly based on C+
+, but the two languages differ in their design. The syntactic similarities between
the two languages can be misleading, as there are many semantic and pragmatic
differences. There are many places where the C++ programmer will truly get lost
when he starts programming in C#.
A C++ programmer needs to have a good understanding of the migration
process and should be clear in his/her approach to get best results from such a
transition. The two languages differ in many fundamental ways: design
approach, memory management, problem solving approach, and the underlying
translation technology are just a few differences. To get the best results, it is
essential that the programmer has an overall view of such issues.
The second section of the case study is not just looking at the differences in
features. Rather, it's a discussion of how the transition can be done from C++ to
C# by analyzing its features. Naturally, a clear picture emerges of what to expect
and what not to expect in such a transition.
When there is a necessity to convert the existing code from C++ to C#, a set of
decisions needs to be made. If the code is available as COM components, it can
be used directly instead of manually converting the code. If the code is a library/
framework available as DLLs, then no conversion needs to be done and it can be
used directly in C#. Managed extensions to C++ can be used for minimal
changes in the code and the application becomes available in the .NET
environment. A decision needs to be made if it is necessary to rewrite the whole
code in C#. In that case, line-by-line conversion of code is not feasible and such
transition will need significant effort on the programmers part. It will also
necessitate a change in design approach and new strategies.
Jan 2004.
Log in to post a comment | https://www.techylib.com/en/view/parkmooseupvalley/migrating_from_c_to_c | CC-MAIN-2017-30 | refinedweb | 8,691 | 52.8 |
Charles E Campbell <address@hidden> writes: > Vim doesn't appear to include <inttypes.h> anywhere and, after checking > out the files under /usr/include/..., none of them include <inttypes.h> > either. This is the first time I've had a problem with <sys/types.h> > conflicting with <inttypes.h>; looks like <inttypes.h> hasn't been > needed by any of the source I've ever compiled heretofore. In IRIX 6.5, the relevant section of <sys/types.h> looks like: /* * inttypes.h also defines these. avoid compiler errors if both inttypes.h * and types.h are included. */ #ifndef __inttypes_INCLUDED #define __inttypes_INCLUDED typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef __int64_t int64_t; typedef __uint64_t uint64_t; typedef __int64_t intmax_t; typedef __uint64_t uintmax_t; typedef signed long int intptr_t; typedef unsigned long int uintptr_t; #endif /* !__inttypes_INCLUDED */ and the section of <inttypes.h> that defines these has the same guard. Is this not true on IRIX 5.3? If it isn't, autoconf may need to check explicitly if <inttypes.h> and <sys/types.h> can be included at the same time, a la the existing checks for <time.h> and <sys/time.h>. -- Russ Allbery (address@hidden) <> | http://lists.gnu.org/archive/html/autoconf/2001-06/msg00078.html | CC-MAIN-2014-15 | refinedweb | 210 | 63.46 |
j
I want solution for this jsp program..
I want solution for this jsp program.. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>
JSP Page
<%!
String
Urgent Solution required
Urgent Solution required This is possible to transfer that file from client to server and read that file and view it in JSP. If it is can you send the example. thanks alot in advance
Hi,
You can create a JSP file
solution
solution A developer wants you to develop a simple take away restaurant order service.
The system reads from a file containing information about the restaurant (such as
the name, place and menu). The system then allows the user
jsp
jsp how to connect the database with jsp using mysql
Hi Friend,
Please visit the following links:
Wimax solution
Java JSP - JDBC
Java JSP JDBC connectivity in JSP? Hi Friend,
Please visit the following link:
Hope that it will be helpful for you.
Thanks
solution of k map in c
solution of k map in c write a program in c to solve k-map with digital circuit
Solution to C prog
Solution to C prog Hi,
Pls any body help, why the following prog crashing while running.
#include<stdio.h>
#include<conio.h>
int main(){
int n,*fact(int *n);
printf("Enter the number:");
scanf
Please find me a solution that
Please find me a solution that Write a java program that calculates the area of rectangular, square,
triangular, and circle.
Your program must have the following:
Two classes named "Area" and "AreaTest".
Class "Area
java - JSP-Servlet
:// code for JSP and MySql Database Connectivity Need an example code for JSP and MySql Database Connectivity Hi here i am giving
solution - Java Beginners
Jaa - JSP-Servlet
Jaa How to access data from the database using JSP program Hi Friend,
Please visit the following links:
Vehicle Tracking Solution
JSP
JSP how to open and view a flat file in browser using java code in jsp?
Hi Friend,
If you want to simply open a file then try...) in the path creates the problem. Any solution is appreciated.
Thanks in advance.
jsp
"
"">
**<jsp:useBean**
<jsp:setProperty...;title>JSP Page</title>
</head>
<body>
Hosted E-Commerce Solution
Hosted E-Commerce Solution
In this article we will explain Hosted E-Commerce Solution and tell you how
to choose the best Hosted E-Commerce Solution... to provide best Hosted E-Commerce
Solution. But sometime you may end up in choosing
jsp
solution to my problem
E-commerce Hosting Solution
E-commerce Hosting Solution
In this article we will explain you about E-commerce Hosting Solution. The
E-commerce Hosting Solution is used by the shopping... Hosting Solution is essential
in success of the online e-commerce portal
JSP Tutorials
:
Introduction to JSP
Java Server Pages or JSP for short is Sun's solution... JSP Tutorials
JSP Tutorials and examples, you will find many examples
error please send me the solution
program - JSP-Servlet
for more information. hi friends...
i hv faced a problem of jsp code.my problem is...
i want to generate a serial no and with this serial no , i want
Introduction to JSP
Pages or JSP for short is Sun's solution for developing dynamic web sites. JSP... JSP Tutorials - Writing First JSP
... applications. JSP enable the developers to directly insert java code into jsp file
Fleet tracking solution
Fleet tracking solution are like gifts for people running fleet companies... tracking solution has become important in today's time as number of carjacking, vehicles theft and illegal use of vehicle has increased.
Fleet tracking solution
JSP Training
JSP Training
Java Server Pages (JSP) is Sun's solution for developing dynamic web sites. JSP provides excellent....
JSP training course Objective: This JSP training course aims at teaching
jsp functions - JSP-Servlet
jsp functions hi,sir
i need a simple jsp program using page directive with session attribute Hi friend,
To get the solution of your problem visit this link....
Latest Fleet Management Solution Services
solution into your entire logistics or transportation business.
Currently... management solution. Roseindia Technologies Pvt. Ltd, a Delhi based software development... fleet management software that provides you the best business solution
JSP Code - JSP-Servlet
JSP Code Hi,
Do we have a datagrid equivalent concept in JSP? If so, then please help me to find the solution of the problem.
Its Urgent...,
Please visit the following links:
VoIP Billing Solution
VoIP Billing Solution
... Billing solution is the strategic choice for service providers seeking telco... Management Software
Looking for a billing and management solution for your
jsp code - JSP-Servlet
jsp code hello frns
i want to display image from the database along...
so please tell me the solution how to write a text after image display... from database in Jsp to visit....
jsp and ajax - JSP-Servlet
jsp and ajax i had some problem
i want to display the current... this link to find the solution about your problem.
Thanks
Introduction to the JSP Java Server Pages
for short is Sun's solution
for developing dynamic web sites. JSP provide excellent... JSP Tutorials
JSP Tutorials and examples, you will find many examples with
working
Need Solution to get vaues from sql database in java
Need Solution to get vaues from sql database in java hi I have written a code in java to get these xml tags
< company comp:
now i... file. please provide me solution to get values for xml tags from database
My big doubt on java prgmn.. need solution asap
My big doubt on java prgmn.. need solution asap How do you write prgrm 4 dis : 3% discount is given if payment is made within 30days of purchase. date of purchase and payment entered by user
Flex with JSP
Flex with JSP i want to draw chart in jsp page using flex.
how can i do that?
any solution??
Flex charts
You can visit the following links:
A Java Program by using JSP
A Java Program by using JSP how to draw lines by using JSP plz show me the solution by using program
jsp code for display of data from database and snap shot of the output
the following link: code for display of data from database and snap shot of the output
jsp images
jsp images hi
I had done a demo application using jsp. And i tried to display some images which is located in the server folder. It has done... with the functionality. Kindly send me a feasible solution.
Thanking you in advancesp dropdown refresh - JSP-Servlet
jsp dropdown refresh Sir
Thank u for your jsp code for dependent dropdown list, i used it in different table for data extraction... some solution with code so that i shall ever great full to you
setting of image resolution on jsp - JSP-Servlet
setting of image resolution on jsp How can i set resolution of images on my jsp page?When i enlarge the image it becomes fade? is there any solution for its setting servlet
jsp servlet i have to create one application in which at one page login id will be entered and after entering it will go to second page where first... the whole solution
Jobs at Rose India
;
Roseindia.net is one of the well-known Internet based solution... solution for individuals and small enterprises that don?t have the budget and time..., Java, JSP, Servlets programming.. Should
have excellent communications
Sorting a jsp page. - JSP-Servlet
Sorting a jsp page. Hi there,
It's me again. I tried to use Ajax as you told but I couldn't get the solution. I've done a little bit of research, and I think I'm closer to a solution.
Would you please help me. I've coded
Technical Content Writer
of the well-known Internet based software solution providers in India. Apart from its... language including JSF, J2EE, Hibernate, Struts, JSP, and JDBC etc. The candidate
probleming in runing jsp - JSP-Servlet
probleming in runing jsp hi
this is my simple jsp code...
HTTP Status 404 - /jsp%20prog/
--------------------------------------------------------------------------------
type Status report
message /jsp%20prog
JSP Paging issue
JSP Paging issue Hi;
How to display large number of users- account profile with photo can be placed in continuous pages using JSP code . If any one have solution please help me .
Amrit;
Visit Here
Jobs at Rose India
;
Roseindia.net is one of the well-known Internet based solution... solution for individuals and small enterprises that don?t have the budget and time... (Trainee)
Should have knowledge of PHP, Java, JSP, Servlets programming
jsp - excel generating problem - JSP-Servlet
jsp - excel generating problem Hi,
I worked with the creating excel through jsp, which is the first example in this tutorial....
I cant view in web page as the tutorial image shows.
Kindly give solution
Need solution to get values for XML namespace tags from SQL database in Java
Need solution to get values for XML namespace tags from SQL database in Java hi I have written a code in java to get these xml tags
< company... and created xml tags in separate file. please provide me solution to get values for xml
Java to create table in jsp file that include other jsp file
Java to create table in jsp file that include other jsp file String jspContent = "table"
+= "tr"
+= "td"
+= "jsp:include page='fileSource...
Please Provide me the solution (or example
pagination in jsp - JDBC
then display.
Could any body give complete simple solution for this.
Thanks....
Simple pagination in jsp...
------------------
Simple pagination in jsp
Simple
Parent - child jsp communication - JSP-Servlet
this be achieved in JSP?
2)Is there a solution with JSP alone or is javascript giving any help...Parent - child jsp communication Hello,
Thanks for your answers....
1) How could I pass values from a parent jsp to a popped up child jsp... for more information,
Thanks
JavaMail and Gmail - JSP-Servlet
the solution asap
To insert attachment file in database in JSP.
To insert attachment file in database in JSP. I am doing project in JSP. How to insert attachment file in mysql database? Please suggest some solution. Your inputs is valuable to me.
Hi Friend,
Visit Here
Thanks
JSP Code - Java Beginners
JSP Code Hi frnds,
This is reference to solution which u have... respect to what the solution you have provided, its really appreciable but since i am... if u just provide an alternate of this function in solution provided
regarding images in jsp
regarding images in jsp Hi,
When I am trying to display an image in jsp, i am getting the image of bar charts in webroots/jspchart/web... me out in fixing the solution for my problem?
Thanks in advance
Jsp Code - Java Beginners
Jsp Code Hi,
I am new to java programming & as per the requirement, i need to implement a 'SEARCH' functionality which will search the database... to find a unique solution to this problem.
Its really urgent.....
Plz
Dynamic Line draw in JSp
multiple target.
And each line should have dynamically link of other jsp page.
Please, I have tried it. But not geeting any solution.
Thanks in advance
seeking info - JSP-Servlet
seeking info Looking for the information on Java, JSP and Servlet... help you to get the solution and you can easily start working on it.Here i am... codes. - JSP
Enterprise Resource Planning,What is ERP,ERP Solution India,ERP Software Solution
connection with database - JSP-Servlet
and the connection with the database using jsp code, I get exceptions that I have mailed you.
I have wasted more than 15 days only in finding the solution... with java code.
Is there any other way to establish a connection with database in jsp
How does Roseindia's GPS Solution improve fleet management?
and advanced GPS based fleet management solution at most competitive prices. Roseindia's GPS fleet management solution covers a wide range of GPS based... to a great extent.
We have a wide range of GPS tracking solution for better
export to excel - JSP-Servlet
clicking the button all the values from the jsp page will save to a excel file.
I have search in net but fail to get the solution. Plz help me
Limiting characters - JSP-Servlet
Limiting characters Iam doing a jsp project. In this i have a text area which should accept not more than 300 characters. I solved...+v and paste option from edit menu. Anyone send me the solution. Please
How to Work - JSP-Servlet
; Hi friend,
JSP : Java Server Pages or JSP for short is Sun's solution... doing final year project using java,jsp,servlet.i only know java.i want details about where we save the jsp and servlet file and how we link with java.send one
Advertisements
If you enjoyed this post then why not add us on Google+? Add us to your Circles | http://roseindia.net/tutorialhelp/comment/88843 | CC-MAIN-2016-07 | refinedweb | 2,150 | 64.41 |
How to let eef reach the goal of path planning, not flange ?
Hello, I'm a beginner of ROS-I and use Ubuntu 16.04 with Kinetic version.
I follow this tutorials to implement Motion Planning with my YASKAWA MH5 model.
After that, I tried Descartes Path Planning and it's working fine with mine.
However, I want the robot to pick some objects, but I found the robot uses the position of flange(link_t) to be the goal of path planning, not eef.
Actually, I add a gripper (design by myself) to my URDF file and setup it in MoveIt! Setup Assistant(another Planning Groups, Label End Effectors), but It still doesn't have any change.
Does it have any possible way to move robot arm to goal position with eef ?
Here is my robot model:
and launch file message:
[ INFO] [1550753805.151307306]: Loading robot model 'motoman_mh5'... [ INFO] [1550753805.196031369]: Loading robot model 'motoman_mh5'... [ INFO] [1550753805.279385319]: Starting scene monitor [ INFO] [1550753805.283462846]: Listening to '/move_group/monitored_planning_scene' [ INFO] [1550753805.722741551]: Constructing new MoveGroup connection for group 'arm' in namespace '' [ INFO] [1550753806.946713982]: Ready to take commands for planning group arm. [ INFO] [1550753806.946780755]: Looking around: no [ INFO] [1550753806.946808706]: Replanning: no [ WARN] [1550753806.969202339]: Interactive marker 'EE:goal_link_t' contains unnormalized quaternions. This warning will only be output once but may be true for others; enable DEBUG messages for ros.rviz.quaternions to see more details. | https://answers.ros.org/question/316322/how-to-let-eef-reach-the-goal-of-path-planning-not-flange/ | CC-MAIN-2021-31 | refinedweb | 236 | 69.48 |
I know there are similar topics on the site but they are either telling me to switch back to regular RDBMS systems if i need transactions or use atomic operations or two-phase commit. The second solution seems the best choice. The third is a way i don’t wish to follow because it seems that many things could go wrong and i can’t test it in every aspect. I’m having hard times to redefine my project to meet the second method. I don’t know if this cames from the viewpoint i have because i’ve only worked with SQL databases so far or it really can’t be done.
We like to pilot test MongoDB at our company. We have chosen a relatively simple project which is an SMS gateway. It allows our softwares to send SMS messages to the cellular network and the gateway does the dirty work: actually communicating with the providers which can have different communication protocols. The gateway also manages the billing of the messages. Every customer who applies for the service have to buy some credits. The system automatically decreases the user’s balance when a message is sent and denies the access if the balance is insufficient. Also because we are customers of third party SMS providers we may also have our own balance by them. We have to keep track of those as well.
I started thinking about how can I store the required data with MongoDB if i cut down some complexity (external billing, queued SMS sending). If i came from SQL world i would create a separate table for the users, another one for SMS messages, and one for storing the transactions regarding the users balance. Let’s say I create separate collections for all of those in MongoDB.
Imagine an SMS sending task with the following steps in the simplified system:
check if the user has sufficient balance; deny access if there’s not enough credits available
send and store the message in the SMS collection with the details and cost (in the live system message would have a status attribute and a task would pick up it for delivery and set the price of the SMS according to it’s current state)
reduce the users’s balance with the cost of the sent message
log the transaction in the transaction collection
Now what’s the problem with that? MongoDB can do atomic updates only on one document. In the previous flow it could happen that some kind of error creeps in and the message gets stored in the database but the user’s balance is not reduced and/or the transaction is not logged.
I came up with two ideas:
Create a single collection for the users, and store the balance as a field, user related transactions and messages as sub documents in the user’s document. Because we can update documents in atomic manner it actually solves the transaction problem. Disadvantages: if the user sends many SMS messages, the size of the document could become large and the 4MB document limit could be reached. Maybe i can create history documents in such scenarios, but i don’t think this would be a good idea. Also i don’t know how fast the system would be if i push more and more data to the same big document.
Create one collection for users, and one for transactions. There can be two kind of transactions: credit purchase with positive balance change and message send with negative balance change. Transaction may have a subdocument for example by message send the details of the SMS can be embedded in the transaction. Disadvantages: i don’t store the current user balance so i have to calculate it every time a user tries to send a message to tell if the message could go or not. I’m affraid this calculation can became slow as the number of stored transactions grows.
I’m a little bit confused which way to choose. Do i have other solutions? I don’t find any best practices online how can I work around this kinds of problems. I guess many of the programmers who are trying to become familiar in NoSQL world facing similar problems in the beginnings.
An Accounting RESTful API or, circumventing MongoDB’s lack of DECIMAL data type and support for TRANSACTIONS
I am evaluating MongoDB as a storage solution for our financial/accounting RESTful API. I know about MongoDB’s lack of transactions and decimal data type, however: I suppose I could overcome the lack
MongoDB transactions?
Playing around with MongoDB and NoRM in .NET. Thing that confused me – there are no transactions (can’t just tell MongoConnection.Begin/EndTransaction or something like that). I want to use Unit of wo
Work around for lack of sqlProjection support within criteria builder? concerns lack of support for sqlProjection. It was closed as a duplicate and supposedly fixed in Grails v1.2. But the duplicate issue concerned sqlRestricti
Work around the lack of templates in java
In C++ I build a little wrapper around cout like this: template <class T> void output( T a ){ if(is_this_enabled==true) std::cout<<a<<endl; return; } When certain kinds of output fl
Transactions In MongoDB
I am using a NoSQL database MongoDB with Java and Spring Data. I am aware that MongoDB only supports transactions for a single document. I am using Spring Transactions to carry out MongoDB transcation
SQL Server: how transactions work
In SQL Server, how many transactions will this produce? DECLARE @deleted BIGINT SET @deleted = 100000 WHILE @deleted = 100000 BEGIN DELETE TOP(100000) FROM MYTABLE WITH (ROWLOCK) where Col1 = 7048 and
Transactions around finder methods
Is it wise to start transactions around finder methods: @Transactional public E getParticularEvent(final String id) { return (E)em.find(carClass, id); } Should this be done?
MySQL Transactions and how does Rollback work?
I just came across Transactions and I wonder what are the pros and cons of using it, how does the rollback work, are the old values kept in memory, if bigger, what happens? For 1. I understand you h
How to design around lack of multiple inheritance?
Using interfaces won’t work because I want a single implementation. Using this solution would end in a lot of redundant code because I plan on having quite a few sub classes (composition vs inheritanc
How to solve lack of space issue in mongodb
I am getting the following error in mongod.log file: journal dir=/var/lib/mongodb/journal Mon Jan 20 15:10:19.742 [initandlisten] recover : no journal files present, no recovery needed Mon Jan 20 15:1
Answers
The project is simple, but you have to support transactions for payment, which makes the whole thing difficult. So, for example, a complex portal system with hundreds of collections (forum, chat, ads, etc…) is in some respect simpler, because if you lose a forum or chat entry, nobody really cares. If you, on the otherhand, lose a payment transaction that’s a serious issue.
So, if you really want a pilot project for MongoDB, choose one which is simple in that respect.
Bring it to the point: if transactional integrity is a must then don’t use MongoDB but use only components in the system supporting transactions. It is extremely hard to build something on top of component in order to provide ACID-similar functionality for non-ACID compliant components. Depending on the individual usecases it may make sense to separate actions into transactional and non-transactional actions in some way…
Transactions are absent in MongoDB for valid reasons. This is one of those things that make MongoDB faster.
In your case, if transaction is a must, mongo seems not a good fit.
May be RDMBS + MongoDB, but that will add complexities and will make it harder to manage and support application.
Now what’s the problem with that? MongoDB can do atomic updates only on one document. In the previous flow it could happen that some kind of error creeps in and the message gets stored in the database but the user’s balance is not gets reduced and/or the transaction is not gets logged.
This is not really a problem. The error you mentioned is either a logical (bug) or IO error (network, disk failure). Such kind of error can leave both transactionless and transactional stores in non-consistent state. For example, if it has already sent SMS but while storing message error occurred – it can’t rollback SMS sending, which means it won’t be logged, user balance won’t be reduced etc.
The real problem here is the user can take advantage of race condition and send more messages than his balance allows. This also applies to RDBMS, unless you do SMS sending inside transaction with balance field locking (which would be a great bottleneck). As a possible solution for MongoDB would be using findAndModify first to reduce the balance and check it, if it’s negative disallow sending and refund the amount (atomic increment). If positive, continue sending and in case it fails refund the amount. The balance history collection can be also maintained to help fix/verify balance field.
Living Without Transactions
Transactions support ACID properties but although there are no transactions in MongoDB, we do have atomic operations. Well, atomic operations means that when you work on a single document that that work will be completed before anyone else sees the document. They’ll see all the changes we made or none of them. And using atomic operations, you can often accomplish the same thing we would have accomplished using transactions in a relational database. And the reason is that, in a relational database, we need to make changes across multiple tables. Usually tables that need to be joined and so we want to do that all at once. And to do it, since there are multiple tables, we’ll have to begin a transaction and do all those updates and then end the transaction. But with MongoDB, we’re going to embed the data, since we’re going to pre-join it in documents and they’re these rich documents that have hierarchy. We can often accomplish the same thing. For instance, in the blog example, if we wanted to make sure that we updated a blog post atomically, we can do that because we can update the entire blog post at once. Where as if it were a bunch of relational tables, we’d probably have to open a transaction so that we can update the post collection and comments collection.
So what are our approaches that we can take in MongoDB to overcome a lack of transactions?
- restructure – restructure the code, so that we’re working within a single document and taking advantage of the atomic operations that we offer within that document. And if we do that, then usually we’re all set.
- implement in software – we can implement locking in software, by creating a critical section. We can build a test, test and set using find and modify. We can build semaphores, if needed. And in a way, that is the way the larger world works anyway. If we think about it, if one bank need to transfer money to another bank, they’re not living in the same relational system. And they each have their own relational databases often. And they’ve to be able to coordinate that operation even though we cannot begin transaction and end transaction across those database systems, only within one system within one bank. So there’s certainly ways in software to get around the problem.
- tolerate – the final approach, which often works in modern web apps and other applications that take in a tremendous amount of data is to just tolerate a bit of inconsistency. An example would, if we’re talking about a friend feed in Facebook, it doesn’t matter if everybody sees your wall update simultaneously. If okey, if one person’s a few beats behind for a few seconds and they catch up. It often isn’t critical in a lot of system designs that everything be kept perfectly consistent and that everyone have a perfectly consistent and the same view of the database. So we could simply tolerate a little bit of inconsistency that’s somewhat temporary.
Update, findAndModify, $addToSet (within an update) & $push (within an update) operations operate atomically within a single document. | http://w3cgeek.com/how-to-work-around-the-lack-of-transactions-in-mongodb.html | CC-MAIN-2019-04 | refinedweb | 2,083 | 60.04 |
This is a great time to be Java developer. According to the latest statistics provided at the JavaOne 2008 conference, there are over 6 billion Java-enabled devices deployed worldwide. These devices can range from large-scale enterprise class servers down to a tiny smart card that fits in your wallet. Java technology is embedded into billions of phones, as well as countless other devices including the traditional desktop computer: Figure 1 shows the various Java platforms that exist today).
The Java platform for Blue-ray disc players is called BD-J. In the first part of this series, I'm going to cover the following topics:
I'm going to assume that you have absolutely no Java ME or video-content creation experience whatsoever. Having that said, let's get started.
Now you might be surprised to learn that although the BD-J standard is a part of the Java ME platform, you're going to need a somewhat more powerful machine in order to play BD-J applications on your PC. Here's a list of the physical requirements that you're going to need to create, burn, and play BD-J applications on your PC:
In other words, a typical $500 desktop PC or a $1000 laptop may be able to create BD-J applications and burn Blu-ray discs, but neither would be able to play Blu-ray discs due to the intense video requirements that are necessitated by high definition (HD) video. Fortunately, CyberLink Corporation makes a handy diagnosis tool to determine if your machine is capable of Blu-ray playback. Figure 2 below shows a screenshot of the tool running on one of my laptops.
So, what exactly can you do with the BD-J platform? I'm glad that you've asked. However, before we cover the capabilities of the BD-J platform, it would be prudent to cover the terminology that is frequently used when creating BD-J applications:
Now that we've covered the terminology used when creating BD-J applications and authoring content, let's examine the capabilities of the BD-J platform. Using the BD-J APIs, you have the ability to draw any text, images, or animation on the display. This enables you to create applications that can do the following:
Additionally, the BD-J APIs allow you to initiate playback of any video content on the disc, which means that you can create applications that do any of the following:
Furthermore, using the BD-J APIs, you can respond to user input from the remote control, access data over network, or store data on the local persistent storage of the Blu-ray player -- wait, a Blu-ray player has local storage? Yes, the current players on the market are required to have 64 kB of memory for persistent storage. Blu-ray players also can persist data to a "virtual file system", but we'll cover that later on in this article. So, having that said, these capabilities of the BD-J APIs will also enable you to create applications that:
So now that you've gotten a pretty good grasp of the capabilities of the BD-J platform, let's dive a little deeper and take a look at the classes of the API in a little more detail.
As you can imagine, the BD-J specification wasn't invented overnight, and it definitely leveraged many other Java specifications that operated in the home platform / consumer electronics arena. If you remember from Figure 1, the Java platform for consumer electronics is the CDC (Connected Device Configuration). In Figure 4, we're going to look at the stack of APIs that constitute the BD-J specification.
Now that you're somewhat familiar with the specifications, let's take a package-by-package overview of the BD-J specific classes.
org.bluray.application
org.bluray.media
org.bluray.net
java.net
org.bluray.storage
org.bluray.system
org.bluray.ti
org.bluray.ui
java.awt
org.bluray.vfs
The GEM and MHP APIs
The BD-J specification is definitely not the first specification that uses Java for consumer electronic devices. The specifications for the Multimedia Home Platform (MHP) and the Globally Executable Multimedia Home Platform (GEM) define APIs that were originally intended for cable boxes and other multimedia devices for the home. Since the GEM specification is a worldwide standard, it has been leveraged by other consumer electronic device standards, namely:
For the purposes of this article, I won't go in depth on the entire GEM/MHP platform. The following list shows the Java packages that make up the GEM/MHP API, which is included in the BD-J standard.
org.davic.media
dvb.event
dvb.test
org.davic.net
dvb.io
dvb.ui
org.davic.resources
dvb.lang
dvb.user
dvb.application
dvb.media
havi.ui
dvb.dsmcc
dvb.net
The Java TV 1.1 APIs
As you may recall from Figure 4, the overall BD-J standard also uses functionality that comes from the Java TV APIs. The Java TV APIs provide essential capabilities or BD-J applications such as the Xlet framework (which I'll go into detail later in this article), as well as the class definition for javax.tv.service.Service. For java-enabled TVs and set-top boxes (which includes cable receivers and DVRs), a service is a channel. So, for instance, if you wanted to write a simple application that programmed your Java-enabled DVR to tune to channel 203 everyday at 4:00pm, then you would use the classes in the javax.tv.service package to accomplish that task. Now, for Blu-ray devices, a javax.tv.service.Service is disc title. Following is a complete list of the packages in the Java TV API:
javax.tv.service.Service
javax.tv.service
javax.tv.graphics
javafx.tv.service
javax.tv.locator
javafx.tv.util
javax.tv.media
javafx.tv.xlet
javax.tv.net
The Personal Basis Profile, Foundation Profile, and Connected Device Configuration APIs
Together, the Personal Basis Profile (PBP), Foundation Profile (FP), and Connected Device configuration (CDC) combine to form the foundation that the other higher-level APIs leverage for embedded and consumer electronic devices. These classes provide the familiar Java SE classes that desktop Java programmers are already familiar with. These classes are not equivalent to the full JDK 1.6 standard (Java SE 6), but they are very similar to the Java SE 1.3 standard with a few exceptions. These are the omission of JDBC, Swing, and high-level AWT widgets that assume that the user input includes a pointing device (that is, a mouse). Now, you should also be aware that since this platform is Java ME (and not Java SE), then you'll also have access to the same javax.microedition.io classes that are also available on Java-enabled mobile phones. Following is a list of classes in the PBP, FP, and CDC APIs:
javax.microedition.io
java.math
java.text
java.beans
java.util
java.io
java.rmi
java.lang
java.security
javax.microedition.xlet
Let's go over the different versions of the Blu-ray disc specification that's implemented on the players that exist on the market.
The first version of the Blu-ray disc specification was released as profile 1.0.
The next release was Blu-ray Disc Profile 1.1, which is also called "Bonus View." In Blu-ray Profile 1.1, the specification required support for Picture-in-Picture (PiP) as well as the presence of the virtual file system, which must possess the capability to store at least 256 MB of data.
The most current profile is 2.0, also called "BD-Live." This profile requires all the features from Profile 1.1 and adds the requirement that an internet connection be present. Profile 2.0 also mandates that the virtual file system store at least 1 GB of data. Now, since a single-layer Blu-ray disc holds 25 GB of data, you can see that virtual file system in Profie 2.0 devices couldn't hold a full movie. However, it is large enough for your applications to utilize the internet connection and to store some HD video content for later playback.
If you've used Java for a while, then you should be familiar with the *let naming convention, which is applied to Applets, Servlets, and MIDlets. Thankfully, applications on the CDC platform are not called CDClets, but they are called Xlets since no one could find a better name.
To create a BD-J application, at least one of your classes must implement the javax.tv.xlet.Xlet interface, which comes from the Java TV API. If you're familiar with the classes from the Personal Basis Profile, then you'd know that Xlets are also defined in the javax.microedition.xlet package. Therefore, to minimize frustration when you're building your BD-J applications, be sure that you're importing the Xlet classes from Java TV package.
javax.tv.xlet.Xlet
Now, understanding the lifecycle of BD-J Xlets is pretty simple. Once the constructor has been called, your Xlet goes into the Loaded state. In addition to having a constructor, the initXlet() method will also be called, which will place your Xlet into the Paused state until the startXlet() method is called. As you can see from Figure 5 below, your application can possibly go between the Paused and Active states multiple times before it's destroyed. Therefore, the startXlet() method is good place to put code that allows you check on network connections and other important resources before you start (or resume) doing the real work.
initXlet()
startXlet()
So now that we've got all the preliminaries out of the way, let's dive right into creating our first application.
In the example code shown below, I have a simple application that implements all the Xlet lifecycle methods, and performs a very simple operation: writing text on the screen.
package test;
import javax.tv.xlet.Xlet;
import javax.tv.xlet.XletContext;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import org.havi.ui.HScene;
import org.havi.ui.HSceneFactory;
public class FirstBDJApp implements Xlet {
private static Font font;
private HScene scene;
private Container gui;
private String text = "My first BD-J app running on the PS3!";
//private String text = "My first BD-J app running on " + System.getProperty("os.name");
public FirstBDJApp() {
}
public void initXlet(XletContext context) {
font = new Font(null, Font.PLAIN, 48);
scene = HSceneFactory.getInstance().getDefaultHScene();
gui = new Container() {
public void paint(Graphics g) {
g.setFont(font);
g.setColor(new Color(10, 10, 10));
g.fillRect(20, 20, getWidth() - 40, getHeight() - 40);
g.setColor(new Color(245, 245, 245));
int message_width = g.getFontMetrics().stringWidth(text);
g.drawString(text, (getWidth() - message_width) / 2, 500);
}
};
gui.setSize(1920, 1080);
scene.add(gui, BorderLayout.CENTER);
scene.validate();
}
public void startXlet() {
gui.setVisible(true);
scene.setVisible(true);
}
public void pauseXlet() {
gui.setVisible(false);
}
public void destroyXlet(boolean unconditional) {
scene.remove(gui);
scene = null;
}
}
As you can see, we're not using any high-level widgets to draw the text on the screen. We're just calculating the size that the text would occupy and using the Graphics object to draw that text on the display. Figure 6 depicts what our application looks like on the PS3 gaming console:
So, there you have ita complete working example from start to finish on how to a create BD-J application that works on any Blu-ray disc player. As you can see from the BD-J APIs, we've only scratched the surface of the tip of the iceberg. In Part 2, we're going into more detailed instructions on how to get your development environment to build BD-J applications. We'll also provide concrete example code on how to respond to user input from a remote control.
UPDATE: The author responds to a couple of reader questions in this follow-up blog Q&A on Blu-ray Disc Application Development with Java ME.
I'd like to thank Bill Foote, Chihiro Saito, and the HD Cookbook team for assistance, feedback, and all their help to improve this article. The example code shown in the article was largely inspired by the demo application created by Chihiro's Netbeans Plugin. | http://java.sun.com/developer/technicalArticles/javame/bluray/ | crawl-002 | refinedweb | 2,068 | 53.61 |
forward select query result to jsp page using struts action class
how to forward select query result to jsp page using struts action class how to forward select query result to jsp page using struts action class
What is Action Class?
What is Action Class? What is Action Class? Explain with Example
Action Configuration - Struts
Action Configuration I need a code for struts action configuration in in Struts 2 Framework
. Actions are mostly associated with a HTTP request of User.
The action class..., and select the view result page that should send back to the user
action class... { return "success"; }
}
action class does not extend another class and nor
struts
struts hi
i would like to have a ready example of struts using "action class,DAO,and services" for understanding.so please guide for the same.
thanks Please visit the following link:
Struts Tutorials"
so please help me
Struts
;Basically in Struts we have only Two types of Action classes.
1.BaseActions... class indirectly.These action classes are available...Struts why in Struts ActionServlet made as a singleton what
User Registration Action Class and DAO code
User Registration Action Class and DAO code... to write code for action class and code for performing database operations (saving data into database).
Developing Action Class
The Action Class Is Action class is thread safe in struts? if yes, how it is thread safe? if no, how to make it thread safe? Please give me with good...://
Thanks
Implementing Actions in Struts 2
the many Action classes and
interface, if you want to make an action class for you... the following Action class by implementing Action
interface.
TestAction.java...;roseindia" extends="struts-default">
<action name="
Action Listeners
Action Listeners Please, could someone help me with how to use action listeners
I am creating a gui with four buttons. I will like to know how to apply the action listener to these four buttons.
Hello Friend,
Try
Struts - Struts
*;
public class UserRegisterForm extends ActionForm{
private String action="add...();
return errors;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public
Developing Login Action Class
Developing Login Action Class
... for login action class and database code for validating the user against database.
Developing Login Action Class
In any application
Struts - Struts
javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
public class UserRegisterForm extends ActionForm{
private String action="add";
private...() {
return action;
}
public void setAction(String
javascript call action class method instruts
javascript call action class method instruts in struts2 onchange event call a method in Actionclass with selected value as parameter how can i do
struts 2.0 - Struts
struts 2.0 I have written print statement in action class. It is printing data 2 times. Why it is happening
Configuring Actions in Struts application
Configuring Actions in Struts Application
To Configure an action in struts application, at first write a simple Action
class such as
SimpleAction.java... Action class which returns the success. Now Write the
following code
Why Struts 2
core interfaces are HTTP
independent. Struts 2 Action classes... as an Action class. Even we don't need to implement interfaces
always... handling per action, if
desired.
Easy Spring
integration - Struts 2
Struts-It
Action class
other Struts-related classes like configuration... to create all Struts artifacts
like Form-bean, Action, Exception, etc... Struts-It
download file Error in struts2 action class
download file Error in struts2 action class Hi,
i am using bellow block of code for download file :
public void downloadGreeting(String filename,HttpServletRequest request, HttpServletResponse response){
String
Testing Struts Application
in the action class code.Intentionally so! The step by step progress gets... Reading:
Struts in Action .
by
Ted Husted
( Manning press/ DreamTech...Testing Struts
Action Or DispatchAction - Development process
Action Or DispatchAction
Hi, Action class has execute() only where as dispatchaction class has multiple methods. plz tell me when to use action and dispatchaction.can we use multiple actions in Action class. Thanks Prakash
doubt is when we are using struts tiles, is there no posibulity to use action class...
in struts-config file i wrote the following action tag... action class and tiles freame work simultaniously
--->it is not working
STRUTS
STRUTS 1) Difference between Action form and DynaActionForm?
2) How the Client request was mapped to the Action file? Write the code and explain
java struts error - Struts
*;
import javax.servlet.http.*;
public class loginaction extends Action{
public...java struts error
my jsp page is
post the problem...*;
import javax.servlet.http.*;
public class loginform extends ActionForm{
private MappingDispatchAction Example
;
Struts MappingDispatch Action... functions into a single
action class. It needs to create multiple... class except that it uses a unique
action corresponding to a new request
Struts MappingDispatchAction Example
to collect related functions into a single
action class. It needs...; MappingDispatch_Action
which is a sub class of ... the request to one
of the methods of the derived Action class. Selection LookupDispatchAction Example
;
Struts LookupDispatch Action... enables a user to collect related functions into a single action class...; LookupDispatch_Action which is a sub class <html:select> - Struts
, allowing Struts to figure out the form class from the
struts-config.xml file... with the action.
For example, the class attribute might be specified...struts i am new to struts.when i execute the following code i am
Need acode for struts implementation - Struts
Need acode for struts implementation I want a code to generate dynamic table with a text field and a drop down list and to retrieve that data in the action class and store in the data base | http://roseindia.net/tutorialhelp/comment/97303 | CC-MAIN-2014-41 | refinedweb | 926 | 58.28 |
NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Reading eeprom
Hi guys,
I have a strange problem.I'm making a device were you enter a password through a dip switch and then it saves it to the eeprom. The first step the program goes through is if you have the original password entered. But everytime I enter the original password I have to reset the uC to get to the next step. Heres my code. its a little messy though.
/*simple eeprom program. stores a byte in 2 locations. stores 10 in register 1 and stores 9 in 46.
*/
#define F_CPU 14745600
#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#include <avr/eeprom.h>
#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd.h"
#include "../libnerdkits/uart.h"(TIMER0_COMPA_vect) {
//
uint8_t a1;
uint8_t a2;
uint8_t a3;
uint8_t b1;
uint8_t b2;
uint8_t b3;
uint16_t origin_password;
uint16_t password;
uint16_t num;
num = eeprom_read_byte((uint8_t*)5);
the_time = 500; //countdown timer for password entry = 10seconds
sei();_line_one();
lcd_write_string(PSTR("Password Please?"));
origin_password = (a1<<6) + (a2<<5) + (a3<<4) + (b1<<3) + (b2<<2) + (b3<<1);
num = eeprom_read_byte((uint8_t*)5);
eeprom_write_byte ((uint8_t*) 6, origin_password);
// After this I have to reset. I want a transition from the Password Please? to Enter a new password so it saves the new password
while(1) {;
num = eeprom_read_byte((uint8_t*)5); //user entered passwrd prevously
if(origin_password == num){
// clear the display and move the cursor to row 1, column 1
lcd_home(); // move to 1, 1 without clearing the display
lcd_line_one();
lcd_write_string(PSTR("Enter new password!"));
fprintf_P(&lcd_stream, PSTR("%16.2f sec"), (double) the_time/100 );
if( the_time == 1){
lcd_clear_and_home(); // clear the display and move the cursor to row 1, column 1
// move to 1, 1 without clearing the display
lcd_line_three();
password = (a1<<6) + (a2<<5) + (a3<<4) + (b1<<3) + (b2<<2) + (b3<<1);
lcd_write_string(PSTR("Saving Password!"));
eeprom_write_byte ((uint8_t*) 5, password);
delay_ms(400);
lcd_clear_and_home();
lcd_line_four();
lcd_write_string(PSTR("Password Saved"));
lcd_clear_and_home;
}
}
}
return 0;
}
missle -
I haven't played around with reading/writing to the eeprom too much, but have you tried using the "eeprom_busy_wait()" function between lines 109 and 111? Since it takes some time to do read/writes, having them execute right after one another may cause a problem.
pcbolt,
Thanks for the suggestion. It still doesn't work though. I think I need a flag or something becuase I cannot go from the main to while loop for some reason. But if the password is right it quickly goes from Please enter password, and then it jumps to enter new password.
-Dan
Please log in to post a reply. | http://www.nerdkits.com/forum/thread/2350/ | CC-MAIN-2018-22 | refinedweb | 444 | 66.44 |
Heaps and priority queues are little-known but surprisingly useful data structures. For many problems that involve finding the best element in a dataset, they offer a solution that’s easy to use and highly effective. The Python
heapq module is part of the standard library. It implements all the low-level heap operations as well as some high-level common uses for heaps.
A priority queue is a powerful tool that can solve problems as varied as writing an email scheduler, finding the shortest path on a map, or merging log files. Programming is full of optimization problems in which the goal is to find the best element. Priority queues and the functions in the Python
heapq module can often help with that.
In this tutorial, you’ll learn:
- What heaps and priority queues are and how they relate to each other
- What kinds of problems can be solved using a heap
- How to use the Python
heapqmodule to solve those problems
This tutorial is for Pythonistas who are comfortable with lists, dicts, sets, and generators and are looking for more sophisticated data structures.
You can follow along with the examples in this tutorial by downloading the source code from the link below:
Get the Source Code: Click here to get the source code you’ll use to learn about the Python heapq module in this tutorial.
What Are Heaps?
Heaps are concrete data structures, whereas priority queues are abstract data structures. An abstract data structure determines the interface, while a concrete data structure defines the implementation.
Heaps are commonly used to implement priority queues. They’re the most popular concrete data structure for implementing the priority queue abstract data structure.
Concrete data structures also specify performance guarantees. Performance guarantees define the relationship between the size of the structure and the time operations take. Understanding those guarantees allows you to predict how much time the program will take as the size of its inputs change.
Data Structures, Heaps, and Priority Queues
Abstract data structures specify operations and the relationships between them. The priority queue abstract data structure, for example, supports three operations:
- is_empty checks whether the queue is empty.
- add_element adds an element to the queue.
- pop_element pops the element with the highest priority.
Priority queues are commonly used for optimizing task execution, in which the goal is to work on the task with the highest priority. After a task is completed, its priority is lowered, and it’s returned to the queue.
There are two different conventions for determining the priority of an element:
- The largest element has the highest priority.
- The smallest element has the highest priority.
These two conventions are equivalent because you can always reverse the effective order. For example, if your elements consist of numbers, then using negative numbers will flip the conventions around.
The Python
heapq module uses the second convention, which is generally the more common of the two. Under this convention, the smallest element has the highest priority. This might sound surprising, but it’s often quite useful. In the real-life examples you’ll see later, this convention will simplify your code.
Note: The Python
heapq module, and the heap data structure in general, is not designed to allow finding any element except the smallest one. For retrieval of any element by size, a better option is a binary search tree.
Concrete data structures implement the operations defined in an abstract data structure and further specify performance guarantees.
The heap implementation of the priority queue guarantees that both pushing (adding) and popping (removing) elements are logarithmic time operations. This means that the time it takes to do push and pop is proportional to the base-2 logarithm of the number of elements.
Logarithms grow slowly. The base-2 logarithm of fifteen is about four, while the base-2 logarithm of a trillion is about forty. This means that if an algorithm is fast enough on fifteen elements, then it’s going to be only ten times slower on a trillion elements and will probably still be fast enough.
In any discussion of performance, the biggest caveat is that these abstract considerations are less meaningful than actually measuring a concrete program and learning where the bottlenecks are. General performance guarantees are still important for making useful predictions about program behavior, but those predictions should be confirmed.
Implementation of Heaps
A heap implements a priority queue as a complete binary tree. In a binary tree, each node will have at most two children. In a complete binary tree, all levels except possibly the deepest one are full at all times. If the deepest level is incomplete, then it will have the nodes as far to the left as possible.
The completeness property means that the depth of the tree is the base-2 logarithm of the number of elements, rounded up. Here’s an example of a complete binary tree:
In this particular example, all levels are complete. Each node except for the deepest ones has exactly two children. There are a total of seven nodes in three levels. Three is the base-2 logarithm of seven, rounded up.
The single node at the base level is called the root node. It might seem weird to call the node at the top of the tree the root, but this is the common convention in programming and computer science.
The performance guarantees in a heap depend on how elements percolate up and down the tree. The practical result of this is that the number of comparisons in a heap is the base-2 logarithm of the size of the tree.
Note: Comparisons sometimes involve calling user-defined code using
.__lt__(). Calling user-defined methods in Python is a relatively slow operation compared with other operations done in a heap, so this will usually be the bottleneck.
In a heap tree, the value in a node is always smaller than both of its children. This is called the heap property. This is different from a binary search tree, in which only the left node will be smaller than the value of its parent.
The algorithms for both pushing and popping rely on temporarily violating the heap property, then fixing the heap property through comparisons and replacements up or down a single branch.
For example, to push an element onto a heap, Python adds the new node to the next open slot. If the bottom layer isn’t full, then the node is added to the next open slot at the bottom. Otherwise, a new level is created and then the element is added to the new bottom layer.
Once the node is added, Python compares it to its parent. If the heap property is violated, then the node and its parent are switched, and the check begins again at the parent. This continues until the heap property holds or the root has been reached.
Similarly, when popping the smallest element, Python knows that, because of the heap property, the element is at the root of the tree. It replaces the element with the last element at the deepest layer and then checks if the heap property is violated down the branch.
Uses of Priority Queues
A priority queue, and a heap as an implementation of a priority queue, is useful for programs that involve finding an element that is extreme in some way. For example, you can use a priority queue for any of the following tasks:
- Getting the three most popular blog posts from hit data
- Finding the fastest way to get from one point to the other
- Predicting which bus will be the first to arrive at a station based on arrival frequency
Another task for which you could use a priority queue is scheduling emails. Imagine a system that has several kinds of emails, each of which needs to be sent at a certain frequency. One kind of email needs to go out every fifteen minutes, and another needs to be sent every forty minutes.
A scheduler could add both types of email to the queue with a timestamp indicating when the email next needs to be sent. Then the scheduler could look at the element with the smallest timestamp—indicating that it’s next in line to be sent—and calculate how long to sleep before sending.
When the scheduler wakes up, it would process the relevant email, take the email out of the priority queue, calculate the next timestamp, and put the email back in the queue at the correct location.
Heaps as Lists in the Python
heapq Module
Although you saw the heap described earlier as a tree, it’s important to remember that it’s a complete binary tree. Completeness means that it’s always possible to tell how many elements are at each layer except the last one. Because of this, heaps can be implemented as a list. This is what the Python
heapq module does.
There are three rules that determine the relationship between the element at the index
k and its surrounding elements:
- Its first child is at
2*k + 1.
- Its second child is at
2*k + 2.
- Its parent is at
(k - 1) // 2.
Note: The
// symbol is the integer division operator. It always rounds down to an integer.
The rules above tell you how to visualize a list as a complete binary tree. Keep in mind that an element always has a parent, but some elements don’t have children. If
2*k is beyond the end of the list, then the element doesn’t have any children. If
2*k + 1 is a valid index but
2*k + 2 is not, then the element has only one child.
The heap property means that if
h is a heap, then the following will never be
False:
h[k] <= h[2*k + 1] and h[k] <= h[2*k + 2]
It might raise an
IndexError if any of the indices is beyond the length of the list, but it will never be
False.
In other words, an element must always be smaller than the elements that are at twice its index plus one and twice its index plus two.
Here’s a visual of a list that satisfies the heap property:
The arrows go from element
k to elements
2*k + 1 and
2*k + 2. For example, the first element in a Python list has the index
0, so its two arrows point at indices
1 and
2. Notice how the arrows always go from a smaller value to a bigger value. This is how you can check that the list satisfies the heap property.
Basic Operations
The Python
heapq module implements heap operations on lists. Unlike many other modules, it does not define a custom class. The Python
heapq module has functions that work on lists directly.
Usually, as in the email example above, elements will be inserted into a heap one by one, starting with an empty heap. However, if there’s already a list of elements that needs to be a heap, then the Python
heapq module includes
heapify() for turning a list into a valid heap.
The following code uses
heapify() to turn
a into a heap:
>>> import heapq >>> a = [3, 5, 1, 2, 6, 8, 7] >>> heapq.heapify(a) >>> a [1, 2, 3, 5, 6, 8, 7]
You can check that even though
7 comes after
8, the list
a still obeys the heap property. For example,
a[2], which is
3, is less than
a[2*2 + 2], which is
7.
As you can see,
heapify() modifies the list in place but doesn’t sort it. A heap doesn’t have to be sorted to satisfy the heap property. However, since every sorted list does satisfy the heap property, running
heapify() on a sorted list won’t change the order of elements in the list.
The other basic operations in the Python
heapq module assume that the list is already a heap. It’s useful to note that an empty list or a list of length one will always be a heap.
Since the root of the tree is the first element, you don’t need a dedicated function to read the smallest element nondestructively. The first element,
a[0], will always be the smallest element.
To pop the smallest element while preserving the heap property, the Python
heapq module defines
heappop().
Here’s how to use
heappop() to pop an element:
>>> import heapq >>> a = [1, 2, 3, 5, 6, 8, 7] >>> heapq.heappop(a) 1 >>> a [2, 5, 3, 7, 6, 8]
The function returns the first element,
1, and preserves the heap property on
a. For example,
a[1] is
5 and
a[1*2 + 2] is
6.
The Python
heapq module also includes
heappush() for pushing an element to the heap while preserving the heap property.
The following example shows pushing a value to a heap:
>>> import heapq >>> a = [2, 5, 3, 7, 6, 8] >>> heapq.heappush(a, 4) >>> a [2, 5, 3, 7, 6, 8, 4] >>> heapq.heappop(a) 2 >>> heapq.heappop(a) 3 >>> heapq.heappop(a) 4
After pushing
4 to the heap, you pop three elements from it. Since
2 and
3 were already in the heap and are smaller than
4, they’re popped first.
The Python
heapq module also defines two more operations:
heapreplace()is equivalent to
heappop()followed by
heappush().
heappushpop()is equivalent to
heappush()followed by
heappop().
These are useful in some algorithms since they’re more efficient than doing the two operations separately.
A High-Level Operation
Since priority queues are so often used to merge sorted sequences, the Python
heapq module has a ready-made function,
merge(), for using heaps to merge several iterables.
merge() assumes its input iterables are already sorted and returns an iterator, not a list.
As an example of using
merge(), here’s an implementation of the email scheduler described earlier:
import datetime import heapq def email(frequency, details): current = datetime.datetime.now() while True: current += frequency yield current, details fast_email = email(datetime.timedelta(minutes=15), "fast email") slow_email = email(datetime.timedelta(minutes=40), "slow email") unified = heapq.merge(fast_email, slow_email)
The inputs to
merge() in this example are infinite generators. The return value assigned to the variable
unified is also an infinite iterator. This iterator will yield the emails to be sent in the order of the future timestamps.
To debug and confirm that the code is merging correctly, you can print the first ten emails to be sent:
>>> for _ in range(10): ... print(next(element)) (datetime.datetime(2020, 4, 12, 21, 27, 20, 305358), 'fast email') (datetime.datetime(2020, 4, 12, 21, 42, 20, 305358), 'fast email') (datetime.datetime(2020, 4, 12, 21, 52, 20, 305360), 'slow email') (datetime.datetime(2020, 4, 12, 21, 57, 20, 305358), 'fast email') (datetime.datetime(2020, 4, 12, 22, 12, 20, 305358), 'fast email') (datetime.datetime(2020, 4, 12, 22, 27, 20, 305358), 'fast email') (datetime.datetime(2020, 4, 12, 22, 32, 20, 305360), 'slow email') (datetime.datetime(2020, 4, 12, 22, 42, 20, 305358), 'fast email') (datetime.datetime(2020, 4, 12, 22, 57, 20, 305358), 'fast email') (datetime.datetime(2020, 4, 12, 23, 12, 20, 305358), 'fast email')
Notice how the
fast email is scheduled every
15 minutes, the
slow email is scheduled every
40, and the emails are properly interleaved so that they’re arranged in the order of their timestamps.
merge() doesn’t read all the input, but rather it works dynamically. Even though both inputs are infinite iterators, printing the first ten items finishes quickly.
In a similar way, when used to merge sorted sequences like log file lines arranged by timestamp, even if the logs are big, this will take reasonable amounts of memory.
Problems Heaps Can Solve
As you saw above, heaps are good for incrementally merging sorted sequences. Two applications for heaps that you’ve already considered are scheduling periodic tasks and merging log files. However, there are many more applications.
Heaps can also help identify the top n or bottom n things. The Python
heapq module has high-level functions that implement this behavior.
For example, this code gets as input the times from the women’s 100 meters final at the 2016 Summer Olympics and prints the medalists, or top three finishers:
>>> import heapq >>>>> top_3 = heapq.nsmallest( ... 3, results.splitlines(), key=lambda x: float(x.split()[-1]) ... ) >>> print("\n".join(top_3)) Elaine Thompson 10.71 Tori Bowie 10.83 Marie-Josee Ta Lou 10.86
This code uses
nsmallest() from the Python
heapq module.
nsmallest() returns the smallest elements in an iterable and accepts three arguments:
nindicates how many elements to return.
iterableidentifies the elements or dataset to compare.
keyis a callable function that determines how elements are compared.
Here, the
key function splits the line by whitespace, takes the last element, and converts it to a floating-point number. This means the code will sort the lines by running time and return the three lines with the smallest running times. These correspond to the three fastest runners, which gives you the gold, silver, and bronze medal winners.
The Python
heapq module also includes
nlargest(), which has similar parameters and returns the largest elements. This would be useful if you wanted to get the medalists from the javelin throw competition, in which the goal is to throw the javelin as far as possible.
How to Identify Problems
A heap, as an implementation of a priority queue, is a good tool for solving problems that involve extremes, like the most or least of a given metric.
There are other words that indicate a heap might be useful:
- Largest
- Smallest
- Biggest
- Smallest
- Best
- Worst
- Top
- Bottom
- Maximum
- Minimum
- Optimal
Whenever a problem statement indicates that you’re looking for some extreme element, it’s worthwhile to think about whether a priority queue would be useful.
Sometimes the priority queue will be only part of the solution, and the rest will be some variant on dynamic programming. This is the case with the full example that you’ll see in the next section. Dynamic programming and priority queues are often useful together.
Example: Finding Paths
The following example serves as a realistic use case for the Python
heapq module. The example will use a classic algorithm that, as one part of it, requires a heap. You can download the source code used in the examples by clicking the link below:
Get the Source Code: Click here to get the source code you’ll use to learn about the Python heapq module in this tutorial.
Imagine a robot that needs to navigate a two-dimensional maze. The robot needs to go from the origin, positioned at the top-left corner, to the destination at the bottom-right corner. The robot has a map of the maze in its memory, so it can plan out the whole path before setting out.
The goal is to have the robot finish the maze as quickly as possible.
Our algorithm is a variant of Dijkstra’s algorithm. There are three data structures that are kept and updated throughout the algorithm:
tentativeis a map of a tentative path from the origin to a position,
pos. The path is called tentative because it’s the shortest known path, but it might be improved upon.
certainis set of points for which the path that
tentativemaps is certain to be the shortest possible path.
candidatesis a heap of positions that have a path. The sorting key of the heap is the length of the path.
At each step, you perform up to four actions:
Pop a candidate from
candidates.
Add the candidate to the
certainset. If the candidate is already a member of the
certainset, then skip next two actions.
Find the shortest known path to the current candidate.
For each of the current candidate’s immediate neighbors, see if going through the candidate gives a shorter path than the current
tentativepath. If so, then update the
tentativepath and the
candidatesheap with this new path.
The steps are run in a loop until the destination is added to the
certain set. When the destination is in the
certain set, you’re done. The output of the algorithm is the
tentative path to the destination, which is now
certain to be the shortest possible path.
Top-Level Code
Now that you understand the algorithm, it’s time to write code to implement it. Before implementing the algorithm itself, it’s useful to write some support code.
First, you need to import the Python
heapq module:
import heapq
You’ll use the functions from the Python
heapq module to maintain a heap that will help you find the position with the shortest known path at each iteration.
The next step is to define the map as a variable in the code:
map = """\ .......X.. .......X.. ....XXXX.. .......... .......... """
The map is a triple-quoted string that shows the area in which the robot can move as well as any obstacles.
Though a more realistic scenario would have you reading the map from a file, for teaching purposes it’s easier to define a variable in the code using this simple map. The code will work on any map, but it’s easier to understand and debug on a simple map.
This map is optimized to be easy to understand for a human reader of the code. The dot (
.) is light enough that it looks empty, but it has the advantage of showing the dimensions of the allowed area. The
X positions mark obstacles that the robot can’t go through.
Support Code
The first function will convert the map to something easier to parse in code.
parse_map() gets a map and analyzes it:
def parse_map(map): lines = map.splitlines() origin = 0, 0 destination = len(lines[-1]) - 1, len(lines) - 1 return lines, origin, destination
The function takes a map and returns a tuple of three elements:
- A list of
lines
- The
origin
- The
destination
This allows the rest of the code to work on data structures designed for computers, not for humans’ ability to visually scan.
The list of
lines can be indexed by
(x, y) coordinates. The expression
lines[y][x] returns the value of the position as one of two characters:
- A dot (
".") indicates the position is an empty space.
- The letter
"X"indicates the position is an obstacle.
This will be useful when you want to find which positions the robot can occupy.
The function
is_valid() calculates whether a given
(x, y) position is valid:
def is_valid(lines, position): x, y = position if not (0 <= y < len(lines) and 0 <= x < len(lines[y])): return False if lines[y][x] == "X": return False return True
This function takes two arguments:
linesis the map as a list of lines.
positionis the position to check as a two-tuple of integers indicating the
(x, y)coordinates.
To be valid, a position has to be inside the boundaries of the map and not an obstacle.
The function checks that
y is valid by checking the length of the
lines list. The function next checks that
x is valid by making sure it’s inside
lines[y]. Finally, now that you know both coordinates are inside the map, the code checks that they’re not an obstacle by looking at the character in this position and comparing the character to
"X".
Another useful helper is
get_neighbors(), which finds all the neighbors of a position:
def get_neighbors(lines, current): x, y = current for dx in [-1, 0, 1]: for dy in [-1, 0, 1]: if dx == 0 and dy == 0: continue position = x + dx, y + dy if is_valid(lines, position): yield position
The function returns all the valid positions surrounding the current position.
get_neighbors() is careful to avoid identifying a position as its own neighbor, but it does allow diagonal neighbors. This is why at least one of
dx and
dy must not be zero, but it’s okay for both of them to be non-zero.
The final helper function is
get_shorter_paths(), which finds shorter paths:
def get_shorter_paths(tentative, positions, through): path = tentative[through] + [through] for position in positions: if position in tentative and len(tentative[position]) <= len(path): continue yield position, path
get_shorter_paths() yields positions for which the path that has
through as its last step is shorter than the current known path.
get_shorter_paths() has three parameters:
tentativeis a dictionary mapping a position to the shortest known path.
positionsis an iterable of positions to which you want to shorten the path.
throughis the position through which, perhaps, a shorter path to the
positionscan be found.
The assumption is that all elements in
positions can be reached in one step from
through.
The function
get_shorter_paths() checks if using
through as the last step will make a better path for each position. If there’s no known path to a position, then any path is shorter. If there is a known path, then you only yield the new path if its length is shorter. In order to make the API of
get_shorter_paths() easier to use, part of the
yield is also the shorter path.
All helper functions were written to be pure functions, meaning they don’t modify any data structures and only return values. This makes it easier to follow the core algorithm, which does all the data structure updates.
Core Algorithm Code
To recap, you’re looking for the shortest path between the origin and the destination.
You keep three pieces of data:
certainis the set of certain positions.
candidatesis the heap of candidates.
tentativeis a dictionary mapping nodes to the current shortest known path.
A position is in
certain if you can be certain that the shortest known path is the shortest possible path. If the destination is in the
certain set, then the shortest known path to the destination is unquestionably the shortest possible path, and you can return this path.
The heap of
candidates is organized by the length of the shortest known path and is managed with the help of the functions in the Python
heapq module.
At each step, you look at the candidate with the shortest known path. This is where the heap is being popped with
heappop(). There is no shorter path to this candidate—all other paths go through some other node in
candidates, and all of these are longer. Because of that, the current candidate can be marked
certain.
You then look at all neighbors that have not been visited, and if going through the current node is an improvement, then you add them to the
candidates heap using
heappush().
The function
find_path() implements this algorithm:
1def find_path(map): 2 lines, origin, destination = parse_map(map) 3 tentative = {origin: []} 4 candidates = [(0, origin)] 5 certain = set() 6 while destination not in certain and len(candidates) > 0: 7 _ignored, current = heapq.heappop(candidates) 8 if current in certain: 9 continue 10 certain.add(current) 11 neighbors = set(get_neighbors(lines, current)) - certain 12 shorter = get_shorter_paths(tentative, neighbors, current) 13 for neighbor, path in shorter: 14 tentative[neighbor] = path 15 heapq.heappush(candidates, (len(path), neighbor)) 16 if destination in tentative: 17 return tentative[destination] + [destination] 18 else: 19 raise ValueError("no path")
find_path() receives a
map as a string and returns the path from the origin to the destination as a list of positions.
This function is a little long and complicated, so let’s walk through it one bit at a time:
Lines 2 through 5 set up the variables that the loop will look at and update. You already know a path from the origin to itself, which is the empty path, of length 0.
Line 6 defines the loop’s termination condition. If there are no
candidates, then no paths can be shortened. If
destinationis in
certain, then the path to
destinationcan’t be made shorter.
Lines 7 through 10 get a candidate using
heappop(), skip the loop if it’s already in
certain, and otherwise add the candidate to
certain. This makes sure every candidate will be processed by the loop at most once.
Lines 11 through 15 use
get_neighbors()and
get_shorter_paths()to find shorter paths to neighboring positions and update the
tentativedictionary and
candidatesheap.
Lines 16 through 19 deal with returning the correct result. If a path was found, then the function will return it. Although computing the paths without the final position made implementing the algorithm simpler, it’s a nicer API to return it with the destination. If no path is found, then an exception is raised.
Breaking the function into separate sections lets you understand it one part at a time.
Visualization Code
If the algorithm was actually used by a robot, then the robot would probably perform better with a list of positions that it should travel through. However, to make the result better looking to humans, it would be nicer to visualize them.
show_path() draws a path on a map:
def show_path(path, map): lines = map.splitlines() for x, y in path: lines[y] = lines[y][:x] + "@" + lines[y][x + 1 :] return "\n".join(lines) + "\n"
The function takes the
path and
map as parameters. It returns a new map with the path indicated by the at symbol (
"@").
Running the Code
Finally, you need to call the functions. This can be done from the Python interactive interpreter.
The following code will run the algorithm and show a pretty output:
>>> path = find_path(map) >>> print(show_path(path, map)) @@.....X.. ..@....X.. ...@XXXX.. ....@@@@@. .........@
First you get the shortest path from
find_path(). Then you pass it to
show_path() to render a map with the path marked on it. Finally, you
print() the map to the standard output.
The path moves one step to the right, then a few diagonal steps toward the bottom-right, then several more steps to the right, and it finally finishes with a diagonal step to the bottom-right.
Congratulations! You’ve solved a problem using the Python
heapq module.
These kinds of pathfinding problems, solvable by a combination of dynamic programming and priority queues, are common in job interviews and programming challenges. For example, the 2019 Advent of Code included a problem that could be solved with the techniques described here.
Conclusion
You now know what the heap and priority queue data structures are and what kinds of problems they’re useful in solving. You learned how to use the Python
heapq module to use Python lists as heaps. You also learned how to use the high-level operations in the Python
heapq module, like
merge(), which use a heap internally.
In this tutorial, you’ve learned how to:
- Use the low-level functions in the Python
heapqmodule to solve problems that need a heap or a priority queue
- Use the high-level functions in the Python
heapqmodule for merging sorted iterables or finding the largest or smallest elements in an iterable
- Recognize problems that heaps and priority queues can help solve
- Predict the performance of code that uses heaps
With your knowledge of heaps and the Python
heapq module, you can now solve many problems in which the solution depends on finding the smallest or largest element. To follow along with the examples you saw in this tutorial, you can download the source code from the link below:
Get the Source Code: Click here to get the source code you’ll use to learn about the Python heapq module in this tutorial. | https://realpython.com/python-heapq-module/ | CC-MAIN-2021-17 | refinedweb | 5,241 | 61.77 |
Playing with Jenkins RCE Vulnerability.
Overview
Exploit Background
Jenkins has a Pipeline feature which is implemented in Groovy. The exploit author discovered that the user issue an unauthenticated GET request to provide Groovy Meta-Programming input. In this input, the attacker can use the
@Grab annotation to invoke Grape, the built-in JAR dependency management tool for Groovy, and have it download a jar and run it. The write-up goes into much more detail if you want more background.
Target Host: Jeeves
I’m going to be testing on Jeeves, from HackTheBox.eu. This is a good place to start because it’s already set up with Jenkins installed. The web interface for Jenkins is available on port 50000, at.
Jeeves is not perfect. This host has authentication turned off for Jenkins. This box was in fact easily solved by just by visiting the Script Console and running Groovy script there. Still, I’ll see if I can get execution going using the path provided, and trusting that even without auth, I would have access.
I will also have to update the payload for a Windows target.
Exploiting
Invoking Grape
If the point of the exploit is to create a GET request that gets Jenkins to connect back to my machine and request the jar file, that seems like a good place to start. In the POC video, they show visiting
/securityRealm/user/admin and getting back a page about the admin, even without auth. I can reproduce that by visiting:
Now I’ll visit the workflow plugin’s checkScriptCompile API endpoint with some Groovy that should use the
@Grab meta annotation to request the jar from me. I’ll start a
python3 -m http.server 80 and visit:;
In that url, I provide a
value parameter which is the Groovy script to run. It uses
%0A for newlines. Here’s how that script looks unencoded:
@GrabConfig(disableChecksums=true) @GrabResolver(name='orange.tw', root='') @Grab(group='tw.orange', module='poc', version='1') import Orange;
It defines the parameters for the ‘orange.tw’ package, including where to get it, and then invokes
@Grab to fetch it.
On visiting the url, I do see activity on my web server:
root@kali# python3 -m http.server 80 Serving HTTP on 0.0.0.0 port 80 () ... 10.10.10.63 - - [27/Feb/2019 11:07:18] code 404, message File not found 10.10.10.63 - - [27/Feb/2019 11:07:18] "HEAD /tw/orange/poc/1/poc-1.pom HTTP/1.1" 404 - 10.10.10.63 - - [27/Feb/2019 11:07:19] code 404, message File not found 10.10.10.63 - - [27/Feb/2019 11:07:19] "HEAD /tw/orange/poc/1/poc-1.jar HTTP/1.1" 404 -
Very cool! It tried to download a pom file, and when that failed, went for
poc-1.jar. That matches the
module and the
version from the url. I can change module to “0xdf” and version to “223” in the url and see that reflected:
10.10.10.63 - - [27/Feb/2019 11:34:35] code 404, message File not found 10.10.10.63 - - [27/Feb/2019 11:34:35] "HEAD /tw/orange/0xdf/223/0xdf-223.pom HTTP/1.1" 404 - 10.10.10.63 - - [27/Feb/2019 11:34:36] code 404, message File not found 10.10.10.63 - - [27/Feb/2019 11:34:36] "HEAD /tw/orange/0xdf/223/0xdf-223.jar HTTP/1.1" 404 -
The web browser is showing a big error message that it can’t resolve the dependency:
Building a Jar Payload
The blog gives an example payload that looks like this:
public class Orange { public Orange(){ try { String payload = "curl orange.tw/bc.pl | perl -"; String[] cmds = {"/bin/bash", "-c", payload}; java.lang.Runtime.getRuntime().exec(cmds); } catch (Exception e) { } } }
I can clearly see that it will exec
/bin/bash -c curl orange.tw/bc.pl | perl -. I can assume that
bc.pl is a reverse shell.
This will have to be modified for a Windows target. I’ll have it run PowerShell to get and Invoke a Nishang shell:
public class Orange { public Orange(){ try { String payload = "powershell iex(new-object net.webclient).downloadstring('')"; String[] cmds = {"cmd", "/c", payload}; java.lang.Runtime.getRuntime().exec(cmds); } catch (Exception e) { } } }
Now I’ll build that into a jar. Compile the java:
root@kali# javac Orange.java
Make the appropriate metadata:
root@kali# mkdir -p META-INF/services/ root@kali# echo Orange > META-INF/services/org.codehaus.groovy.plugins.Runners root@kali# find . ./Orange.java ./Orange.class ./META-INF ./META-INF/services ./META-INF/services/org.codehaus.groovy.plugins.Runners
Bundle it into a jar:
root@kali# jar cvf 0xdf-223%)
Stage Payloads
Next I’ll move the jar into the path expected by the GET request:
root@kali# mkdir -p tw/orange/0xdf/223/ root@kali# mv 0xdf-223.jar tw/orange/0xdf/223/
I’ll also get a copy of
Invoke-PowerShellTcp.ps1 and named it
shell.ps1 to match what’s in the jar:
root@kali# cp /opt/nishang/Shells/Invoke-PowerShellTcp.ps1 shell.ps1
Then I’ll grab the example line and paste it at the end of the file, with my IP/port information:
root@kali# tail -1 shell.ps1 Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.21 -Port 443
Now the PowerShell will request this file, and execute it loading all of the functions into the PowerShell session, and then Invoking the one that creates a shell connection back to me.
Exploit
I’ll open a
nc listener on port 443. Now I just need to visit the url again. On refresh, I first see activity in the web server, the requet for the jar file followed 6 seconds later by the request for
shell.ps1:
10.10.10.63 - - [27/Feb/2019 12:15:36] "HEAD /tw/orange/0xdf/223/0xdf-223.pom HTTP/1.1" 404 - 10.10.10.63 - - [27/Feb/2019 12:15:36] "HEAD /tw/orange/0xdf/223/0xdf-223.jar HTTP/1.1" 200 - 10.10.10.63 - - [27/Feb/2019 12:15:37] "GET /tw/orange/0xdf/223/0xdf-223.jar HTTP/1.1" 200 - 10.10.10.63 - - [27/Feb/2019 12:15:43] "GET /shell.ps1 HTTP/1.1" 200 -
Shortly after that, I get a connection on
nc, and I have a shell:
root@kali# nc -lnvp 443 Ncat: Version 7.70 ( ) Ncat: Listening on :::443 Ncat: Listening on 0.0.0.0:443 Ncat: Connection from 10.10.10.63. Ncat: Connection from 10.10.10.63:49680. Windows PowerShell running as user kohsuke on JEEVES Copyright (C) 2015 Microsoft Corporation. All rights reserved. PS C:\Users\Administrator\.jenkins>whoami jeeves\kohsuke
Troubleshooting
Java Version
The first time I tried this, after Jenkins downloaded my jar file, I got the following error message in the web browser:
java.lang.UnsupportedClassVersionError: Orange has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Basically, I compiled the class file using a later version of java, and it can’t understand it.
According to the Wikipedia page on Java Class Files, version 55 is Java SE 11, and 52 is Java SE 8.
I installed Java 8 on my computer with
root@kali# apt install openjdk-8-jdk
Then I used
update-alternatives to select the right version for now:
root@kali# update-alternatives --config javac There are 4 choices for the alternative javac (providing /usr/bin/javac). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/javac 1111 auto mode * 1 /opt/jdk-11.0.2/bin/javac 1 manual mode 2 /usr/lib/jvm/java-10-openjdk-amd64/bin/javac 1101 manual mode 3 /usr/lib/jvm/java-11-openjdk-amd64/bin/javac 1111 manual mode 4 /usr/lib/jvm/java-8-openjdk-amd64/bin/javac 1081 manual mode Press <enter> to keep the current choice[*], or type selection number: 4 update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/javac to provide /usr/bin/javac (javac) in manual mode
Then I recompiled and re-made my jar, and it worked!
Updating the Jar
If I mess up something in the jar file, I can’t just update it locally and refresh. When I do that, Grape thinks the correct module is already there, and doesn’t go to re-fetch it. Obviously I can reset the box at this point to start over. But I can also rebuild it with the next version number.
For example, if I uploaded with a version of java that isn’t compatible with the box, I can recompile that locally, rebuild the jar, and everything else using version 224 instead of 223. I’ll need a new directory and filename for the jar:
root@kali# javac Orange.java root@kali# jar cvf 0xdf-224%) root@kali# mkdir tw/orange/0xdf/224 root@kali# cp 0xdf-224.jar tw/orange/0xdf/224/
Now I update the version in the url and refresh, and I get a shell. | https://0xdf.gitlab.io/2019/02/27/playing-with-jenkins-rce-vulnerability.html | CC-MAIN-2022-40 | refinedweb | 1,535 | 66.84 |
language mapping document.
Emitting Client and Server BindingsTo generate Java bindings for an IDL file named My.idl:
idlj My.idlThis generates the client-side bindings and is equivalent to:
idlj -fclient My.idlThe client-side bindings do not include the server-side skeleton. If you want to generate the server-side bindings for the interfaces:
idlj -fserver My.idlServer-side bindings include the client-side bindings plus the skeleton, all of which are My.idl included another idl file, MyOther.idl, the compiler assumes that MyOther.idl resides in the local directory. If it resides in /includes, for example, then you would invoke the compiler with the following command:
idlj -i /includes My.idlIf My.idl also included Another.idl that resided in /moreIncludes, for example, then you would invoke the compiler with the following command:
idlj -i /includes -i /moreIncludes My.idlSince. Inside of idl.config, provide a line with the following form:
includes=/includes;/moreIncludesThe compiler will find this file and read in the includes list. Note that in this example the separator character between the two directories is a semicolon (;). This separator character is platform dependent. On NT it is a semicolon, on AIX it is a colon, etc.
Emitting Bindings for Include FilesBy default, only those interfaces, structs, etc, that are defined in the idl file on the command line have Java bindings generated for them. The types defined in included files are not generated. For example, assume the following two idl files:
My.idl
#include <MyOther.idl>The following command will only generate the java bindings for My:
interface My
{
};
MyOther.idl
interface MyOther
{
};
idlj My.idlTo generate all of the types in My.idl and all of the types in the files that My.idl includes (in this example, MyOther.idl), use the following command:
idlj -emitAll My.idlThere:
My.idl
#include <MyOther.idl>
interface My
{
#include <Embedded.idl>
};
MyOther.idl
interface MyOther
{
};
Embedded.idl
enum E {one, two, three};Running the following command:
idlj My.idlwill generate the following list of Java files:
./MyHolder.javaNotice).
./MyHelper.java
./_MyStub.java
./MyPackage
./MyPackage/EHolder.java
./MyPackage/EHelper.java
./MyPackage/E.java
./My.java
If the -emitAll flag had been used in the previous example, then all types in all included files would be emitted.
Inserting Package PrefixesSuppose that you work for a company named ABC that has constructed the following IDL file::
Widgets.idl
module Widgets
{
interface W1 {...};
interface W2 {...};
};
idlj -pkgPrefix Widgets com.abc Widgets.idlIf the Java binding files already exist, the -keep flag will keep the compiler from overwriting them. The default is to generate all files without considering if they already exist. If you've customized those files (which you should not do unless you are very comfortable with their contents), then the -keep option is very useful. The command
idlj -keep My.idlemit all client-side bindings that do not already exist.
To display the build version of the IDL-to-Java compiler, specify the -version option on the command-line:
idlj -version
Version information also appears within the bindings generated by the compiler. Any additional options appearing on the command-line are ignored.
See the Description section for more option information.See the Description section for more option information.
- -d symbol
- This is equivalent to the following line in an IDL file:#define symbol
- -emitAll
- Emit all types, including those found in
#includefiles.
- -fside
- Defines what bindings to emit. side is one of client, server, serverTIE, all, or allTIE..
- -Joption
- Pass option to the Java virtual machine, where option is one of the options described on the reference page for the java application launcher. For example, -J-Xms48m sets the startup memory to 48 megabytes.
interface t { const long foo = 1; attribute long foo; };
interface A { struct S { short s; }; }; interface B:A { typedef S new_S; exception ex {S f1;}; // Error for "S" here }; | http://java.sun.com/j2se/1.3/docs/guide/rmi-iiop/toJavaPortableUG.html | crawl-002 | refinedweb | 646 | 60.01 |
Who locked that file?
I can't even imagine how many times I've heard someone complain about a locked file. Sometimes it's simple - the call goes out "Who has record 758 open?" or something like that, and sure enough, Bill forgot he was working on that, closes it out and all is well. But other times it is not simple, and a system admin has to track down who is doing what.
Note that in this post we're talking about real locking - not a volume that can't be ejected (Mac speak) or a file system that can't be unmounted (the rest of us). For that, just use "lsof" to find out what process is stopping you.
I had a customer call today with the locking problem: "How can we tell if a user has a lock on a file in our application?". I immediately thought of "lsof", because the man page says it should display locking information. It does so on several Linux systems I tested, but does not show that on my Mac.
For testing purposes, we'll need something that locks a file. This very simple C program does that. Note that there is no error checking at all here; it just assumes success on everything. Be sure to "touch mylockedfile" before using this.
#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <stdio.h> main() { int fd; struct flock lock; lock.l_type=F_WRLCK; lock.l_start=0; lock.l_whence=0; lock.l_len=2; fd=open("mylockedfile", O_WRONLY,S_IWUSR ); printf("%d\n",fcntl(fd,F_SETLK,&lock)); getchar(); }
All that does is apply a lock to a few bytes of "mylocked" file. It sits and waits for you to press enter, and then teminates. Locks are removed upon process termination, so pressing enter ends everything cleanly.
If you called that program "makelock.c", then "make makelock" should compile it and "touch mylockedfile;./makelock" should set it running. You should see this:
open 3 lock 0
If you saw "-1" for either of those, something did not work, and I'm not going to take the space here to try to help you figure out what you did wrong - probably permissions.
In another screen, type "lsof mylockedfile". On a Linux system, you should see something like this:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME makelock 6386 tonyl 3ww REG 3,2 0 2785316 mylockedfile
It's the extra "w" that indicates the lock. If you simply had the file open, there would only be one "w". OK, that's nice, and it certainly wouldn't be hard to wrap a shell script around lsof to find the offending user. But unfortunately, on Mac OS X Leopard, lsof can't seem to spot the lock:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME makelock 3331 apl 3w REG 14,2 0 9714583 mylockedfile
That doesn't help. And if we don't have root access, "lsof" won't help anyway.
Fortunately it's easy to write a little C program that tests for other processes locking files. Again, this program has no error checking; you'd want to dress it up much more for a production tool, but the raw basics are this:
#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <stdio.h> main() { int fd; struct flock lock; lock.l_type=F_WRLCK; lock.l_start=0; lock.l_whence=0; lock.l_len=0; printf("open %d\n",fd=open("mylockedfile", O_RDONLY )); printf("lock %d\n",fcntl(fd,F_GETLK,&lock)); if (lock.l_type == F_UNLCK) { printf("%d\n",0); return(0); } printf("%d\n",lock.l_pid); return(lock.l_pid); }
With "makelock" running, type "make testlock && ./testlock" and it should return the process id of "makelock".
This "testlock" tries to lock the entire file. If you modified it so that it had "lock.l_start=3;" and recompiled it, it would report 0, meaning no lock (because "makelock" only locks the first two bytes).
So, if you can use "lsof" in a shell script, that's an easy way to find the responsible PID, but if you can't, something like this certainly can. By the way, on Linux, there's also /proc/locks, which does show all file locks, but you'd need to grep inode numbers from it:
1: POSIX ADVISORY WRITE 6641 03:02:4014117 0 1 d7693680 c0281850 d76934b8 00000000 d769368c
The "6641" after "WRITE is the PID, and the "4014117" is the inode. That's a bit more difficult than using "lsof" or this program, but everything you need is there. The "03:02" is the major-device:minor-device of the partition that has the file (/dev/hda2 in this case), the rest of it has to do with the region locked, which you probably don't care about for this purpose.
If you didn't understand any of this, I suggest you read at least Writing and Compiling C programs on Linux. If you think I just plucked those programs out of thin air and my prodigious memory, well, that's pretty funny, but really I did what I always do: cracked open my copy of Steven's Advanced Programming in the Unix Environment and cribbed what I needed.
Got something to add? Send me email.
(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version
Increase ad revenue 50-250% with Ezoic
Inexpensive and informative Apple related e-books:
Take Control of Preview
Take Control of iCloud
El Capitan: A Take Control Crash Course
Yosemite Crash Course
Take Control of the Mac Command Line with Terminal, Second Edition
More Articles by Anthony Lawrence
Find me on Google+
© 2012-07-15 Anthony Lawrence
Thu Nov 15 15:29:16 2007: 3258 BigDumbDinosaur
If you think I just plucked those programs out of thin air and my prodigious memory, well, that's pretty funny...
What? You mean you didn't? You're supposed to remember everything there is to know about computers.
...but really I did what I always do: cracked open my copy of Steven's Advanced Programming in the Unix Environment and cribbed what I needed.
Steven's book is ancient by computer standards (anything more than one year old is ancient these days) but is still one of the best ever written. My copy has gone well beyond the dog-eared state and now looks as though the dog has been chewing on it.
------------------------
Printer Friendly Version
Who locked that file? Copyright © November | http://aplawrence.com/Unixart/who_locked_file.html | CC-MAIN-2017-30 | refinedweb | 1,084 | 72.26 |
On Fri, Feb 04, 2000 at 11:10:05PM +0000, mdvorak at ninell.cz wrote: > My idea is that each component will sit in > a module and there will be some functions which > will take care of starting the module and performing > clean up upon exit. > But the problem is there is no way to force Python to > delete module together with all variables/functions > which exist in its global namespace - that is > I cannot perform any clean up. Upon exit I would > have to go through all global objects and delete > them explicitly, but I cannot do this, because > throughout the application one module can be > started multiple times and each time it has to > run like it was started for the first time. There is no guaranteed automatic way to make Python delete something. The only way to 'delete' something is to remove all references to it, and make the refcounter (or garbage collector, in Java) delete the object. But it sounds to me like you are trying to use the wrong tool for the wrong task -- modules only get executed once, upon the first load time. The top level of a module is intended to run just once in it's lifetime, not every time you wish to reset the data to the starting point. To do what you want, either work with functioncalls to reset the module to its initial state, or just use objects. Using objects is probably the best method, as it groups data, methods and state in one easy-to-use package ;) So you can do either: module.py: ----- var = SomeState def reset(): global var var = SomeState def do_something_with_var(): ... ----- and manually call reset() when you wish to reset the data, or: module.py: ----- class Module: def __init__(self): self.var = SomeState def do_something_with_var(self): ... ----- If you then wish to reset to the initial state, just create a new module.Module object. Regards, -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread! | https://mail.python.org/pipermail/python-list/2000-February/054507.html | CC-MAIN-2019-51 | refinedweb | 341 | 70.02 |
I have a function that takes two filenames, and reads the contents of those two files into
Strings, and then returns if they match or not. Here's the function:
f :: String -> String -> IO Bool f fileName1 fileName2 = do str1 <- readFile fileName1 str2 <- readFile fileName2 return (str1 == str2)
And if I use it like this from inside
main:
main = do res <- f "A.txt" "B.txt" print res
It works and prints either
True or
False. What I want to do is, apply this function
f to a list (of tuples) of filenames. For something like:
[("a.txt", "b.txt"), ("c.txt", "d.txt")]
(Assume that
a.txt and
b.txt have the same content and
c.txt and
d.txt are different).
I want to transform it (the list of file names) into a
Bool list like:
[True, False]. I tried using
mapM, but that doesn't appear to map anything (when I print the list after using
mapM, it prints the same list of tuples).
So my question is: What am I doing wrong, and how can I get a list of
Bools like I mentioned above?
Please go easy on me as I'm still quite new to Haskell and functional programming :)
Here is a function
f' which does what you describe.
f' :: [(String,String)] -> IO [Bool] f' = mapM $ uncurry f
Let me know if something is unclear! And, just to be clear, here is how you run it:
main = do res <- f' [("a.txt", "b.txt"), ("c.txt", "d.txt")] print res
The function is in pointfree form, so it is equivalent to
f' lst = mapM (uncurry f) lst.
mapM essentially maps each element of
lst using
f as the function, and pushes the
IO to the outside of the list.
uncurry just takes a function of the form
a -> b -> c and transforms it into one
(a,b) -> c, which is what we want since you have a list of tuples. | http://databasefaq.com/index.php/answer/15405/list-haskell-io-mapping-with-io-actions-in-haskell | CC-MAIN-2018-39 | refinedweb | 326 | 88.87 |
: John Francis Lee
> Sent: Monday, September 21, 2009 3:35:15 AM
[snip]
> jfl@...:~/tmp$ rst2odt.py test.rst test.odt
> Traceback (most recent call last):
> File "/usr/local/bin/rst2odt.py", line 18, in <module>
> from docutils.core import publish_cmdline_to_binary, default_description
> ImportError: cannot import name publish_cmdline_to_binary
This traceback error message is telling you that it cannot find
publish_cmdline_to_binary in the file docutils/core.py.
Perhaps it's *not* looking in the version that you installed from
SVN. Is there another version somewhere?
Here is what you can do:
1. Look in the file docutils/core.py that you downloaded from SVN.
Make sure that publish_cmdline_to_binary is defined in that
file.
2. Find out where that module was installed. Make sure that it is
the same file.
3. Make sure that the newly installed file is the one being
imported. In order to find out where Python is looking for that
file, try, for example, the following::
~ [6] python
Python 2.6.2 (r262:71600, Apr 27 2009, 13:32:04)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from docutils.core import publish_cmdline_to_binary
>>> from docutils import core
>>> core
<module 'docutils.core' from '/usr/local/lib/python2.6/site-packages/docutils/core.pyc'>
>>>
In order to find out where Python is looking for modules to be
imported, do this::
>>> import sys
>>> sys.path
> jfl@...:~/tmp$ man rst2odt.py
> No manual entry for rst2odt.py
>
Documentation of the odf_odt writer is here:
- Dave K
--
Dave Kuhlman
On Sun, Sep 20, 2009 at 09:38, John Francis Lee <jfl@...> wrote:
> I just this afternoon found this reply to my earlier posting. I tried
> the svn build to no effect.
It sounds like you may have multiple versions of Docutils installed.
Just to be sure, please tell us the version of Docutils you're using,
as reported by Docutils itself. Like this ("$" is the shell prompt,
don't type it):
$ rst2odt.py --version
Also, tell us your $PYTHONPATH environment variable, and report the
output from this:
$ python
>>> import docutils
>>> docutils
Where did you install the Docutils snapshot (from SVN)?
--
David Goodger <>
> From: John Francis Lee <jfl@...>
> To: Docutils-users@...
> Sent: Sunday, September 20, 2009 6:38:55 AM
> Subject: [Docutils-users] trouble with rst2odt, still
>
[snip]
>
> I just this afternoon found this reply to my earlier posting. I tried
> the svn build to no effect.
>
> jfl@...:~/tmp$ rst2odt test.rst test.odtTraceback (most recent call last):
> File "/usr/bin/rst2odt", line 21, in
> from docutils.writers.odtwriter import Writer
> ImportError: No module named odtwriter
>
A couple of points:
1. The name of the file is rst2odt.py (not rst2odt). Is it
possible that rst2odt is left over from a previous install? Did
the install from SVN install rst2odt.py? If so, use that
instead.
2. In rst2odt.py the relevant import line (line 19) is::
from docutils.writers.odf_odt import Writer, Reader
which is different from the line reported in your traceback.
So, I'm guessing you need to be using rst2odt.py (not rst2odt).
You can find rst2odt.py in the SVN download at::
docutils/tools/rst2odt.py
Perhaps you could check to see if it is really the one you are
executing.
Hope this helps.
- Dave K
--
Dave Kuhlman
I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details | https://sourceforge.net/p/docutils/mailman/docutils-users/?viewmonth=200909&viewday=21 | CC-MAIN-2017-34 | refinedweb | 588 | 69.48 |
Assigning SOA randomly without repetition with Inline Script
edited May 2016 in OpenSesame
Hi Everyone!
I'm trying to run a loop of 105 Prime-Target stimuli while each Prime-Target pair will be called randomly and will be assigned with a random SOA from 105 SOAs list. I'm having a problem with the SOAs assigning.
Before the Prime-Target loop, I set in Inline_Script the variables as follow:
import random self.experiment.set("ChooseSOA",0) ChooseSOA=[100 for i in range(50)]+[200 for i in range(55)] random.shuffle(ChooseSOA)
Then, in the sequence running in the loop I wrote:
self.experiment.set("SOA", self.experiment.get(ChooseSOA.pop()))
Then, I added a sketchpad with the duration "SOA".
when I'm running the experiment, the OpenSesame says:'int' object has no attribute 'pop'
Help? Anyone?
Hi S_H,
Using print in inline script might give you some insight in a situation like this.
will print '0'
will print your list [100, 100, 100, 200, etc. ]
Basically you use both a local and a global variable ChooseSOA. You could make this work by filling the global variable ChooseSOA with you local list instead of '0' like this:
Another thing; instead of
you want to use
because you are trying to pop a value from list self.experiment.get('ChooseSOA')
And last but not least if you are using OpenSesame 3 you want to be using the var object
Hope this helps and please correct me if I'm wrong,
Jarik
Dear Jarik!
Thank you very much for your kind answer!
I rewrote my code according to your detailed suggestions and now I'm having: "'unicode' object has no attribute 'pop'".
I used
printin order to spot the problem. at the end of the first script I wrote
print(len(ChooseSOA))and the length was 105, as it should be. at the beginning of the second script(before setting "SOA") I wrote
print(len(self.experiment.get("ChooseSOA")))and it oddly printed 616.
Do you have any idea what am I doing wrong now?
(btw, I am using version 2.8.7 and I'm not able to update it at the moment...)
Thanks!
Couldn't find 2.8.7 so I used 2.9.7 to test:
I think you will be OK using the local variable ChooseSOA because all inline_script items share the same workspace:
Note you will have to do
after the shuffle if you want to be able to log the complete ChooseSOA list with the logger item! | https://forum.cogsci.nl/discussion/2132/assigning-soa-randomly-without-repetition-with-inline-script | CC-MAIN-2019-26 | refinedweb | 422 | 73.17 |
Opened 7 years ago
Closed 7 years ago
#2735 closed defect (worksforme)
The status and summary of a wrong ticket is applied.
Description
The patch to ticket/web_ui.py is wrong. Maybe below is correct, isn't it?
near line 601:
if rtype == "ticket": t = Ticket(self.env, rid) ref.update({ "shortname': '#%i' % rid, 'summary': t['summary'], 'closed': t['status'] == 'closed' })
Attachments (0)
Change History (4)
comment:1 Changed 7 years ago by ghama
- Cc ghama added; anonymous removed
comment:2 follow-up: ↓ 3 Changed 7 years ago by ghama
comment:3 in reply to: ↑ 2 Changed 7 years ago by ghama
and, import of Ticket is also needed
from trac.ticket import Ticket
comment:4 Changed 7 years ago by nferchen
- Resolution set to worksforme
- Status changed from new to closed
Hallo Ghama, I could not follow your changes. The line numbers does not match with the 0.10.4 (last stable in 0.10). You mixed up quote and double-quote for the string "shortname'. The import of Ticket was done in line 26. Please give me further information about the patch you tried.
Note: See TracTickets for help on using tickets.
one more modification needed in wiki/web_ui.py
near line 519: | http://trac-hacks.org/ticket/2735 | CC-MAIN-2015-11 | refinedweb | 205 | 76.62 |
DescribeAlarmsForMetric
Retrieves the alarms for the specified metric. To filter the results, specify a statistic, period, or unit.
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
- Dimensions.member.N
The dimensions associated with the metric. If the metric has any associated dimensions, you must specify them in order for the call to succeed.
Type: Array of Dimension objects
Array Members: Maximum number of 10 items.
Required: No
- ExtendedStatistic
The percentile statistic for the metric. Specify a value between p0.0 and p100.
Type: String
Pattern:
p(\d{1,2}(\.\d{0,2})?|100)
Required: No
- MetricName
The name of the metric.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 255.
Required: Yes
- Namespace
The namespace of the metric.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 255.
Pattern:
[^:].*
Required: Yes
- Period
The period, in seconds, over which the statistic is applied.
Type: Integer
Valid Range: Minimum value of 1.
Required: No
- Statistic
The statistic for the metric, other than percentiles. For percentile statistics, use
ExtendedStatistics.
Type: String
Valid Values:
SampleCount | Average | Sum | Minimum | Maximum
Required: No
- Unit
The unit for the metric. element is returned by the service.
- MetricAlarms.member.N
The information for each alarm with the specified metric.
Type: Array of MetricAlarm objects
Errors
For information about the errors that are common to all actions, see Common Errors.
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: | https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarmsForMetric.html | CC-MAIN-2018-17 | refinedweb | 254 | 53.27 |
- Training Library
- Microsoft Azure
- Courses
- Introduction to Azure Storage
An Introduction to Blob Storage blob storage. In this lesson, we are going to take a closer look at blob storage and when you should use it.
Azure Blob storage, as I mentioned earlier in this course, is an object storage solution in Azure. It’s optimized to allow the storage of massive amounts of unstructured data, including text and binary data.
You would typically use blob storage to host images and documents that you wish to serve up to a web browser. Think images on a website. Blob storage is also used when you wish to stream video or audio or to store log files. Organizations will also often use blob storage to store backup data, archive data, and data that needs to be analyzed by some on-prem process or Azure-hosted process.
To access objects in blob storage, you can use HTTP or HTTPS. You can also access blob storage objects through the Azure storage rest API, through Azure PowerShell, through the Azure CLI, or through an Azure storage client library such as Java, PHP, .NET, or several others.
There are three types of resources that you should be familiar with when discussing blob storage. They include the storage account that hosts the blob storage, containers within the storage account, and the blobs within those containers.
The image on your screen depicts the relationship between these resources.
The storage account creates the unique namespace in Azure that you use to access your data. When you access your data, you’ll use a combination of the storage account name and the Azure Storage blob endpoint that you are trying to access. Together, these two pieces form the base address for the objects that reside in the storage account.
For example, the URL that you see on your screen would be used to access blob storage in a storage account called MyStorage:
Containers within a storage account are used to organize the blobs within the account. You can view containers like directories in a file system. You can create an unlimited number of containers within a storage account, and each container can store an unlimited number of blobs.
There are actually three types of blobs that Azure storage supports. They include block blobs, append blobs, and page blobs. Block blobs can contain up to about 190.7TiB of text and binary data. They are called block blobs because they consist of blocks of data that can be managed individually.
Append blobs are similar to block blobs insofar as they, too, consist of blocks of data. However, unlike block blobs, append blobs are optimized for append operations. This makes append blobs a good choice for logging data from virtual machines.
Page blobs are used to store random access files up to 8 TiB in size. You would typically use page blobs to store VHD files, which would serve as disks for Azure virtual machines.
To learn more about blob storage,. | https://cloudacademy.com/course/intro-to-azure-storage/introduction-blob-storage-1/ | CC-MAIN-2022-40 | refinedweb | 499 | 63.8 |
Table of Contents:
Projects and Configurations
Let your studio configuration evolve
Each Project has a Pipeline Configuration
Checking for updates to the Core API
Choosing which Engines and Apps to Run
Environments in the Default Configuration
Environments in Shotgun - Populating the Context Menu
Running from Shotgun and the Shell
Security and Authentication
Authentication and prompting
Using a global script key
Running in non-interactive environments
The Shotgun Authentication Library
Shotgun authentication and permissions
Multi-threaded environments
Toolkit technical details and further reading
Introduction
Want to learn more about the Shotgun Pipeline Toolkit? You have come to the right place! This document explains some of the key features in more depth. With explanations, examples and small demos, we show what the Shotgun Toolkit is all about. This document is a good starting point if you want to familiarize yourself with our Toolkit or if you want to understand how the Toolkit could add value to your studio. After you have read it, you'll have a good grasp of some of the key concepts and how they work in practice.
Below is a brief description of the Shotgun Pipeline Toolkit (Sgtk):
- Sgtk is a Pipeline Toolkit based on the Shotgun platform - it makes it easier to write and install tools for a studio.
- Sgtk is file system based - it helps you organize where things are stored on disk, so that what you have on disk is nicely structured.
- Sgtk is an assistant - it does not try to take over or abstract the data in your pipeline, but rather is there to provide artists with compelling tools to make finding information easier and avoid making mistakes.
- Sgtk is helping you to share - By storing all its publishes in Shotgun, the Toolkit makes it easy to share updates and work that is going on across a production.
In the following sections, we will be looking in depth at the Shotgun Pipeline Toolkit and how it works.
Projects and Configurations
In the Shotgun Pipeline Toolkit, everything is project centric. A project typically starts its life cycle inside of Shotgun, goes through a bidding and a pre-production phase. Once a project is ready for the content creation phase, the Toolkit can be set up for that project.
When you set up a new project, you use a template configuration. This is a pre-defined config containing engines and apps, file system configuration and other settings. If you are just starting with the Toolkit, you can use our example configuration as a starting point for your exploration. If you have already been using the Toolkit on another project, we suggest that you take that configuration and use that as the starting point for your new project. That way, you will be evolving a studio configuration and it will be refined with each new project. Of course, you can also maintain a studio configuration separately and use this as a template for all new projects.
Each configuration defines a number of storage points. For the standard sample configuration,
tk-config-default, we define a single storage point called primary. This means that all your production data will be under a single file system project root. You can also set up configs with more than a single file system root. We call these multi-root configurations. Examples when you need multi-root configurations include having a separate storage for renders, a separate storage for editorial etc. Each of these storage points need to exist as a Local File Storage in Shotgun - these can be set up in the Site Preferences, under the File Management tab.
The Shotgun Toolkit will install the actual project configuration in any location you like, typically this will go into a software install area on disk and not into the project data area itself. (and don't worry, you can always move it later if you are not happy with the location!).
Let your studio configuration evolve
When you set up a new project, you can base it off an existing project. The Shotgun Toolkit will then copy the configuration folder from that project to your new project. This means that your new project will get exactly the same versions of apps and engines, the same settings and the same customization as the project you are basing it on. This can be useful if you want to evolve your pipeline and take advantage of improvements and tweaks that have happened as part of an existing production.
Alternatively, you can just take the configuration folder from a project when you are happy with that project's setup and save it in a central location somewhere. This config can then be used as a studio template and each time you create a new project, you can base it off this config. If you want, you can even source control this studio template config using for example git, and tracking how the pipeline configuration template evolves over time becomes simple and transparent. Whenever you want to update it, just copy the config from one of your projects and commit the changes.
For detailed information about configuration management, check out our detailed docs:
Each Project has a Pipeline Configuration
Whenever you set up Shotgun Toolkit for a project, a pipeline configuration is created. This configuration contains all the settings and files needed for the project. The configuration has a dedicated
tank command which you can run in a shell if you want to address the project directly (there is also a global tank command that works with all projects). In Shotgun, the Pipeline Configuration has been registered as a special Pipeline Configuration Entity to make it easy to keep track of where your project configurations reside on disk.
In addition to the master config that is created when the project is set up, you can create additional configurations for a project. This is often useful if you want to make changes to the configuration without affecting everyone on the project. If you want to do this, you can navigate to a pipeline configuration in Shotgun, right click it and choose to clone it. This will create a new pipeline configuration for a project, based on another one, and using the new configuration you can safely test out for example a new app without affecting other users.
Please note that the main configuration for a project needs to be named
Primary. If you rename, modify or delete it, things may not work as expected. The Pipeline Configurations stored in Shotgun are not intended to be manipulated by hand but rather through various specific
tank administration commands and are therefore read-only by default.
Example: How to clone a configuration
Checking for updates
Similar to other App stores out there, the Shotgun Toolkit app store constantly gets new versions for apps and engines. These new versions may contain important bug fixes, or interesting new features. Upgrading your apps and engines is completely optional. It is normally a quick process and the upgrade scripts will always prompt you before making any changes. Likewise, it is straight forward to roll back, should you have accidentally installed a unsatisfactory version.
A single command handles the upgrade process. Simply run the
tank command located in your project configuration folder and add an
updates parameter:
> /software/shotgun/bug_buck_bunny/tank updates
Running this command with no parameters will check all environments, engines and app. This may take a long time. You can also run the updater on a subset of your installed apps and engines.
General syntax:
> tank updates [environment_name] [engine_name] [app_name]
The special keyword ALL can be used to denote all items in a category. Examples:
- Check everything:
tank updates
- Check the Shot environment:
tank updates Shot
- Check all maya apps in all environments:
tank updates ALL tk-maya
- Check all maya apps in the Shot environment:
tank updates Shot tk-maya
- Make sure the loader app is up to date everywhere:
tank updates ALL ALL tk-multi-loader
- Make sure the loader app is up to date in maya:
tank updates ALL tk-maya tk-multi-loader
In addition to checking the app store, this script checks all other registered locations too, so it may query your local git, a Github repository, a file on disk and the app store, depending on where you have deployed your apps.
Please note that a new version of an app may introduce changes to the app configuration. For example, there may be a new feature which requires a new configuration parameter. In that case, the tank upgrade script will prompt you to type in values for these parameters.
Checking for updates to the Core API
Sometimes we release new versions of the Toolkit Core API. A separate command is used to update the Core API. In this case, the command is
tank core.
Creating folders on disk
Once the Shotgun Pipeline Toolkit has been set up for your project, you can use our Toolkit to help you create a consistent folder structure. This folder structure is configured by creating a file system template as part of the pipeline configuration on disk. In this folder structure, some of the paths will be dynamic - for example, you may have a folder called
asset, that represents a shotgun asset. These dynamic folders can be connected to shotgun queries and many other things.
Shotgun Toolkit provides a number of different dynamic folder types that handle different setups and scenarios. You can use the standard Shotgun API query syntax when you set up your folder creation, so you could for example organize your file system so that assets with different asset types end up in different folders on the file system. For a detailed walkthrough of how this works, see the admin guide:
The Shotgun Pipeline Toolkit folder creation happens in two passes - a direct pass, which can be run by anyone at any time, and a deferred pass, which is typically run by the artist just before application launch. This deferred pass is completely automatic and can be used to set up application specific folders and user sandboxes.
The Current Context
Once the file system structure has been created, the Shotgun Toolkit knows the relationship between a folder on disk and the shotgun object that the folder came from. This is important, because it allows the Toolkit to easily associate an object in Shotgun with a folder or disk, or file, when publishing, loading or resolving paths. It also relates to what we call the context or sometimes the current work area. The context object is part of the Toolkit Core and tracks the current thing that is being worked on. It is a central mechanism when the Toolkit resolves file system paths (which will be described further down in this document).
The context can be created either from a Shotgun object such as a Task, Asset or Shot, or from a path on disk. When apps are running, they can always access the context, and this makes it easy to construct apps that have no knowledge of the file system naming convention or whether the App is used in an Asset or Shot pipeline. This is all handled by the Toolkit Core API and the context.
File System Template
The Toolkit Core contains a system for handling file paths. It is called the Templates System. Since the Shotgun Toolkit is file system based, Apps will need to resolve file paths whenever they need to read or write data from disk. Apps are file system structure agnostic - meaning that they don't know how the file system is organized. The template system handles all this for them.
At the heart of the template system, there is a Templates Configuration File. This file contains all the important file system locations for a project. A Template looks something like this:
maya_shot_publish: 'shots/{Shot}/{Step}/pub/{name}.v{version}.ma'
It basically defines a path which contains certain dynamic fields. Each field can be configured with validation and typing, so you can, for example, define that the
{version} field in the template above is an integer padded with three zeros (e.g.
001,
012,
132). Whenever and App needs to write or read something from disk, a template is added to the templates file to describe that location. Since Apps often are set up to form a pipeline, the output template of one App (e.g. a publishing app) is often the input template of another app (e.g. a loading app). This is why all the file system locations are kept in a single file.
The template API lets you jump between a list of field values and paths:
# get a template object from the API >>> template_obj = sgtk.templates["maya_shot_publish"] <Sgtk Template maya_asset_project: shots/{Shot}/{Step}/pub/{name}.v{version}.ma> # we can use the template object to turn a path into a set of fields... >>>>> fields = template_obj.get_fields(path) {'Shot': '001_002', 'Step': 'comp', 'name': 'main_scene', 'version': 3} # alternatively, we can take a fields dictionary and make a path >>> template_obj.apply_fields(fields) '/projects/bbb/shots/001_002/comp/pub/main_scene.v003.ma'
Note how the above path and template has two different types of fields: The
Shot and
Step fields are high-level fields with equivalent objects in Shotgun (a Shot and a Pipeline Step) where the
name and the
version fields are very specific to this particular type of template (in this case a publish path.). If we wanted to describe a publish path for an asset rather than a shot, we would still have a
name and a
version field, since this is needed for all publishes, regardless of what type of data it is - however, we would not have a
Shot and a
Step field. Instead, we may have an
Asset and a
Step field, where the asset field would be associated with an asset in Shotgun.
When we develop an app that does Publishing, we obviously don't want to have a separate App that does Shot publishing and one that does Asset publishing. Instead, we want a single Publishing app that can handle any publish scenario, regardless if it is a Sequence, Shot, Asset or Whatever.
This is where the Toolkit Context comes in. Essentially, the Toolkit Context allows us to split the template fields into two distinct groups (as mentioned above); the Context fields (
Shot,
Step,
Asset etc) are fields that we want to ensure are resolved outside of the App - in such a way that the App Code will not have to have code that specifically handles concepts such as Shots and Assets. Instead, the App should only populate the fields that are directly associated with the particular business logic of the App. In our example with a publish app, the business logic consists of the
name and the
version fields. As the figure above illustrates, the Shotgun Toolkit therefore splits the field resolve into two distinct phases: Some fields are populated by the context and some fields are populated by the business logic inside the App. This way, Apps can be designed that are not tied to a particular file system layout. We believe this is an important aspect of building good pipeline tools.
The App Code that would deal with the path resolve would typically look something like this:
# start with an empty fields dictionary fields = {} # first let the context populate all its fields fields.update( self.context.as_template_fields( publish_template_obj ) ) # fields is now {'Shot': '001_002', 'Step': 'comp' } # now the app can add its business logic fields["name"] = "main_scene" fields["version"] = 234 # and finally the app can produce the path it needs in # order to save out the file path = publish_template_obj.apply_fields(fields)
For more details of how you can configure and use the Templates API, see the following:
Choosing which Engines and Apps to Run
Another important role that the Toolkit Core plays is in deciding which Apps should be presented to a user. If you are working on Character Rigging and start up Maya, you probably want a different collection of Apps than if you are doing lighting on a shot. Furthermore, the Apps can be configured differently depending on how you want them to operate, so a review App for rigging may be generating a turntable whereas the same review App is doing a playblast using the shot camera when an animator runs it.
In order to allow for this flexibility, a Shotgun Toolkit project configuration contains a collection of environments. An environment is a configuration file that defines a collection of apps and engines, and all their configuration parameters.
Example: What does an environment file look like?
An environment file is a yaml file which defines a collection of Engines and Apps.
description: Example environment file engines: tk-maya: debug_logging: false location: {name: tk-maya, type: app_store, version: v0.2.10} apps: tk-maya-breakdown: hook_multi_update: default hook_scan_scene: default location: {name: tk-maya-breakdown, type: app_store, version: v0.2.7} tk-multi-about: location: {name: tk-multi-about, type: app_store, version: v0.1.8} tk-multi-loader-1: dependency_mode: false hook_add_file_to_scene: default location: {name: tk-multi-loader, type: app_store, version: v0.2.6} menu_name: Load Assets... publish_filters: [] sg_entity_types: Asset: [] single_select: true tank_types: [Maya Model, Maya Rig] tk-nuke: debug_logging: false location: {name: tk-nuke, type: app_store, version: v0.2.10} apps: tk-multi-setframerange: location: {name: tk-multi-setframerange, type: app_store, version: v0.1.2} sg_in_frame_field: sg_cut_in sg_out_frame_field: sg_cut_out tk-multi-snapshot: hook_copy_file: default hook_scene_operation: default hook_thumbnail: default location: {name: tk-multi-snapshot, type: app_store, version: v0.1.15} template_snapshot: nuke_shot_snapshot template_work: nuke_shot_work
As you can see, each App and Engine has a
location parameter. This defines where the code is located and which version is currently used. This is used by Toolkit Core to manage app updates checks. The example above shows locations of type
app_store, e.g. coming from the Centralized Store of approved and curated apps, but we also support other locations such as
git. This makes it easy to manage and upgrade internal tools using the upgrade system that comes with the Shotgun Pipeline Toolkit.
When the Toolkit starts up, it needs to decide which environment to initialize. This is done via a piece of Python code called a hook, where you can add your own business logic. The context object (the current work area) is passed in to this piece of code, and this is often what is used in order to determine which environment to use.
This makes it possible to configure separate collections of apps for different parts of the pipeline. Furthermore, you can also update them independently and even have different supervisors managing them separately.
Example: What does the Pick Environment Hook look like?
The Pick environment hook can be customized per project and could for example look like this. It is located in
PIPELINE_CONFIG/core/hooks/pick_environment.py.
from tank import Hook class PickEnvironment(Hook): def execute(self, context, **kwargs): """ Example Pick Environment Hook! """ if context.project is None: # our context is completely empty! # don't know how to handle this case. return None if context.entity is None: # we have a project but not an entity return "project" if context.entity and context.step: # we have a step and an entity if context.entity["type"] == "Shot": return "shot_step" if context.entity["type"] == "Asset": return "asset_step" return None
Environments in the Default Configuration
To give you a practical example of how environments work and can be structured, let's take a look at the environment that comes with the default configuration.
The default configuration comes with the following environments:
project.yml- Apps and Engines to run when the context only contains a project.
shot_and_asset.yml- Apps and Engines to run when the context contains a shot or an asset.
shot_step.yml- Apps ane Engines when the context contains a Shot and a Pipeline Step.
asset_step.yml- Apps and Engines when the context contains an Asset and a Pipeline Step.
The default config has organized its file system based on pipeline steps. This means that under for example a Shot location, you can find folders for Modeling, Rigging etc. Essentially, there is one folder for each pipeline step you work on. Each of these folders have its own work areas and publish areas on disk. This means that for example a publish template may look like this:
maya_shot_publish: 'sequences/{Sequence}/{Shot}/{Step}/pub/{name}.v{version}.ma'
In order to use this template, the context needs to contain both an entity (a Shot in this case) and a Pipeline Step. For Shot 1122, parented under Sequence ABC and pipeline step Modeling, the above template would resolve to
sequences/ABC/1122/Modeling/.... This means that a context that for example contains a Shot but not a Pipeline Step is not enough to populate the above template. You cannot launch Maya for a Shot-only context and use the above template - in order for it to be functional, a Step is required.
This leads us to the environment breakdown shown above. Because the file system structure defined in the default configuration is centered around steps, all the main apps need to run in a context which has a step defined. We define two such environemnts in the default config: the
asset_step.yml file and the
shot_step.yml file. Each of these files contain engines for a number of DCCs - Maya, Nuke, 3dsmax, Motionbuilder, Photoshop to mention a few. When you for example launch maya from a shot task inside of Shotgun, the pick environment hook will choose the
shot_step environment, start maya and load up the maya app configuration.
It can also be useful to launch Maya directly from a Shot object inside of Shotgun. More importantly, it can be really useful to be able to type in a console
tank Shot 1122 launch_maya. This is where the
shot_and_asset environment comes in. When you load maya with a context which contains a shot (or asset) but no pipeline step, it will load this environment. But since the file system structure is all organized per pipeline step, it is not really possible to do any loading or publishing if we only have the shot. Maya instead launches with a bare configuration, only containing the Work Files app. This app let's you choose a task to work on and then switches the context to this task. Once you have picked a task, the Toolkit switches the context and restarts the engine for you and will load up the
shot_step environment with the full range of apps.
Similarly, the
project environment is a catch-all fallback, also just containing the Work Files app. This makes it possible to launch maya (or other apps) from pretty much anywhere inside the project and it will initialize the Toolkit in a minimal state, allowing you to jump to a valid work area using the Work Files App.
Environments in Shotgun - Populating the Context Menu
Apart from the dynamic environments explained above, automatically selected by the Shotgun Pipeline Toolkit depending on the context, the Toolkit also comes with a set of special Shotgun environments. These environments control which apps show up on the context menus inside of Shotgun. All of these environment files are named on the form
shotgun_entitytype.yml, for example
shotgun_shot.yml,
shotgun_asset.yml. Whatever apps you define in these environments will show up on the context menu for that entity type in Shotgun.
Configuring Apps
Each App has number of configuration parameters that need to be specified. When you install or upgrade an app, the Toolkit makes sure that you have specified all the required settings. Settings are typically automatically documented - head over to the App Listings Section of the documentation to see some examples:
Simple setting values such as strings or ints are specified directly in the environment config. Templates are different. Since the Shotgun Toolkit wants to keep all templates in a single place, the environment file merely points to templates defined in the templates file. Each App will require different fields to be present in the templates that it uses in its configuration. For example, in our previous example, an example Publish App was using a template with the fields
name and
version when creating its output files on disk. The App would therefore have a configuration setting which requires a template containing the fields
name and
version.
If you would try to configure the app using a template that has more than the context fields,
name and
version, the App Code would not know how to populate these additional fields, and therefore would not be able to generate a path from that template. Similarly, if you provided a template that was missing one of the fields (for example
version), it would lead to confusing results - in our case, version numbers would not be written out of the app. Therefore, the Toolkit will validate the configuration at startup to make sure that the necessary fields are provided for all templates. The Shotgun Toolkit also supports several ways of using default values and optional fields. For a complete reference, check the following links:
Hooks
In addition to app settings using templates, the Shotgun Pipeline Toolkit also supports a concept called Hooks. Hooks are small snippets of Python code, effectively allowing you to customize parts of the App Code as part of your configuration. Here's how it works and why it is useful:
Apps are powerful because they can be reused across multiple engines and projects. But Apps tend to need some small snippets of engine specific code. For example, if we are building a loader app which should work both in Nuke and Maya, there will need to be code that handles the actual file load - and this code will have to be different in Nuke and Maya, since their APIs are totally different. Furthermore, it would be great if it would be possible to use this app with Any Engine! Also, different studios may have different ways to load items into a scene - someone may need to support a custom Maya reference node where other studios may just do an import.
This situation is handled in the Toolkit using a Hook. The hook is a customizable piece of code. The App comes with a default hook which contains a base level implementation, meaning that the App will work fine out of the box. However, if you want to customize the behaviour, you can copy that hook file into your configuration, and Toolkit will use that code instead.
Running from Shotgun and the Shell
Once the Shotgun Toolkit is installed, you can access it from several primary entry points:
- Shotgun Actions will appear on the right-click menus inside of Shotgun
- Launch icons will appear for the project in the Shotgun Desktop app
- You can use the
tankcommand in a console.
- The Toolkit Python API is available both inside applications and in the shell.
Running the Toolkit from within Shotgun is a common way of starting applications and carrying out tasks. The Shotgun Toolkit will use the Shotgun Browser Plugin to communicate with the Toolkit install that is local on your machine and use a local Python to execute a Shotgun engine and apps. This means that you can run local operations such as folder creation right from inside of Shotgun. You can also execute QT UI based apps from inside of Shotgun.
You can also access the Shotgun Toolkit from the command shell. Each project configuration comes with its own tank command. Simply navigate to your project configuration root and execute the
./tank command from there.
Lastly, you can simply add the Toolkit API to the
PYTHONPATH and import it. Using the API is straight forward and if you, for example, want to start up the Shotgun Pipeline Toolkit inside of Maya manually, or as part of an existing studio launch system, instead of using the Launch App facility, all you need to execute is a couple of simple commands.
Publishing to Shotgun
When you want to share files that you are working on with others, you can publish them. What this means is that a publish record is created inside of Shotgun.
The details of exactly what this means in terms of the data management (where on disk things are saved, what the file contains etc) is left to the App doing the actual work. The Toolkit API provides App Developers with Methods to easily create publishes inside of Shotgun and link these up to the right objects to ensure that Shotgun can go ahead and push notifications to all the right people. We also provide a default Publish app that is meant to be versatile and highly configurable, but this is by no means the only way to implement version control using the Shotgun Toolkit. Because Sgtk is a pipeline toolkit, you could build your own custom version control and publishing system using the Toolkit if this is desirable. As a starting point, however, we recommend our Publish App:
Building Reusable Apps
The Shotgun Pipeline Toolkit is not just a collection of Apps and Engines. It is also a framework that you can use to develop your own Tools and Technology! We have included a lot of features to make the Shotgun Toolkit a rich studio development platform. With the Toolkit as a foundation, you can focus on the problem at hand rather than building the underlying pipeline stack. We have tried to make it easy for developers to build, evaluate and release software without accidentally breaking the pipeline for artists.
The Engines ensure that apps can be written in Python and QT (PySide/PyQt) regardless of the underlying foundation. This means that some engines are very simple (Nuke for example, where Nuke already contains PySide and Python) and some engines are more complex (Photoshop for example which doesn't have Python support). This means that there is a straight forward, consistent way to develop tools for the studio. In our experience, python and PyQt/PySide is often found being the development environment studios use and many TDs are familiar with it.
The engine layer also means that Apps can be written once and then be deployed in multiple environments. We have developed the standard App Suite as Multi Apps, meaning that the same App is used in all engines. There will inevitably be specific code that needs to be tailored to work with the specific API that each DCC application exposes, but this is typically contained in one or more hooks, making it easy to reuse an app. Another consequence of being able to create multi apps like this is that when a new engine is being developed, all the standard apps can be easily configured to work with that new engine.
Via Pipeline Configurations and Cloning, it is easy to create a development sandbox, allowing developers to do development on a production without interfering with the day to day production activity. Once the tools are ready to be deployed, the main project configuration can be easily updated and the tool is rolled out to all artists.
Since Apps run inside an engine, it is easy to reload them. Instead of having to restart Nuke or Maya every time you want to test a new code change, simply hit the reload button in Toolkit and the latest code is loaded in.
For an more extensive introduction to App Development, see the following documents:
Security and Authentication
When you run the Shotgun pipeline Toolkit, it will connect to Shotgun on a regular basis in order to carry out certain operations. It may be when you publish a new render or when you browse for an item that you want to load into your scene. At this point, Toolkit will need to log in to Shotgun, either to read or write data, meaning that it will need to make sure the current user is authenticated so that a connection with the Shotgun server can be established.
With Toolkit core versions prior to v0.16, this was handled automatically by using a single Shotgun API script user to handle all Toolkit operations. With Core v0.16, Toolkit instead defaults to a mode where it requests a login and password for each user, making the interaction experience similar to how the rest of Shotgun works.
Toolkit uses session tokens for authentication. These are unique identifiers which are generated by the Shotgun server. Whenever a Shotgun API request comes in from Toolkit, this session token is passed along so that the server can validate it and grant access to the request. These session tokens time out after a certain period of inactivity, usually 24 hours, and whenever this happens, the user is typically prompted to enter their password again in order for Toolkit to retrieve a new session token.
In a pipeline, it is not uncommon to encounter situations where it is hard or even impossible to prompt the user for a password. For these use cases, Toolkit provides several ways to run completely "headless" or to completely customize the process around authentication. The following section outlines how the Toolkit security model works and how it can be customized.
Upgrading to Core v0.16
Prior to v0.16, all authentication would be handled via a configuration file called
shotgun.yml, which would contain Shotgun script credentials, allowing all users to access Shotgun in the same way, without needing to log in. Core v0.16 still supports this behavior, however defaults to prompting users for their username and password, giving Toolkit a more fine grained control over its users and avoid storing script credentials in a global location.
Core v0.16 is fully backwards compatible and whenever it encounters a Toolkit project with script credentials specified in the
shotgun.yml file, it will use these for its authentication purposes. This means that when you update to Toolkit Core v0.16, existing projects won't be affected by the new authentication features.
An existing
shotgun.yml file typically looks something like this:
# Shotgun Pipeline Toolkit configuration file # this file was automatically created host: api_key: abcdefghijklmnopqrstuvwxyz01234567890ABCDE api_script: Toolkit http_proxy: null # End of file.
If the
api_script and
api_key lines are removed, Toolkit will start prompting the user for a login and password. When new projects are set up in v0.16, they will automatically use this form:
# Core v0.16 example which doesn't store script # credentials in a file but instead prompts each # user to individually log in host: http_proxy: null # End of file.
If you want to enable an existing project to run with the new authentication features introduced in Core v0.16, simply locate its
shotgun.ymlfile (typically located in
config/corein your configuration folder) and comment out the
api_keyand
api_scriptkeys.
Conversely, if you create a new project and you want to to use the automatic authentication model previously used in Toolkit, just update
shotgun.ymlwith valid script credentials.
Please note that commenting out the
api_keyand
api_scriptfields for an existing project means that the config will no longer work with cores prior to v0.16. Before doing so, please make sure that all users working on that project have upgraded to Core v0.16.
Note for advanced users and similar to the above: If you are running Shotgun Desktop v1.0.x, please do not manually remove the
api_keyand
api_scriptfields from the local site configuration that the Shotgun Desktop uses. While the older v1.0.x version of the Shotgun Desktop is able to handle projects that don't have script credentials stored in their
shotgun.ymlfiles, it still requires its site config file to have those fields present. In order to completely eradicate hard coded credentials from your pipeline, you need to update to the latest version of the Shotgun Desktop.
If you are using a shared core for your projects, the
shotgun.ymlfile is found in the core configuration location rather than the project configuration. If this is the case, any changes you make will affect all projects using that core.
No user login matching - Previously, every user would connect to Shotgun using the same Script user, meaning that the Shotgun connection had no strong concept of which user was actually connecting. Toolkit attempted to identify who the actual current user was by getting the operating system login for the current user (using a hook) and trying to match that against a user in Shotgun. This behavior still exists in v0.16 as a fallback mechanism, but for all new projects where per-user authentication is enabled, this system login matching logic is no longer needed and won't be used.
New permissions - Previously, when Toolkit was using a single
Toolkitscript user to connect, the Shotgun permissions associated with this script user would be the limiting factor for which operations could be carried out within Shotgun. With new projects where the user instead starts logging in to Toolkit, it will be the user's Shotgun permissions that will dictate which operations can be carried out. This may affect the behavior of operations - both in-house tools and customizations, where previously the
Toolkitscript user would carry out Shotgun operations on behalf of the artist, but now the artist is executing those same operations with her/his own credentials. Potential issues are usually quickly fixed by adjusting the Shotgun permissions for the users to ensure that they have permission to carry out all necessary pipeline operations.
Authentication and prompting
As of Toolkit Core v0.16, a couple of different security modes are now supported and these are all documented below.
Using a global script key
If you don't ever want anyone to be prompted for their login and password, you can specify a global Shotgun script key in the
shotgun.yml file. Toolkit will use this for all Shotgun operations. This is the security mode that was used by all projects prior to Toolkit Core v0.16. By default, new projects will be created without this global script key, but you can enable it by adding two
api_script and
api_key options to
shotgun.yml. For an example, see the previous documentation section.
Logging in to Shogun
When running with per-user security enabled, Shotgun will need your login and password in order to authenticate you. It remembers this between sessions, however it may occasionally ask you to put in your login and password.
When you log on to Toolkit, your password is sent securely to the Shotgun server and a session token will be returned. Toolkit will then use this token to connect and won't ask you for your password again while the token is valid. The token expires after a while, typically after 24 hours of inactivity, and Toolkit will then again prompt you for your password. The prompting for a login and/or password can happen in several different places:
When you start up the Shotgun Desktop.
When you run the
tankcommand in a terminal. There are ways to turn this prompting off - this is documented in the next section.
When you click on a Toolkit action menu item in the Shotgun web application.
Normally when you launch Maya, Nuke or other DCCs, you won't be prompted for your password. This is because the Shotgun Desktop, Shotgun web application or
tankcommand has already refreshed your authentication. However, if you have left Maya or Nuke open and inactive for more than 24 hours, it may show a dialog, asking you to renew your password. This will happen right before Toolkit needs to access Shotgun.
Running in non-interactive environments
Many times, pipeline code needs to execute in environments where there isn't a UI or user present. Execution of code on a render farm is the classic example. For these use cases, Toolkit provides several ways to provide credentials via the API and command line.
If you are using the tank command, there are several options you can use. You can provide a script name and script key for authentication directly via the
--script-name and
--script-key command line arguments:
# never prompt for a username or password > tank --script-name=headless_launcher --script-key=xxx Shot ABC123 launch_maya
If you don't want to provide the details directly on the command line, you can also store them in a file and point the tank command to this file via a
--credentials-file argument:
# never prompt for a username or password > tank --credentials-file=/path/to/script_credentials.yml Shot ABC123 launch_maya
This file should be on the following form:
script-name: Toolkit script-key: abcdefghijklmnopqrstuvwxyz01234567890ABCDE
This way you can maintain multiple Shotgun script users, each with different permission settings, for each of your various pipeline services, thereby ensuring that your processes have limited access only to the Shotgun data that they require.
If you are using the Toolkit API directly, you currently have to write some code in order to ensure that Toolkit get authenticated. The main security api method in the sgtk API is
sgtk.set_authenticated_user(user), which you can use to associate a particular user with a Toolkit core session. The user object that you pass into this method is generated by the Shotgun Authentication API which abstracts the logic around authentication. The sample code below illustrates how to set up a Toolkit Core API session which uses a Shotgun script to authenticate:
import sgtk from tank_vendor.shotgun_authentication import ShotgunAuthenticator # create an authenticator object. This is the main object which # handles all authentication sa = ShotgunAuthenticator() # Use the authenticator to create a user object. This object # identifies a Shotgun user or script and also wraps around # a Shotgun API instance which is associated with that user. user = sa.create_script_user(api_script="myscript", api_key="xxxxx", host="") # tell the Toolkit Core API which user to use sgtk.set_authenticated_user(user)
Once the authenticated user is set in Toolkit, the user object is automatically serialized as part of the built-in
context serialization methods. This means that when you for example launch Maya, Nuke or Other DCCs, credentials will be passed from the launch process (typically the
tank command, Shotgun Desktop or Shotgun web application) into the launched DCC. This makes it very easy to pass valid credentials from one process to another.
For more information about the Shotgun Authenticator API, please see the inline code documentation.
Technical details
The Shotgun Authentication Library
All Shotgun related authentication logic has been developed as a standalone Python library which is used by the Toolkit Core and Shotgun desktop. It can also be used by other (non-Toolkit) applications which need to handle scenarios where a user is required to log in to Shotgun. The library wraps around the Shotgun API and contains a standardized QT-based Shotgun login dialog which will appear when the user needs to authenticate. The Shotgun Authentication module handles many common scenarios around Shotgun authentication and helps maintain a standardized user experience to ensure users feel secure and comfortable. A summary of the feature set:
A standardized QT and command line based user experience around prompting for user name and password
Default mechanisms for persisting Shotgun session tokens across API instances, allowing the API to minimize user disruption.
A configurable, overridable defaults manager which allows a client of the API to configure the behavior around default values.
A Shotgun Authenticator instance sits at the center of the API and acts as a factory for Shotgun User objects. These objects represent a User or Script in Shotgun.
The Shotgun user object returned by the authentication library has a
create_sg_connection()method which will create a Shotgun API instance associated with that user. In the case of a non-script user, the session token used by the Shotgun API instance may become invalid - typically after 24 hours of inactivity - and in this case the Shotgun API instance will trap this error and automatically prompt the user to type in their password.
For more details, see the inline code documentation of the Shotgun Authentication module.
Shotgun authentication and permissions
Whenever a user authenticates with her/his login and password in Toolkit, the Shotgun Authentication library will connect to the Shotgun server and exchange this information for a session token which will then be used for subsequent requests. The password is not stored anywhere, instead the session token is stored in a file on disk with restrictive file permissions and used whenever authentication is needed. Toolkit will attempt to use this saved session token whenever possible, and only prompt the user whenever the token is no longer valid. This typically happens afters 24 hours of inactivity.
When Toolkit is communicating with Shotgun in this fashion, the API session will use the same shotgun permission rules as the user normally has when she/he is logged in to the Shotgun web application. Please note that these permissions may be different and often more restrictive than the default Shotgun API script permissions, meaning that operations that work when logged in as a script user may fail when logged in as a user and vice versa. If you run into permissions errors, double check your permissions for users and API scripts in the Shotgun Permissions editor. You can find this on the administrator menu in the Shotgun web application.
Toolkit serialization
When a DCC such as Maya or Nuke is launched in Toolkit (using the
tk-multi-launchapp), the current
context typically is serialized out into a string-based form. The DCC process is then started and usually requested to execute a startup or bootstrap script provided by Toolkit. This script will deserialize the context string into an object, create a new
tk instance and finally start the engine.
As part of this, the user object is also being serialized, meaning that the new process will run with the exact same credentials setup as its parent process. This makes it easy to for example launch different processes for different users or to capture a context on one machine and then execute it on another.
File locations
Session tokens are stored in the following files:
~/Library/Caches/Shotgun/SITENAME/authentication.ymlon macosx
~/.Shotgun/SITENAME/authentication.ymlon Linux
%APPDATA%/Shotgun/SITENAME/authentication.ymlon Windows
The toolkit authentication library maintains the concept of a current site and a current user, meaning that the library can be used to maintain a single sign-on, where all applications and sessions have access to the same login credentials.
Multi-threaded environments
When a session token has expired after a period of inactivity, the Shotgun authentication library will prompt the user, asking for a password. Just like at login, this password is sent to the Shotgun server and exchanged for a new, valid session token.
What happens more practically is that the Shotgun API handle returned by the Shotgun authentication library
user_object.create_sg_connection() method contains wrapper code to check for session expiry. Whenever this is detected, the user will be prompted to re-authenticate and the operation is retried.
In multi-threaded scenarios, where several worker threads keep Shotgun API instances and several threads encounter a session expiry at the same time, the Shotgun Authentication library will pause all threads except the first one and use this to prompt the user for a new password. This is to avoid the user being prompted over and over again. Whenever the user is prompted, the QT UI code always executes in the main thread.
Toolkit technical details and further reading
The Shotgun Pipeline Toolkit is written in Python (v2.6+ but not 3.x) and is essentially a series of scripts that are executed on the client machine. The Toolkit works on Linux, Windows and Macosx.
Most asset management systems have a database for storage of metadata. The Toolkit does not have a database of its own, instead it uses the Shotgun database for storage and context management. A majority of the operations in the Core API are using the file system to resolve paths and data rather than communicating with Shotgun.
The Core API is not trying to "run the show" and it is not an "all-or-nothing" deal. Instead, it sits on the side and tries to be a place where scripts and artists can go for advice and assistance. One common approach to asset management is to attempt to gain full control over the file system and data flows in a pipeline. By knowing about everything that is going on in the pipeline, a system can track the content creation and processing in a very precise fashion. However, this approach comes at a cost - taking full ownership often requires that any existing tools would need to be rewritten and it introduces a central point where all the data needs to flow through. While this is sometimes a great approach, the Toolkit does not attempt to take ownership of the data. Instead, the Toolkit tries to understand the data and be a helper that sits on the side. The Shotgun Toolkit knows where things should go on disk, and it make it easy for artists and developers to collaborate and to be organized throughout the production process.
You can run the Shotgun Toolkit side by side with existing pipeline setups and content tracking systems. As long as they share an understanding of where things are located on disk, the Toolkit should be able to exchange data with them.
For more in-depth information, check out the following documents: | https://support.shotgunsoftware.com/hc/en-us/articles/219040648-An-overview-of-Toolkit | CC-MAIN-2019-51 | refinedweb | 8,219 | 50.77 |
poll()
Multiplex input/output over a set of file descriptors
Synopsis:
#include <sys/poll.h> int poll( struct pollfd fds*, nfds_t nfds, int timeout );.
The fds argument is an array of pollfd structures:
struct pollfd { int fd; short events; short revents; };
The members are:
- fd
- The file descriptor to be examined.
- events
- Flags that indicate the type of events to look for.
- revents
- Returned event flags. a POLLIN event rather than POLLHUP..
The significance and semantics of normal, priority, and high-priority data are file- and device-specific.
If the value of fd is less than 0, events is ignored, and revents is set to 0 in that entry on return from poll().
In each pollfd structure, poll() clears the revents member, except that where the application requested a report on a condition by setting one of the bits of events listed above, poll() sets the corresponding bit in revents if the requested condition is true. In addition, poll() sets the POLLHUP, POLLERR, and POLLNVAL flag in revents if the condition is true, even if the application didn't set the corresponding bit in events.
If none of the defined events occurs on any selected file descriptor, poll() waits at least timeout milliseconds for an event to occur on any of the selected file descriptors. If the value of timeout is 0, poll() returns immediately. If the value of timeout is -1, poll() blocks until a requested event occurs or until the call is interrupted..
See also <sys/poll.h>.
Returns:
- > 0
- The total number of file descriptors that have been selected.
- 0
- The call timed out, and no file descriptor has been selected.
- -1
- An error occurred (errno is set).
Errors:
- EAGAIN
- The allocation of internal data structures failed, but a subsequent request may succeed.
- EINTR
- A signal was caught during poll().
- EFAULT
- The fds argument pointed to a nonexistent portion of the calling process's address space.
Examples:
; }
Classification:
Caveats:
Not all managers support POLLPRI, POLLPRI, POLLERR, and POLLHUP. | https://developer.blackberry.com/playbook/native/reference/com.qnx.doc.neutrino.lib_ref/topic/p/poll.html | CC-MAIN-2020-05 | refinedweb | 331 | 64.41 |
The same bits released with Orcas Beta 1.0 are now available as a standalone package. The documentation update is out too, although few days ago (our technical writers rocks!)
To download the runtime click here.
To download the documentation client here.
Quick Notes:
- I ran into an error when I tried to install it on top of existing CTP. If you happen to have the CTP bits installed in your machine, try to uninstall it first before installing the beta.
- You will get compilation errors if you tried any of my demos with the new bits; the errors are more around clean up and name changes. The two errors you will most likely hit are:
1- The namespace Microsoft.Sync.xxx does not exist – Remove the using statement altogether.
2- SyncProgressEventArgs.Stage property does not exist – Rename it to SyncStage instead.
I will try to update the demos in the following few days. If you have any questions don’t hesitate to ask..
The Synchronizer Just Published! Microsoft Synchronization Services for ADO.NET Beta 1.0 Synchronization
Congrats!
Have you been able to verify the problems I reported May 2 with the Beta 1 implementation of the Sync Designer in my Sync Services forum post ()?
Thanks in advance,
–rj
Wow this week went quickly. On the Silverlight front I’ve managed to watch a few more Mix sessions and | https://blogs.msdn.microsoft.com/synchronizer/2007/05/11/just-published-microsoft-synchronization-services-for-ado-net-beta-1-0/ | CC-MAIN-2016-50 | refinedweb | 230 | 68.67 |
So i'm learning how to program with C++ through "Beginning C++ through game programming, 3rd ed".
Which i want 2 say is a great book and anyone that wants to learn C++ through examples, test and a friendly type of writing style. It's all console programing and there isn't any real GFX game programming to speak of.
So i need help with one of the exercises at the end of intro to STL chapter. What hes asking is:
"Write a program using vectors and iterators that allows a user to maintain
a list of his or her favorite games. The program should allow the
user to list all game titles, add a game title, and remove a game title."
so far this is what I've got:
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <iterator> using namespace std; int main() { vector<string> favGame; vector<string>::iterator iter; iter = favGame.begin(); vector<string>::iterator othIter; string other; string done = ("no", "No", "Done", "done"); other != done; string erase; cout << "\tWhat are your favourite games?"; cout << "\nList of favourite games? "; cout << "\nIf the list is done just say so.\n"; while (other != done) { { cout << "Game: "; } cin >> other; // this is where i insert the new string into the list. othIter = favGame.insert(favGame.begin(), other); } othIter = favGame.erase(favGame.begin()); // this is so that 'done' doesnt appear in the displayed string. cout << "\n\n\tUpdated list: \n"; for (iter = favGame.begin();iter < favGame.end();++iter) { cout << *iter << endl; } cout << "\n\n\tWould you like to erase a game?\n"; while (erase != done) { { // this is where the problem is, the program runs fine if i take out this chunk. cout << "Erase: "; } cin >> erase; //really i think im going about this whole chunk of code wrong. i think an if statement... othIter = find(favGame.begin(), favGame.end(), erase); // that goes like if erase == ( string in favGame), delete string... favGame.erase(othIter); // else game not found. } cout << "\n\n\tUpdated list: \n"; for (iter = favGame.begin();iter < favGame.end();++iter) { cout << *iter << endl; }}
My Problem is i need a way to enter a string into the console and then find it in favGame and erase it.
Also how is my layout of the code, any pointers you want 2 give. | http://www.gamedev.net/topic/601316-help-with-finding-a-string-in-a-vector-and-removing-it/ | CC-MAIN-2016-30 | refinedweb | 378 | 83.56 |
Your Account
This part of the book is a reference section that documents the classes, methods, properties,
and event handlers defined in client-side JavaScript. This introduction
and the sample reference page found at the beginning of Part III, “Core JavaScript Reference” explain how to use and get the most out
of this reference section. Take the time to read this material
carefully, and you will find it easier to locate and use the information
you need!
This excerpt is from JavaScript: The Definitive Guide.
The indispensable reference for JavaScript programmers since 1996, JavaScript: The Definitive Guide, 5th Edition is completely revised and expanded to cover JavaScript as it is used in today's Web 2.0 applications.
This reference section is arranged alphabetically. The reference
pages for the methods and properties of classes are alphabetized by
their full names, which include the names of the classes that define
them. For example, if you want to read about the submit( ) method of the Form class, you would
look under "Form.submit," not just "submit."
submit( )
Most client-side JavaScript properties do not have reference pages
of their own (all methods and event handlers do have their own reference
pages, however). Instead, simple properties are completely documented in
the reference page for the class that defines them. For example, you can
read about the images[] property of
the HTMLDocument class in the HTMLDocument reference page. Nontrivial
properties that require substantial explanation do have reference pages
of their own, and you'll find a cross-reference to these pages within
the reference page of the class or interface that defines the
properties. For example, when you look up the cookie property in the HTMLDocument reference page, you'll find a
short description of the property and a reference to more information
under HTMLDocument.cookie.
images[]
HTMLDocument
cookie
HTMLDocument.cookie
Client-side JavaScript has a number of global properties and
functions, such as window, history, and alert(
). In client-side JavaScript, a Window object serves as the
global object, and the "global" properties and functions of client-side
JavaScript are actually properties of the Window class. Therefore,
global properties and functions are documented in the Window reference page or under names such as
Window.alert( ).
window
history
alert(
)
Window
Window.alert( )
Once you've found the reference page you're looking for, you
shouldn't have much difficulty finding the information you need. Still,
you'll be able to make better use of this reference section if you
understand how the reference pages are written and organized. Part III, “Core JavaScript Reference” begins with an a sample reference page
titled "Sample Entry." That entry explains the structure of each
reference page and tells how to find the information you need within a
reference page.
Anchor: the target of a hypertext link — DOM Level 0: Node → Element → HTMLElement →
Anchor
Stringname
Contains the name of an Anchor object. The value of this property is set by the
name attribute of the
<a> tag.
name
<a>
focus( )
Scrolls the document so the location of the anchor is
visible.
An Anchor object is created by any standard HTML <a> tag that contains a name attribute:
<a name="name"> // Links may refer to this anchor by this name
...
</a>
An anchor is a named location within an HTML document. Anchors
are created with an <a> tag
that has a name attribute
specified. The Document object has an anchors[] array property that contains
Anchor objects that represent each of the anchors in the document.
Anchor objects can be referenced by index or by name within this
array.
anchors[]
You can make a browser display the location of an anchor by
setting the hash property of the
Location object to a # character
followed by the name of the anchor or by simply calling the focus( ) method of the Anchor object
itself.
hash
Location
Note that the <a> tag
used to create anchors is also used to create hypertext links.
Although hypertext links are often called anchors in HTML parlance,
they are represented in JavaScript with the Link object, not with
the Anchor object.
// Scroll the document so the anchor named "_bottom_" is visible
document.anchors['_bottom_'].focus( );
Document, Link, Location
Document
Link
Anchor.focus( ): scroll to make the anchor location
visible — DOM Level 0:
void focus( );
This method scrolls the document so the location of the Anchor
object is visible.
Applet: an applet embedded in a web page — DOM Level 0:
document.applets[i]
document.appletName
document
i
appletName
The Applet object has properties that mirror the HTML attributes of the
<applet> tag (see HTMLElement for details). It also has
properties corresponding to the public fields of the Java applet it
represents.
<applet>
HTMLElement
The methods of an Applet object are the same as the public
methods of the Java applet it represents.
The Applet object represents a Java applet embedded in an HTML
document. The Applet objects of a document may be obtained through
the applets[] collection of the
Document object.
applets[]
The properties of the Applet object represent the public
fields of the applet, and the methods of the Applet object represent
the public methods of the applet. Remember that Java is a strongly
typed language. This means that each field of an applet has been
declared to have a specific data type, and setting it to a value of
some other type causes a runtime error. The same is true of applet
methods: each argument has a specific type, and arguments cannot be
omitted as they can be in JavaScript. See Chapter 23, Scripting Java Applets and Flash Movies for further details.
JSObject; JavaObject in Part III, “Core JavaScript Reference” ; Chapter 12, Scripting Java,
Chapter 23, Scripting Java Applets and Flash Movies
JSObject
JavaObject
Attr: an attribute of a document element — DOM Level 1 Core: Node → Attr
readonly String
name
The name of the attribute.
readonly Element
ownerElement
The Element object that contains this attribute, or
null if the Attr
object is not currently associated with any
Element.
null
readonly boolean
specified
true if the attribute
is explicitly specified in the document source or set by a
script; false if the
attribute is not explicitly specified but a default value is
specified in the document's DTD.
true
false
String value
The value of the attribute. When reading this property,
the attribute value is returned as a string. When you set this
property to a string, it automatically creates a Text node
that contains the same text and makes that Text node the sole
child of the Attr object.
An Attr object represents an attribute of an Element node.
Attr objects are associated with Element nodes but are not directly
part of the document tree (and have a null
parentNode property). You can obtain an Attr object
through the attributes property
of the Node interface or by calling the getAttributeNode( ) or getAttributeNodeNS( ) methods of the
Element interface.
null
parentNode
attributes
getAttributeNode( )
getAttributeNodeNS( )
The value of an attribute is represented by the descendant
nodes of an Attr node. In HTML documents, an Attr node always has a
single Text node child, and the value property provides a shortcut for
reading and writing the value of this child node.
value
The XML grammar allows XML documents to have attributes that
consist of Text nodes and EntityReference nodes, which is why an
attribute value cannot be fully represented by a string. In
practice, however, web browsers expand any entity references in XML
attribute values and do not implement the EntityReference interface
(which is not documented in this book). Therefore, in client-side
JavaScript, the value property is
all that is needed to read and write attribute values.
Since attribute values can be completely represented by
strings, it is not usually necessary to use the Attr interface at
all. In most cases, the easiest way to work with attributes is with
the Element.getAttribute( ) and
Element.setAttribute( ) methods.
These methods use strings for attribute values and avoid the use of
Attr nodes altogether.
Element.getAttribute( )
Element.setAttribute( )
Element
Element
Button: see Input
Canvas: an HTML element for scripted drawing — Firefox 1.5, Safari 1.3, Opera 9: Node → Element →
HTMLElement → Canvas
String height
The height of the canvas. As with an image, this may be
specified as an integer pixel value or percentage of the
window height. When this value is changed, any drawing that
has been done in the canvas is erased. The default value is
300.
String width
The width of the canvas. As with an image, this may be
specified as an integer pixel value or percentage of the
window width. When this value is changed, any drawing that has
been done in the canvas is erased. The default value is
300.
getContext( )
Returns a CanvasRenderingContext2D object with which to
draw on the canvas. You must pass the string "2d" to this
method to specify that you want to do two-dimensional
drawing.
The Canvas object represents an HTML canvas element. It has no behavior
of its own but defines an API that supports scripted client-side
drawing operations. You may specify the width and height directly on this object, but most
of its functionality is available via the CanvasRenderingContext2D
object. This is obtained by calling the getContext( ) method of the Canvas object
and passing the literal string "2d" as the sole argument.
width
height
The <canvas> tag was
introduced in Safari 1.3 and, at this writing, is also supported in
Firefox 1.5 and Opera 9. The <canvas> tag, and its API, can be
simulated in IE with the ExplorerCanvas open source project at.
<canvas>
CanvasRenderingContext2D;
Chapter 22, Scripted Client-Side Graphics
CanvasRenderingContext2D
Canvas.getContext( ): return a context for drawing on the
canvas
CanvasRenderingContext2D getContext(StringcontextID)
contextID
This argument specifies the type of drawing you want
to do with the canvas. Currently the only valid value is
"2d", which specifies two-dimensional drawing and causes
this method to return a context object that exports a 2-D
drawing API.
A CanvasRenderingContext2D object with which you can draw
into the Canvas element.
Returns a context representing the type of context to use in
drawing. The intent is to provide different contexts for different
drawing types (2-D, 3-D). Currently, the only one supported is "2d",
which returns a CanvasRenderingContext2D object that implements most
of the methods used by a canvas.
CanvasRenderingContext2D
CanvasGradient: a color gradient for use in a
canvas — Firefox 1.5, Safari 1.3, Opera 9: Object →
CanvasGradient
addColorStop( )
Specifies a color and position for the gradient.
A CanvasGradient object represents a color gradient that may be assigned to
both the strokeStyle and fillStyle properties of a
CanvasRenderingContext2D object. The createLinearGradient( ) and createRadialGradient( ) methods of
CanvasRenderingContext2D both return CanvasGradient objects.
strokeStyle
fillStyle
createLinearGradient( )
createRadialGradient( )
Once you have created a CanvasGradient object, use addColorStop( ) to specify what colors
should appear at what positions within the gradient. Between the
positions you specify, colors are interpolated to create a smooth
gradient or fade. Transparent black stops are created implicitly at
the start and end points of the gradient.
CanvasRenderingContext2D.createLinearGradient(
)
CanvasRenderingContext2D.createRadialGradient(
)
CanvasGradient.addColorStop( ): add a change of color at
some point in the gradient
void addColorStop(floatoffset, String color)
offset
color
A floating-point value in the range 0.0 to 1.0 that
represents a fraction between the start and end points of
the gradient. An offset of 0 corresponds to the start point,
and an offset of 1 corresponds to the end point.
Specifies the color to be displayed at the specified
offset, as a CSS color string. Colors at other points along
the gradient are interpolated based on this and any other
color stops.
addColorStop( ) provides
the mechanism for describing color changes in a gradient. This
method may be called one or more times to change the color at
particular percentages between the gradient's start and end
points.
If this method is never called on a gradient, the gradient is
transparent. At least one color stop must be specified to produce a
visible color gradient.
CanvasPattern: an image-based pattern for use in a
Canvas — Firefox 1.5, Safari 1.3, Opera 9: Object →
CanvasPattern
A CanvasPattern object is returned by the createPattern( ) method of a
CanvasRenderingContext2D object. A CanvasPattern object may be used as the
value of the strokeStyle and
fillStyle properties of a
CanvasRenderingContext2D object.
createPattern( )
A CanvasPattern object has no properties or methods of its
own. See CanvasRenderingContext2D.createPattern( )
for details on how to create one.
CanvasRenderingContext2D.createPattern( )
CanvasRenderingContext2D.createPattern(
)
CanvasRenderingContext2D.createPattern(
)
CanvasRenderingContext2D: the object used for drawing on a
canvas — Firefox 1.5, Safari 1.3, Opera 9: Object →
CanvasRenderingContext2D
readonly Canvas
canvas
The Canvas element upon which this context will
draw.
Object fillStyle
The current color, pattern, or gradient used for filling
paths. This property may be set to a string or to a
CanvasGradient or CanvasPattern object. When set to a string,
it is parsed as a CSS color value and used for solid fills.
When set to a CanvasGradient or CanvasPattern object, fills
are done using the specified gradient or pattern. See CanvasRenderingContext2D.createLinearGradient(
), CanvasRenderingContext2D.createRadialGradient(
), and CanvasRenderingContext2D.createPattern(
).
CanvasRenderingContext2D.createLinearGradient(
)
CanvasRenderingContext2D.createRadialGradient(
)
CanvasRenderingContext2D.createPattern(
)
float
globalAlpha
Specifies the opacity of content drawn on the canvas.
The range of values is between 0.0 (fully transparent) and 1.0
(no additional transparency). The default value for this
property is 1.0.
String
globalCompositeOperation
Specifies how colors being drawn are combined (or
"composited") with colors already on the canvas. See the
individual reference entry for this property for possible
values.
String lineCap
Specifies how the ends of lines are rendered. Legal
values are "butt", "round", and "square". The default is
"butt". See the individual reference page for this property
for further details.
String lineJoin
Specifies how two lines are joined. Legal values are
"round", "bevel", and "miter". The default is "miter". See the
individual reference page for this property for further
details.
float lineWidth
Specifies the line width for stroking (line drawing)
operations. The default is 1.0, and this property must be
greater than 0.0. Wide lines are centered over the path, with
half of the line width on each side.
float miterLimit
When the lineJoin
property is "miter", this property specifies the maximum ratio
of miter length to line width. See the individual reference
page for this property for further details.
lineJoin
float shadowBlur
Specifies how much feathering shadows should have. The
default is 0. Shadows are supported by Safari but not by
Firefox 1.5 or Opera 9.
String
shadowColor
Specifies the color of shadows as a CSS or web style
string and may include an alpha component for transparency.
The default is black. Shadows are supported by Safari but not
by Firefox 1.5 or Opera 9.
float shadowOffsetX,
shadowOffsetY
Specify the horizontal and vertical offset of the
shadows. Larger values make the shadowed object appear to
float higher above the background. The default is 0. Shadows
are supported by Safari, but not by Firefox 1.5 or Opera
9.
Object
strokeStyle
Specifies the color, pattern, or gradient used for
stroking (drawing) paths. This property may be a string, or a
CanvasGradient or a CanvasPattern object. If it is a string,
it is parsed as a CSS color value and the stroking is done
with the resulting solid color. If the value of this property
is a CanvasGradient or a CanvasPattern object, stroking is
done with a gradient or pattern. See CanvasRenderingContext2D.createLinearGradient(
), CanvasRenderingContext2D.createRadialGradient(
), and CanvasRenderingContext2D.createPattern(
).
arc( )
Adds an arc to the current subpath of a canvas, using a
center point and radius.
arcTo( )
Adds an arc to the current subpath, using tangent points
and a radius.
beginPath( )
Starts a new path (or a collection of subpaths) in a
canvas.
bezierCurveTo( )
Adds a cubic Bézier curve to the current subpath.
clearRect( )
Erases the pixels in a rectangular area of a
canvas.
clip( )
Uses the current path as the clipping region for
subsequent drawing operations.
closePath( )
Closes the current subpath if it's open.
createLinearGradient(
)
Returns a CanvasGradient object that represents a linear
color gradient.
Returns a CanvasPattern object that represents a tiled
image.
createRadialGradient(
)
Returns a CanvasGradient object that represents a radial
color gradient.
drawImage( )
Draws an image.
fill( )
Paints or fills the interior of the current path with
the color, gradient, or pattern specified by the fillStyle property.
fillRect( )
Paints or fills a rectangle.
lineTo( )
Adds a straight line segment to the current
subpath.
moveTo( )
Sets the current position and begins a new
subpath.
quadraticCurveTo(
)
Adds a quadratic Bézier curve to the current
subpath.
rect( )
Add a rectangle subpath to the current path.
restore( )
Resets the canvas to the graphics state most recently
saved.
rotate( )
Rotates the canvas.
save( )
Saves the properties, clipping region, and
transformation matrix of the CanvasRenderingContext2D
object.
scale( )
Scales the user coordinate system of the canvas.
stroke( )
Draws, or strokes, a line following the current path.
The line is drawn according to the lineWidth, lineJoin, lineCap, and strokeStyle properties, among
others.
lineWidth
lineCap
strokeRect( )
Draws (but does not fill) a rectangle.
translate( )
Translates the user coordinate system of the
canvas.
The CanvasRenderingContext2D object provides a set of graphics
functions to draw on a canvas. While text support is unfortunately
omitted, the functions available are quite rich. They fall into a
number of categories.
You can outline and fill rectangles with strokeRect( ) and fillRect( ). In addition, you can clear
the area defined by a rectangle with clearRect( ).
In the Canvas API, images are specified using Image objects
that represent HTML <img>
elements or offscreen images created with the Image( ) constructor. (See the Image reference page for details.) A
canvas object can also be used as an image source.
<img>
Image( )
Image
You can draw an image into a canvas with the drawImage( ) method, which, in its most
general form, allows an arbitrary rectangular region of the source
image to be scaled and rendered into the canvas.
A powerful feature of the canvas is its ability to build
shapes up from basic drawing operations, then either draw their
outlines (stroke them) or paint their
contents (fill them). The operations
accumulated are collectively referred to as the current
path. A canvas maintains a single current path.
In order to build a connected shape out of multiple
segments, a joining point is needed between drawing operations.
For this purpose, the canvas maintains a current
position. The canvas drawing operations implicitly use
this as their start point and update it to what is typically their
end point. You can think of this like drawing with a pen on paper:
when finishing a particular line or curve, the current position is
where the pen rested after completing the operation.
You can create a sequence of disconnected shapes in the
current path that will be rendered together with the same drawing
parameters. To separate shapes, use the moveTo( ) method; this moves the current
position to a new location without adding a connecting line. When
you do this, you create a new subpath, which
is the canvas term used for a collection of operations that are
connected.
Once the path is formed to your liking, you can draw its
outline with stroke( ), paint
its contents with fill( ), or
do both.
The available shape operations are lineTo( ) for drawing straight lines,
rect( ) for drawing rectangles,
arc( ) or arcTo( ) for drawing partial circles,
and bezierCurveTo( ) or
quadraticCurveTo( ) for drawing
curves.
quadraticCurveTo( )
In addition to stroking and filling, you can also use the
current path to specify the clipping region
the canvas uses when rendering. Pixels inside this region are
displayed; those outside are not. The clipping region is
cumulative; calling clip( )
intersects the current path with the current clipping region to
yield a new region. Unfortunately, there is no direct method for
resetting the clipping region to the extent of the canvas; to do
so, you must save and restore the entire graphics state of the
canvas (described later in this entry).
If the segments in any of the subpaths do not form a closed
shape, fill( ) and clip( ) operations implicitly close them
for you by adding a virtual (not visible with a stroke) line
segment from the start to the end of the subpath. Optionally, you
can call closePath( ) to
explicitly add this line segment.
When filling or stroking paths, you can specify how the
lines or painted area are rendered using the fillStyle and strokeStyle properties. Both accept
CSS-style color strings, as well as CanvasGradient and
CanvasPattern objects that describe gradients and patterns. To
create a gradient, use the createLinearGradient( ) or createRadialGradient( ) methods. To
create a pattern, use createPattern(
).
createPattern(
)
To specify an opaque color using CSS notation, use a string
of the form "#RRGGBB", where RR, GG, and BB are hexadecimal digits
that specify the red, green, and blue components of the color as
values between 00 and FF. For example, bright red is "#FF0000". To
specify a partially transparent color, use a string of the form
"rgba(R,G,B,A)". In this form, R, G, and B specify the red, green,
and blue components of the color as decimal integers between 0 and
255, and A specifies the alpha (opacity) component as a
floating-point value between 0.0 (fully transparent) and 1.0
(fully opaque). For example, half-transparent bright red is
"rgba(255,0,0,0.5)".
Canvas offers several options for tailoring how lines
appear. You can specify the width of the line with the lineWidth property, how the end points
of lines are drawn with the lineCap property, and how lines are
joined using the lineJoin
property.
By default, the coordinate space for a canvas has its origin
at (0,0) in the upper-left
corner of the canvas, with x values
increasing to the right and y values
increasing down. A single unit in this coordinate space normally
translates to a single pixel.
(0,0)
x
y
You can, however, transform the
coordinate space, causing any coordinates or extents you specify
in drawing operations to be shifted, scaled, or rotated. This is
done with the translate( ),
scale( ), and rotate( ) methods, which affect the
transformation matrix of the canvas. Because
the coordinate space can be transformed like this, the coordinates
you pass to methods such as lineTo(
) may not be measured in pixels. For this reason, the
Canvas API uses floating-point numbers instead of integers.
lineTo(
)
Transformations are processed in reverse of the order in
which they are specified. So, for example, a call to scale( ) followed by a call to translate( ) causes the coordinate
system first to be translated, then scaled.
Commonly, shapes are drawn on top of one another, with the
new shape obscuring any shapes that were previously drawn below
it. This is the default behavior in a canvas. However, you can
perform many interesting operations by specifying different values
for the globalCompositeOperation property. These
range from XORing to lightening or darkening shaped regions; see
CanvasRenderingContext2D.globalCompositeOperation
for all the possible options.
globalCompositeOperation
CanvasRenderingContext2D.globalCompositeOperation
The Canvas API includes properties that can automatically
add a drop shadow to any shape you draw. At the time of this
writing, Safari is the only browser that implements this API,
however. The color of the shadow may be specified with shadowColor, and its offset changed
using shadowOffsetX and
shadowOffsetY. In addition, the
amount of feathering applied to the shadow's edge may be set with
shadowBlur.
shadowColor
shadowOffsetX
shadowOffsetY
shadowBlur
The save( ) and restore( ) methods allow you to save and
restore the state of a CanvasRenderingContext2D object. save( ) pushes the current state onto a
stack, and restore( ) pops the
most recently saved state off the top of the stack and sets the
current drawing state based on those stored values.
All properties of the CanvasRenderingContext2D object
(except for the canvas
property, which is a constant) are part of the saved state. The
transformation matrix and clipping region are also part of the
state, but the current path and current point are not.
canvas
Canvas
Canvas
CanvasRenderingContext2D.arc( ): add an arc to the current
subpath of a canvas, using a center point and radius
void arc(floatx, float y, float radius, float startAngle, endAngle,
boolean counterclockwise)
radius
startAngle
endAngle
counterclockwise
x, y
The coordinates of the center of the circle describing
the arc.
The radius of the circle describing the arc.
startAngle, endAngle
The angles that specify the start and end points of
the arc along the circle. These angles are measured in
radians. The three o'clock position along the positive X
axis is an angle of 0, and angles increase in the clockwise
direction.
Whether the arc is traversed counterclockwise
(true) or clockwise
(false) along the
circle's circumference.
The first five arguments to this method describe specify a
start point and an end point on the circumference of a circle.
Invoking this method adds a straight line between the current point
and the start point to the current subpath. Next it adds the arc
along the circumference of the circle between the start and end
points to the subpath. The final argument specifies the direction in
which the circle should be traversed to connect the start and end
points. This method leaves the current point set to the end point of
the arc.
CanvasRenderingContext2D.arcTo(
)
CanvasRenderingContext2D.beginPath(
)
CanvasRenderingContext2D.closePath(
)
CanvasRenderingContext2D.arcTo( ): add an arc of a circle
to the current subpath, using tangent points and a radius
void arcTo(floatx1, float y1, float x2, float y2, float radius)
x1
y1
x2
y2
x1, y1
The coordinates of point P1.
x2, y2
The coordinates of point P2.
The radius of the circle that defines the arc.
This method adds an arc to the current subpath but describes
that arc much differently than the arc(
) method does. The arc that is added to the path is a
portion of a circle with the specified
radius. The arc has one point tangent to
the line from the current position to P1 and one point that is
tangent to the line from P1 to P2. The arc begins and ends at these
two tangent points and is drawn in the direction that connects those
two points with the shortest arc.
arc(
)
In many common uses, the arc begins at the current position
and ends at P2, but this is not always the case. If the current
position is not the same as the starting point of the arc, this
method adds a straight line from the current position to the start
position of the arc. This method always leaves the current position
set to the end point of the arc.
You could draw the upper-right corner of a rectangle, giving
it a rounded corner with code like the following:
c.moveTo(10,10); // start at upper left
c.lineTo(90, 10) // horizontal line to start of round corner
c.arcTo(100, 10, 100, 20, 10); // rounded corner
c.lineTo(100, 100); // vertical line down to lower right
This method is not implemented in Firefox 1.5.
CanvasRenderingContext2D.arc(
)
CanvasRenderingContext2D.arc(
)
CanvasRenderingContext2D.beginPath( ): start a new
collection of subpaths in a canvas
void beginPath( )
beginPath( ) discards any
currently defined path and begins a new one. It sets the current
point to (0,0).
When the context for a canvas is first created, beginPath( ) is implicitly called.
CanvasRenderingContext2D.fill(
)
CanvasRenderingContext2D.stroke(
)
CanvasRenderingContext2D.bezierCurveTo( ): add a cubic
Bézier curve to the current subpath
void bezierCurveTo(floatcpX1, float cpY1, float cpX2, float cpY2, float x,
float y)
cpX1
cpY1
cpX2
cpY2
cpX1, cpX2
The coordinates of the control point associated with
the curve's start point (the current position).
cpX2, cpY2
The coordinates of the control point associated with
the curve's end point.
The coordinates of the curve's end point.
bezierCurveTo( ) adds a
cubic Bézier curve to the current subpath of a canvas. The start
point of the curve is the current point of the canvas, and the end
point is (x,y). The two Bezier
control points (cpX1, cpY1) and
(cpX2, cpY2) define the shape of
the curve. When this method returns, the current position is
(x,y).
(x,y)
(cpX1, cpY1)
(cpX2, cpY2)
CanvasRenderingContext2D.quadraticCurveTo(
)
CanvasRenderingContext2D.quadraticCurveTo(
)
CanvasRenderingContext2D.clearRect( ): erase a rectangular
area of a canvas
void clearRect(floatx, float y,
float width, float height)
The coordinates of the upper-left corner of the
rectangle.
width, height
The dimensions of the rectangle.
clearRect( ) erases the
specified rectangle, filling it with a transparent color.
CanvasRenderingContext2D.clip( ): set the clipping path of
a canvas
void clip( )
This method clips the current path using the current clipping
path and then uses the clipped path as the new clipping path. Note
that there is no way to enlarge the clipping path. If you want a
temporary clipping path, you should first call save( ) in order to use restore( ) to restore the original
clipping path. The default clipping path for a canvas is the canvas
rectangle itself.
This method resets the current path so that it is
empty.
CanvasRenderingContext2D.closePath( ): closes an open
subpath
void closePath( )
If the current subpath of the canvas is open, closePath( ) closes it by adding a line
connecting the current point to the subpath's starting point. If the
subpath is already closed, this method does nothing. Once a subpath
is closed, no more lines or curves can be added to it. To continue
adding to the path, you must begin a new subpath with a call to
moveTo( ).
You do not need to call closePath(
) before stroking or filling a path. Paths are implicitly
closed when filled (and also when you call clip( )).
closePath(
)
CanvasRenderingContext2D.moveTo(
)
CanvasRenderingContext2D.createLinearGradient( ): create a
linear color gradient
CanvasGradient createLinearGradient(floatxStart, float yStart,
float xEnd, float yEnd)
xStart
yStart
xEnd
yEnd
xStart, yStart
The coordinates of the gradient's start point.
xEnd, yEnd
The coordinates of the gradient's end point.
A CanvasGradient object representing a linear color
gradient.
This method creates and returns a new CanvasGradient object
that linearly interpolates colors between the specified start point
and end point. Note that this method does not specify any colors for
the gradient. Use the addColorStop(
) method of the returned object to do that. To stroke
lines or fill areas using a gradient, assign a CanvasGradient object
to the strokeStyle or fillStyle properties.
addColorStop(
)
CanvasGradient.addColorStop(
), CanvasRenderingContext2D.createRadialGradient(
)
CanvasGradient.addColorStop(
)
CanvasRenderingContext2D.createRadialGradient(
)
CanvasRenderingContext2D.createPattern( ): create a pattern
of tiled images
CanvasPattern createPattern(Imageimage,
String repetitionStyle)
image
repetitionStyle
The image to be tiled. This argument is typically an
Image object, but you may also use a Canvas element.
Specifies how the image is tiled. The possible values
are the following:
Value
Meaning
"repeat"
"repeat"
Tile the image in both
directions. This is the default.
"repeat-x"
"repeat-x"
Tile the image in the X
dimension only.
"repeat-y"
"repeat-y"
Tile the image in the Y
dimension only.
"no-repeat"
"no-repeat"
Do not tile the image; use it a
single time only.
A CanvasPattern object representing the pattern.
This method creates and returns a CanvasPattern object that
represents the pattern defined by a tiled image. To use a pattern
for stroking lines or filling areas, use a CanvasPattern object as
the value of the strokeStyle or
fillStyle properties.
Firefox 1.5 supports only the "repeat" style. Others are ignored.
CanvasPattern
CanvasPattern
CanvasRenderingContext2D.createRadialGradient( ): create a
radial color gradient
CanvasGradient createRadialGradient(floatxStart, float yStart, float
radiusStart,
float xEnd, float yEnd, float radiusEnd)
radiusStart
radiusEnd
The coordinates of the center of the starting
circle.
The radius of the starting circle.
The coordinates of the center of the ending
circle.
The radius of the ending circle.
A CanvasGradient object representing a radial color
gradient.
This method creates and returns a new CanvasGradient object
that radially interpolates colors between the circumferences of the
two specified circles. Note that this method does not specify any
colors for the gradient. Use the addColorStop( ) method of the returned
object to do that. To stroke lines or fill areas using a gradient,
assign a CanvasGradient object to the strokeStyle or fillStyle properties.
Radial gradients are rendered by using the color at offset 0
for the circumference of the first circle, the color at offset 1 for
the second circle, and interpolated color values (red, green, blue,
and alpha) at circles between the two.
CanvasGradient.addColorStop(
), CanvasRenderingContext2D.createLinearGradient(
)
CanvasRenderingContext2D.createLinearGradient(
)
CanvasRenderingContext2D.drawImage( ): draw an
image
void drawImage(Imageimage, float x, float y)
void drawImage(Image image, float x, float y,
float width, float height)
void drawImage(Image image, integer sourceX, integer sourceY,
integer sourceWidth, integer sourceHeight,
float destX, float destY,
float destWidth, float destHeight)
sourceX
sourceY
sourceWidth
sourceHeight
destX
destY
destWidth
destHeight
The image to be drawn. This must be an Image object
representing an <img> tag, or an offscreen
image or a Canvas object.
The point at which the upper-left corner of the image
is drawn.
The size at which the image should be drawn.
Specifying these arguments causes the image to be
scaled.
sourceX, sourceY
The upper-left corner of the region of the image that
is to be drawn. These integer arguments are measured in
image pixels.
sourceWidth,
sourceHeight
The dimensions, in image pixels, of the region of the
image that is to be drawn.
destX, destY
The canvas coordinates at which the upper-left corner
of the image region is to be drawn
destWidth, destHeight
The canvas dimensions at which the image region should
be drawn.
There are three variants of this method. The first copies the
entire image to the canvas, placing its upper-left corner at the
specified point and mapping each image pixel to one unit in the
canvas coordinate system. The second variant also copies the entire
image to the canvas but allows you to specify the desired width and
height of the image in canvas units. The third variant is fully
general: it allows you to specify any rectangular region of the
image and copy it, with arbitrary scaling to any position within the
canvas.
The images passed to this method must be Image or Canvas
objects. An Image object may represent an <img> tag in the document or an
offscreen image created with the Image(
) constructor.
Image(
)
Image
CanvasRenderingContext2D.fill( ): fill the path
void fill( )
fill( ) fills the current
path with the color, gradient, or pattern specified by the fillStyle property. Each subpath of the
path is filled independently. Any subpaths that are not closed are
filled as if the closePath( )
method had been called on them. (Note, however, that this does not
actually cause those subpaths to become closed.)
The canvas uses the "non-zero winding rule" to determine which
points are inside the path and which are outside. The details of
this rule are beyond the scope of this book, but they typically
matter only for complex paths that intersect themselves.
Filling a path does not clear the path. You may call stroke( ) after calling fill( ) without redefining the
path.
CanvasRenderingContext2D.fillRect(
)
CanvasRenderingContext2D.fillRect(
)
CanvasRenderingContext2D.fillRect( ): fill a
rectangle
void fillRect(floatx, float y,
float width, float height)
The coordinates of the upper-left corner of
rectangle.
fillRect( ) fills the
specified rectangle with the color, gradient, or pattern specified
by the fillStyle property.
Current implementations of fillRect(
) also clear the path as if beginPath( ) had been called. This
surprising behavior may not be standardized and should not be relied
upon.
fillRect(
)
CanvasRenderingContext2D.rect(
)
CanvasRenderingContext2D.strokeRect(
)
CanvasRenderingContext2D.globalCompositeOperation:
specifies how colors are combined on the canvas
String globalCompositeOperation
This property specifies how colors being rendered onto the
canvas are combined (or "composited") with the colors that already
exist in the canvas. The following table lists the possible values
and their meanings. The word source in the
these values refers to the colors being drawn onto the canvas, and
the word destination refers to the existing
colors on the canvas. The default is "source-over".
"copy"
Draws only the new shape, removing
everything else.
"darker"
Where both shapes overlap, the
color is determined by subtracting color
values.
"destination-atop"
Existing content is kept only
where it overlaps the new shape. The new shape is drawn
behind the content.
"destination-in"
Existing content is kept where
both the new shape and existing canvas content overlap.
Everything else is made transparent.
"destination-out"
Existing content is kept where it
doesn't overlap the new shape. Everything else is made
transparent.
"destination-over"
The new shape is drawn behind
existing content.
"lighter"
Where both shapes overlap, the
color is determined by adding the two color
values.
"source-atop"
The new shape is drawn only where
it overlaps existing content.
"source-in"
The new shape is drawn only where
both the new shape and existing content overlap. Everything
else is made transparent.
"source-out"
The new shape is drawn where it
doesn't overlap existing content.
"source-over"
The new shape is drawn on top of
existing content. This is the default
behavior.
"xor"
Shapes are made transparent where
both overlap and drawn normal everywhere
else.
Firefox 1.5 does not support the values "copy" or
"darker".
CanvasRenderingContext2D.lineCap: specifies how the ends of
lines are rendered
The lineCap property
specifies how lines should be terminated. It matters only when
drawing wide lines. Legal values for this property are listed in the
following table. The default value is "butt".
"butt"
This default value specifies that
the line should have no cap. The end of the line is straight
and is perpendicular to the direction of the line. The line
is not extended beyond its endpoint.
"round"
This value specifies that lines
should be capped with a semicircle whose diameter is equal
to the width of the line and which extends beyond the end of
the line by one half the width of the line.
"square"
This value specifies that lines
should be capped with a rectangle. This value is like
"butt", but the line is extended by half of its
width.
Firefox 1.5 does not properly implement the "butt" cap style.
Butt caps are rendered as if they were "square" line caps.
CanvasRenderingContext2D.lineJoin
CanvasRenderingContext2D.lineJoin
CanvasRenderingContext2D.lineJoin: specifies how vertices
are rendered
When a path includes vertices where line segments and/or
curves meet, the lineJoin
property specifies how those vertices are drawn. The effect of this
property is apparent only when drawing with wide lines.
The default value of the property is "miter", which specifies
that the outside edges of the two line segments are extended until
they intersect. When two lines meet at an acute angle, mitered joins
can become quite long. The miterLimit property places an upper bound
on the length of a miter. Beyond this limit, the miter is beveled
off.
miterLimit
The value "round" specifies that the outside edges of the
vertex should be joined with a filled arc whose diameter is equal to
the width of the line.
The value "bevel" specifies that the outside edges of the
vertex should be joined with a filled triangle.
Firefox 1.5 does not correctly implement beveled joins and
renders them as rounded joins. Also, mitered joins are not displayed
correctly when stroked in a partially transparent color.
CanvasRenderingContext2D.lineCap, CanvasRenderingContext2D.miterLimit
CanvasRenderingContext2D.lineCap
CanvasRenderingContext2D.miterLimit
CanvasRenderingContext2D.lineTo( ): add a straight line to
the current subpath
void lineTo(floatx, float y)
The coordinates of the end point of the line.
lineTo( ) adds a straight
line to the current subpath. The line begins at the current point
and ends at (x,y). When this
method returns, the current position is (x,y).
CanvasRenderingContext2D.beginPath(
), CanvasRenderingContext2D.moveTo( )
CanvasRenderingContext2D.beginPath(
)
CanvasRenderingContext2D.moveTo( )
CanvasRenderingContext2D.miterLimit:
maximum-miter-length-to-line-width ratio
When wide lines are drawn with the lineJoin property set to "miter" and two
lines meet at an acute angle, the resulting miter can be quite long.
When miters are too long, they become visually jarring. This
miterLimit property places an
upper bound on the length of the miter. This property expresses a
ratio of the miter length to the line width. The default value is
10, which means that a miter should never be longer than 10 times
the line width. If a miter reaches this length, it is beveled off.
This property has no effect when lineJoin is "round" or "bevel".
Firefox 1.5 does not correctly implement this property. When a
mitered join exceeds the miterLimit, the join is converted to a
rounded join instead.
CanvasRenderingContext2D.lineJoin
CanvasRenderingContext2D.moveTo( ): sets the current
position and begins a new subpath
void moveTo(floatx, float y)
The coordinates of the new current point.
moveTo( ) sets the current
position to (
x ,
y )
and creates a new subpath with this as its first point. If there was
a previous subpath and it consisted of just one point, that subpath
is removed from the path.
(
,
)
CanvasRenderingContext2D.beginPath(
)
CanvasRenderingContext2D.quadraticCurveTo( ): add a
quadratic Bezier curve to the current subpath
void quadraticCurveTo(floatcpX, float cpY,
float x, float y)
cpX
cpY
cpX, cpY
The coordinates of the control point.
The coordinates of the end point of the curve.
This method adds a quadratic Bézier curve segment to the
current subpath. The curve starts at the current point and ends at
( x
, y
). The control point ( cpX , cpY ) specifies the shape of the curve between
these two points. (The mathematics of Bezier curves is beyond the
scope of this book, however.) When this method returns, the current
position is (
x ,
y ).
Firefox 1.5 implements this method incorrectly.
CanvasRenderingContext2D.bezierCurveTo(
)
CanvasRenderingContext2D.bezierCurveTo(
)
CanvasRenderingContext2D.rect( ): add a rectangle subpath
to the path
void rect(floatx, float y,
float width, float height)
This method adds a rectangle to the path. This rectangle is in
a subpath of its own and is not connected to any other subpaths in
the path. When this method returns, the current position is (0,0).
CanvasRenderingContext2D.fillRect(
), CanvasRenderingContext2D.strokeRect(
)
CanvasRenderingContext2D.strokeRect(
)
CanvasRenderingContext2D.restore( ): reset drawing state to
saved values
void restore( )
This method pops the stack of saved graphics states and
restores the values of the CanvasRenderingContext2D properties, the
clipping path, and the transformation matrix. See the save( ) method for further
information.
Firefox 1.5 does not correctly save and restore the strokeStyle property.
CanvasRenderingContext2D.save(
)
CanvasRenderingContext2D.save(
)
CanvasRenderingContext2D.rotate( ): rotate the coordinate
system of the canvas
void rotate(floatangle)
angle
The amount of rotation, in radians. Positive values
result in clockwise rotation, and negative values result in
counterclockwise rotation.
This method alters the mapping between canvas coordinates and
the pixels of the <canvas>
element in the web browser so that any subsequent drawing appears
rotated within the canvas by the specified angle. It does not rotate
the <canvas> element
itself. Note that the angle is specified in radians. To convert
degrees to radians, multiply by Math.PI and divide by 180.
Math.PI
CanvasRenderingContext2D.scale(
), CanvasRenderingContext2D.translate(
)
CanvasRenderingContext2D.scale(
)
CanvasRenderingContext2D.translate(
)
CanvasRenderingContext2D.save( ): save a copy of the
current graphics state
void save( )
save( ) pushes a copy of
the current graphics state onto a stack of saved graphics states.
This allows you to temporarily change the graphics state, and then
restore the previous values with a call to restore( ).
The graphics state of a canvas includes all the properties of
the CanvasRenderingContext2D object (except for the read-only
canvas property). It also
includes the transformation matrix that is the result of calls to
rotate( ), scale( ), and translate( ). Additionally, it includes
the clipping path, which is specified with the clip( ) method. Note, however, that the
current path and current position are not part of the graphics state
and are not saved by this method.
Firefox 1.5 does not save and restore the strokeStyle property.
CanvasRenderingContext2D.restore(
)
CanvasRenderingContext2D.restore(
)
CanvasRenderingContext2D.scale( ): scale the user
coordinate system of the canvas
void scale(floatsx, float sy)
sx
sy
sx, sy
The horizontal and vertical scaling factors.
scale( ) adds a scale
transformation to the current transformation matrix of the canvas.
Scaling is done with independent horizontal and vertical scaling
factors. For example, passing the values 2.0 and 0.5 causes
subsequently drawn paths to be twice as wide and half as high as
they would otherwise have been. Specifying a negative value for
sx causes X coordinates to be flipped
across the Y axis, and a negative value of
sy causes Y coordinates to be flipped
across the X axis.
CanvasRenderingContext2D.rotate(
), CanvasRenderingContext2D.translate(
)
CanvasRenderingContext2D.rotate(
)
CanvasRenderingContext2D.stroke( ): draw the current
path
void stroke( )
The stroke( ) method draws
the outline of the current path. The path defines the geometry of
the line that is produced, but the visual appearance of that line
depends on the strokeStyle,
lineWidth, lineCap, lineJoin, and miterLimit properties.
The term stroke refers to a pen or
brush stroke. It means "draw the outline of." Contrast this stroke( ) method with fill( ), which fills the interior of a
path rather than stroking the outline of the path.
CanvasRenderingContext2D.strokeRect( ): draw a
rectangle
void strokeRect(floatx, float y,
float width, float height)
This method draws the outline (but does not fill the interior)
of a rectangle with the specified position and size. Line color and
line width are specified by the strokeStyle and lineWidth properties. The appearance of
the rectangle corners are specified by the lineJoin property.
Current implementations of strokeRect( ) clear the path as if
beginPath( ) had been called.
This surprising behavior may not be standardized and should not be
relied upon.
CanvasRenderingContext2D.fillRect(
)
CanvasRenderingContext2D.translate( ): translate the user
coordinate system of the canvas
void translate(floatdx, float dy)
dx
dy
dx, dy
The amounts to translate in the X and Y
dimensions.
translate( ) adds
horizontal and vertical offsets to the transformation matrix of the
canvas. The arguments dx and
dy are added to all points in any
subsequently defined paths.
CanvasRenderingContext2D.rotate(
), CanvasRenderingContext2D.scale( )
CanvasRenderingContext2D.scale( )
CDATASection: a CDATA node in an XML document — DOM Level 1 XML: Node → CharacterData → Text →
CDATASection
This infrequently used interface represents a CDATA section in
an XML document. Programmers working with HTML documents never
encounter nodes of this type and do not need to use this
interface.
CDATASection is a subinterface of Text and does not define any
properties or methods of its own. The textual content of the CDATA
section is available through the nodeValue property inherited from Node or
through the data property
inherited from CharacterData. Although CDATASection nodes can often
be treated in the same way as Text nodes, note that the Node.normalize( ) method does not merge
adjacent CDATA sections. Create a CDATASection with Document.createCDATASection( ).
nodeValue
data
Node.normalize( )
Document.createCDATASection( )
CharacterData, Text
CharacterData
Text
CharacterData: common functionality for Text and Comment
nodes — DOM Level 1 Core: Node → CharacterData
Comment, Text
String data
The text contained by this node.
readonly unsigned long
length
The number of characters contained by this node.
appendData( )
Appends the specified string to the text contained by
this node.
deleteData( )
Deletes text from this node, starting with the character
at the specified offset and continuing for the specified
number of characters.
insertData( )
Inserts the specified string into the text of this node
at the specified character offset.
replaceData( )
Replaces the characters starting at the specified
character offset and continuing for the specified number of
characters with the specified string.
substringData( )
Returns a copy of the text starting at the specified
character offset and continuing for the specified number of
characters.
CharacterData is the superinterface for Text and Comment
nodes. Documents never contain CharacterData nodes; they contain
only Text and Comment nodes. Since both of these node types have
similar functionality, however, that functionality has been defined
here so that both Text and Comment can inherit it.
Note that it is not necessary to use the string-manipulation
methods defined by this interface. The data property is an ordinary JavaScript
string, and you can manipulate it with the + operator for string concatenation and
with various String and RegExp methods.
+
Comment
CharacterData.appendData( ): append a string to a Text or
Comment node — DOM Level 1 Core:
void appendData(Stringarg)
throws DOMException;
arg
The string to be appended to the Text or Comment
node.
This method throws a DOMException with a code of NO_MODIFICATION_ALLOWED_ERR if called on
a node that is read-only.
code
NO_MODIFICATION_ALLOWED_ERR
This method appends the string arg
to the end of the data property
for this node.
CharacterData.deleteData( ): delete characters from a Text
or Comment node — DOM Level 1 Core:
void deleteData(unsigned longoffset,
unsigned long count)
throws DOMException;
count
The position of the first character to be
deleted.
The number of characters to be deleted.
This method may throw a DOMException with one of the
following code values:
INDEX_SIZE_ERR
The offset or
count argument is negative, or
offset is greater than the length
of the Text or Comment node.
The node is read-only and may not be modified.
This method deletes characters from this Text or Comment node,
starting with the character at the position
offset and continuing for
count characters. If
offset plus
count is greater than the number of
characters in the Text or Comment node, all characters from
offset to the end of the string are
deleted.
CharacterData.insertData( ): insert a string into a Text or
Comment node — DOM Level 1 Core:
void insertData(unsigned longoffset,
String arg)
throws DOMException;
The character position within the Text or Comment node
at which the string is to be inserted.
The string to insert.
This method may throw a DOMException with one of the
following code values in the
following circumstances:
offset is negative or
greater than the length of the Text or Comment node.
This method inserts the specified string
arg into the text of a Text or Comment
node at the specified position
offset.
CharacterData.replaceData( ): replace characters of a Text
or Comment node with a string — DOM Level 1 Core:
void replaceData(unsigned longoffset,
unsigned long count,
String arg)
throws DOMException;
The character position within the Text or Comment node
at which the replacement is to begin.
The number of characters to be replaced.
The string that replaces the characters specified by
offset and
count.
offset is negative or
greater than the length of the Text or Comment node, or
count is negative.
This method replaces count
characters starting at position offset
with the contents of the string arg. If
the sum of offset and
count is greater than the length of the
Text or Comment node, all characters from
offset on are replaced.
Notice that the insertData(
) and deleteData( )
methods are both special cases of this one.
insertData(
)
CharacterData.substringData( ): extract a substring from a
Text or Comment node — DOM Level 1 Core:
String substringData(unsigned longoffset,
unsigned long count)
throws DOMException;
The position of the first character to be
returned.
The number of characters in the substring to be
returned.
A string that consists of count
characters of the Text or Comment node starting with the character
at position offset.
DOMSTRING_SIZE_ERR
The specified range of text is too long to fit into a
string in the browser's JavaScript implementation.
This method extracts the substring that starts at
position offset and continues for
count characters from the text of a Text
or Comment node. This method is useful only when the amount of text
contained by the node is larger than the maximum number of
characters that can fit in a string in a browser's JavaScript
implementation. In this case, a JavaScript program cannot use the
data property of the Text or
Comment node directly and must instead work with shorter substrings
of the node's text. This situation is unlikely to arise in
practice.
Checkbox: see Input
Comment: an HTML or XML comment — DOM Level 1 Core: Node → CharacterData →
Comment
A Comment node represents a comment in an HTML or XML
document. The content of the comment (i.e., the text between
<!-- and -->) is available through the data property inherited from the
CharacterData interface or through the nodeValue property inherited from the Node
interface. This content may be manipulated using the various methods
inherited from CharacterData. Create a comment object with Document.createComment( ).
<!--
-->
Document.createComment( )
CharacterData
CSS2Properties: a set of CSS attributes and their
values — DOM Level 2 CSS2: Object → CSS2Properties
String cssText
The textual representation of a set of style attributes
and their values. The text is formated as in a CSS stylesheet,
minus the element selector and the curly braces that surround
the attributes and values. Setting this property to an illegal
value throws a DOMException with a code of SYNTAX_ERR. Attempting to set this
property when the CSS2Properties object is read-only throws a DOMException with a
code of NO_MODIFICATION_ALLOWED_ERR.
SYNTAX_ERR
In addition to the cssText
property, a CSS2Properties object also has a property corresponding
to each CSS attribute that the browser supports. These property
names correspond closely to the CSS attribute names, with minor
changes required to avoid syntax errors in JavaScript. Multiword
attributes that contain hyphens, such as "font-family", are written
without hyphens in JavaScript, and each word after the first is
capitalized: fontFamily. Also,
the "float" attribute conflicts with the reserved word float, so it translates to the property
cssFloat.
cssText
fontFamily
float
cssFloat
The CSS2Properties property names corresponding to each
attribute defined by the CSS2 specification are listed in the
following table. Note, however, that some browsers do not support
all CSS attributes and may not implement all of the listed
properties. Since the properties correspond directly to CSS
attributes, no individual documentation is given for each property.
See a CSS reference, such as Cascading Style Sheets: The
Definitive Guide by Eric A. Meyer (O'Reilly), for the
meaning and legal values of each. All of the properties are strings.
Setting any of these properties may throw the same exceptions as
setting the cssText
property:
azimuth
azimuth
background
background
backgroundAttachment
backgroundAttachment
backgroundColor
backgroundColor
backgroundImage
backgroundImage
backgroundPosition
backgroundPosition
backgroundRepeat
backgroundRepeat
border
border
borderBottom
borderBottom
borderBottomColor
borderBottomColor
borderBottomStyle
borderBottomStyle
borderBottomWidth
borderBottomWidth
borderCollapse
borderCollapse
borderColor
borderColor
borderLeft
borderLeft
borderLeftColor
borderLeftColor
borderLeftStyle
borderLeftStyle
borderLeftWidth
borderLeftWidth
borderRight
borderRight
borderRightColor
borderRightColor
borderRightStyle
borderRightStyle
borderRightWidth
borderRightWidth
borderSpacing
borderSpacing
borderStyle
borderStyle
borderTop
borderTop
borderTopColor
borderTopColor
borderTopStyle
borderTopStyle
borderTopWidth
borderTopWidth
borderWidth
borderWidth
bottom
bottom
captionSide
captionSide
clear
clear
clip
clip
color
content
content
counterIncrement
counterIncrement
counterReset
counterReset
cssFloat
cue
cue
cueAfter
cueAfter
cueBefore
cueBefore
cursor
cursor
direction
direction
display
display
elevation
elevation
emptyCells
emptyCells
font
font
fontFamily
fontSize
fontSize
fontSizeAdjust
fontSizeAdjust
fontStretch
fontStretch
fontStyle
fontStyle
fontVariant
fontVariant
fontWeight
fontWeight
height
left
left
letterSpacing
letterSpacing
lineHeight
lineHeight
listStyle
listStyle
listStyleImage
listStyleImage
listStylePosition
listStylePosition
listStyleType
listStyleType
margin
margin
marginBottom
marginBottom
marginLeft
marginLeft
marginRight
marginRight
marginTop
marginTop
markerOffset
markerOffset
marks
marks
maxHeight
maxHeight
maxWidth
maxWidth
minHeight
minHeight
minWidth
minWidth
orphans
orphans
outline
outline
outlineColor
outlineColor
outlineStyle
outlineStyle
outlineWidth
outlineWidth
overflow
overflow
padding
padding
paddingBottom
paddingBottom
paddingLeft
paddingLeft
paddingRight
paddingRight
paddingTop
paddingTop
page
page
pageBreakAfter
pageBreakAfter
pageBreakBefore
pageBreakBefore
pageBreakInside
pageBreakInside
pause
pause
pauseAfter
pauseAfter
pauseBefore
pauseBefore
pitch
pitch
pitchRange
pitchRange
playDuring
playDuring
position
position
quotes
quotes
richness
richness
right
right
size
size
speak
speak
speakHeader
speakHeader
speakNumeral
speakNumeral
speakPunctuation
speakPunctuation
speechRate
speechRate
stress
stress
tableLayout
tableLayout
textAlign
textAlign
textDecoration
textDecoration
textIndent
textIndent
textShadow
textShadow
textTransform
textTransform
top
top
unicodeBidi
unicodeBidi
verticalAlign
verticalAlign
visibility
visibility
voiceFamily
voiceFamily
volume
volume
whiteSpace
whiteSpace
widows
widows
width
wordSpacing
wordSpacing
zIndex
zIndex
A CSS2Properties object represents a set of CSS style
attributes and their values. It defines one JavaScript property for
each CSS attribute defined by the CSS2 specification. The style property of an HTMLElement is a
read/write CSS2Properties object, as is the style property of a CSSRule
object. The return value of Window.getComputedStyle( ), however, is a
CSS2Properties object whose properties are read-only.
style
Window.getComputedStyle( )
CSSRule, HTMLElement, Window.getComputedStyle( ); Chapter 16, Cascading Style Sheets and Dynamic HTML
CSSRule
CSSRule: a rule in a CSS stylesheet — DOM Level 2 CSS, IE 5: Object → CSSRule
String
selectorText
The selector text that specifies the document elements
this style rule applies to. Setting this property raises a
DOMException with a code of
NO_MODIFICATION_ALLOWED_ERR
if the rule is read-only or a code of SYNTAX_ERR if the new value does not
follow CSS syntax rules.
readonly CSS2Properties
style
The style values that should be applied to elements
specified by selectorText.
Note that while the style
property itself is read-only, the properties of the
CSS2Properties object to which it refers are
read/write.
selectorText
A CSSRule object represents a rule in a CSS stylesheet: it
represents style information to be applied to a specific set of
document elements. selectorText
is the string representation of the element selector for this rule,
and style is a CSS2Properties
object that represents the set of style attributes and values to
apply to the selected elements.
The DOM Level 2 CSS specification actually defines a somewhat
complex hierarchy of CSSRule interfaces to represent different types
of rules that can appear in a CSSStyleSheet. The properties listed
here are actually defined by the DOM CSSStyleRule interface. Style
rules are the most common and most important types of rules in a
stylesheet, and the properties listed here are the only ones that
can be used portably across browsers. IE does not support the DOM
Level 2 specification very well (at least not through IE 7) but does
implement a CSSRule object that supports the two properties listed
here.
CSS2Properties, CSSStyleSheet
CSS2Properties
CSSStyleSheet
CSSStyleSheet: a CSS stylesheet — DOM Level 2 CSS, IE 4: Object →
CSSStyleSheet
readonly CSSRule[]
cssRules
A read-only, array-like object holding the CSSRule
objects that compose the stylesheet. In IE, use the rules property instead. In
DOM-compliant implementations, this array includes objects
that represent all rules in a stylesheet, including at-rules
such as @import directives.
Rules of these sorts implement a different interface than that
described for CSSRule. These other type of rule objects are
not well supported across browsers and are not documented in
this book. Be aware, therefore, that you must test any entries
in this array to ensure that they define CSSRule properties
before you attempt to use those properties.
rules
@import
boolean disabled
If true, the
stylesheet is disabled and is not applied to the document. If
false, the stylesheet is
enabled and is applied to the document.
readonly String
href
The URL of a stylesheet that is linked to the document
or null for inline
stylesheets.
readonly StyleSheet
parentStyleSheet
The stylesheet that included this one or null if this stylesheet was included
directly in the document.
readonly CSSRule[]
rules
The IE equivalent of the DOM-standard cssRules[] array.
cssRules[]
readonly String
title
The title of the stylesheet, if specified. A title may
be specified by the title
attribute of a <style> or <link> element that refers to
this stylesheet.
title
<style>
<link>
readonly String
type
The type of this stylesheet, as a MIME type. CSS
stylesheets have a type of "text/css".
addRule( )
IE-specific method to add a CSS rule to a
stylesheet.
deleteRule( )
DOM-standard method to delete the rule at the specified
position.
insertRule( )
DOM-standard method to insert a new rule into the
stylesheet.
removeRule( )
IE-specific method to delete a rule.
This interface represents a CSS stylesheet. It has properties
and methods for disabling the stylesheet, and for querying,
inserting, and removing style rules. IE implements a slightly
different API than the DOM standard. In IE, use the rules[] array instead of cssRules[], and use addRule( ) and removeRule( ) instead of the DOM standard
insertRule( ) and deleteRule( ).
rules[]
The CSSStyleSheet objects that apply to a document are members
of the styleSheets[] array of the
Document object. The DOM standard also requires (although this is
not widely implemented at the time of this writing) that any
<style> or <link> element or
ProcessingInstruction node that defines or links to a stylesheet
should make the CSSStyleSheet object available through a sheet property.
styleSheets[]
sheet
CSSRule, the styleSheets[] property of the Document object; Chapter 16, Cascading Style Sheets and Dynamic HTML
CSSStyleSheet.addRule( ): IE-specific method to insert a
rule into a stylesheet — IE 4:
void addRule(Stringselector,
String style,
integer index)
selector
index
The CSS selector for the rule.
The styles to be applied to elements that match the
selector. This style string is a
semicolon-delimited list of attribute:value pairs. It does
not begin and end with curly
braces.
The position in the rules array at which the rule is
to be inserted or appended. If this optional argument is
omitted, the new rule is appended to the array of
rules.
This method inserts (or appends) a new CSS style rule at the
specified index of the rules array of this stylesheet. This is an
IE-specific alternative to the standard insertRule( ) method. Note that the
arguments to this method are different from those to insertRule( ).
CSSStyleSheet.deleteRule( ): delete a rule from a
stylesheet — DOM Level 2 CSS:
void deleteRule(unsigned longindex)
throws DOMException;
The index within the cssRules array of the rule to be
deleted.
cssRules
This method throws a DOMException with a code of INDEX_SIZE_ERR if
index is negative or greater than or
equal to cssRules.length. It
throws a DOMException with a code of NO_MODIFICATION_ALLOWED_ERR if this
stylesheet is read-only.
cssRules.length
This method deletes the rule at the specified
index from the cssRules array. This is a DOM-standard
method; see CSSStyleSheet.removeRule(
) for an IE-specific alternative.
CSSStyleSheet.removeRule(
)
CSSStyleSheet.insertRule( ): insert a rule into a
stylesheet — DOM Level 2 CSS:
unsigned long insertRule(Stringrule,
unsigned long index)
throws DOMException;
rule
The complete, parseable text representation of the
rule to be added to the stylesheet. For style rules, this
includes both the element selector and the style
information.
The position in the cssRules array at which the rule
is to be inserted or appended.
The value of the index
argument.
This method throws a DOMException with one of the following
code values in the following
circumstances:
HIERARCHY_REQUEST_ERR
CSS syntax does not allow the specified rule at the
specified location.
index is negative or
greater then cssRules.length.
The stylesheet is read-only.
The specified rule text
contains a syntax error.
This method inserts (or appends) a new CSS
rule at the specified
index of the cssRules array of this stylesheet. This is
a DOM-standard method; see CSSStyleSheet.addRule( ) for an
IE-specific alternative.
CSSStyleSheet.addRule( )
CSSStyleSheet.removeRule( ): IE-specific method to remove a
rule from a stylesheet — IE 4:
void removeRule(integerindex)
The index in the rules[] array of the rule to be
removed. If this optional argument is omitted, the first
rule in the array is removed.
This method removes the CSS style rule at the specified
index of the rules array of this stylesheet. This is an
IE-specific alternative to the standard deleteRule( ) method.
Document: an HTML or XML document — DOM Level 1 Core: Node → Document
readonly Window
defaultView
The web browser Window object (the "view" in DOM
terminology) in which this document is displayed.
readonly DocumentType
doctype
For XML documents with a <!DOCTYPE<
declaration, specifies a DocumentType node that represents
the document's DTD. For HTML documents and for XML documents
with no <!DOCTYPE>,
this property is null.
<!DOCTYPE<
<!DOCTYPE>
readonly Element
documentElement
A reference to the root element of the document. For
HTML documents, this property is always the Element object
representing the <html> tag. This root element
is also available through the childNodes[] array inherited from
Node. See also the body
property of HTMLDocument.
<html>
childNodes[]
body
readonly DOMImplementation
implementation
The DOMImplementation object that represents the
implementation that created this document.
readonly CSSStyleSheet[]
styleSheets
A collection of objects representing all stylesheets
embedded in or linked into a document. In HTML documents, this
includes stylesheets defined with <link> and <style> tags.
addEventListener(
)
Adds an event-handler function to the set of event
handlers for this document. This is a DOM-standard method
supported by all modern browsers except IE.
attachEvent( )
Adds an event-handler function to the set of handlers
for this document. This is the IE-specific alternative to
addEventListener( ).
addEventListener( )
createAttribute(
)
Creates a new Attr node with the specified name.
createAttributeNS(
)
Creates a new Attr node with the specified name and
namespace.
createCDATASection(
)
Creates a new CDATASection node containing the specified
text.
createComment( )
Creates a new Comment node containing the specified
string.
createDocumentFragment(
)
Creates a new, empty DocumentFragment node.
createElement( )
Creates a new Element node with the specified tag
name.
createElementNS(
)
Creates a new Element node with the specified tag name
and namespace.
createEvent( )
Creates a new synthetic Event object of the named
type.
createExpression(
)
Creates a new XPathExpression object that represents a
compiled XPath query. For an IE-specific alternative, see
Node.selectNodes( ).
Node.selectNodes( )
createProcessingInstruction(
)
Creates a new ProcessingInstruction node with the
specified target and data string.
createRange( )
Creates a new Range object. This method is technically
part of the DocumentRange interface; it is implemented by the
Document object only in implementations that support the Range
module.
createTextNode(
)
Creates a new Text node to represent the specified
text.
detachEvent( )
Removes an event-handler function from this document.
This is the IE-specific alternative to the standard removeEventListener( )
method.
removeEventListener( )
dispatchEvent( )
Dispatches a synthetic event to this document.
evaluate( )
Evaluates an XPath query against this document. See
Node.selectNodes( ) for an
IE-specific alternative.
getElementById(
)
Returns a descendant Element of this document that has
the specified value for its id attribute, or null if no such Element exists in
the document.
id
getElementsByTagName(
)
Returns an array (technically a NodeList) of all Element
nodes in this document that have the specified tag name. The
Element nodes appear in the returned array in the order in
which they appear in the document source.
getElementsByTagNameNS(
)
Returns an array of all Element nodes that have the
specified tag name and namespace.
importNode( )
Makes a copy of a node from some other document that is
suitable for insertion into this document.
loadXML( )
Parses a string of XML markup and stores the result in
this document object.
removeEventListener(
)
Removes an event handler function from the set of
handlers for this document. This is a standard DOM method
implemented by all modern browsers except IE.
The Document interface is the root node of a document tree. A
Document node may have multiple children, but only one of those
children may be an Element node: it is the root element of the
document. The root element is most easily accessed through the
documentElement property. The
doctype and implementation properties provide access
to the DocumentType object (if any) and the DOMImplementation object
for this document.
documentElement
doctype
implementation
Most of the methods defined by the Document interface are
"factory methods" that create various types of nodes that can be
inserted into this document. The notable exceptions are getElementById( ) and getElementsByTagName( ), which are quite
useful for finding a specific Element or a set of related Element
nodes within the document tree. Other exceptions are event-handler
registration methods such as addEventHandler( ). These event-related
methods are also defined by the Element interface and are documented
in complete detail there.
getElementById( )
getElementsByTagName( )
addEventHandler( )
You most commonly obtain a Document object via the document property of a Window. Document
objects are also available through the contentDocument property of Frame and
IFrame, and the ownerDocument
property of any Node that has been added to a document.
contentDocument
ownerDocument
If you are working with XML (including XHTML), you can create
new Document objects with the createDocument( ) method of the
DOMImplementation:
createDocument( )
document.implementation.createDocument(namespaceURL, rootTagName, null);
In IE, you would use code like this instead:
new ActiveXObject("MSXML2.DOMDocument");
See Example 21-1, “Creating an empty XML document” for a
cross-platform utility function that creates a new Document
object.
It is also possible to load an XML file from the network and
parse it into a Document object. See the responseXML property of the XMLHttpRequest
object. You can also parse a string of XML markup into a Document
object: see DOMParser.parseFromString(
) and the IE-specific Document.loadXML( ). (Example 21-4, “Parsing an XML document” is a cross-platform utility
function that uses these methods to parse XML markup.)
responseXML
DOMParser.parseFromString(
)
Document.loadXML( )
See HTMLDocument for
additional properties and methods that are specific to HTML
documents.
DOMImplementation,
DOMParser, HTMLDocument, Window, XMLHttpRequest; Chapter 15, Scripting Documents
DOMImplementation
DOMParser
XMLHttpRequest
Document.addEventListener( ): see Element.addEventListener(
)
Document.attachEvent( ): see Element.attachEvent(
)
Document.createAttribute( ): create a new Attr
node — DOM Level 1 Core:
Attr createAttribute(Stringname)
throws DOMException;
The name for the newly created attribute.
A newly created Attr node with its nodeName property set to
name.
nodeName
This method throws a DOMException with a code of INVALID_CHARACTER_ERR if
name contains an illegal
character.
INVALID_CHARACTER_ERR
Attr, Element.setAttribute( ), Element.setAttributeNode( )
Attr
Element.setAttributeNode( )
Document.createAttributeNS( ): create an Attr with a name
and namespace — DOM Level 2 Core:
Attr createAttributeNS(StringnamespaceURI,
String qualifiedName)
throws DOMException;
namespaceURI
qualifiedName
The unique identifier of the namespace for the Attr or
null for no
namespace.
The qualified name of the attribute, which should
include a namespace prefix, a colon, and a local
name.
A newly created Attr node with the specified name and
namespace.
qualifiedName contains an
illegal character.
NAMESPACE_ERR
qualifiedName is malformed
or there is a mismatch between
qualifiedName and
namespaceURI.
NOT_SUPPORTED_ERR
The implementation does not support XML documents and
therefore does not implement this method.
createAttributeNS( ) is
just like createAttribute( ),
except that the created Attr node has a name and namespace instead
of just a name. This method is useful only with XML documents that
use namespaces.
createAttributeNS( )
createAttribute( )
Document.createCDATASection( ): create a new CDATASection
node — DOM Level 1 Core:
CDATASection createCDATASection(Stringdata)
throws DOMException;
The text of the CDATASection to create.
A newly created CDATASection node, with the specified
data as its contents.
If the document is an HTML document, this method throws a
DOMException with a code of
NOT_SUPPORTED_ERR because HTML
documents do not allow CDATASection nodes.
Document.createComment( ): create a new Comment
node — DOM Level 1 Core:
Comment createComment(Stringdata);
The text of the Comment node to create.
A newly created Comment node, with the specified
data as its text.
Document.createDocumentFragment( ): create a new, empty
DocumentFragment node — DOM Level 1 Core:
DocumentFragment createDocumentFragment( );
A newly created DocumentFragment node with no
children.
Document.createElement( ): create a new Element
node — DOM Level 1 Core:
Element createElement(StringtagName)
throws DOMException;
tagName
The tag name of the Element to be created. Since HTML
tags are case-insensitive, you may use any capitalization
for HTML tag names. XML tag names are case-sensitive.
A newly created Element node with the specified tag
name.
This method throws a DOMException with a code of INVALID_CHARACTER_ERR if
tagName contains an illegal
character.
Document.createElementNS( ): create a new Element node
using a namespace — DOM Level 2 Core:
Element createElementNS(StringnamespaceURI,
String qualifiedName)
throws DOMException;
The unique identifier for the namespace of the new
Element or null for no
namespace.
The qualified name of the new Element. This should
include a namespace prefix, a colon, and a local
name.
A newly created Element node, with the specified tag name
and namespace.
createElementNS( ) is just
like createElement( ), except
that the created Element node has a name and namespace instead of
just a name. This method is useful only with XML documents that use
namespaces.
createElementNS( )
Document.createEvent( ): create an Event object — DOM Level 2 Events:
Event createEvent(StringeventType)
throws DOMException
eventType
The name of the event module for which an Event object
is desired. Valid event types are listed in the
Description.
A newly created Event object of the specified type.
This method throws a DOMException with a code of NOT_SUPPORTED_ERR if the implementation
does not support events of the requested type.
This method creates a new event object of the type specified
by the eventType argument. Note that the
value of this argument should not be the (singular) name of the
event interface to be created but instead should be the (plural)
name of the DOM module that defines that interface. The following
table shows the legal values for
eventType and the event interface each
value creates:
eventType argument
Event interface
Initialization
method
HTMLEvents
Event
initEvent( )
initEvent( )
MouseEvents
MouseEvent
initMouseEvent( )
initMouseEvent( )
UIEvents
UIEvent
initUIEvent( )
initUIEvent( )
After creating an Event object with this method, you must
initialize the object with the initialization method shown in the
table. See the appropriate Event interface reference page for
details about the initialization method.
This method is actually defined not by the Document interface
but by the DOM DocumentEvent interface. If an implementation
supports the Events module, the Document object always implements
the DocumentEvent interface and supports this method. Note that
Internet Explorer does not support the DOM Events module.
Event, MouseEvent, UIEvent
Document.createExpression( ): create an XPath expression
for later evaluation — Firefox 1.0, Safari 2.01, Opera 9:
XPathExpression createExpression(StringxpathText,
Function namespaceURLMapper)
throws XPathException
xpathText
namespaceURLMapper
The string representing the XPath expression to
compile.
A function that will map from a namespace prefix to a
full namespace URL, or null if no such mapping is
required.
An XPathExpression object.
This method throws an exception if the
xpathText contains a syntax error or if
it uses a namespace prefix that cannot be resolved by
namespaceURLMapper.
This method takes a string representation of an XPath
expression and converts it to a compiled representation, an XPathExpression. In addition to the
expression, this method takes a function of the form function(prefix) that resolves a namespace
prefix string and returns it as a full namespace URL string.
XPathExpression
function(prefix)
Internet Explorer does not support this API. See Node.selectNodes( ) for an IE-specific
alternative.
Document.evaluate( ),
Node.selectNodes( ), XPathExpression, XPathResult
Document.evaluate( )
XPathResult
Document.createProcessingInstruction( ): create a
ProcessingInstruction node — DOM Level 1 Core:
ProcessingInstruction createProcessingInstruction(Stringtarget,
String data)
throws DOMException;
target
The target of the processing instruction.
The content text of the processing instruction.
A newly created ProcessingInstruction node.
The specified target
contains an illegal character.
This is an HTML document and does not support
processing instructions.
Document.createRange( ): create a Range object — DOM Level 2 Range:
Range createRange( );
A newly created Range object with both boundary points set
to the beginning of the document.
This method creates a Range object that can be used to
represent a region of this document or of a DocumentFragment
associated with this document.
Note that this method is actually defined not by the Document
interface but by the DocumentRange interface. If an implementation
supports the Range module, the Document object always implements
DocumentRange and defines this method. Internet Explorer 6 does not
support this module.
Range
Range
Document.createTextNode( ): create a new Text
node — DOM Level 1 Core:
Text createTextNode(Stringdata);
The content of the Text node.
A newly created Text node that represents the specified
data string.
Document.detachEvent( ): see Element.detachEvent(
)
Document.dispatchEvent( ): see Element.dispatchEvent(
)
Document.evaluate( ): evaluate an XPath
expression — Firefox 1.0, Safari 2.01, Opera 9:
XPathResult evaluate(StringxpathText,
Node contextNode,
Function namespaceURLMapper,
short resultType,
XPathResult result)
throws DOMException, XPathException
contextNode
resultType
result
The string representing the XPath expression to
evaluate.
The node in this document against which the expression
is to be evaluated.
A function that will map from a namespace prefix to a
full namespace URL or null if no such mapping is
required.
Specifies the type of object expected as a result,
using XPath conversions to coerce the result. Possible
values for type are the
constants defined by the XPathResult object.
type
An XPathResult object to be reused or null if you want a new XPathResult
object to be created.
A XPathResult object representing the evaluation of the
expression against the given context node.
This method may throw an exception if the
xpathText contains a syntax error, if
the result of the expression cannot be converted to the desired
resultType, if the expression contains
namespaces that namespaceURLMapper
cannot resolve, or if contextNode is of
the wrong type or is not associated with this document.
This method evaluates the specified XPath expression
against the given context node and returns an XPathResult object,
using type to determine what the
result type should be. If you want to evaluate an expression more
than once, use Document.createExpression(
) to compile the expression to an XPathExpression object
and then use the evaluate( )
method of XPathExpression.
Document.createExpression(
)
Internet Explorer does not support this API. See Node.selectNodes( ) and Node.selectSingleNode( ) for an
IE-specific alternative.
Node.selectSingleNode( )
Document.createExpression(
)
Node.selectNodes(
)
Node.selectSingleNode(
)
Document.getElementById( ): find an element with the
specified unique ID — DOM Level 2 Core:
Element getElementById(StringelementId);
elementId
The value of the id
attribute of the desired element.
The Element node that represents the document element with
the specified id attribute or
null if no such element is
found.
This method searches the document for an Element node with an
id attribute whose value is
elementId and returns that Element. If no
such Element is found, it returns null. The value of the id attribute is intended to be unique
within a document, and if this method finds more than one Element
with the specified elementId, it may
return one at random, or it may return null. This is an important and commonly
used method because it provides a simple way to obtain the Element
object that represents a specific document element. Note that the
name of this method ends with "Id", not with "ID"; be careful not to
misspell it.
In HTML documents, this method searches for an element based
on the value of its id attribute.
Use HTMLDocument.getElementsByName(
) to search for HTML elements based on the value of their
name attributes.
HTMLDocument.getElementsByName(
)
In XML documents, this method performs its search using any
attribute whose type is id,
regardless of what the name of that attribute is. If XML attribute
types are not known (because, for example, the XML parser ignored or
could not locate the document's DTD), this method always returns
null. In client-side JavaScript,
this method is not usually useful with XML documents. In fact,
getElementById( ) was originally
defined as a member of the HTMLDocument interface but was then moved
to the Document interface in DOM Level 2.
Document.getElementsByTagName(
)
Element.getElementsByTagName(
)
HTMLDocument.getElementsByName(
)
Document.getElementsByTagName( ): return all Element nodes
with the specified name — DOM Level 1 Core:
Element[] getElementsByTagName(Stringtagname);
tagname
The tag name of the Element nodes to be returned, or
the wildcard string "*" to return all Element nodes in the
document regardless of tag name. For HTML documents, tag
names are compared in a case-insensitive fashion. (Prior to
version 6, IE does not support this wildcard syntax.)
A read-only array (technically, a NodeList) of all Element
nodes in the document tree with the specified tag name. The
returned Element nodes are in the same order in which they appear
in the document source.
This method returns a NodeList (which you can treat as a
read-only array) that contains all Element nodes from the document
that have the specified tag name, in the order in which they appear
in the document source. The NodeList is "live"—i.e., its contents
are automatically updated as necessary if elements with the
specified tag name are added to or removed from the document.
HTML documents are case-insensitive, and you can specify
tagname using any capitalization; it
matches all tags with the same name in the document, regardless of
how those tags are capitalized in the document source. XML
documents, on the other hand, are case-sensitive, and
tagname matches only tags with the same
name and exactly the same capitalization in the document
source.
Note that the Element interface defines a method by the same
name that searches only a subtree of the document. Also, the
HTMLDocument interface defines getElementsByName( ), which searches for
elements based on the value of their name attributes rather than their tag
names.
getElementsByName( )
You can find and iterate through all <h1> tags in a document with code
like the following:
<h1>
var headings = document.getElementsByTagName("h1");
for(var i = 0; i < headings.length; i++) { // Loop through the returned tags
var h = headings[i];
// Now do something with the <h1> element in the h variable
}
Document.getElementById(
)
Document.getElementsByTagNameNS( ): return all Element
nodes with a specified name and namespace — DOM Level 2 Core:
Node[] getElementsByTagNameNS(StringnamespaceURI,
String localName);
localName
The unique identifier of the namespace of the desired
elements, or "*" to match all namespaces.
The local name of the desired elements, or "*" to
match any local name.
A read-only array (technically, a NodeList) of all Element
nodes in the document tree that have the specified namespace and
local name.
This method works just like getElementsByTagName( ), except that it
searches for elements by namespace and name. It is useful only with
XML documents that use namespaces.
Document.importNode( ): copy a node from another document
for use in this document — DOM Level 2 Core:
Node importNode(NodeimportedNode,
boolean deep)
throws DOMException;
importedNode
deep
The node to be imported.
If true,
recursively copy all descendants of
importedNode as well.
A copy of importedNode (and
possibly all of its descendants) with its ownerDocument set to this
document.
This method throws a DOMException with a code of NOT_SUPPORTED_ERR if
importedNode is a Document or
DocumentType node, because those types of nodes cannot be
imported.
This method is passed a node defined in another document and
returns a copy of the node that is suitable for insertion into this
document. If deep is true, all descendants of the node are also
copied. The original node and its descendants are not modified in
any way. The returned copy has its ownerDocument property set to this
document but has a parentNode of
null because it has not yet been
inserted into the document. Event-listener functions registered on
the original node or tree are not copied.
parentNode
When an Element node is imported, only the attributes that are
explicitly specified in the source document are imported with it.
When an Attr node is imported, its specified property is automatically set to
true.
specified
Node.cloneNode( )
Node.cloneNode( )
Document.loadXML( ): populate this Document by parsing a
string of XML markup — Internet Explorer:
void loadXML(Stringtext)
text
The XML markup to parse.
This IE-specific method parses the specified string of XML
text and builds a tree of DOM nodes in the current Document object,
discarding any nodes that previously existed in the Document.
This method does not exist on Document objects that represent
HTML documents. Before calling loadXML(
), you typically create a new, empty Document to hold the
parsed content:
loadXML(
)
var doc = new ActiveXObject("MSXML2.DOMDocument");
doc.loadXML(markup);
See DOMParser.parseFromString(
) for a non-IE alternative.
DOMParser.parseFromString(
)
Document.removeEventListener( ): see
Element.removeEventListener( )
DocumentFragment: adjacent nodes and their
subtrees — DOM Level 1 Core: Node → DocumentFragment
The DocumentFragment interface represents a portion—or
fragment—of a document. More specifically, it is a list of adjacent
nodes and all descendants of each, but without any common parent
node. DocumentFragment nodes are never part of a document tree, and
the inherited parentNode property
is always null. DocumentFragment
nodes exhibit a special behavior that makes them quite useful,
however: when a request is made to insert a DocumentFragment into a
document tree, it is not the DocumentFragment node itself that is
inserted but it is instead each child of the DocumentFragment. This
makes DocumentFragment useful as a temporary placeholder for nodes
that you wish to insert, all at once, into a document.
DocumentFragment is also particularly useful for implementing
document cut, copy, and paste operations, particularly when combined
with the Range interface.
You can create a new, empty DocumentFragment with Document.createDocumentFragment( ), or you
can use Range.extractContents( )
or Range.cloneContents( ) to
obtain a DocumentFragment that contains a fragment of an existing
document.
Document.createDocumentFragment( )
Range.extractContents( )
Range.cloneContents( )
Range
DocumentType: the DTD of an XML document — DOM Level 1 XML: Node → DocumentType
readonly String
internalSubset
The unparsed text of the internal subset of the DTD
(i.e., the portion of the DTD that appears in the document
itself rather than in an external file). The delimiting square
brackets of the internal subset are not part of the returned
value. If there is no internal subset, this property is
null.
The name of the document type. This is the identifier
that immediately follows <!DOCTYPE> at the start of an
XML document, and it is the same as the tag name of the
document's root element.
readonly String
publicId
The public identifier of the external subset of the DTD,
or null if none is
specified.
readonly String
systemId
The system identifier of the external subset of the DTD,
or null if none is
specified.
This infrequently used interface represents the DTD of
an XML document. Programmers working exclusively with HTML documents
never need to use this interface.
Because a DTD is not part of a document's content,
DocumentType nodes never appear in the document tree. If an XML
document has a DTD, the DocumentType node for that DTD is available
through the doctype property of
the Document node.
Although the W3C DOM includes an API for accessing the XML
entities and notations defined in a DTD, that API is not documented
here. Typical web browsers do not parse the DTDs for the documents
they load, and client-side JavaScript can not access those entities
and notations. For client-side JavaScript programming, this
interface represents only the contents of the <!DOCTYPE> tag, not the contents of
the DTD file it references.
DocumentType nodes are immutable and may not be modified in
any way.
Document, DOMImplementation.createDocument( ),
DOMImplementation.createDocumentType(
)
DOMImplementation.createDocument( )
DOMImplementation.createDocumentType(
)
DOMException: signal exceptions or errors for core DOM
objects — DOM Level 1 Core: Object → DOMException
The following constants define the legal values for the
code property of a DOMException
object. Note that these constants are static properties of
DOMException, not properties of individual exception objects:
unsigned short INDEX_SIZE_ERR =
1
Indicates an out-of-bounds error for an array or string
index.
unsigned short DOMSTRING_SIZE_ERR
= 2
Indicates that a requested text is too big to fit into a
string in the current JavaScript implementation.
unsigned short
HIERARCHY_REQUEST_ERR = 3
Indicates that an attempt was made to place a node
somewhere illegal in the document-tree hierarchy.
unsigned short WRONG_DOCUMENT_ERR
= 4
Indicates an attempt to use a node with a document that
is different from the document that created the node.
unsigned short
INVALID_CHARACTER_ERR = 5
Indicates that an illegal character is used (in an
element name, for example).
unsigned short
NO_DATA_ALLOWED_ERR = 6
Not currently used.
unsigned short
NO_MODIFICATION_ALLOWED_ERR = 7
Indicates that an attempt was made to modify a node that
is read-only and does not allow modifications.
unsigned short NOT_FOUND_ERR =
8
Indicates that a node was not found where it was
expected.
unsigned short NOT_SUPPORTED_ERR
= 9
Indicates that a method or property is not supported in
the current DOM implementation.
unsigned short
INUSE_ATTRIBUTE_ERR = 10
Indicates that an attempt was made to associate an Attr
with an Element when that Attr node was already associated
with a different Element node.
unsigned short INVALID_STATE_ERR
= 11
Indicates an attempt to use an object that is not yet,
or is no longer, in a state that allows such use.
unsigned short SYNTAX_ERR =
12
Indicates that a specified string contains a syntax
error. Commonly used with CSS property specifications.
unsigned short
INVALID_MODIFICATION_ERR = 13
Indicates an attempt to modify the type of a CSSRule or
CSSValue object.
unsigned short NAMESPACE_ERR =
14
Indicates an error involving element or attribute
namespaces.
unsigned short INVALID_ACCESS_ERR
= 15
Indicates an attempt to access an object in a way that
is not supported by the implementation.
unsigned short
code
An error code that provides some detail about what
caused the exception. The legal values (and their meanings)
for this property are defined by the constants just
listed.
A DOMException object is thrown when a DOM method or property
is used incorrectly or in an inappropriate context. The value of the
code property indicates the
general type of exception that occurred. Note that a DOMException
may be thrown when reading or writing a property of an object as
well as when calling a method of an object.
The descriptions of object properties and methods in this
reference include a list of exception types they may throw. Note,
however, that certain commonly thrown exceptions are omitted from
these lists. A DOMException with a code of NO_MODIFICATION_ALLOWED_ERR is thrown any
time an attempt is made to modify a read-only node. Thus, most
methods and read/write properties of the Node interface (and of its
subinterfaces) may throw this exception. Because read-only nodes
appear only in XML documents and not in HTML documents, and because
it applies so universally to the methods and writable properties of
Node objects, the NO_MODIFICATION_ALLOWED_ERR exception is
omitted from the descriptions of those methods and
properties.
Similarly, many DOM methods and properties that return strings
may throw a DOMException with a code of DOMSTRING_SIZE_ERR, which indicates that
the text to be returned is too long to be represented as a string
value in the underlying JavaScript implementation. Although this
type of exception may theoretically be thrown by many properties and
methods, it is very rare in practice and is omitted from the
descriptions of those methods and properties.
Note that not all exceptions in the DOM are signaled with a
DOMException: exceptions involving the DOM Range module cause a
RangeException to be thrown.
RangeException
RangeException
DOMImplementation: methods independent of any particular
document — DOM Level 1 Core: Object →
DOMImplementation
createDocument(
)
Creates a new Document object with a root element (the
documentElement property of
the returned Document object) of the specified type.
createDocumentType(
)
Creates a new DocumentType node.
hasFeature( )
Checks whether the current implementation supports a
specified version of a named feature.
The DOMImplementation interface is a placeholder for methods
that are not specific to any particular Document object but rather
are "global" to an implementation of the DOM. You can obtain a
reference to the DOMImplementation object through the implementation property of any Document
object.
DOMImplementation.createDocument( ): create a new Document
and the specified root element — DOM Level 2 Core:
Document createDocument(StringnamespaceURI,
String qualifiedName,
DocumentType doctype)
throws DOMException;
The unique identifier of the namespace of the root
element to be created for the document, or null for no namespace.
The name of the root element to be created for this
document. If namespaceURI is not
null, this name should
include a namespace prefix and a colon.
The DocumentType object for the newly created
Document, or null if none
is desired.
A Document object with its documentElement property set to a root
Element node of the specified type.
This method may throw a DOMException with the following
code values in the following
circumstances:
The current implementation does not support XML
documents and has not implemented this method.
WRONG_DOCUMENT_ERR
doctype is already in use
for another document or was created by a different
DOMImplementation object.
This method creates a new XML Document object and the
specified root documentElement
object for that document. If the doctype
argument is non-null, the
ownerDocument property of this
DocumentType object is set to the newly created document.
This method is used to create XML documents and may not be
supported by HTML-only implementations.
DOMImplementation.createDocumentType(
)
DOMImplementation.createDocumentType( ): create a
DocumentType node — DOM Level 2 Core:
DocumentType createDocumentType(StringqualifiedName,
String publicId,
String systemId)
throws DOMException;
publicId
systemId
The name of the document type. If you are using XML
namespaces, this may be a qualified name that specifies a
namespace prefix and a local name separated by a
colon.
The public identifier of the document type, or
null.
The system identifier of the document type, or
null. This argument
typically specifies the local filename of a DTD file.
A new DocumentType object
with an ownerDocument property
of null.
DocumentType
qualifiedName is
malformed.
This method creates a new DocumentType node. This method
specifies only an external subset of the document type. As of Level
2, the DOM standard does not provide any way to specify an internal
subset, and the returned DocumentType does not define any Entity or
Notation nodes. This method is useful only with XML
documents.
DOMImplementation.hasFeature( ): determine whether the
implementation supports a feature — DOM Level 1 Core:
boolean hasFeature(Stringfeature,
String version);
feature
version
The name of the feature for which support is being
tested. The set of valid feature names for the DOM Level 2
standard is listed in the table in the Description. Feature
names are case-insensitive.
The feature version number for which support is being
tested, or null or the
empty string "" if
support for any version of the feature is sufficient. In the
Level 2 DOM specification, supported version numbers are 1.0
and 2.0.
""
true if the
implementation completely supports the specified version of the
specified feature; false
otherwise. If no version number is specified, the method returns
true if the implementation
completely supports any version of the specified feature.
The W3C DOM standard is modular, and implementations are not
required to implement all modules or features of the standard. This
method tests whether a DOM implementation supports a named module of
the DOM specification. The availability information for each entry
in this DOM reference includes the name of the module. Note that
although Internet Explorer 5 and 5.5 include partial support for the
DOM Level 1 specification, this important method is not supported
before IE 6.
The complete set of module names that may be used as the
feature argument are shown in the
following table:
Feature
Description
Core
Node, Element, Document, Text, and
the other fundamental interfaces required by all DOM
implementations are implemented. All conforming
implementations must support this module.
HTML
HTMLElement, HTMLDocument, and the
other HTML-specific interfaces are
implemented.
XML
Entity, EntityReference,
ProcessingInstruction, Notation, and the other node types
that are useful only with XML documents are
implemented.
StyleSheets
Simple interfaces describing
generic stylesheets are implemented.
CSS
Interfaces that are specific to
CSS stylesheets are implemented.
CSS2
The CSS2Properties interface is
implemented.
Events
The basic event-handling
interfaces are implemented.
The interfaces for user-interface
events are implemented.
The interfaces for mouse events
are implemented.
The interfaces for HTML events are
implemented.
MutationEvents
The interfaces for document
mutation events are implemented.
The interfaces for manipulating
ranges of a document are implemented.
Traversal
The interfaces for advanced
document traversal are implemented.
Views
The interfaces for document views
are implemented.
You might use this method in code like the following:
// Check whether the browser supports the DOM Level 2 Range API
if (document.implementation &&
document.implementation.hasFeature &&
document.implementation.hasFeature("Range", "2.0")) {
// If so, use it here...
}
else {
// If not, fall back on code that doesn't require Range objects
}
Node.isSupported( )
Node.isSupported( )
DOMParser: parses XML markup to create a Document — Firefox 1.0, Safari 2.01, Opera 7.60: Object →
DOMParser
new DOMParser( )
parseFromString(
)
Parses XML markup and returns a Document.
A DOMParser object parses
XML text and returns an XML Document object. To use a DOMParser,
instantiate one with the no-argument constructor and then call its
parseFromString( ) method:
parseFromString( )
var doc = (new DOMParser( )).parseFromString(text);
Internet Explorer does not support the DOMParser
object. Instead, it supports XML parsing with Document.loadXML( ). Note that the
XMLHttpRequest object can also parse XML documents. See the responseXML property of
XMLHttpRequest.
Document.loadXML( ),
XMLHttpRequest; Chapter 21, JavaScript and XML
DOMParser.parseFromString( ): parse XML markup
Document parseFromString(Stringtext,
String contentType)
contentType
The content type of the text. This may be one of
"text/xml", "application/xml", or "application/xhtml+xml".
Note that "text/html" is not supported.
A Document object that holds the parsed representation of
text. See Document.loadXML( ) for an IE-specific
alternative to this method.
Element: an HTML or XML element — DOM Level 1 Core: Node → Element
readonly String
tagName
The tag name of the element. This is the string "P" for
an HTML <p> element,
for example. For HTML documents, the tag name is returned in
uppercase, regardless of its capitalization in the document
source. XML documents are case-sensitive, and the tag name is
returned exactly as it is written in the document source. This
property has the same value as the inherited nodeName property of the Node
interface.
<p>
Adds an event-handler function to the set of event
handlers for this element. This is a DOM-standard method
supported by all modern browsers except IE.
Adds an event-handler function to the set of handlers
for this element. This is the IE-specific alternative to
addEventListener( ).
Removes an event-handler function from this element.
This is the IE-specific alternative to the standard removeEventListener( )
method.
Dispatches a synthetic event to this node.
getAttribute( )
Returns the value of a named attribute as a
string.
getAttributeNS(
)
Returns the string value of an attribute specified by
local name and namespace URI. Useful only with XML documents
that use namespaces.
getAttributeNode(
)
Returns the value of a named attribute as an Attr
node.
getAttributeNodeNS(
)
Returns the Attr value of an attribute specified by
local name and namespace URI. Useful only with XML documents
that use namespaces.
Returns an array (technically, a NodeList) of all
descendant Element nodes of this element that have the
specified tag name, in the order in which they appear in the
document.
Like getElementsByTagName(
), except that the element tag name is specified by
local name and namespace URI. Useful only with XML documents
that use namespaces.
getElementsByTagName(
)
hasAttribute( )
Returns true if this
element has an attribute with the specified name, or false otherwise. Note that this
method returns true if the
named attribute is explicitly specified in the document source
or if the document's DTD specifies a default value for the
named attribute.
hasAttributeNS(
)
Like hasAttribute( ),
except that the attribute is specified by a combination of
local name and namespace URI. This method is useful only with
XML documents that use namespaces.
removeAttribute(
)
Deletes the named attribute from this element. Note,
however, that this method deletes only attributes that are
explicitly specified in the document source for this element.
If the DTD specifies a default value for this attribute, that
default becomes the new value of the attribute.
removeAttributeNode(
)
Removes the specified Attr node from the list of
attributes for this element. Note that this works only to
remove attributes that are explicitly specified in the
document source for this attribute. If the DTD specifies a
default value for the removed attribute, a new Attr node is
created to represent the default value of the
attribute.
removeAttributeNS(
)
Like removeAttribute(
), except that the attribute to be removed is
specified by a combination of local name and namespace URI.
Useful only for XML documents that use namespaces.
removeAttribute(
)
Removes an event-handler function from the set of
handlers for this element. This is a standard DOM method
implemented by all modern browsers except IE, which uses
detachEvent( ).
setAttribute( )
Sets the named attribute to the specified string value.
If an attribute with that name does not already exist, a new
attribute is added to the element.
setAttributeNode(
)
Adds the specified Attr node to the list of attributes
for this element. If an attribute with the same name already
exists, its value is replaced.
setAttributeNodeNS(
)
Like setAttributeNode(
), but this method is suitable for use with nodes
returned by Document.createAttributeNS( ).
Useful only with XML documents that use namespaces.
setAttributeNode(
)
Document.createAttributeNS( )
setAttributeNS(
)
Like setAttribute( ),
except that the attribute to be set is specified by the
combination of a local name and a namespace URI. Useful only
with XML documents that use namespaces.
The Element interface represents HTML or XML elements or tags.
The tagName property specifies
the name of the element. The documentElement property of a Document
refers to the root Element object for that document. The body property of the HTMLDocument object
is similar: it refers to the <body> element of the document. To
locate a specific named element in an HTML document, use Document.getElementById( ) (and give the
element a unique name with the id
attribute). To locate elements by tag name, use getElementsByTagName( ), which is a method
of both Element and Document. In HTML documents, you can also use
similar HTMLDocument.getElementsByName(
) to look up elements based on the value of their name attribute. Finally, you can create
new Element objects for insertion into a document with Document.createElement( ).
<body>
Document.getElementById( )
Document.createElement( )
The addEventListener( )
method (and its IE-specific alternative attachEvent( )) provide a way to register
event-handler functions for specific types of events on the element.
See Chapter 17, Events and Event Handling for complete details.
Technically, addEventListener( ),
removeEventListener( ), and
dispatchEvent( ) are defined by
the EventTarget interface of the DOM Level 2 Events specification.
Since all Element objects implement EventTarget, the methods are
listed here instead.
The various other methods of this interface provide access to
the attributes of the element. In HTML documents (and many XML
documents), all attributes have simple string values, and you can
use the simple methods getAttribute(
) and setAttribute( )
for any attribute manipulation you need to do.
getAttribute(
)
If you are working with XML documents that may contain entity
references as part of attribute values, you will have to work with
Attr objects and their subtree of nodes. You can get and set the
Attr object for an attribute with getAttributeNode( ) and setAttributeNode( ), or you can iterate
through the Attr nodes in the attributes[] array of the Node interface.
If you are working with an XML document that uses XML namespaces,
you need to use the various methods whose names end with
"NS".
setAttributeNode( )
attributes[]
In the DOM Level 1 specification, the normalize( ) method was part of the
Element interface. In the Level 2 specification, normalize( ) is instead part of the Node
interface. All Element nodes inherit this method and can still use
it.
normalize( )
HTMLElement, Node; Chapter 15, Scripting Documents,
Chapter 17, Events and Event Handling
Node
Element.addEventListener( ): register an event
handler — DOM Level 2 Events:
void addEventListener(Stringtype,
Function listener,
boolean useCapture);
listener
useCapture
The type of event for which the event listener is to
be invoked. For example, "load", "click", or
"mousedown".
The event-listener function that is invoked when an
event of the specified type is dispatched to this element.
When invoked, this listener function is passed an Event
object and is invoked as a method of the element on which it
is registered.
If true, the
specified listener is to be
invoked only during the capturing phase of event
propagation. The more common value of false means that the
listener is not invoked during
the capturing phase but instead is invoked when this node is
the actual event target or when the event bubbles up to this
node from its original target.
This method adds the specified event-listener function to the
set of listeners registered on this node to handle events of the
specified type. If
useCapture is true, the listener is registered as a
capturing event listener. If useCapture
is false, it is registered as a
normal event listener.
addEventListener( ) may be
called multiple times to register multiple event handlers for the
same type of event on the same node. Note, however, that the DOM
makes no guarantees about the order in which multiple event handlers
are invoked.
If the same event-listener function is registered twice on the
same node with the same type and
useCapture arguments, the second
registration is simply ignored. If a new event listener is
registered on this node while an event is being handled at this
node, the new event listener is not invoked for that event.
When a node is duplicated with Node.cloneNode( ) or Document.importNode( ), the event
listeners registered for the original node are not copied.
Document.importNode( )
This method is also defined by, and works analogously on, the
Document and Window objects.
Event; Chapter 17, Events and Event Handling
Element.attachEvent( ): register an event handler — IE 4:
void attachEvent(Stringtype,
Function listener);
The type of event for which the event listener is to
be invoked, with a leading "on" prefix. For example,
"onload", "onclick", or "onmousedown".
The event listener function that is invoked when an
event of the specified type is dispatched to this element.
This function is not passed any arguments but can obtain the
Event object from the event property of the Window
object.
event
This method is an IE-specific event registration method. It
serves the same purpose as the standard addEventListener( ) method (which IE does
not support) but is different from that function in several
important ways:
Since the IE event model does not support event capturing, attachEvent( ) and detachEvent( ) expect only two
arguments: the event type and the handler function.
The event-handler names passed to the IE methods should
include the "on" prefix. For example, use "onclick" with
attachEvent( ) instead of
"click" for addEventListener(
).
Functions registered with attachEvent( ) are invoked with no
Event object argument. Instead, they must read the event property of the Window
object..
attachEvent(
)
this
attachEvent( ) allows
the same event-handler function to be registered more than once.
When an event of the specified type occurs, the registered
function is invoked as many times as it is registered.
Element.addEventListener(
), Event; Chapter 17, Events and Event Handling
Element.addEventListener(
)
Element.detachEvent( ): delete an event listener — IE 4:
void detachEvent(Stringtype,
Function listener)
The type of event for which the event listener is to
be deleted, with an "on" prefix. For example:
"onclick".
The event-listener function that is to be
removed.
This method undoes the event-handler function registration
performed by the attachEvent( )
method. It is the IE-specific analog to removeEventListener( ). To remove an event
handler function for an element, simply invoke detachEvent with the same arguments you
originally passed to attachEvent(
).
detachEvent
attachEvent(
)
Element.dispatchEvent( ): dispatch a synthetic event to
this node — DOM Level 2 Events:
boolean dispatchEvent(Eventevt)
throws EventException;
evt
The Event object to be dispatched.
false if the preventDefault( ) method of
evt is called at any time during the
propagation of the event, or true otherwise.
preventDefault( )
This method throws an exception if the Event object
evt is not initialized, or if its
type property is null or the empty string.
This method dispatches a synthetic event created with Document.createEvent( ) and initialized
with the initialization method defined by the Event interface or one
of its subinterfaces. The node on which this method is called
becomes the target of the event, but the event first propagates down
the document tree during the capturing phase, and then, if the
bubbles property of the event is
true, it bubbles up the document
tree after being handled at the event target itself.
Document.createEvent( )
bubbles
Document.createEvent( ),
Event.initEvent( ), MouseEvent.initMouseEvent( )
Event.initEvent( )
MouseEvent.initMouseEvent( )
Element.getAttribute( ): return the string value of a named
attribute — DOM Level 1 Core:
String getAttribute(Stringname);
The name of the attribute whose value is to be
returned.
The value of the named attribute as a string. If the
attribute is not defined, this method is supposed to return an
empty string. Some implementations return null in this case, however.
getAttribute( ) returns the
value of a named attribute of an element. Note that the HTMLElement
object defines JavaScript properties that match each of the standard
HTML attributes, so you need to use this method with HTML documents
only if you are querying the value of nonstandard attributes.
In XML documents, attribute values are not available directly
as element properties and must be looked up by calling this method.
For XML documents that use namespaces, use getAttributeNS( ).
getAttributeNS( )
The following code illustrates two different ways of obtaining
an attribute value for an HTML <img> element:
// Get all images in the document
var images = document.body.getElementsByTagName("img");
// Get the src attribute of the first one
var src0 = images[0].getAttribute("src");
// Get the src attribute of the second simply by reading the property
var src1 = images[1].src;
Element.getAttributeNode(
), Element.getAttributeNS(
), Node
Element.getAttributeNode(
)
Element.getAttributeNS(
)
Element.getAttributeNode( ): return the Attr node for the
named attribute — DOM Level 1 Core:
Attr getAttributeNode(Stringname);
The name of the desired attribute.
An Attr node that represents the value of the named
attribute, or null if this
element has no such attribute.
getAttributeNode( ) returns
an Attr node that represents the value of a named attribute. Note
that this Attr node can also be obtained through the attributes property inherited from the
Node interface.
Element.getAttribute( ),
Element.getAttributeNodeNS(
)
Element.getAttributeNodeNS(
)
Element.getAttributeNodeNS( ): return the Attr node for an
attribute with a namespace — DOM Level 2 Core:
Attr getAttributeNodeNS(StringnamespaceURI,
String localName);
The URI that uniquely identifies the namespace of this
attribute, or null for no
namespace.
The identifier that specifies the name of the
attribute within its namespace.
The Attr node that represents the value of the specified
attribute, or null if this
element has no such attribute.
This method works like getAttributeNode( ), except that the
attribute is specified by the combination of a namespace URI and a
local name defined within that namespace. This method is useful only
with XML documents that use namespaces.
Element.getAttributeNode(
), Element.getAttributeNS(
)
Element.getAttributeNS( ): get the value of an attribute
that uses namespaces — DOM Level 2 Core:
String getAttributeNS(StringnamespaceURI,
String localName);
The URI that uniquely identifies the namespace of this
attribute or null for no
namespace.
The value of the named attribute, as a string. If the
attribute is not defined, this method is supposed to return an
empty string, but some implementations return null instead.
This method works just like the getAttribute( ) method, except that the
attribute is specified by a combination of namespace URI and local
name within that namespace. This method is useful only with XML
documents that use namespaces.
Element.getElementsByTagName( ): find descendant elements
with a specified tag name — DOM Level 1 Core:
Element[] getElementsByTagName(Stringname);
The tag name of the desired elements, or the value "*"
to specify that all descendant elements should be returned,
regardless of their tag names.
A read-only array (technically, a NodeList) of Element
objects that are descendants of this element and have the
specified tag name.
This method traverses all descendants of this element and
returns an array (really a NodeList object) of Element nodes
representing all document elements with the specified tag name. The
elements in the returned array appear in the same order in which
they appear in the source document.
Note that the Document interface also has a getElementsByTagName( ) method that works
just like this one but that traverses the entire document, rather
than just the descendants of a single element. Do not confuse this
method with HTMLDocument.getElementsByName(
), which searches for elements based on the value of their
name attributes rather than by
their tag names.
You can find all <div< tags in a document with code
like the following:
<div<
var divisions = document.body.getElementsByTagName("div");
And you can find all <p> tags within the first <div> tag with code like
this:
<div>
var paragraphs = divisions[0].getElementsByTagname("p");
Element.getElementsByTagNameNS( ): return descendant
elements with the specified name and namespace — DOM Level 2 Core:
The URI that uniquely identifies the namespace of the
element.
The identifier that specifies the name of the element
within its namespace.
A read-only array (technically, a NodeList) of Element
objects that are descendants of this element and have the
specified name and namespace.
This method works like getElementsByTagName( ), except that the
tag name of the desired elements is specified as a combination of a
namespace URI and a local name defined within that namespace. This
method is useful only with XML documents that use namespaces.
Document.getElementsByTagNameNS(
), Element.getElementsByTagName(
)
Document.getElementsByTagNameNS(
)
Element.getElementsByTagName(
)
Element.hasAttribute( ): determine whether this element has
a specified attribute — DOM Level 2 Core:
boolean hasAttribute(Stringname);
true if this element has
a specified or default value for the named attribute, and false otherwise.
This method determines whether an element has an attribute
with the specified name but does not return the value of that
attribute. Note that hasAttribute(
) returns true if the
named attribute is explicitly specified in the document and also if
the named attribute has a default value specified by the internal
subset of the document type.
hasAttribute(
)
Element.getAttribute( ),
Element.setAttribute( )
Element.hasAttributeNS( ): determine whether this element
has a specified attribute — DOM Level 2 Core:
boolean hasAttributeNS(StringnamespaceURI,
String localName);
The unique namespace identifier for the attribute, or
null for no
namespace.
The name of the attribute within the specified
namespace.
true if this element has
an explicitly specified value or a default value for the specified
attribute; false
otherwise.
This method works like hasAttribute(
), except that the attribute to be checked for is
specified by namespace and name. This method is useful only with XML
documents that use namespaces.
Element.getAttributeNS(
), Element.hasAttribute(
), Element.setAttributeNS(
)
Element.hasAttribute(
)
Element.setAttributeNS(
)
Element.removeAttribute( ): delete a named attribute of an
element — DOM Level 1 Core:
void removeAttribute(Stringname);
The name of the attribute to be deleted.
This method may throw a DOMException with a code of NO_MODIFICATION_ALLOWED_ERR if this
element is read-only and does not allow its attributes to be
removed.
removeAttribute( ) deletes
a named attribute from this element. If the named attribute has a
default value specified by the document type, subsequent calls to
getAttribute( ) return that
default value. Attempts to remove nonexistent attributes or
attributes that are not specified but have a default value are
silently ignored.
removeAttribute( )
Element.getAttribute( ),
Element.setAttribute( ), Node
Element.removeAttributeNode( ): remove an Attr node from an
element — DOM Level 1 Core:
Attr removeAttributeNode(AttroldAttr)
throws DOMException;
oldAttr
The Attr node to be removed from the element.
The Attr node that was removed.
This method may throw a DOMException with the following
code values:
This element is read-only and does not allow
attributes to be removed.
NOT_FOUND_ERR
oldAttr is not an attribute
of this element.
This method removes (and returns) an Attr node from
the set of attributes of an element. If the removed attribute has a
default value specified by the DTD, a new Attr is added representing
this default value. If is often simpler to use removeAttribute( ) instead of this
method.
Attr, Element.removeAttribute( )
Element.removeAttribute( )
Element.removeAttributeNS( ): delete an attribute specified
by name and namespace — DOM Level 2 Core:
void removeAttributeNS(StringnamespaceURI,
String localName);
The unique identifier of the namespace of the
attribute, or null for no
namespace.
removeAttributeNS( ) works
just like removeAttribute( ),
except that the attribute to be removed is specified by name and
namespace instead of simply by name. This method is useful only with
XML documents that use namespaces.
removeAttributeNS( )
Element.getAttributeNS( ),
Element.removeAttribute( ),
Element.setAttributeNS( )
Element.getAttributeNS( )
Element.setAttributeNS( )
Element.removeEventListener( ): delete an event
listener — DOM Level 2 Events:
void removeEventListener(Stringtype,
Function listener,
boolean useCapture);
The type of event for which the event listener is to
be deleted.
true if a capturing
event listener is to be removed; false if a normal event listener
is to be removed.
This method removes the specified event-listener function. The
type and
useCapture arguments must be the same as
they are in the corresponding call to addEventListener( ). If no event listener
is found that matches the specified arguments, this method does
nothing.
Once an event-listener function has been removed by this
method, it will no longer be invoked for the specified
type of event on this node. This is true
even if the event listener is removed by another event listener
registered for the same type of event on the same node.
Element.setAttribute( ): create or change an attribute of
an element — DOM Level 1 Core:
void setAttribute(Stringname,
String value)
throws DOMException;
The name of the attribute to be created or
modified.
The string value of the attribute.
The name argument contains
a character that is not allowed in HTML or XML attribute
names.
This element is read-only and does not allow
modifications to its attributes.
This method sets the specified attribute to the specified
value. If no attribute by that name already exists, a new one is
created.
Note that HTMLElement objects of an HTML document define
JavaScript properties that correspond to all standard HTML
attributes. Thus, you need to use this method only if you want to
set a nonstandard attribute.
// Set the TARGET attribute of all links in a document
var links = document.body.getElementsByTagName("a");
for(var i = 0; i < links.length; i++) {
links[i].setAttribute("target", "newwindow");
// Or more easily: links[i].target = "newwindow"
}
Element.getAttribute( ),
Element.removeAttribute( ),
Element.setAttributeNode(
)
Element.setAttributeNode(
)
Element.setAttributeNode( ): add a new Attr node to an
Element — DOM Level 1 Core:
Attr setAttributeNode(AttrnewAttr)
throws DOMException;
newAttr
The Attr node that represents the attribute to be
added or whose value is to be modified.
The Attr node that was replaced by
newAttr, or null if no attribute was
replaced.
This method may throw a DOMException with a code of the following values:
INUSE_ATTRIBUTE_ERR
newAttr is already a member
of the attribute set of some other Element node.
The Element node is read-only and does not allow
modifications to its attributes.
newAttr has a different
ownerDocument property
than the Element on which it is being set.
This method adds a new Attr node to the set of attributes of
an Element node. If an attribute with the same name already exists
for the Element, newAttr replaces that
attribute, and the replaced Attr node is returned. If no such
attribute already exists, this method defines a new attribute for
the Element.
It is usually easier to use setAttribute( ) instead of setAttributeNode( ).
Attr, Document.createAttribute( ), Element.setAttribute( )
Document.createAttribute( )
Element.setAttributeNodeNS( ): add a namespace Attr node to
an Element — DOM Level 2 Core:
Attr setAttributeNodeNS(AttrnewAttr)
throws DOMException;
This method throws exceptions for the same reasons as
setAttributeNode( ). It may
also throw a DOMException with a code of NOT_SUPPORTED_ERR to signal that the
method is not implemented because the current implementation does
not support XML documents and namespaces.
This method works just like setAttributeNode( ), except that it is
designed for use with Attr nodes that represent attributes specified
by namespace and name.
This method is useful only with XML documents that use
namespaces. It may be unimplemented (i.e., throw a NOT_SUPPORTED_ERR) on browsers that do not
support XML documents.
Attr, Document.createAttributeNS( ), Element.setAttributeNS( ), Element.setAttributeNode( )
Element.setAttributeNS( ): create or change an attribute
with a namespace — DOM Level 2 Core:
void setAttributeNS(StringnamespaceURI,
String qualifiedName,
String value)
throws DOMException;
The URI that uniquely identifies the namespace of the
attribute to be set or created, or null for no namespace.
The name of the attribute, specified as an optional
namespace prefix and colon followed by the local name within
the namespace.
The new value of the attribute.
The qualifiedName argument
contains a character that is not allowed in HTML or XML
attribute names.
qualifiedName is malformed,
or there is a mismatch between the namespace prefix of
qualifiedName and the
namespaceURI argument.
The DOM implementation does not support XML
documents.
This method is like setAttribute(
), except that the attribute to be created or set is
specified by a namespace URI and a qualified name that consists of a
namespace prefix, a colon, and a local name within the
namespace.
setAttribute(
)
Element.setAttribute( ),
Element.setAttributeNode(
)
Event: information about an event — DOM Level 2 Events, IE: Object → Event
The following properties are defined by the DOM Level 2 Events
standard. See also KeyEvent,
MouseEvent, and UIEvent for additional type-specific event
properties:
KeyEvent
readonly boolean
bubbles
true if the event is
of a type that bubbles (unless stopPropagation( ) is called);
false otherwise.
stopPropagation( )
readonly boolean
cancelable
true if the default
action associated with the event can be canceled with preventDefault( ); false otherwise.
readonly Object
currentTarget
The Element, Document, or Window that is currently
handling this event. During capturing and bubbling, this is
different from target.
readonly unsigned short
eventPhase
The current phase of event propagation. The value is one
of the following three constants, which represent the
capturing phase, normal event dispatch, and the bubbling
phase:
eventPhase
Constant
Event.CAPTURING_PHASE
Event.CAPTURING_PHASE
1
1
Event.AT_TARGET
Event.AT_TARGET
2
2
Event.BUBBLING_PHASE
Event.BUBBLING_PHASE
3
3
readonly Object
target
The target node for this event—i.e., the Element,
Document, or Window that generated the event.
readonly Date
timeStamp
The date and time at which the event occurred (or,
technically, at which the Event object was created). Implementations are not required
to provide valid time data in this field, and if they do not,
the getTime( ) method of
this Date object should return 0. See Date in Part III, “Core JavaScript Reference” of this book.
getTime( )
Date
The name of the event that this Event object represents.
This is the name under which the event handler was registered,
or the name of the event-handler property with the leading
"on" removed—for example, "click", "load", or "submit".
Internet Explorer does not (at least as of IE 7)
support the standard DOM event model, and IE's Event object defines
a completely different set of properties. The IE event model does
not define an inheritance hierarchy for different types of events,
so all properties relevant to any type of event are listed
here:
boolean altKey
Whether the Alt key
was held down when the event occurred.
integer button
For mouse events, button specifies which mouse button
or buttons were pressed. This value is a bit mask: the 1 bit
is set if the left button was pressed, the 2 bit is set if the
right button was pressed, and the 4 bit is set if the middle
button (of a three-button mouse) was pressed.
button
boolean
cancelBubble
If an event handler wants to stop an event from being
propagated up to containing objects, it must set this property
to true.
integer clientX,
clientY
The coordinates, relative to the web browser page, at
which the event occurred.
boolean ctrlKey
Whether the Ctrl key
was held down when the event occurred.
Element
fromElement
For mouseover and mouseout events, fromElement refers to the object
from which the mouse pointer is moving.
fromElement
integer keyCode
For keypress events, this property specifies the Unicode
character code generated by the key that was struck. For
keydown and keyup events, it specifies the virtual keycode of
the key that was struck. Virtual keycodes may be dependent on
the keyboard layout in use.
integer offsetX,
offsetY
The coordinates at which the event occurred within the
coordinate system of the event's source element (see srcElement).
srcElement
boolean
returnValue
If this property is set, its value takes precedence over
the value actually returned by an event handler. Set this
property to false to cancel
the default action of the source element on which the event
occurred.
integer screenX,
screenY
Specify the coordinates, relative to the screen, at
which the event occurred.
boolean shiftKey
Whether the Shift key
was held down when the event occurred.
Object
srcElement
A reference to the Window, Document, or Element object
that generated the event.
Element
toElement
For mouseover and mouseout events, toElement refers to the object into
which the mouse pointer is moving.
toElement
String type
The type of the event. Its value is the name of the
event handler minus the "on" prefix. So when the onclick( ) event handler is invoked,
the type property of the
Event object is "click".
onclick( )
integer x, y
Specify the X and Y coordinates at which the event
occurred relative to the document or the innermost containing
element that is dynamically positioned using CSS.
The following methods are defined by the DOM Level 2
Events specification. In the IE event model, the Event object has no
methods:
Initializes the properties of a newly created Event
object.
preventDefault(
)
Tells the web browser not to perform the default action
associated with this event, if there is one. If the event is
not of a type that is cancelable, this method has no
effect.
stopPropagation(
)
Stops the event from propagating any further through the
capturing, target, or bubbling phases of event propagation.
After this method is called, any other event handlers for the
same event on the same node are called, but the event is not
dispatched to any other nodes.
The properties of an Event object provide details about an
event, such as the element on which the event occurred. The methods
of an Event object can control the propagation of the event. The DOM
Level 2 Events standard defines a standard event model, which is
implemented by all modern browsers except Internet Explorer, which
defines its own, incompatible model. This reference page lists the
properties of both the standard Event object and also of the IE
Event object. See Chapter 17, Events and Event Handling for further
details about the two event models. In particular, however, note
that an Event object is passed to event-handler functions in the
standard event model but is stored in the event property of the Window object in the
IE event model.
In the standard event model, various subinterfaces of Event
define additional properties that provide details pertinent to
specific types of events. In the IE event model, there is only this
one type of Event object, and it is used for events of all
types.
KeyEvent, MouseEvent, UIEvent; Chapter 17, Events and Event Handling
Event.initEvent( ): initialize the properties of a new
event — DOM Level 2 Events
void initEvent(StringeventTypeArg,
boolean canBubbleArg,
boolean cancelableArg);
eventTypeArg
canBubbleArg
cancelableArg
The type of event. This may be one of the predefined
event types, such as "load" or "submit", or it may be a
custom type of your own choosing. Names that begin with
"DOM" are reserved, however.
Whether the event will bubble.
Whether the event can be canceled with preventDefault( ).
This method initializes the type, bubbles, and cancelable properties of a synthetic Event
object created by Document.createEvent(
). This method may be called on newly created Event
objects only before they have been dispatched with the dispatchEvent( ) method of the Document or
Element objects.
cancelable
Document.createEvent(
)
Document.createEvent( ),
MouseEvent.initMouseEvent( ),
UIEvent.initUIEvent( )
UIEvent.initUIEvent( )
Event.preventDefault( ): cancel default action of an
event — DOM Level 2 Events
void preventDefault( );
This method tells the web browser not to perform the default
action (if any) associated with this event. For example, if the
type property is "submit", any
event handler called during any phase of event propagation can
prevent form submission by calling this method. Note that if the
cancelable property of an Event
object is false, either there is
no default action or there is a default action that cannot be
prevented. In either case, calling this method has no effect.
Event.stopPropagation( ): do not dispatch an event any
further — DOM Level 2 Events
void stopPropagation( );
This method stops the propagation of an event and prevents it
from being dispatched to any other Document nodes. It may be called
during any phase of event propagation. Note that this method does
not prevent other event handlers on the same Document node from
being called, but it does prevent the event from being dispatched to
any other nodes.
ExternalInterface: a bidirectional interface to
Flash — ActionScript Object in Flash 8
available
Indicates whether Flash may communicate with JavaScript.
This will be false if the
security policy for the browser prevents communication.
addCallback( )
Exports an ActionScript method so it can be invoked from
JavaScript.
call( )
Invokes a JavaScript function from ActionScript.
ExternalInterface is an ActionScript object defined by the
Adobe Flash plug-in in version 8 and later. It defines two static
functions for use by ActionScript code in Flash movies. These
functions enable communication between JavaScript code in a web
browser and ActionScript code in a Flash movie.
FlashPlayer; Chapter 23, Scripting Java Applets and Flash Movies
FlashPlayer
ExternalInterface.addCallback( ): expose an ActionScript
method for execution from JavaScript — ActionScript function in Flash 8
boolean ExternalInterface.addCallback(Stringname,
Object instance,
Function func)
instance
func
The name of the JavaScript function to be defined.
Invoking a JavaScript function with this name causes the
Flash player to invoke the ActionScript function
func as a method of the
instance object.
The ActionScript object on which
func is to be invoked or null. This argument becomes the
value of the this keyword
when func is invoked.
The ActionScript function that is invoked when the
JavaScript function named name is
invoked.
true on success or
false on failure.
This static function is used by ActionScript code in a Flash
movie to enable JavaScript code in a web browser to invoke
ActionScript code. When addCallback(
) is invoked, it defines a top-level JavaScript function
called name which, when invoked, calls
the ActionScript function func as a
method of the ActionScript object
instance.
addCallback(
)
The arguments to the JavaScript function are converted and
passed to func, and the return value of
func is converted and becomes the return
value of the JavaScript function. Arguments and return values can be
primitive numbers, strings, boolean values, and objects and arrays
that contain primitive values. However, it is not possible, for
example, to pass a client-side JavaScript object such as a Window or
Document to an ActionScript function. It is also not possible to
return a Flash-specific ActionScript object such as a MovieClip to
JavaScript.
FlashPlayer; Chapter 23, Scripting Java Applets and Flash Movies
ExternalInterface.call( ): call a JavaScript function from
ActionScript — ActionScript function in Flash 8
Object ExternalInterface.call(Stringname,
Object args...)
args...
The name of the JavaScript function to invoke.
Zero or more arguments to convert and pass to the
JavaScript function.
The return value of the JavaScript function, converted to an
ActionScript value.
This static function is used by ActionScript code in a Flash
movie to invoke a JavaScript function defined in the web browser in
which the Flash movie is embedded. See ExternalInterface.addCallback( ) for a
discussion about the conversion of function arguments and return
values between ActionScript and JavaScript.
ExternalInterface.addCallback( )
FileUpload: see Input
FlashPlayer: plug-in for Flash movies — Flash 2.0
GetVariable( )
Returns the value of a variable defined by a Flash
movie.
GotoFrame( )
Jumps to the specified frame number in the movie.
IsPlaying( )
Checks whether the movie is playing.
LoadMovie( )
Loads an auxiliary Flash movie and displays it at a
specified layer or level of the current movie.
Pan( )
Moves the viewport of the movie.
PercentLoaded( )
Determines how much of the movie has loaded.
Play( )
Begins playing the movie.
Rewind( )
Rewinds the movie to its first frame.
SetVariable( )
Sets a variable defined by a Flash movie.
SetZoomRect( )
Sets the area of the movie displayed by the Flash
player.
StopPlay( )
Stops the movie.
TotalFrames( )
Returns the length of the movie, as a number of
frames.
Zoom( )
Changes the size of the movie's viewport.
A FlashPlayer object represents a Flash movie embedded in a
web page and the instance of the Flash plug-in that is playing that
movie. You can obtain a FlashPlayer object using Document.getElementById( ), for example,
to get the <embed> or
<object> tag that embeds
the movie in the web page.
<embed>
<object>
Once you have obtained a FlashPlayer object, you can use the
various JavaScript methods it defines to control playback of the
movie and to interact with it by setting and querying variables.
Note that FlashPlayer methods all begin with a capital letter, which
is not a common naming convention in client-side JavaScript.
Chapter 23, Scripting Java Applets and Flash Movies
FlashPlayer.GetVariable( ): return a value defined in a
Flash movie — Flash 4
String GetVariable(StringvariableName)
variableName
The name of the variable defined in the Flash
movie.
The value of the named variable as a string, or null if no such variable exists.
FlashPlayer.GotoFrame( ): skip to the specified frame of a
movie — Flash 2
void GotoFrame(integerframeNumber)
frameNumber
The frame number to skip to.
This function skips to the specified frame of the movie, or
skips to the last available frame, if the specified frame has not
been loaded yet. To avoid this indeterminate behavior, use PercentLoaded( ) to determine how much of
the movie is available.
FlashPlayer.IsPlaying( ): check whether a movie is
playing — Flash 2
boolean IsPlaying( )
true if the movie is
playing; false
otherwise.
FlashPlayer.LoadMovie( ): load an auxiliary movie — Flash 3
void LoadMovie(integerlayer,
String url)
layer
url
The level or layer within the current movie on which
the newly loaded movie is to be displayed.
The URL of the movie to load.
This method loads an auxiliary movie from the specified
url and displays it at the specified
layer within the current movie.
FlashPlayer.Pan( ): move the viewport of the
movie — Flash 2
void Pan(integerdx, integer dy,
integer mode)
mode
The horizontal and vertical amounts to pan.
This argument specifies how to interpret the
dx and
dy values. If this argument is 0,
the other arguments are taken as pixels. If this argument is
1, the others are percentages.
The Flash player defines a viewport through which Flash movies
are visible. Typically, the size of the viewport and the size of the
movie are the same, but this may not be not the case when SetZoomRect( ) or Zoom( ) have been called: those methods
can alter the viewport so that only a portion of the movie shows
through.
When the viewport is showing only a portion of the movie, this
Pan( ) method moves (or "pans")
the viewport so that a different portion of the movie shows. This
method doesn't allow you to pan beyond the edges of a movie,
however.
FlashPlayer.SetZoomRect( ),
FlashPlayer.Zoom( )
FlashPlayer.SetZoomRect( )
FlashPlayer.Zoom( )
FlashPlayer.PercentLoaded( ): determine how much of the
movie has loaded — Flash 2
integer PercentLoaded( )
An integer between 0 and 100 representing the approximate
percentage of the movie that has been loaded into the
player.
FlashPlayer.Play( ): play a movie — Flash 2
void Play( )
FlashPlayer.Rewind( ): rewind the movie to its first
frame — Flash 2
void Rewind( )
This method rewinds the movie to its first frame.
FlashPlayer.SetVariable( ): set a variable defined by a
Flash movie — Flash 4
void SetVariable(Stringname, String value)
The name of the variable to set.
The new value for the named variable. This value must
be a string.
This method specifies a value for a named variable defined by
the Flash movie.
FlashPlayer.SetZoomRect( ): set the viewport of a
movie — Flash 2
void SetZoomRect(integerleft, integer top,
integer right, integer bottom)
left, top
The coordinates, in twips, of the upper-left corner of
the viewport.
right, bottom
The coordinates, in twips, of the lower-right corner
of the viewport.
This method defines the movie's viewport—that is, it specifies
a subrectangle of the movie to appear in the Flash player. Flash
movies are measured in a unit known as the
twip. There are 20 twips to a point and 1,440
twips to an inch.
FlashPlayer.Pan( ),
FlashPlayer.Zoom( )
FlashPlayer.Pan( )
FlashPlayer.StopPlay( ): stop the movie — Flash 2
void StopPlay( )
Stop the movie.
FlashPlayer.TotalFrames( ): return the length of the movie,
in frames — Flash 2
integer TotalFrames( )
This method returns the length of the movie in frames.
FlashPlayer.Zoom( ): zoom in or out — Flash 2
void Zoom(integerpercentage)
percentage
The percentage by which to scale the viewport, or 0 to
restore the viewport to its full size.
This method scales the viewport by a specified
percentage. Arguments between 1 and 99 reduce the size of the
viewport, which makes objects in the movie appear larger. Arguments
greater than 100 enlarge the viewport (but never beyond the size of
the movie) and make objects in the movie appear smaller. As a
special case, the argument 0 restores the viewport to full size, so
that the entire movie is visible.
Form: a <form> in an HTML document — DOM Level 2 HTML: Node → Element → HTMLElement →
Form
readonly HTMLCollection
elements
An array (HTMLCollection) of all elements in the form.
See Form.elements[].
Form.elements[]
readonly long
length
The number of form elements in the form. This is the
same value as elements.length.
elements.length
In addition to these properties, Form also defines the
properties in the following table, which correspond directly to HTML
attributes:
Property
Attribute
String
acceptCharset
String
acceptCharset
acceptcharset
acceptcharset
Character sets the server can
accept
String
action
String
action
action
action
URL of the form
handler
String
enctype
String
enctype
enctype
enctype
Encoding of the
form
String
method
String
method
method
method
HTTP method used for form
submission
String
name
String
name
name
Name of the form
String
target
String
target
target
Frame or window name for form
submission results
reset( )
Resets all form elements to their default values.
Submits the form to a web server.
onreset
Invoked just before the elements of the form are
reset.
onsubmit
Invoked just before the form is submitted. This event
handler allows form entries to be validated before being
submitted.
A Form object is created with a standard HTML <form> tag. The form contains input
elements created with <input>, <select>, <textarea>, and other tags:
<form>
<input>
<textarea>
<form
[ name="form_name" ] // Used to name the form in JavaScript
[ target="window_name" ] // The name of the window for responses
[ action="url" ] // The URL to which the form is submitted
[ method=("get"|"post") ] // The method of form submission
[ enctype="encoding" ] // How the form data is encoded
[ onreset="handler" ] // A handler invoked when form is reset
[ onsubmit="handler" ] // A handler invoked when form is submitted
>
// Form text and input elements go here
</form>
form_name
window_name
encoding
handler
The Form object represents a <form> element in an HTML document.
The elements property is an
HTMLCollection that provides convenient access to all elements of
the form. The submit( ) and
reset( ) methods allow a form to
be submitted or reset under program control.
elements
Each form in a document is represented as an element of the
Document.forms[] array. Named
forms are also represented by the
form_name property of their document,
where form_name is the name specified by
the name attribute of the
<form> tag.
Document.forms[]
The elements of a form (buttons, input fields, checkboxes, and
so on) are collected in the Form.elements[] array. Named elements,
like named forms, can also be referenced directly by name: the
element name is used as a property name of the Form object. Thus, to
refer to an Input element named phone within a form named questionnaire, you might use the
JavaScript expression:
phone
questionnaire
document.questionnaire.phone
Input, Select, Textarea; Chapter 18, Forms and Form Elements
Input
Textarea
Form.elements[]: the input elements of a form — DOM Level 2 HTML
readonly HTMLCollection elements
elements[] is an array-like
HTMLCollection of the form elements (such as Input, Select, and
Textarea objects) that appear in an HTML form. The elements of the
array are in the same order they appear in the HTML source code for
the form. Each element has a type
property whose string value identifies its type.
elements[]
If an item in the elements[] array has been given a name
with the name="
name "
attribute of its HTML <input> tag, that item's name
becomes a property of form, and this
property refers to the item. Thus, it is possible to refer to input
elements by name instead of by number:
name="
"
form
form.name
Input, HTMLCollection, Select, Textarea
HTMLCollection
Form.onreset: event handler invoked when a form is
reset — DOM Level 0
Function onreset
The onreset property of a
Form object specifies an event-handler function that is invoked when
the user clicks on a Reset button
in the form. Note that this handler is not invoked in response to
the Form.reset( ) method. If the
onreset handler returns false, the elements of the form are not
reset. See Element.addEventListener(
) for another way to register event handlers.
Form.reset( )
Element.addEventListener(
), Form.onsubmit,
Form.reset( ); Chapter 17, Events and Event Handling
Form.onsubmit
Form.onsubmit: event handler invoked when a form is
submitted — DOM Level 0
Function onsubmit
The onsubmit property of a
Form object specifies an event-handler function that is invoked when
the user submits a form by clicking on its Submit button. Note that this event handler
is not invoked when the Form.submit(
) method is called.
Form.submit(
)
If the onsubmit handler
returns false, the elements of
the form are not submitted. If the handler returns any other value
or returns nothing, the form is submitted normally. Because the
onsubmit handler can cancel form
submission, it is ideal for performing form data validation.
See Element.addEventListener(
) for another way to register event handlers.
Element.addEventListener(
), Form.onreset,
Form.submit( ); Chapter 17, Events and Event Handling
Form.onreset
Form.submit( )
Form.reset( ): reset the elements of a form to their
default values — DOM Level 2 HTML
void reset( );
This method resets each element of a form to its default
value. The results of calling this method are like the results of a
user clicking on a Reset button,
except that the onreset event
handler of the form is not invoked.
Form.onreset, Form.submit( )
Form.submit( ): submit form data to a web server — DOM Level 2 HTML
void submit( );
This method submits the values of the form elements to the
server specified by the form's action property. It submits a form in the
same way that a user's clicking on a Submit button does, except that the
onsubmit event handler of the
form is not triggered.
Form.onsubmit, Form.reset( )
Frame: a <frame> in an HTML document — DOM Level 2 HTML: Node → Element → HTMLElement →
Frame
As explained in the Description, HTML frames can be accessed
as Frame objects or as Window objects. When accessed as Frame
objects, they inherit properties from HTMLElement and define these
additional properties:
Document
contentDocument
The document that holds the content of the frame.
String src
The URL from which the frame's content was loaded.
Setting this property causes the frame to load a new document.
This property simply mirrors the src attribute of the HTML <frame> tag: it is not a
Location object like Window.location.
src
<frame>
Window.location
In addition to these properties, the Frame object also defines
the following properties, which correspond directly to HTML
attributes:
String
frameBorder
String
frameBorder
frameborder
frameborder
Set to "0" for borderless
frames
String
longDesc
String
longDesc
longdesc
longdesc
The URL of a frame
description
String
marginHeight
String
marginHeight
marginheight
marginheight
Top and bottom frame margin, in
pixels
String
marginWidth
String
marginWidth
marginwidth
marginwidth
Left and right frame margin, in
pixels
The name of the frame, for DOM
Level 0 lookup and form and link targets
boolean
noResize
boolean
noResize
noresize
noresize
If true, user cannot resize
frame
String
scrolling
String
scrolling
scrolling
scrolling
Frame scroll policy: "auto",
"yes", or "no"
Frames have a dual nature and may be represented in
client-side JavaScript by either Window or Frame objects. In the
traditional Level 0 DOM, each <frame> is treated as an independent
window and is represented by a Window object, referenced by name, or
as an element of the frames[]
array of the containing Window:
frames[]
// Get a frame as a Window object
var win1 = top.frames[0]; // Index frames[] array by number
var win2 = top.frames['f1']; // Index frames[] array by name
var win3 = top.f1; // Get frame as a property of its parent
When frames are looked up this way, the returned object is a
Window, and the properties listed in the previous section are not
available. Instead, use Window properties, such as document to access the frame's document
and location to access the URL of
that document.
location
In the Level 2 DOM, <frame> elements can be looked up by
ID or tag name, just as any other document element can be:
// Get a frame as a Frame object
var frame1 = top.document.getElementById('f1'); // by id
var frame2 = top.document.getElementsByTagName('frame')[1]; // by tag name
When frames are looked up using DOM methods like these, the
result is a Frame object rather than a Window object, and the
properties listed previously are available. Use contentDocument to access the frame's
document, and use the src
property to query the URL of that document or to make the frame load
a new document. To obtain the Window object of a Frame object
f, use f.contentDocument.defaultView.
f
f.contentDocument.defaultView
<iframe> elements are
very similar to <frame>
elements. See the IFrame
reference page.
<iframe>
IFrame
Note that the same-origin policy (see the section called “The Same-Origin Policy”) applies to multiframed
documents. Browsers do not allow you to access the content of frames
loaded from a different origin than that of the content that
includes the script. This is true whether the frame is represented
by a Window or a Frame object.
IFrame, Window; Chapter 14, Scripting Browser Windows
Hidden: see Input
History: the URL history of the browser — JavaScript 1.0: Object → History
window.history
history
length
This numeric property specifies the number of URLs in
the browser's history list. Since there is no way to determine
the index of the currently displayed document within this
list, knowing the size of this list is not particularly
helpful.
back( )
Goes backward to a previously visited URL.
forward( )
Goes forward to a previously visited URL.
go( )
Goes to a previously visited URL.
The History object was originally designed to represent the browsing
history of a window. For privacy reasons, however, the
History object no longer allows scripted access to the actual URLs
that have been visited. The only functionality that remains is in
the use of the back( ), forward( ), and go( ) methods.
The following line performs the same action as clicking a
browser's Back button:
history.back( );
The following line performs the same action as clicking the
Back button twice:
history.go(-2);
The history property of the
Window object, Location
History.back( ): return to the previous URL — JavaScript 1.0
history.back( )
back( ) causes the window
or frame to which the History object belongs to revisit the URL (if
any) that was visited immediately before the current one. Calling
this method has the same effect as clicking on the browser's
Back button. It is also
equivalent to:
history.go(-1);
History.forward( ): visit the next URL — JavaScript 1.0
history.forward( )
forward( ) causes the
window or frame to which the History object belongs to revisit the
URL (if any) that was visited immediately after the current one.
Calling this method has the same effect as clicking on the browser's
Forward button. It is also
equivalent to:
history.go(1);
Note that if the user has not used the Back button or the Go menu to move backward through the
history, and if JavaScript has not invoked the History.back( ) or History.go( ) methods, the forward( ) method has no effect because
the browser is already at the end of its list of URLs, and there is
no URL to go forward to.
History.back( )
History.go( )
History.go( ): revisit a URL — JavaScript 1.0
history.go(relative_position)
history.go(target_string)
relative_position
target_string
The relative position in the history list of the URL
to be visited.
A URL (or URL fragment) to be visited, if a matching
URL exists in the history list.
The first form of the History.go(
) method takes an integer argument and causes the browser
to visit the URL that is the specified number of positions away in
the history list maintained by the History object. Positive
arguments move the browser forward through the list, and negative
arguments move it backward. Thus, calling history.go(-1) is equivalent to calling
history.back( ) and produces the
same effect as clicking on the Back button. Similarly, history.go(3) revisits the same URL that
would be visited by calling history.forward( ) three times.
History.go(
)
history.go(-1)
history.go(3)
The second form of the History.go(
) takes a string argument and causes the browser to
revisit the first (i.e., most recently visited) URL that contains
the specified string. This form of the method is not well specified
and may work differently on different browsers. For example,
Microsoft's documentation specifies that the argument must match the
URL of a previously specified site exactly, while old Netscape
documentation (Netscape created the History object) says that the
argument may be a substring of a previously visited URL.
HTMLCollection: array of HTML elements accessible by
position or name — DOM Level 2 HTML: Object → HTMLCollection
The number of elements in the collection.
item( )
Returns the element at the specified position in the
collection. You can also simply specify the position within
array brackets instead of calling this method
explicitly.
namedItem( )
Returns the element from the collection that has the
specified value for its id
or name attribute, or
null if there is no such
element. You can also place the element name within array
brackets instead of calling this method explicitly.
An HTMLCollection is a collection of HTML elements with
methods that allow you to retrieve an element by its position in the
collection or by its id or
name attribute. In JavaScript,
HTMLCollection objects behave like read-only arrays, and you can use
JavaScript square-bracket notation to index an HTMLCollection by
number or by name instead of calling the item( ) and namedItem( ) methods.
A number of the properties of the HTMLDocument object are
HTMLCollection objects and provide convenient access to document
elements such as forms, images, and links. The Form.elements property and Select.options property are HTMLCollection
objects. The HTMLCollection object also provides a convenient way to traverse the rows
of a Table and the cells of a TableRow.
Form.elements
Select.options
HTMLCollection objects are read-only: you cannot assign new
elements to them, even when using JavaScript array notation. They
are "live," meaning that if the underlying document changes, those
changes are immediately visible through all HTMLCollection
objects.
HTMLCollection objects are similar to NodeList objects but may
be indexed by name as well as by number.
var c = document.forms; // This is an HTMLCollection of form elements
var firstform = c[0]; // It can be used like a numeric array
var lastform = c[c.length-1]; // The length property gives the number of elements
var address = c["address"]; // It can be used like an associative array
var address = c.address; // JavaScript allows this notation, too
HTMLDocument, NodeList
NodeList
HTMLCollection.item( ): get an element by
position — DOM Level 2 HTML
Node item(unsigned longindex);
The position of the element to be returned. Elements
appear in an HTMLCollection in the same order in which they
appear in the document source.
The element at the specified
index, or null if index
is less than zero or greater than or equal to the length property.
The item( ) method returns
a numbered element from an HTMLCollection. In JavaScript, it is
easier to treat the HTMLCollection as an array and to index it using
array notation.
var c = document.images; // This is an HTMLCollection
var img0 = c.item(0); // You can use the item( ) method this way
var img1 = c[1]; // But this notation is easier and more common
NodeList.item( )
NodeList.item( )
HTMLCollection.namedItem( ): get an element by
name — DOM Level 2 HTML
Node namedItem(Stringname);
The name of the element to be returned.
The element in the collection that has the specified value
for its id or name attribute, or null if no elements in the
HTMLCollection have that name.
This method finds and returns an element from the
HTMLCollection that has the specified name. If any element has an
id attribute whose value is the
specified name, that element is returned. If no such element is
found, an element whose name
attribute has the specified value is returned. If no such element
exists, namedItem( ) returns
null.
Note that any HTML element may be given an id attribute, but only certain HTML
elements—such as forms, form elements, images, and anchors—may have
a name attribute.
In JavaScript, it is easier to treat the HTMLCollection as an
associative array and to specify name
between square brackets using array notation.
var forms = document.forms; // An HTMLCollection of forms
var address = forms.namedItem("address"); // Finds <form name="address">
var payment = forms["payment"] // Simpler syntax: finds <form name="payment">
var login = forms.login; // Also works: finds <form name="login">
HTMLDocument: the root of an HTML document tree — DOM Level 0: Node → Document → HTMLDocument
Element[] all
This nonstandard property is an array-like object that
provides access to all HTMLElements in the document. The
all[] array originated in
IE4, and although it has been superseded by methods such as
Document.getElementById( )
and Document.getElementsByTagName(
), it is still used in deployed code. See HTMLDocument.all[] for further
details.
all[]
Document.getElementsByTagName(
)
HTMLDocument.all[]
readonly HTMLCollection
anchors
An array (HTMLCollection) of all Anchor objects in the
document.
readonly HTMLCollection
applets
An array (HTMLCollection) of all Applet objects in a
document.
HTMLElement body
A convenience property that refers to the HTMLElement
that represents the <body> tag of this document.
For documents that define framesets, this property refers to
the outermost <frameset> tag instead.
<frameset>
String cookie
Allows cookies to be queried and set for this document.
See HTMLDocument.cookie for
details.
String domain
The domain name of the server from which the document
was loaded, or null if
there is none. This property can also be used to ease the
same-origin security policy in specific circumstances. See
HTMLDocument.domain for
details.
HTMLDocument.domain
readonly HTMLCollection
forms
An array (HTMLCollection) of all Form objects in the
document.
readonly HTMLCollection
images
An array (HTMLCollection) of Image objects in the
document. Note that for compatibility with the Level 0 DOM,
images defined with an <object> tag instead of the
<img> tag are not
included in this collection.
readonly String
lastModified
Specifies the date and time of the most recent
modification to the document. This value comes from the
Last-Modified HTTP header that is optionally sent by the web
server.
readonly HTMLCollection
links
An array (HTMLCollection) of all Link objects in the
document.
readonly String
referrer
The URL of the document that linked to this document, or
null if this document was
not accessed through a hyperlink. This property allows
client-side JavaScript to access the HTTP referer header. Note the spelling
difference, however: the HTTP header has three r's, and the
JavaScript property has four r's.
referer
String title
The contents of the <title> tag for this
document.
<title>
readonly String
URL
The URL of the document. This value is often the same as
the location.href property
of the Window that contains the document. When URL redirection
occurs, however, this URL
property holds the actual URL of the document, and location.href holds the URL that was
requested.
location.href
URL
Closes a document stream opened with the open( ) method, forcing any buffered
output to be displayed.
open( )
getElementsByName(
)
Returns an array of nodes (a NodeList) of all elements
in the document that have a specified value for their name attribute.
Opens a stream to which new document contents may be
written. Note that this method erases any current document
content.
write( )
Appends a string of HTML text to an open
document.
writeln( )
Appends a string of HTML text followed by a newline
character to an open document.
This interface extends Document and defines
HTML-specific properties and methods. A number of the properties are
HTMLCollection objects (essentially read-only arrays that can be
indexed by number or name) that hold references to anchors, forms,
links, and other important scriptable elements of the document.
These collection properties originated with the Level 0 DOM. They
have been superseded by Document.getElementsByTagName( ) but
remain in common use because they are so convenient.
Document.getElementsByTagName( )
The write( ) method is
notable: it allows a script to insert dynamically generated content
into a document while the document is being loaded and
parsed.
Note that in the Level 1 DOM, HTMLDocument defined a very
useful method named getElementById(
). In the Level 2 DOM, this method has been moved to the
Document interface, and it is now inherited by HTMLDocument rather
than defined by it. See Document.getElementById( ) for
details.
getElementById(
)
Document, Document.getElementById( ), Document.getElementsByTagName( )
HTMLDocument.all[]: all HTML elements in a
document — IE 4
document.all[i]
document.all[name]
document.all.tags(tagname)
all[] is a versatile
array-like object that provides access to all the HTML elements in a
document. The all[] array
originated in IE 4 and has been adopted by a number of other
browsers. It has been superseded by the standard getElementById( ) and getElementsByTagName( ) methods of the
Document interface, and the standard getElementsByName( ) method of the
HTMLDocument interface. Despite this, the all[] array is still used in existing
code.
all[] contains the elements
in source order, and you can extract them directly from the array if
you know their exact numeric position within the array. It is more
common, however, to use the all[]
array to retrieve elements by the value of their name or id HTML attributes. If more than one
element has the specified name, using that name as an index into
all[] returns an array of
elements that share the name.
all.tags( ) is passed a tag
name and returns an array of HTML elements of the specified
type.
all.tags( )
Document.getElementById(
), Document.getElementsByTagName(
), HTMLElement
Document.getElementById(
)
Document.getElementsByTagName(
)
HTMLDocument.close( ): close an open document and display
it — DOM Level 0
void close( );
This method closes a document stream that was opened with the
open( ) method and forces any
buffered output to be displayed. If you use the write( ) method to dynamically output a
document, you must remember to call this method when you are done to
ensure that all your document content is displayed. Once you have
called close( ), you should not
call write( ) again, as this
implicitly calls open( ) to erase
the current document and begin a new one.
HTMLDocument.open( ),
HTMLDocument.write( )
HTMLDocument.open( )
HTMLDocument.write( )
HTMLDocument.cookie: the cookie(s) of the
document — DOM Level 0
cookie is a string property
that allows you to read, create, modify, and delete the cookie or
cookies that apply to the current document. A
cookie is a small amount of named data stored
by the web browser. It gives web browsers a "memory" so they can use
data input on one page in another page or recall user preferences
across web browsing sessions. Cookie data is automatically
transmitted between web browser and web server when appropriate so
server-side scripts can read and write cookie values. Client-side
JavaScript code can also read and write cookies with this
property.
The HTMLDocument.cookie
property does not behave like a normal read/write property. You may
both read and write the value of HTMLDocument.cookie, but the value you
read from this property is, in general, not the same as the value
you write. For details on the use of this particularly complex
property, see Chapter 19, Cookies and Client-Side Persistence.
Cookies are intended for infrequent storage of small
amounts of data. They are not intended as a general-purpose
communication or programming mechanism, so use them in moderation.
Note that web browsers are not required to retain the value of more
than 20 cookies per web server, nor to retain a cookie
name/value
pair of more than 4 KB in length.
Chapter 19, Cookies and Client-Side Persistence
HTMLDocument.domain: the security domain of a
document — DOM Level 0
According to the DOM Level 2 HTML standard, the domain property is simply a read-only
string that contains the hostname of the web server from which the
document was loaded.
domain
This property has another important use (although this use has
not been standardized). The same-origin security policy (described
in the section called “The Same-Origin Policy”) prevents a script in
one document from reading the content of another document (such as a
document displayed in an <iframe>) unless the two documents
have the same origin (i.e., were retrieved from the same web
server). This can cause problems for large web sites that use
multiple servers. For example, a script on the host might want to read the content of
documents from the host search.oreilly.com.
The domain property helps
to address this problem. You can set this property but only in a
very restricted way: it can be set only to a domain suffix of
itself. For example, a script loaded from search.oreilly.com could set its own domain property to "". If a script from is running in another window, and it
also sets its domain property to
"", then each script can read
content from the other script's document, even though they did not
originate on the same server. Note, that a script from search.oreilly.com cannot set its domain property to "search.oreilly" or to
".com".
the section called “The Same-Origin Policy”
HTMLDocument.getElementsByName( ): find elements with the
specified name attribute — DOM Level 2 HTML
Element[] getElementsByName(StringelementName);
elementName
The desired value for the name attribute.
A read-only array (technically a NodeList) of Element
objects that have a name
attribute with the specified value. If no such elements are found,
the returned array is empty and has a length of 0.
This method searches an HTML document tree for Element nodes
that have a name attribute of the
specified value and returns a NodeList (which you can treat as a
read-only array) containing all matching elements. If there are no
matching elements, a NodeList with length 0 is returned.
Do not confuse this method with the Document.getElementById( ) method, which
finds a single Element based on the unique value of an id attribute, or with the Document.getElementsByTagName( ) method,
which returns a NodeList of elements with the specified tag
name.
Document.getElementById( ),
Document.getElementsByTagName(
)
HTMLDocument.open( ): begin a new document, erasing the
current one — DOM Level 0
void open( );
This method erases the current HTML document and begins a new
one, which may be written to with the write( ) and writeln( ) methods. After calling open( ) to begin a new document and
write( ) to specify document
content, you must always remember to call close( ) to end the document and force its
content to be displayed.
This method should not be called by a script or event handler
that is part of the document being overwritten, because the script
or handler will itself be overwritten.
var w = window.open(""); // Open a new window
var d = w.document; // Get its HTMLDocument object
d.open( ); // Open the document for writing
d.write("<h1>Hello world</h1>"); // Output some HTML to the document
d.close( ); // End the document and display it
HTMLDocument.close( ),
HTMLDocument.write( )
HTMLDocument.close( )
HTMLDocument.write( ): append HTML text to an open
document — DOM Level 0
void write(Stringtext);
The HTML text to be appended to the document.
This method appends the specified HTML text to the document.
According to the DOM standard, this method takes a single string
argument. According to common practice, however, the write( ) method may be passed any number
of arguments. These arguments are converted to strings and appended,
in order, to the document.
Document.write( ) is
normally used in one of two ways. First, it can be invoked on the
current document within a <script> tag or within a function
that is executed while the document is being parsed. In this case,
the write( ) method writes its
HTML output as if that output appeared literally in the file at the
location of the code that invoked the method.
Document.write( )
<script>
Second, you can use Document.write(
) to dynamically generate new documents in a window,
frame, or iframe other than the one in which the calling script is
running. If the target document is open, write( ) appends to that document. If the
document is not open, write( )
discards the existing document and opens a new (empty) one to which
it appends its arguments.
Document.write(
)
Once a document is open, Document.write( ) can append any amount of
output to the end of the document. When a new document has been
completely generated by this technique, the document must be closed
by calling Document.close( ).
Note that although the call to open(
) is optional, the call to close(
) is never optional.
Document.close( )
open(
)
)
The results of calling Document.write( ) may not be immediately
visible in the target document. This is because a web browser may
buffer up text to parse and display in larger chunks. Calling
Document.close( ) is the only way
to explicitly force all buffered output to be "flushed" and
displayed.
HTMLDocument.close( ),
HTMLDocument.open( )
HTMLDocument.writeln( ): append HTML text and a newline to
an open document — DOM Level 0
void writeln(Stringtext);
This method is like HTMLDocument.write( ), except that it
follows the appended text with a newline character, which may be
useful when writing the content of a <pre> tag, for example.
<pre>
HTMLDocument.write(
)
HTMLDocument.write(
)
HTMLElement: an element in an HTML document — DOM Level 2 HTML: Node → Element →
HTMLElement
Each element of an HTML document has properties that
correspond to the HTML attributes of the element. The properties
supported by all HTML tags are listed here. Other properties,
specific to certain kinds of HTML tags, are listed in the long table
in the following Description section. HTMLElement objects inherit a
number of useful standard properties from Node and Element, and also
implement several nonstandard properties described here:
String className
The value of the class attribute of the element,
which specifies zero or more space-separated CSS class names.
Note that this property is not named "class" because that name
is a reserved word in JavaScript.
class
CSS2Properties
currentStyle
This IE-specific property represents the cascaded set of
all CSS properties that apply to the element. It is an IE-only
alternative to Window.getComputedStyle( ).
String dir
The value of the dir
attribute of the element, which specifies the text direction
for the document.
dir
String id
The value of the id
attribute. No two elements within the same document should
have the same value for id.
String innerHTML
A read/write string that specifies the HTML text that is
contained within the element, not including the opening and
closing tags of the element itself. Querying this property
returns the content of the element as a string of HTML text.
Setting this property to a string of HTML text replaces the
content of the element with the parsed representation of the
HTML. You cannot set this property while the document is
nonstandard property that originated in IE 4. It has been
implemented by all modern browsers.
String lang
The value of the lang
attribute, which specifies the language code for the element's
content.
lang
int offsetHeight,
offsetWidth
The height and width, in pixels, of the element and all
its content, including the element's CSS padding and border,
but not its margin. These are nonstandard but well-supported
properties.
int offsetLeft,
offsetTop
The X and Y coordinates of the upper-left corner of the
CSS border of the element relative to the offsetParent container element.
These are nonstandard but well-supported properties.
offsetParent
Element
offsetParent
Specifies the container element that defines the
coordinate system in which offsetLeft and offsetTop are measured. For most
elements, offsetParent is
the Document object that contains them. However, if an element
has a dynamically positioned container, the dynamically
positioned element is the offsetParent. In some browsers,
table cells are positioned relative to the row in which they
are contained, rather than relative to the containing
document. See Chapter 16, Cascading Style Sheets and Dynamic HTML for an
example that uses this property portably. This is a
nonstandard but well-supported property.
offsetLeft
offsetTop
int scrollHeight,
scrollWidth
The overall height and width, in pixels, of an element.
When an element has scrollbars (because of the CSS overflow attribute, for example)
these properties differ from offsetHeight and offsetWidth, which simply report the
size of the visible portion of the element. These are
non-standard but well-supported properties.
offsetHeight
offsetWidth
int scrollLeft,
scrollTop
The number of pixels that have scrolled off the left
edge of the element or off the top edge of the element. These
properties are useful only for elements with scrollbars, such
as elements with the CSS overflow attribute set to auto. These properties are also
defined on the <body>
or <html> tag of the
document (this is browser-dependent) and specify the amount of
scrolling for the document as a whole. Note that these
properties do not specify the amount of scrolling in an
<iframe> tag. These
are non-standard but well-supported properties.
auto
CSS2Properties
style
The value of the style attribute that specifies
inline CSS styles for this element. Note that the value of
this property is not a string. See CSS2Properties for details.
The value of the title attribute of the element. Many
browsers display the value of this attribute in a tool tip
when the mouse hovers over the element.
HTMLElement objects inherit the standard methods of
Node and Element. Certain types of elements implement tag-specific
methods, which are listed in the long table in the Description
section and documented in other reference pages such as Form, Input, and Table. Most modern browsers also implement
the following nonstandard method as well:
Form
Table
scrollIntoView(
)
Scrolls the document so the element is visible at the
top or bottom of the window.
All HTML elements respond to raw mouse and key events
and can trigger the event handlers listed here. Some elements, such as links and
buttons, perform default actions when these events occur. For
elements like these, further details are available on the
element-specific reference page; see Input and Link, for example:
onclick
Invoked when the user clicks on the element.
ondblclick
Invoked when the user double-clicks on the
element.
onkeydown
Invoked when the user presses a key.
onkeypress
Invoked when the user presses and releases a key.
onkeyup
Invoked when the user releases a key.
onmousedown
Invoked when the user presses a mouse button.
onmousemove
Invoked when the user moves the mouse.
onmouseout
Invoked when the user moves the mouse off the
element.
onmouseover
Invoked when the user moves the mouse over an
element.
onmouseup
Invoked when the user releases a mouse button.
Each tag in an HTML document is represented by an
HTMLElement object. HTMLElement defines properties that represent the
attributes shared by all HTML elements. The following HTML tags do
not have any properties other than those listed previously and are
fully described by the HTMLElement interface:
<abbr>
<abbr>
<acronym>
<acronym>
<address>
<address>
<b>
<b>
<bdo>
<bdo>
<big>
<big>
<center>
<center>
<cite>
<cite>
<code>
<code>
<dd>
<dd>
<dfn>
<dfn>
<dt>
<dt>
<em>
<em>
<i>
<i>
<kbd>
<kbd>
<noframes>
<noframes>
<noscript>
<noscript>
<s>
<s>
<samp>
<samp>
<small>
<small>
<span>
<span>
<strike>
<strike>
<strong>
<strong>
<sub>
<sub>
<sup>
<sup>
<tt>
<tt>
<u>
<u>
<var>
<var>
Most HTML tags define properties other than those explicitly
listed previously. The DOM Level 2 HTML specification defines
tag-specific interfaces for these tags, so that all standard HTML
attributes have a corresponding standard JavaScript property.
Typically, a tag named T has a tag-specific
interface named HTMLTElement. For example, the
<head> tag is represented
by the HTMLHeadElement interface. In a few cases, two or more
related tags share a single interface, as in the case of the
<h1> through <h6> tags, which are all represented
by the HTMLHeadingElement interface.
<head>
<h6>
Most of these tag-specific interfaces do nothing more than
define a JavaScript property for each attribute of the HTML tag. The
JavaScript properties have the same names as the attributes and use
lowercase (e.g., id) or, when the
attribute name consists of multiple words, mixed case (e.g.,
longDesc). When an HTML attribute
name is a reserved word in Java or JavaScript, the property name is
changed slightly. For example, the for attribute of <label> and <script> tags becomes the htmlFor property of the HTMLLabelElement
and HTMLScriptElement interfaces because for is a reserved word. The meanings of
those properties that correspond directly to HTML attributes are
defined by the HTML specification, and documenting each one is
beyond the scope of this book.
longDesc
for
<label>
htmlFor
The following table lists all the HTML tags that have a
corresponding subinterface of HTMLElement. For each tag, the table
lists the DOM interface name and the names of the properties and
methods it defines. All properties are read/write strings unless
otherwise specified. For properties that are not read/write strings,
the property type is specified in square brackets before the
property name. Quite a few tags and attributes are deprecated in
HTML 4 and are marked with an * in this table.
Because these interfaces and their properties map so directly
to HTML elements and attributes, most interfaces do not have
reference pages of their own in this book, and you should consult an
HTML reference for details. The exceptions are interfaces that
represent tags that are particularly important to client-side
JavaScript programmers, such as the <form> and <input> tags. Those tags are
documented in this book, under names that do not include the "HTML"
prefix or the "Element" suffix. See, for example, the entries for
Anchor, Applet, Canvas, Form, Image, Input, Link, Option, Select, Table, and Textarea:
Anchor
Applet
Option
HTML tag
DOM interface, properties, and
methods
[*]
all tags
HTMLElement: id, title, lang, dir, className
className
<a>
HTMLAnchorElement: accessKey, charset, coords, href, hreflang, name, rel, rev, shape, [long] tabIndex, target, type, blur( ), focus( )
accessKey
charset
coords
href
hreflang
rel
rev
shape
[long] tabIndex
blur( )
<applet>
HTMLAppletElement[*]: align [*], alt [*], archive [*], code [*], codeBase [*], height [*], hspace [*], name [*], object [*], vspace [*], width [*]
align
alt
archive
codeBase
hspace
object
vspace
<area>
<area>
HTMLAreaElement: accessKey, alt, coords, href, [boolean] noHref, shape, [long] tabIndex, target
[boolean] noHref
<base>
<base>
HTMLBaseElement: href, target
<basefont>
<basefont>
HTMLBaseFontElement[*]: color [*], face [*], size [*]
face
<blockquote>, <q>
<blockquote>
<q>
HTMLQuoteElement: cite
cite
<body>
HTMLBodyElement: aLink [*], background [*], bgColor [*], link [*], text [*], vLink [*]
aLink
bgColor
link
vLink
HTMLBRElement: clear [*]
<button>
<button>
HTMLButtonElement: [readonly HTMLFormElement] form,
accessKey, [boolean] disabled, name, [long] tabIndex, [readonly] type, value
[readonly HTMLFormElement] form
[boolean] disabled
[readonly] type
<caption>
<caption>
HTMLTableCaptionElement: align [*]
<col>, <colgroup>
<col>
<colgroup>
HTMLTableColElement: align, ch, chOff, [long] span, vAlign, width
ch
chOff
[long] span
vAlign
<del>, <ins>
<del>
<ins>
HTMLModElement: cite, dateTime
dateTime
<dir>
<dir>
HTMLDirectoryElement[*]: [boolean] compact [*]
[boolean] compact
<div>
HTMLDivElement: align [*]
<dl>
<dl>
HTMLDListElement: [boolean] compact [*]
<fieldset>
<fieldset>
HTMLFieldSetElement: [readonly HTMLFormElement] form
<font>
<font>
HTMLFontElement[*]: color [*], face [*], size [*]
<form>
HTMLFormElement: [readonly HTMLCollection]
elements, [readonly long]
length, name,
acceptCharset, action, enctype, method, target, submit( ), reset( )
[readonly HTMLCollection]
elements
[readonly long]
length
acceptCharset
<frame>
HTMLFrameElement: frameBorder, longDesc, marginHeight, marginWidth, name, [boolean] noResize, scrolling, src, [readonly Document]
contentDocument
frameBorder
marginHeight
marginWidth
[boolean] noResize
[readonly Document]
contentDocument
<frameset>
HTMLFrameSetElement: cols, rows
cols
rows
<h1>, <h2>, <h3>, <h4>, <h5>, <h6>
<h2>
<h3>
<h4>
<h5>
HTMLHeadingElement: align [*]
<head>
HTMLHeadElement: profile
profile
<hr>
<hr>
HTMLHRElement: align [*], [boolean] noShade [*], size [*], width [*]
[boolean] noShade
<html>
HTMLHtmlElement: version [*]
<iframe>
HTMLIFrameElement: align [*], frameBorder, height, longDesc, marginHeight, marginWidth, name, scrolling, src, width, [readonly Document]
contentDocument
<img>
HTMLImageElement: align [*], alt, [long] border [*], [long] height, [long] hspace [*], [boolean] isMap, longDesc, name, src, useMap, [long] vspace [*], [long] width
[long] border
[long] height
[long] hspace
[boolean] isMap
useMap
[long] vspace
[long] width
<input>
HTMLInputElement: defaultValue, [boolean] defaultChecked, [readonly HTMLFormElement] form,
accept, accessKey, align [*], alt, [boolean] checked, [boolean] disabled, [long] maxLength, name, [boolean] readOnly, size, src, [long] tabIndex, type, useMap, value, blur( ), focus( ), select( ), click( )
defaultValue
[boolean] defaultChecked
accept
[boolean] checked
[long] maxLength
[boolean] readOnly
click( )
<ins>
See <del>
<isindex>
<isindex>
HTMLIsIndexElement[*]: [readonly HTMLFormElement] form,
prompt [*]
prompt
<label>
HTMLLabelElement: [readonly HTMLFormElement] form,
accessKey, htmlFor
<legend>
<legend>
HTMLLegendElement: [readonly HTMLFormElement] form,
accessKey, align [*]
<li>
<li>
HTMLLIElement: type [*], [long] value [*]
[long] value
<link>
HTMLLinkElement: [boolean] disabled, charset, href, hreflang, media, rel, rev, target, type
media
<map>
<map>
HTMLMapElement: [readonly HTMLCollection of HTMLAreaElement]
areas, name
[readonly HTMLCollection of HTMLAreaElement]
areas
HTMLMenuElement[*]: [boolean] compact [*]
<meta>
<meta>
HTMLMetaElement: content, httpEquiv, name, scheme
httpEquiv
scheme
<object>
HTMLObjectElement: code, align [*], archive, border [*], codeBase, codeType, data, [boolean] declare, height, hspace [*], name, standby, [long] tabIndex, type, useMap, vspace [*], width, [readonly Document]
contentDocument
codeType
[boolean] declare
standby
<ol>
<ol>
HTMLOListElement: [boolean] compact [*], [long] start [*], type [*]
[long] start
<optgroup>
<optgroup>
HTMLOptGroupElement: [boolean] disabled, label
label
<option>
<option>
HTMLOptionElement: [readonly HTMLFormElement] form,
[boolean]
defaultSelected, [readonly] text, [readonly long] index, [boolean] disabled, label, [boolean] selected, value
[boolean]
defaultSelected
[readonly] text
[readonly long] index
[boolean] selected
<p>
HTMLParagraphElement: align [*]
<param>
<param>
HTMLParamElement: name, type, value, valueType
valueType
<pre>
HTMLPreElement: [long] width [*]
<q>
See <blockquote>
<script>
HTMLScriptElement: text, html For, event, charset, [boolean] defer, src, type
html For
[boolean] defer
HTMLSelectElement: [readonly] type, [long] selectedIndex, value, [readonlylong] length, [readonly HTMLFormElement] form,
[readonly HTMLCollection of
HTMLOptionElement] options, [boolean] disabled, [boolean] multiple, name, [long] size, [long] tabIndex, add( ), remove( ), blur( ), focus( )
[long] selectedIndex
[readonlylong] length
[readonly HTMLCollection of
HTMLOptionElement] options
[boolean] multiple
[long] size
add( )
remove( )
<style>
HTMLStyleElement: [boolean] disabled, media, type
<table>
<table>
HTMLTableElement: , align [*], bgColor [*], border, cellPadding, cellSpacing, frame, rules, summary, width, createTHead( ), deleteTHead( ), createTFoot( ), deleteTFoot( ), createCaption( ), deleteCaption( ), insertRow( ), deleteRow( )
cellPadding
cellSpacing
frame
summary
createTHead( )
deleteTHead( )
createTFoot( )
deleteTFoot( )
createCaption( )
deleteCaption( )
insertRow( )
deleteRow( )
<tbody>, <tfoot>, <thead>
<tbody>
<tfoot>
<thead>
HTMLTableSectionElement: align, ch, chOff, vAlign, [readonly HTMLCollection of
HTMLTableRowElement] rows, insertRow( ), deleteRow( )
<td>, <th>
<td>
<th>
HTMLTableCellElement: [readonly long] cellIndex,
abbr, align, axis, bgColor [*], ch, chOff, [long] colSpan, headers, height [*], [boolean] noWrap [*], [long] rowSpan, scope, vAlign, width [*]
[readonly long] cellIndex
abbr
axis
[long] colSpan
headers
[boolean] noWrap
[long] rowSpan
scope
<textarea>
HTMLTextAreaElement: defaultValue, [readonly HTMLFormElement] form,
accessKey, [long] cols, [boolean] disabled, name, [boolean] readOnly, [long] rows, [long] tabIndex, [readonly] type, value, blur( ), focus( ), select( )
[long] cols
[long] rows
<tfoot>
See <tbody>
<th>
See <td>
<thead>
<title>
HTMLTitleElement: text
<tr>
<tr>
HTMLTableRowElement: [readonly long] rowIndex, [readonly long] sectionRowIndex,
[readonly HTMLCollection of
HTMLTableCellElement] cells, align, bgColor [*], ch, chOff, vAlign, insertCell( ), deleteCell( )
[readonly long] rowIndex
[readonly long] sectionRowIndex
[readonly HTMLCollection of
HTMLTableCellElement] cells
insertCell( )
deleteCell( )
<ul>
<ul>
HTMLUListElement: [boolean] compact [*], type [*]
[*] Indicates deprecated elements and
attributes.
Anchor, Element, Form, HTMLDocument, Image, Input, Link, Node, Option, Select, Table, TableCell, TableRow, TableSection, Textarea; Chapter 15, Scripting Documents
TableCell
TableRow
TableSection
HTMLElement.onclick: event handler invoked when the user
clicks on an element — DOM Level 0
Function onclick
The onclick property of an
HTMLElement object specifies an event-handler function that is invoked
when the user clicks on the element. Note that onclick is different from onmousedown. A click event does not occur
unless a mousedown event and the subsequent mouseup event both occur
over the same element.
Element.addEventListener(
), Event, MouseEvent; Chapter 17, Events and Event Handling
HTMLElement.ondblclick: event handler invoked when the user
double-clicks on an element — DOM Level 0
Function ondblclick
The ondblclick property of
an HTMLElement object specifies an event-handler function that is
invoked when the user double-clicks on the element.
HTMLElement.onkeydown: event handler invoked when the user
presses a key — DOM Level 0
Function onkeydown
The onkeydown property of
an HTMLElement object specifies an event-handler function that is
invoked when the user presses a key while the element has keyboard
focus. Determing which key or keys were pressed is somewhat
browser-dependent. See Chapter 17, Events and Event Handling for
details.
The onkeydown handler is
usually the prefered handler for function keys, but use onkeypress to respond to regular
alphanumeric key presses.
HTMLElement.onkeypress;
Chapter 17, Events and Event Handling
HTMLElement.onkeypress
HTMLElement.onkeypress: event handler invoked when the user
presses a key — DOM Level 0
Function onkeypress
The onkeypress property of
an HTMLElement object specifies an event-handler function that is
invoked when the user presses and releases a key while the element
has the keyboard focus. A keypress event is generated after a
keydown event and before the corresponding keyup event. The keypress
and keydown events are similar, although a keypress event is often
more useful for alphanumeric keys, and a keydown handler can be more
useful for function keys.
Determining which key was pressed and what modifier keys were
in effect at the time is somewhat complex and browser-dependent. See
Chapter 17, Events and Event Handling for details.
HTMLElement.onkeydown;
Chapter 17, Events and Event Handling
HTMLElement.onkeydown
HTMLElement.onkeyup: event handler invoked when the user
releases a key — DOM Level 0
Function onkeyup
The onkeyup property of an
HTMLElement object specifies an event-handler function that is
invoked when the user releases a key while the element has the
keyboard focus.
HTMLElement.onmousedown: event handler invoked when the
user presses a mouse button — DOM Level 0
Function onmousedown
The onmousedown property of
an HTMLElement object specifies an event-handler function that is
invoked when the user presses a mouse button over the
element.
HTMLElement.onmousemove: event handler invoked when the
mouse moves within an element — DOM Level 0
Function onmousemove
The onmousemove property of
an HTMLElement object specifies an event-handler function that is
invoked when the user moves the mouse pointer within the
element.
If you define an onmousemove event handler, mouse motion
events are generated and reported in huge quantities when the mouse
is moved within element. Keep this in
mind when writing the function to be invoked by the event handler.
If you are interested in tracking mouse drags, register a handler of
this type in response to a mousedown event and then deregister it
when the mouseup event arrives.
element
HTMLElement.onmouseout: event handler invoked when mouse
moves out of an element — DOM Level 0
Function onmouseout
The onmouseout property of
an HTMLElement object specifies an event-handler function that is
invoked when the user moves the mouse pointer out of the
element.
HTMLElement.onmouseover: event handler invoked when the
mouse moves over an element — DOM Level 0
Function onmouseover
The onmouseover property of
an HTMLElement object specifies an event-handler function that is
invoked when the user moves the mouse pointer over the
element.
HTMLElement.onmouseup: event handler invoked when the user
releases a mouse button — DOM Level 0
Function onmouseup
The onmouseup property of
an HTMLElement object specifies an event-handler function that is
invoked when the user releases a mouse button over the
element.
HTMLElement.scrollIntoView( ): make an element
visible — Firefox 1.0, IE 4, Safari 2.02, Opera 8.5
element.scrollIntoView(top)
An optional boolean argument that specifies whether
the element should be scrolled to the top (true) or bottom (false) of the screen. This
argument is not supported by all browsers, and elements near
the top or bottom of a document cannot usually be scrolled
to the opposite edge of the window, so this argument should
be considered only a hint.
If an HTML element is not currently visible in the window,
this method scrolls the document so that it becomes visible. The
top argument is an optional hint about
whether the element should be scrolled to the top or bottom of the
window. For elements that accept the keyboard focus, such as the
Link and Input elements, the focus(
) method implicitly performs this same scroll-into-view
operation.
focus(
)
Anchor.focus( ), Input.focus( ), Link.focus( ), Window.scrollTo( )
Anchor.focus( )
Input.focus( )
Link.focus( )
Window.scrollTo( )
IFrame: an <iframe> in an HTML document — DOM Level 2 HTML: Node → Element → HTMLElement →
IFrame
As explained in the following Description, iframe elements can
be accessed as IFrame objects or as Window objects. When accessed as
IFrame objects, they inherit properties from HTMLElement and define
the additional properties below:
The document that holds the content of the <iframe>.
The URL from which the iframe's content was loaded.
Setting this property causes the iframe to load a new
document. This property simply mirrors the src attribute of the HTML <iframe> tag.
In addition to these properties, the IFrame object also defines the following properties, which
correspond directly to HTML attributes of the <iframe> tag:
deprecated String align
deprecated String align
align
Alignment with respect to inline
content
String
height
String
height
Height of the viewport in pixels
or percent
String
width
String
width
Width of the viewport in pixels or
percent
Except for small differences in their HTML attributes,
<iframe> elements behave
very much like <frame>
elements in client-side JavaScript. <iframe> elements become part of the
frames[] array of the containing
window. When accessed through that array, they are represented by
Window objects, and the properties listed earlier do not apply.
When an <iframe>
element is accessed as a document element by ID or tag name, it is
represented by an IFrame object, with the properties shown
previously. Use src to query or
set the URL of the <iframe>, and use contentDocument to access the contents of
the iframe. Be aware, however, that the same-origin policy (see
the section called “The Same-Origin Policy”) may prevent access to
the contentDocument.
Frame, Window; Chapter 14, Scripting Browser Windows
Frame
Image: an image in an HTML document — DOM Level 2 HTML: Node → Element → HTMLElement →
Image
new Image(integerwidth, integer height)
An optionally specified width and height for the
image.
String name
This property specifies the name for the image object.
If an <img> tag has a
name attribute, you can
access the corresponding Image object as a named property of the Document
object.
A read/write string that specifies the URL of the image
to be displayed by the browser. The initial value of this
property is specified by the src attribute of the <img> tag. When you set this
property to the URL of a new image, the browser loads and
displays that new image. This is useful for updating the
graphical appearance of your web pages in response to user
actions and can also be used to perform simple
animation.
In addition to these properties, Image objects also support
the following properties, which simply mirror HTML
attributes:
String
alt
String
alt
alt
Alternate text when image can't be
displayed
deprecated String border
deprecated String border
Size of image
border
long
height
long
height
Image height, in
pixels
deprecated long hspace
deprecated long hspace
hspace
Left and right margins, in
pixels
boolean
isMap
boolean
isMap
ismap
ismap
Whether to use a server-side image
map
The URI of a long image
description
String
useMap
String
useMap
usemap
usemap
Specifies a client-side image map
for the image
deprecated long vspace
deprecated long vspace
vspace
Top and bottom margin, in
pixels
long
width
long
width
Image width, in
pixels.
Image inherits event handlers from HTMLElement and defines the following:
onabort
Invoked if page loading is stopped before the image is
fully downloaded.
onerror
Invoked if an error occurs while downloading the
image.
onload
Invoked when the image successfully finishes
The Image object is created with a standard HTML <img> tag. Some <img> attributes have been omitted
from the following syntax because they are not commonly used in
JavaScript:
<img src="url" // The image to display
width="pixels" // The width of the image
height="pixels" // The height of the image
alt="description" // Short description of image
[ onload="handler" ] // Invoked when image is fully loaded
[ onerror="handler" ] // Invoked if error in loading
[ onabort="handler" ] // Invoked if user aborts load
>
pixels
description
An Image object represents an image embedded in an HTML
document with an <img> tag.
The images that appear in a document are collected in the document.images[] array. Images that have
name attributes can also be
accessed through named properties of the Document object. For
example:
document.images[]
document.images[0] // The first image in the document
document.banner // An image with name="banner"
The src property of the
Image object is the most interesting one. When you set this
property, the browser loads and displays the image specified by the
new value. This allows visual effects such as image rollovers and
animations. See Chapter 22, Scripted Client-Side Graphics for
examples.
You can create offscreen Image objects dynamically in your
JavaScript code using the Image(
) constructor function. Note that this constructor method
does not have an argument to specify the image to be loaded. As with
images created from HTML, you tell the browser to load an image by
setting the src property of any
images you create explicitly. There is no way to display an Image
object created in this way; all you can do is force the Image object
to download an image by setting the src property. This is useful, however,
because it loads an image into the browser's cache; if that same
image URL is used later with an actual <img> tag, it will display quickly
since it has already been loaded.
Chapter 22, Scripted Client-Side Graphics
Image.onabort: event handler invoked when the user aborts
image loading — DOM Level 2 Events
Function onabort
The onabort property of an
Image object specifies an event-handler function that is invoked
when the user aborts the loading of a page (for example, by clicking
the Stop button) before the image
has finished loading.
Image.onerror: event handler invoked when an error occurs
during image loading — DOM Level 2 Events
Function onerror
The onerror property of an
Image object specifies an event-handler function that is invoked
when an error occurs during the loading of an image. See also
Window.onerror.
Window.onerror
Image.onload: event handler invoked when an image finishes
Function onload
The onload property of an
Image object specifies an event-handler function that is invoked
when an image loads successfully. See also Window.onload.
Window.onload
Input: an input element in an HTML form — DOM Level 2 HTML: Node → Element → HTMLElement →
Input
String accept
When type is "file",
this property is a comma-separated list of MIME types that
specify the types of files that may be uploaded. Mirrors the
accept attribute.
String accessKey
The keyboard shortcut (which must be a single character)
a browser can use to transfer keyboard focus to this input
element. Mirrors the accesskey attribute.
accesskey
deprecated String
align
The vertical alignment of this element with respect to
the surrounding text, or the left or right float for the
element. Mirrors the align
attribute.
String alt
Alternate text to be displayed by browsers that cannot
render this input element. Particularly useful when type is "image". Mirrors the
alt attribute.
boolean checked
When type is "radio"
or "checkbox", this property specifies whether the element is
"checked" or not. Setting this property changes the visual
appearance of the input element. Mirrors the checked attribute.
checked
boolean
defaultChecked
When type is "radio"
or "checkbox", this property holds the initial value of the
checked attribute as it
appears in the document source. When the form is reset, the
checked property is
restored to the value of this property. Changing the value of
this property changes the value of the checked property and the current
checked state of the element.
String
defaultValue
When type is "text",
"password", or "file", this property holds the initial value
displayed by the element. When the form is reset, the element
is restored to this value. Changing the value of this property
also changes the value
property and the currently displayed value.
If true, the input
element is disabled and is unavailable for user input. Mirrors
the disabled
attribute.
disabled
readonly HTMLFormElement
form
The Form object representing the <form> element that contains
this input element, or null
if the input element is not within a form.
long maxLength
If type is "text" or
"password", this property specifies the maximum number of
characters that the user is allowed to enter. Note that this
is not the same as the size
property. Mirrors the maxlength attribute.
maxlength
The name of the input element, as specified by the
name attribute. See the
following Description section for further details on form
element names.
boolean readOnly
If true and type is "text" or "password", the
user is not allowed to enter text into the element. Mirrors
the readonly
attribute.
readonly
unsigned long
size
If type is "text" or
"password", this property specifies the width of the element
in characters. Mirrors the size attribute. See also maxLength.
maxLength
For input elements with a type of "image", specifies the URL
of the image to be displayed. Mirrors the src attribute.
long tabIndex
The position of this input element in the tabbing order.
Mirrors the tabindex
attribute.
tabindex
The type of the input element. Mirrors the type attribute. See the Description
section for further details on form element types.
String useMap
For elements with a type of "image", this property
specifies the name of a <map>element that provides a
client-side image map for the element.
The value that is passed to the web server when the form
is submitted. For elements with a type of "text", "password", or
"file", this property is the editable text contained by the
input element. For elements with a type of "button", "submit", or
"reset", this is the (noneditable) label that appears in the
button. For security reasons, the value property of FileUpload
elements may be read-only. Similarly, the value returned by
this property for Password elements may not contain the user's
actual input.
Takes keyboard focus away from the element.
If type is "button",
"checkbox", "radio", "reset", or "submit", this method
simulates a mouse-click on the element.
Transfers keyboard focus to this input element.
If type is "file",
"password", or "text", this method selects the text displayed
by the element. In many browsers, this means that when the
user next enters a character, the selected text is deleted and
replaced with the newly typed character.
onblur
Invoked when the user takes keyboard focus away from the
element.
onchange
For text-entry elements, this event handler is invoked
when the user changes the displayed text and then "commits"
those changes by tabbing or clicking to transfer keyboard
focus to another element. This handler does not report
keystroke-by-keystroke edits. Toggle button elements of type
"checkbox" and "radio" may also fire this event (in addition
to the onclick event) when
the user toggles them.
For push button and toggle button elements, this event
handler is invoked when the user activates the button with a
mouse click or by keyboard traversal.
onfocus
Invoked when the user gives keyboard focus to the
element.
An Input object represents an HTML <input> tag that defines a
scriptable form input element. The three most important properties
of an Input object are type,
value, and name. These properties are described in
the subsections that follow. See Chapter 18, Forms and Form Elements
for more information about HTML forms and form elements.
The type attribute of the
HTML <input> tag
specifies the kind of input element that is to be created. This
attribute is available to client-side JavaScript as the type property of the Input object and is
useful to determine the type of an unknown form element, for
example, when iterating through the elements[] array of a Form
object.
The legal values of type
are the following:
The input element is a graphical push button that
displays the plain text specified by the value property. The button has no
default behavior and must be given an onclick event handler in order to
be useful. For buttons that submit or reset a form, use a
type of "submit" or
"reset". Note that the HTML <button> tag can create
buttons that display arbitrary HTML instead of plain
text.
An input element of this type displays a toggle button
that the user can check and uncheck. The checked property holds the current
state of the button, and the onclick event handler is triggered
whenever this value changes (browsers may also trigger the
onchange handler). The
value property is an
internal value for submission to a web server and is not
displayed to the user. To associate a label with a checkbox,
simply place the label text near the <input> tag, optionally
using a <label>
tag. Checkbox elements often appear in groups, and the
members of a group are sometimes given the same name property and different
value properties, for the
convenience of the web server to which the form is
submitted.
This type creates a "file upload" element. This
element consists of a text input field for entering the name
of a file, along with a button that opens a file-selection
dialog box for graphical selection of a file. The value property holds the name of
the file the user has specified, but when a form containing
a file-upload element is submitted, the browser sends the
contents of the selected file to the server instead of just
sending the filename. (For this to work, the form must use
"multipart/form-data" encoding and the POST method.)
For security, the file-upload element does not allow
HTML authors or JavaScript programmers to specify a default
filename. The HTML value
attribute is ignored, and the value property is read-only for
this type of element, which means that only the user may
enter a filename. When the user selects or edits a filename,
a file-upload element triggers the onchange event handler.
An input element of this type is, in fact, hidden. The
value property of this
invisible form element holds an arbitrary string to be
submitted to the web server. Use an element of this type if
you want to submit data that the user did not input
directly.
This type of input element is a form submit button
that displays an image (specified by the src property) instead of
displaying a textual label. The value property is unused.
See the element type "submit" for further details.
This text input field is intended for input of
sensitive data, such as passwords. As the user types, her
input is masked (with asterisks, for example) to prevent
bystanders from reading the input value over her shoulder.
Note, however that the user's input is not encrypted in any
way: when the form is submitted, it is sent in clear text.
As a security precaution, some browsers may prevent
JavaScript code from reading the value property. In other respects,
a password input element behaves like an element of type
"text". It triggers the onchange event handler when the
user changes the displayed value.
An input element of this type displays a single
graphical radio button. A radio button
is a button in a group of buttons that represents a set of
mutually exclusive choices. When one button is selected, the
previously selected button is deselected (as in the
mechanical station preset buttons of old car radios). In
order for a group of radio buttons to exhibit this mutually
exclusive behavior, they must appear in the same <form> and must have the
same name. For toggle
buttons without mutual exclusion, use a type of "checkbox". Note that the
HTML <select> tag
can also be used for presenting exclusive or nonexclusive
choices (see Select).
The checked
property indicates whether a radio button is selected. There
is no way to determine which button in a mutually exclusive
group of radio buttons is selected: you must examine the
checked property of each
one. Radio buttons trigger the onclick event handler when
selected or deselected.
The value property
specifies a value to be submitted to a web server and is not
displayed within the form. To specify a label for a radio
button, do so externally to the <input> tag, such as with a
<label> tag.
An input element of this type is like a push button
created with type
"button" but has a more specialized purpose. When a reset
button element is clicked, the values of all input elements
in the form that contains it are reset to their default
values (specified by the HTML value attribute or the JavaScript
defaultValue
property).
The value property
specifies the text to appear in the button. A reset button
triggers the onclick
handler before resetting the form, and this handler may
cancel the reset by returning false or by using other event
cancellation methods described in Chapter 17, Events and Event Handling. See also the Form.reset( ) method and the
Form.onreset event
handler.
An element of this type is a push button that submits
the containing <form> when clicked. The
value property specifies
the text to appear in the button. The onclick event handler is triggered
before the form is submitted, and a handler may cancel form
submission by returning false. See also the Form.submit( ) method and Form.onsubmit event
handler.
This is the default value of the type property; it creates a
single-line text input field. The HTML value attribute specifies the
default text to appear in the field, and the JavaScript
value property holds the
currently displayed text. The onchange event handler is
triggered when the user edits the displayed text and then
transfers input focus to some other element. Use size to specify the width of the
input field and maxLength
to specify the maximum number of characters that may be
entered. When a form contains only a single input element of
type "text", pressing Enter submits the form.
For multiline text input, use the HTML <textarea> tag (see Textarea). For masked text input,
set type to
The value
property of the Input object is a read/write string property that
specifies the text that is sent to the web server when the form
that contains the input element is submitted.
Depending on the value of the type property, the value property may also hold
user-visible text. For input elements of type "text" and "file",
this property holds whatever text the user has entered. For
elements of type "button", "reset", and "submit", the value property specifies the text that
appears in the button. For other element types, such as
"checkbox", "radio", and "image", the contents of the value property are not displayed to the
user and are used only for form submission purposes.
The name property of the
Input object is a String that provides a name for the input
element. Its value comes from the HTML name attribute. The name of a form
element is used for two purposes. First, it is used when the form
is submitted. Data for each element in the form is usually
submitted in the format:
name=value
where name and
value are encoded as necessary for
transmission. If a name is not specified for a form element, the
data for that element cannot be submitted to a web server.
The second use of the name property is to refer to a form
element in JavaScript code. The name of an element becomes a
property of the form that contains the element. The value of this
property is a reference to the element. For example, if address is a form that contains a text
input element with the name zip, address.zip refers to that text input
element.
address
zip
address.zip
For input elements of type "radio" and "checkbox", it is
common to define more than one related object, each of which have
the same name property. In this
case, data is submitted to the server with this format:
name=value1,value2,...,valuen
Similarly, in JavaScript, each element that shares a name
becomes an element of an array with that name. Thus, if four
Checkbox objects in the form order share the name options, they are available in
JavaScript as elements of the array order.options[].
order
options
order.options[]
The HTML <input>
tag allows you to create a number of different form elements. But
<button>, <select>, and <textarea> tags also create form
elements.
Form, Form.elements[], Option, Select, Textarea; Chapter 18, Forms and Form Elements
Input.blur( ): remove keyboard focus from a form
element — DOM Level 2 HTML
void blur( )
The blur() method of a form element removes
keyboard focus from that element, triggering any onblur event
handlers that were registered on the element. Note that calling
blur() does not transfer focus to any other
element.
blur()
Input.click( ): simulate a mouse click on a form
element — DOM Level 2 HTML
void click( )
The click() method of a form element
simulates a mouse click on the form element, triggering any onclick
event handlers that were registered on the element.
click()
Input.focus( ): give keyboard focus to a form
element — DOM Level 2 HTML
void focus( )
The focus( ) method of a
form element transfers keyboard focus to that element and triggers
any onfocus event handlers that were registered on the element. That
is, it makes the element active with respect to keyboard navigation
and keyboard input. Thus, if you call focus( ) for an input element of type
"text", any text the user subsequently types appears in that text
element. Or, if you call focus( )
for an element of type "button", the user can then invoke that
button from the keyboard.
Input.onblur: the handler invoked when a form element loses
focus — DOM Level 0
Function onblur
The onblur property of an
Input object specifies an event-handler function that is invoked
when the user or the program transfers keyboard focus away from that
input element. Calling blur( ) to
remove focus from an element invokes onblur for that element. Note also that
calling focus( ) to transfer
focus to some other element causes the onblur event handler to be invoked for
whichever element currently has the focus.
Element.addEventListener(
), Window.onblur; Chapter 17, Events and Event Handling
Window.onblur
Input.onchange: event handler invoked when a form element's
value changes — DOM Level 2 Events
Function onchange
The onchange property of an
Input object specifies an event-handler function that is invoked
when the user changes the value displayed by a form element. Such a
change may be an edit to the text displayed in input elements of
type "text", "password", and "file", or the selection or deselection
of a toggle button of type "radio" or "checkbox". (Radio and
checkbox elements always trigger the onclick handler and may also trigger the
onchange handler.) Note that this
event handler is invoked only when the user makes such a change; it
is not invoked if a JavaScript program changes the value displayed
by an element.
Also note that the onchange
handler is not invoked every time the user enters or deletes a
character in a text-entry form element. onchange is not intended for that type of
character-by-character event handling; instead, onchange is invoked when the user's edit
is complete. The browser assumes that the edit is complete when
keyboard focus is moved from the current element to some other
element—for example, when the user clicks on the next element in the
form. See HTMLElement.onkeypress
for character-by-character event notification.
The onchange event handler
is not used by input elements of type "button", "hidden", "image",
"reset", and "submit". Elements of those types use the onclick handler instead.
Element.addEventListener(
), HTMLElement.onkeypress; Chapter 17, Events and Event Handling
Input.onclick: event handler invoked when a form element is
clicked — DOM Level 2 Events
The onclick property of an
Input object specifies an event-handler function that is invoked
when the user activates the input element. This is typically done by
clicking the element with the mouse, but the onclick handler is also triggered when the
user activates the element using keyboard traversal. The onclick handler is also invoked when the
click( ) method is called for the
element.
Note that the input elements of type "reset" and "submit"
perform a default action when clicked: they reset and submit,
respectively, the form that contains them. You can use the onclick event handlers of each element to
perform actions in addition to these default actions. You can also
prevent these default actions by returning false or by using the other
event-cancellation techniques described in Chapter 17, Events and Event Handling. Note that you can do similar things
with the onsubmit and onreset event handlers of the Form object
itself.
Element.addEventListener(
); Chapter 17, Events and Event Handling
Input.onfocus: event handler invoked when a form element
gains focus — DOM Level 2 Events
Function onfocus
The onfocus property of an
Input object specifies an event-handler function that is invoked
when the user transfers keyboard focus to that input element.
Calling focus( ) to set focus to
an element also invokes onfocus
for that object.
Element.addEventListener(
), Window.onfocus;
Chapter 17, Events and Event Handling
Window.onfocus
Input.select( ): select the text in a form
element — DOM Level 2 HTML
void select( )
The select( ) method
selects the text displayed in an input element of type "text",
"password", or "file". The effects of selecting text may vary from
platform to platform, but typically: the text is highlighted, it
becomes available for cut and paste, and it is deleted if the user
types another character.
JavaArray, JavaClass, JavaObject, JavaPackage: see Part
III
JSObject: Java representation of a JavaScript
object — Java class in Java plug-in
public final class netscape.javascript.JSObject extends Object
Invokes a method of the JavaScript object.
eval( )
Evaluates a string of JavaScript code in the context of
the JavaScript object.
getMember( )
Gets the value of a property of the JavaScript
object.
getSlot( )
Gets the value of an array element of the JavaScript
object.
getWindow( )
Gets a "root" JSObject that represents the JavaScript
Window object of the web browser.
removeMember( )
Deletes a property from the JavaScript object.
setMember( )
Sets the value of a property of the JavaScript
object.
setSlot( )
Sets the value of an array element of the JavaScript
object.
toString( )
Invokes the JavaScript toString( ) method of the JavaScript
object and returns its result.
JSObject is a Java class, not a JavaScript object; it cannot
be used in your JavaScript programs. Instead, the JSObject is used
by Java applets that wish to communicate with JavaScript by reading
and writing JavaScript properties and array elements, invoking
JavaScript methods, and evaluating and executing arbitrary strings
of JavaScript code. Obviously, since JSObject is a Java class, you
must understand Java programming in order to use it.
Full details on programming with the JSObject can be found in
Chapter 23, Scripting Java Applets and Flash Movies.
Chapter 23, Scripting Java Applets and Flash Movies, Chapter 12, Scripting Java ; JavaObject in Part III, “Core JavaScript Reference”
JSObject.call( ): invoke a method of a JavaScript
object — Java method in Java plug-in
public Object call(StringmethodName, Object args[])
methodName
args[]
The name of the JavaScript method to be
invoked.
An array of Java objects to be passed as arguments to
the method.
A Java object that represents the return value of the
JavaScript method.
The call( ) method of the
Java JSObject class invokes a named method of the JavaScript object
represented by the JSObject. Arguments are passed to the method as
an array of Java objects, and the return value of the JavaScript
method is returned as a Java object.
Chapter 23, Scripting Java Applets and Flash Movies describes the data
conversion of the method arguments from Java objects to JavaScript
values, and the method return value from a JavaScript value to a
Java object.
JSObject.eval( ): evaluate a string of JavaScript
code — Java method in Java plug-in
public Object eval(Strings)
s
A string that contains arbitrary JavaScript statements
separated by semicolons.
The JavaScript value of the last expression evaluated in
s, converted to a Java object.
The eval( ) method of the
Java JSObject class evaluates the JavaScript code contained in the
string s in the context of the JavaScript
object specified by the JSObject. The behavior of the eval( ) method of the Java JSObject class
is much like that of the JavaScript global eval( ) function.
The argument s may contain any
number of JavaScript statements separated by semicolons; these
statements are executed in the order in which they appear. The
return value of eval( ) is the
value of the last statement or expression evaluated in
s.
JSObject.getMember( ): read a property of a JavaScript
object — Java method in Java plug-in
public Object getMember(Stringname)
The name of the property to be read.
A Java object that contains the value of the named property
of the specified JSObject.
The getMember( ) method of
the Java JSObject class reads and returns to Java the value of a
named property of a JavaScript object. The return value may be
another JSObject object or a Double, Boolean, or String object, but
it is returned as a generic Object, which you must cast as
necessary.
JSObject.getSlot( ): read an array element of a JavaScript
object — Java method in Java plug-in
public Object getSlot(intindex)
The index of the array element to be read.
The value of the array element at the specified
index of a JavaScript object.
The getSlot( ) method of
the Java JSObject class reads and returns to Java the value of an
array element at the specified index of a
JavaScript object. The return value may be another JSObject object
or a Double, Boolean, or String object, but it is returned as a
generic Object, which you must cast as necessary.
JSObject.getWindow( ): return initial JSObject for browser
window — Java method in Java plug-in
public static JSObject getWindow(java.applet.Appletapplet)
applet
An Applet object running in the web browser window for
which a JSObject is to be obtained.
A JSObject that represents the JavaScript Window object for
the web browser window that contains the specified
applet.
The getWindow( ) method is
the first JSObject method that any Java applet calls. JSObject does
not define a constructor, and the static getWindow( ) method provides the only way
to obtain an initial "root" JSObject from which other JSObjects may
be obtained.
JSObject.removeMember( ): delete a property of a JavaScript
object — Java method in Java plug-in
public void removeMember(Stringname)
The name of the property to be deleted from the
JSObject.
The removeMember( ) method
of the Java JSObject class deletes a named property from the
JavaScript object represented by the JSObject.
JSObject.setMember( ): set a property of a JavaScript
object — Java method in Java plug-in
public void setMember(Stringname, Object value)
The name of the property to be set in the
JSObject.
The value to which the named property should be
set.
The setMember( ) method of
the Java JSObject class sets the value of a named property of a
JavaScript object from Java. The specified
value may be any Java Object. Primitive
Java values may not be passed to this method. In JavaScript, the
specified value is accessible as a
JavaObject object.
JSObject.setSlot( ): set an array element of a JavaScript
object — Java method in Java plug-in
public void setSlot(intindex, Object value)
The index of the array element to be set in the
JSObject.
The value to which the specified array element should
be set.
The setSlot( ) method of
the Java JSObject class sets the value of a numbered array element
of a JavaScript object from Java. The specified
value may be any Java Object. Primitive
Java values may not be passed to this method. In JavaScript, the
specified value is accessible as a
JavaObject object.
JSObject.toString( ): return the string value of a
JavaScript object — Java method in Java plug-in
public String toString( )
The string returned by invoking the toString( ) method of the JavaScript
object represented by the specified Java JSObject.
The toString( ) method of
the Java JSObject class invokes the JavaScript toString( ) method of the JavaScript
object represented by a JSObject and returns the result of that
method.
KeyEvent: details about a keyboard event — Firefox and compatible browsers: Event → UIEvent →
KeyEvent
readonly boolean
altKey
readonly integer
charCode
This number is the Unicode encoding of the printable
character (if any) generated by a keypress event. This
property is zero for nonprinting function keys and is not used
for keydown and keyup events. Use String.fromCharCode( ) to convert
this property to a string.
String.fromCharCode( )
readonly boolean
ctrlKey
Whether the Ctrl key
was held down when the event occurred. Defined for all types
of mouse events.
readonly integer
keyCode
The virtual keycode of the key that was pressed. This
property is used for all types of keyboard events. Keycodes
may be browser-, OS-, and keyboard-hardware-dependent.
Typically, when a key displays a printing character on it, the
virtual keycode for that key is the same as the encoding of
the character. Key codes for nonprinting function keys may
vary more, but see Example 17-6, “A Keymap class for keyboard shortcuts” for
a set of commonly used codes.
readonly boolean
shiftKey
Whether the Shift key
was held down when the event occurred. Defined for all types
of mouse events.
A KeyEvent object provides details about a keyboard event and is passed
to event handlers for keydown, keypress, and keyup events. The DOM
Level 2 Events standard does not cover keyboard events, and the
KeyEvent object has not been standardized. This entry describes the
Firefox implementation. Many of these properties are also supported
in the IE event model; see the IE-specific properties described for
the Event object. Note that in
addition to the properties listed here, KeyEvent objects also
inherit the properties of Event and UIEvent.
Chapter 17, Events and Event Handling includes several practical
examples of working with KeyEvent objects.
Event, UIEvent; Chapter 17, Events and Event Handling
Layer: an obsolete Netscape API — Netscape 4 only; discontinued in Netscape 6
The Layer object was Netscape 4's technique for supporting dynamically
positionable HTML elements. It was never standardized and is now
obsolete.
Chapter 16, Cascading Style Sheets and Dynamic HTML
Link: a hyperlink or anchor in an HTML document — DOM Level 0: Node → Element → HTMLElement →
Link
The most important property of a Link is its href, which is the URL to which it links.
The Link object also defines a number of other properties that hold
portions of the URL. For each of these properties, the example given
is a portion of the following (fictitious) URL:
String hash
Specifies the anchor portion of the Link's URL,
including the leading hash (#) mark—for example, "#results".
This anchor portion of a URL refers to a named position within
the document referenced by the Link. In HTML files, positions
are named with the name
attribute of the <a>
tag. (see Anchor).
String host
Specifies the hostname and port portions of a Link's
URL—for example, "".
String hostname
Specifies the hostname portion of a Link's URL—for
example, "".
String href
Specifies the complete text of the Link's URL, unlike
other Link URL properties that specify only portions of the
URL.
String pathname
Specifies the pathname portion of a Link's URL—for
example, "/catalog/search.html".
String port
Specifies the port portion of a Link's URL—for example,
"1234".
String protocol
Specifies the protocol portion of a Link's URL,
including the trailing colon—for example, "http:".
String search
Specifies the query portion of a Link's URL, including
the leading question mark—for example,
"?q=JavaScript&m=10".
In addition to these URL-related properties, Link objects also
define properties that correspond to the attributes for the HTML
<a> and <area> tags:
String
accessKey
String
accessKey
accesskey
Keyboard shortcut
String
charset
String
charset
charset
Encoding of the destination
document
String
coords
String
coords
coords
For <area> tags
String
hreflang
String
hreflang
hreflang
Language of the linked
document
Anchor name; see Anchor
String
rel
String
rel
rel
Link type
String
rev
String
rev
rev
Reverse link type
String
shape
String
shape
shape
long
tabIndex
long
tabIndex
tabindex
Link's position in tabbing
order
Name of the frame or window in
which the destination document is to be
displayed
String
type
String
type
type
Content type of the destination
document
Takes keyboard focus away from the link.
Scrolls the document so the link is visible and gives
keyboard focus to the link.
The Link object has special behavior for three event
handlers:
Invoked when the user clicks on the link.
Invoked when the user moves the mouse off the
link.
Invoked when the user moves the mouse over the
link.
A Link object is created with standard <a> and </a> tags. The href attribute is required for all Link
objects. If the name attribute is
also specified, an Anchor object is also created:
</a>
<a href="url" // The destination of the link
[ name="anchor_tag" ] // Creates an Anchor object
[ target="window_name" ] // Where the new document should be displayed
[ onclick="handler" ] // Invoked when link is clicked
[ onmouseover="handler" ] // Invoked when mouse is over link
[ onmouseout="handler" ] // Invoked when mouse leaves link
>link text or image // The visible part of the link
</a>
anchor_tag
link text or image
A Link object represents a hyperlink in a document. Links are
usually created with <a>
tags that have an href attribute
defined, but they may also be created with <area> tags inside a client-side
image map. When an <a> tag
has a name attribute instead of
an href attribute, it defines a
named position in a document and is represented by an Anchor object
instead of a Link object. See Anchor for details.
All links in a document (whether created with <a> or <area> tags) are represented by Link
objects in the links[] array of
the Document object.
links[]
The destination of a hypertext link is a URL, of course, and
many of the properties of the Link object specify the contents of
that URL. In this way, the Link object is similar to the Location
object, which also has a full set of URL properties.
// Get the URL of the first hyperlink in the document
var url = document.links[0].href;
Anchor, Location
Link.blur( ): take keyboard focus away from a
hyperlink — DOM Level 0
void blur( );
For web browsers that allow hyperlinks to have the keyboard
focus, this method takes keyboard focus away from a
hyperlink.
Link.focus( ): make a link visible and give it keyboard
focus — DOM Level 0
This method scrolls the document so the specified hyperlink is
visible. If the browser allows links to have keyboard focus, this
method also gives keyboard focus to the link.
Link.onclick: event handler invoked when a Link is
clicked — DOM Level 0
The onclick property of a
Link object specifies an event-handler function that is invoked
when the user clicks on the link. The browser default action after
the event handler returns is to follow the hyperlink that was
clicked. You can prevent this default by returning false or by using one of the other
event-cancellation methods described in Chapter 17, Events and Event Handling.
Element.addEventListener(
), MouseEvent; Chapter 17, Events and Event Handling
Link.onmouseout: event handler invoked when the mouse
leaves a link — DOM Level 0
The onmouseout property of
a Link object specifies an event-handler function that is invoked
when the user moves the mouse off a hypertext link. It is often used
with the onmouseover event
handler.
Element.addEventListener(
), Link.onmouseover,
MouseEvent; Chapter 17, Events and Event Handling
Link.onmouseover
Link.onmouseover: event handler invoked when the mouse goes
over a link — DOM Level 0
The onmouseover property of
a Link object specifies an event-handler function that is invoked
when the user moves the mouse over a hypertext link. When the user
holds the mouse over a hyperlink, the browser displays the URL for
that link in the status line. In older browsers, it is possible to
prevent this default action and display your own text in the status
line. For security reasons (to help prevent phishing attacks, for
example) most modern browsers have disabled this capability.
Element.addEventListener(
), Link.onmouseout,
MouseEvent; Chapter 17, Events and Event Handling
Link.onmouseout
Location: represents and controls browser
location — JavaScript 1.0: Object → Location
locationwindow.location
The properties of a Location object refer to the various portions of the current
document's URL. In each of the following property descriptions, the
example given is a portion of this (fictitious) URL:
A read/write string property that specifies the anchor
portion of the URL, including the leading hash (#) mark—for
example, "#results". This portion of the document URL
specifies the name of an anchor within the document.
host
A read/write string property that specifies the hostname
and port portions of the URL—for example, "".
hostname
A read/write string property that specifies the hostname
portion of a URL—for example, "".
A read/write string property that specifies the complete
text of the document's URL, unlike other Location properties
that specify only portions of the URL. Setting this property
to a new URL causes the browser to read and display the
contents of the new URL.
pathname
A read/write string property that specifies the pathname
portion of a URL—for example, "/catalog/search.html".
port
A read/write string (not a number) property that
specifies the port portion of a URL— for example,
"1234".
protocol
A read/write string property that specifies the protocol
portion of a URL, including the trailing colon—for example,
"http:".
search
A read/write string property that specifies the query
portion of a URL, including the leading question mark—for
example, "?q=JavaScript&m=10".
reload( )
Reloads the current document from the cache or the
server.
replace( )
Replaces the current document with a new one without
generating a new entry in the browser's session
history.
The location property of
the Window object refers to a Location object that represents the
web address (the "location") of the document currently displayed in
that window. The href property
contains the complete URL of that document, and the other properties
of the Location object each describe a portion of that URL. These
properties are much like the URL properties of the Link object. When
a Location object is converted to a string, the value of the
href property is returned. This
means that you can use the expression location in place of location.href.
While the Link object represents a hyperlink in a document,
the Location object represents the URL, or location, currently
displayed by the browser. However, the Location object does more
than that: it also controls the location
displayed by the browser. If you assign a string containing a URL to
the Location object or to its href property, the web browser responds by
refers to.
Instead of setting location
or location.href to replace the
current URL with a completely new one, you can modify just a portion
of the current URL by assigning strings to the other properties of
the Location object. This creates a new URL with one new portion,
which the browser loads and displays. For example, if you set the
hash property of the Location
object, you can cause the browser to move to a named location within
the current document. Similarly, if you set the search property, you can cause the browser
to reload the current URL with a new query string appended.
In addition to its URL properties, the Location object also
defines two methods. The reload( )
method reloads the current document. The replace( ) method loads a new document
without creating a new history entry for it; the new document
replaces the current one in the browser's history list.
Link, the URL property of the HTMLDocument object
Location.reload( ): reload the current document — JavaScript 1.1
location.reload( )
location.reload(force)
force
An optional boolean argument that specifies whether
the document should be reloaded even if the server reports
that it has not been modified since it was last loaded. If
this argument is omitted, or if it is false, the method reloads the full
page only if it has changed since last loaded.
The reload( ) method of the
Location object reloads the document that is currently displayed in
the window of the Location object. When called with no arguments or
with the argument false, it uses
the If-Modified-Since HTTP header
to determine whether the document has changed on the web server. If
the document has changed, reload
reloads the document from the server, and if not, it reloads the
document from the cache. This is the same action that occurs when
the user clicks on the browser's Reload button.
If-Modified-Since
reload
When reload( ) is called
with the argument true, it always
bypasses the cache and reloads the document from the server,
regardless of the last-modified time of the document. This is the
same action that occurs when the user Shift-clicks on the browser's Reload button.
Location.replace( ): replace one displayed document with
another — JavaScript 1.1
location.replace(url)
A string that specifies the URL of the new document
that is to replace the current one.
The replace( ) method of
the Location object loads and displays a new document. Loading a
document in this way is different from simply setting
location or
location .href in one important respect: the
replace( ) method does not
generate a new entry in the History object. When you use replace( ), the new URL overwrites the
current entry in the History object. After calling replace( ), the browser's Back button does not return you to the
previous URL; it returns you to the URL before that one.
.href
History
History
MimeType: represents a MIME datatype — JavaScript 1.1; not supported by IE: Object →
MimeType
navigator.mimeTypes[i]
navigator.mimeTypes["type"]
navigator.mimeTypes.length
A read-only string that provides a human-readable
description (in English) of the data type described by the
MimeType.
enabledPlugin
A read-only reference to a Plugin object that represents
the installed and enabled plug-in that handles the specified
MIME type. If the MIME type is not handled by any
plug-ins (for example, if it's handled directly by the
browser), the value of this property is null. This property is also null when a plug-in exists but has
been disabled.
suffixes
A read-only string that contains a comma-separated list
of filename suffixes (not including the "." character) that
are commonly used with files of the specified MIME type. For
example, the suffixes for the "text/html" MIME type are "html,
htm".
A read-only string that specifies the name of the MIME
type. This is a unique string such as "text/html" or
"image/jpeg" that distinguishes the MIME type from all others.
It describes the general type of data and the data format
used. The value of the type
property can also be used as an index to access the elements
of the navigator.mimeTypes[] array.
navigator.mimeTypes[]
The MimeType object represents a MIME type (i.e., a data format)
supported by a web browser. The format may be supported directly by
the browser, or through an external helper application or a plug-in
for embedded data. MimeType objects are members of the mimeTypes[] array of the Navigator object.
In IE, the mimeTypes[] array is
always empty, and there is no equivalent of this
functionality.
mimeTypes[]
The navigator.mimeTypes[]
array may be indexed numerically or with the name of the desired
MIME type (which is the value of the type property). To check which MIME types
are supported by a browser, you can loop through each element in the
array numerically. Or, if you just want to check whether a specific
type is supported, you can write code like the following:
var show_movie = (navigator.mimeTypes["video/mpeg"] != null);
Navigator, Plugin
Navigator
Plugin
MouseEvent: details about a mouse event — DOM Level 2 Events: Event → UIEvent →
MouseEvent
Whether the Alt key
was held down when the event occurred. Defined for all types
of mouse events.
readonly unsigned short
button
Which mouse button changed state during a mousedown,
mouseup, or click event. A value of 0 indicates the left
button, a value of 2 indicates the right button, and a value
of 1 indicates the middle mouse button. Note that this
property is defined when a button changes state; it is not
used to report whether a button is held down during a
mousemove event, for example. Also, this property is not a
bitmap: it cannot tell you if more than one button is held
down.
readonly long clientX,
clientY
The X and Y coordinates of the mouse pointer relative to
the client area, or browser window. Note
that these coordinates do not take document scrolling into
account; if an event occurs at the very top of the window,
clientY is 0 regardless of
how far down the document has been scrolled. These properties
are defined for all types of mouse events.
clientY
readonly boolean
metaKey
Whether the Meta key
was held down when the event occurred. Defined for all types
of mouse events.
readonly Node
relatedTarget
Refers to a document node that is related to the
target node of the event.
For mouseover events, it is the node the mouse left when it
moved over the target. For mouseout events, it is the node the
mouse entered when leaving the target. relatedTarget is undefined for other
types of mouse events.
relatedTarget
readonly long screenX,
screenY
The X and Y coordinates of the mouse pointer relative to
the upper-left corner of the user's monitor. These properties
are defined for all types of mouse events.
initMouseEvent(
)
Initializes the properties of a newly created MouseEvent
object.
This interface defines the type of Event object that is passed
to events of types click, mousedown, mousemove, mouseout, mouseover,
and mouseup. Note that in addition to the properties listed here,
this interface also inherits the properties of the UIEvent and Event
interfaces.
Event, UIEvent; Chapter 17, Events and Event Handling
MouseEvent.initMouseEvent( ): initialize the properties of
a MouseEvent object — DOM Level 2 Events
void initMouseEvent(StringtypeArg,
boolean canBubbleArg,
boolean cancelableArg,
AbstractView viewArg,
long detailArg,
long screenXArg,
long screenYArg,
long clientXArg,
long clientYArg,
boolean ctrlKeyArg,
boolean altKeyArg,
boolean shiftKeyArg,
boolean metaKeyArg,
unsigned short buttonArg,
Element relatedTargetArg);
typeArg
viewArg
detailArg
screenXArg
screenYArg
clientXArg
clientYArg
ctrlKeyArg
altKeyArg
shiftKeyArg
metaKeyArg
buttonArg
relatedTargetArg
The many arguments to this method specify the initial values
of the properties of this MouseEvent object, including the
properties inherited from the Event and UIEvent interfaces. The
name of each argument clearly indicates the property for which it
specifies the value, so they are not listed individually
here.
This method initializes the various properties of a newly
created MouseEvent object. It may be called only on a MouseEvent
object created with Document.createEvent(
) and only before that MouseEvent is passed to Element.dispatchEvent( ).
Element.dispatchEvent( )
Document.createEvent( ),
Event.initEvent( ), UIEvent.initUIEvent( )
Navigator: information about the browser in use — JavaScript 1.0: Object → Navigator
navigator
appCodeName
A read-only string that specifies the code name of the
browser. In all browsers based on the Netscape code base
(Netscape, Mozilla, Firefox), this is "Mozilla". For
compatibility, this property is "Mozilla" in Microsoft
browsers as well.
appName
A read-only string property that specifies the name of
the browser. For Netscape-based browsers, the value of this
property is "Netscape". In IE, the value of this property is
"Microsoft Internet Explorer". Other browsers may identify
themselves correctly or spoof another browser for
compatibility.
appVersion
A read-only string that specifies version and platform
information for the browser. The first part of this string is
a version number. Pass the string to parseInt( ) to obtain only the major
version number or to parseFloat(
) to obtain the major and minor version numbers as a
floating-point value. The remainder of the string value of
this property provides other details about the browser
version, including the operating system it is running on.
Unfortunately, however, the format of this information varies
widely from browser to browser.
parseInt( )
parseFloat(
)
cookieEnabled
A read-only boolean that is true if the browser has cookies
enabled and false if they
are disabled.
An array of MimeType objects, each of which represents
one of the MIME types (e.g., "text/html" and "image/gif")
supported by the browser. This array may be indexed
numerically or by the name of the MIME type. The mimeTypes[] array is defined by
Internet Explorer but is always empty because IE does not
support the MimeType object.
platform
A read-only string that specifies the operating system
and/or hardware platform on which the browser is running.
Although there is no standard set of values for this property,
some typical values are "Win32", "MacPPC", and "Linux
i586".
plugins[]
An array of Plugin objects, each of which represents one
plug-in that is installed in the browser. The Plugin object
provides information about the plug-in, including a list of
MIME types it supports.
The plugins[] array
is defined by Internet Explorer but is always empty because IE
does not support the Plugin object.
userAgent
A read-only string that specifies the value the browser
uses for the user-agent header in HTTP requests. Typically,
this is the value of navigator.appCodeName followed by a
slash and the value of navigator.appVersion. For
example:
navigator.appCodeName
navigator.appVersion
Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)
navigator.javaEnabled(
)
Tests whether Java is supported and enabled in the
current browser.
The Navigator object contains properties that describe the web
browser in use. You can use its properties to perform
platform-specific customization. The name of this object obviously
refers to the Netscape Navigator browser, but all browsers that
implement JavaScript support this object as well. There is only a
single instance of the Navigator object, which you can reference
through the navigator property of
any Window object.
Historically, the Navigator object has been used for "client
sniffing" to run different code depending on what browser was in
use. Example 14-3, “Determining browser vendor and version” shows a simple way to
do this, and the accompanying text describes the many pitfalls of
relying on the Navigator object. A better approach to cross-browser
compatibility is described in the section called “Feature Testing”.
MimeType, Plugin
MimeType
Navigator.javaEnabled( ): test whether Java is
available — JavaScript 1.1
navigator.javaEnabled( )
true if Java is supported
by and enabled on the current browser; false otherwise.
You can use navigator.javaEnabled(
) to check whether the current browser supports Java and
can therefore display applets.
navigator.javaEnabled(
)
Node: a node in a document tree — DOM Level 1 Core
Attr, CDATASection, CharacterData, Comment, Document,
DocumentFragment, DocumentType, Element, ProcessingInstruction,
Text
All Node objects implement one of the subinterfaces
listed above. Every Node object has a nodeType property that specifies which
subinterface it implements. These constants are the legal values for
that property; their names are self-explanatory. Note that these are
static properties of the Node( )
constructor function; they are not properties of individual Node
objects. Also note that they are not supported by Internet Explorer.
For compatibilty with IE, you must use numeric literals directly.
For example, use 1 instead of
Node.ELEMENT_NODE:
nodeType
Node( )
Node.ELEMENT_NODE
Node.ELEMENT_NODE = 1; // Element
Node.ATTRIBUTE_NODE = 2; // Attr
Node.TEXT_NODE = 3; // Text
Node.CDATA_SECTION_NODE = 4; // CDATASection
Node.PROCESSING_INSTRUCTION_NODE = 7; // ProcessingInstruction
Node.COMMENT_NODE = 8; // Comment
Node.DOCUMENT_NODE = 9; // Document
Node.DOCUMENT_TYPE_NODE = 10; // DocumentType
Node.DOCUMENT_FRAGMENT_NODE = 11; // DocumentFragment
readonly Attr[]
attributes
If this is an Element node, the attributes property is a read-only,
array-like object of Attr nodes that represent the attributes
of that element. Note that this array is "live": any changes
to the attributes of this element are immediately visible
through it.
Technically, the attributes[] array is a NamedNodeMap
object. The NamedNodeMap interface is specified by the Level 1
DOM standard and defines a number of methods for querying,
setting, and removing elements. The Element interface defines
better methods for setting and querying element attributes,
and there are no other uses of NamedNodeMap that are relevant
to client-side JavaScript. For these reasons, therefore,
NamedNodeMap is not documented in this book. Treat the
attributes property as a
read-only array of Attr objects, or use the methods defined by
Element to query, set, and delete attributes.
readonly Node[]
childNodes
Contains the child nodes of the current node. This
property should never be null: for nodes with no children,
childNodes is an array with
length zero. This property
is technically a NodeList object, but it behaves just like a
read-only array of Node objects. Note that the NodeList object
is live: any changes to this element's list of children are
immediately visible through the NodeList.
childNodes
readonly Node
firstChild
The first child of this node, or null if the node has no
children.
readonly Node
lastChild
The last child of this node, or null if the node has no
children.
readonly String
localName
In XML documents that use namespaces, specifies the
local part of the element or attribute name. This property is
never used with HTML documents. See also the namespaceURI and prefix properties.
prefix
readonly String
namespaceURI
In XML documents that use namespaces, specifies the URI
of the namespace of an Element or Attribute node. This
property is never used with HTML documents. See also the
localName and prefix properties.
readonly Node
nextSibling
The sibling node that immediately follows this one in
the childNodes[] array of
the parentNode, or null if there is no such
node.
readonly String
nodeName
The name of the node. For Element nodes, specifies the
tag name of the element, which can also be retrieved with the
tagName property of the
Element interface. For other types of nodes, the value depends
on the node type. See the upcoming table in the Description
section for details.
readonly unsigned short
nodeType
The type of the node—i.e., which subinterface the node
implements. The legal values are defined by the previously
listed constants. Since these constants are not supported by
Internet Explorer, however, you may prefer to use hardcoded
values instead of the constants. In HTML documents, the common
values for this property are 1 for Element nodes, 3 for Text
nodes, 8 for Comment nodes, and 9 for the single top-level
Document node.
String nodeValue
The value of a node. For Text nodes, it holds the text
content. For other node types, the value depends on the
nodeType, as shown in the
upcoming table in the Description section.
readonly Document
ownerDocument
The Document object of which this node is a part. For
Document nodes, this property is null.
readonly Node
parentNode
The parent (or container) node of this node, or null if there is no parent. Note
that the Document, DocumentFragment, and Attr nodes never have
parent nodes. Also, nodes that have been removed from the
document, or that are newly created and have not yet been
inserted into the document tree, have a parentNode of null.
String prefix
For XML documents that use namespaces, specifies the
namespace prefix of an Element or Attribute node. This
property is never used with HTML documents. See also the
localName and namespaceURL properties.
namespaceURL
readonly Node
previousSibling
The sibling node that immediately precedes this one in
the childNodes[] array of
the parentNode, or null if there is no such
node.
readonly String xml
If the node is an XML Document or an Element within an
XML document, this IE-specific property returns the text of
the element or document as a string. Compare this property to
the innerHTML property of
HTMLElement, and see XMLSerializer for a cross-platform
alternative.
innerHTML
XMLSerializer
appendChild( )
Adds a node to the document tree by appending it to the
childNodes[] array of this
node. If the node is already in the document tree, it is
removed and then reinserted at its new position.
cloneNode( )
Makes a copy of this node, or of the node and all its
descendants.
hasAttributes( )
Returns true if this
node is an Element and has any attributes.
hasChildNodes( )
Returns true if this
node has any children.
insertBefore( )
Inserts a node into the document tree immediately before
the specified child of this node. If the node being inserted
is already in the tree, it is removed and reinserted at its
new location.
isSupported( )
Returns true if the
specified version number of a named feature is supported by
this node.
"Normalizes" all Text node descendants of this node by
deleting empty Text nodes and merging adjacent Text
nodes.
removeChild( )
Removes (and returns) the specified child node from the
document tree.
replaceChild( )
Removes (and returns) the specified child node from the
document tree, replacing it with another node.
selectNodes( )
This IE-specific method performs an XPath query using
this node as the root and returns the result as a NodeList.
See Document.evaluate( )
and Document.createExpression(
) for DOM-based alternatives.
Document.createExpression(
)
selectSingleNode( )
This IE-specific method performs an XPath query using
this node as the root and returns the result as a single node.
See Document.evaluate( )
and Document.createExpression(
) for DOM-based alternatives.
transformNode( )
This IE-specific method applies an XSLT stylesheet to
this node and returns the results as a String. See XSLTProcessor for a non-IE
alternative.
XSLTProcessor
transformNodeToObject(
)
This IE-specific method applies an XSLT stylesheet to
this node and returns the results as a new Document object.
See XSLTProcessor for a
non-IE alternative.
All objects in a document tree (including the Document object
itself) implement the Node interface, which provides the fundamental
properties and methods for traversing and manipulating the tree. (In
Internet Explorer, the Node interface also defines some IE-specific
properties and methods for working with XML documents, XPath
expressions, and XSLT transforms. See Chapter 21, JavaScript and XML for details.)
The parentNode property and
childNodes[] array allow you to
move up and down the document tree. You can enumerate the children
of a given node by looping through the elements of childNodes[] or by using the firstChild and nextSibling properties (or the lastChild and previousSibling properties, to loop
backward). The appendChild( ),
insertBefore( ), removeChild( ), and replaceChild( ) methods allow you to
modify the document tree by altering the children of a node.
firstChild
nextSibling
lastChild
previousSibling
Every object in a document tree implements both the Node
interface and a more specialized subinterface, such as Element or
Text. The nodeType property
specifies which subinterface a node implements. You can use this
property to test the type of a node before using properties or
methods of the more specialized interface. For example:
var n; // Holds the node we're working with
if (n.nodeType == 1) { // Or use the constant Node.ELEMENT_NODE
var tagname = n.tagName; // If the node is an Element, this is the tag name
}
The nodeName and nodeValue properties specify additional
information about a node, but their value depends on nodeType, as shown in the following table.
Note that subinterfaces typically define specialized properties
(such as the tagName property of
Element nodes and the data
property of Text nodes) for obtaining this information:
ELEMENT_NODE
ELEMENT_NODE
The element's tag
name
null
ATTRIBUTE_NODE
ATTRIBUTE_NODE
The attribute name
The attribute value
TEXT_NODE
TEXT_NODE
#text
#text
The text of the
node
CDATA_SECTION_NODE
CDATA_SECTION_NODE
#cdata-section
#cdata-section
PROCESSING_INSTRUCTION_NODE
PROCESSING_INSTRUCTION_NODE
The target of the
PI
The remainder of the
PI
COMMENT_NODE
COMMENT_NODE
#comment
#comment
The text of the
comment
DOCUMENT_NODE
DOCUMENT_NODE
#document
#document
DOCUMENT_TYPE_NODE
DOCUMENT_TYPE_NODE
The document type
name
DOCUMENT_FRAGMENT_NODE
DOCUMENT_FRAGMENT_NODE
#document-fragment
#document-fragment
Document, Element, Text, XMLSerializer, XPathExpression, XSLTProcessor; Chapter 15, Scripting Documents
Node.appendChild( ): insert a node as the last child of
this node — DOM Level 1 Core
Node appendChild(NodenewChild)
throws DOMException;
newChild
The node to be inserted into the document. If the node
is a DocumentFragment, it is not directly inserted, but each
of its children are.
The node that was added.
The node does not allow children, it does not allow
children of the specified type, or
newChild is an ancestor of this
node (or is this node itself).
The ownerDocument
property of newChild is not the
same as the ownerDocument
property of this node.
This node is read-only and does not allow children to
be appended, or the node being appended is already part of
the document tree, and its parent is read-only and does not
allow children to be removed.
This method adds the node newChild
to the document, inserting it as the last child of this node. If
newChild is already in the document tree,
it is removed from the tree and then reinserted at its new location.
If newChild is a DocumentFragment node,
it is not inserted itself; instead, all its children are appended,
in order, to the end of this node's childNodes[] array. Note that a node from
(or created by) one document cannot be inserted into a different
document. That is, the ownerDocument property of
newChild must be the same as the ownerDocument property of this
node.
The following function inserts a new paragraph at the end of
the document:
function appendMessage(message) {
var pElement = document.createElement("p");
var messageNode = document.createTextNode(message);
pElement.appendChild(messageNode); // Add text to paragraph
document.body.appendChild(pElement); // Add paragraph to document body
}
Node.insertBefore( ),
Node.removeChild( ), Node.replaceChild( )
Node.insertBefore( )
Node.removeChild( )
Node.replaceChild( )
Node.cloneNode( ): duplicate a node and, optionally, all of
its descendants — DOM Level 1 Core
Node cloneNode(booleandeep);
If this argument is true, cloneNode( ) recursively clones
all descendants of this node. Otherwise, it clones only this
node.
A copy of this node.
The cloneNode( ) method
makes and returns a copy of the node on which it is called. If
passed the argument true, it
recursively clones all descendants of the node as well. Otherwise,
it clones only the node and none of its children. The returned node
is not part of the document tree, and its parentNode property is null. When an Element node is cloned, all
of its attributes are also cloned. Note, however, that
event-listener functions registered on a node are not cloned.
Node.hasAttributes( ): determine whether a node has
attributes — DOM Level 2 Core
boolean hasAttributes( );
true if this node has one
or more attributes; false if it
has none. Note that only Element nodes can have attributes.
Element.getAttribute( ),
Element.hasAttribute( ), Node
Element.hasAttribute( )
Node.hasChildNodes( ): determine whether a node has
children — DOM Level 1 Core
boolean hasChildNodes( );
true if this node has one
or more children; false if it
has none.
Node.insertBefore( ): insert a node into the document tree
before the specified node — DOM Level 1 Core
Node insertBefore(NodenewChild,
Node refChild)
throws DOMException;
refChild
The node to be inserted into the tree. If it is a
DocumentFragment, its children are inserted instead.
The child of this node before which
newChild is to be inserted. If
this argument is null,
newChild is inserted as the last
child of this node.
The node that was inserted.
This node does not support children, it does not allow
children of the specified type, or
newChild is an ancestor of this
node (or is this node itself).
The ownerDocument
property of newChild and this
node are different.
This node is read-only and does not allow insertions,
or the parent of newChild is
read-only and does not allow deletions.
refChild is not a child of
this node.
This method inserts the node
newChild into the document tree as a
child of this node. The new node is positioned within this node's
childNodes[] array so that it
comes immediately before the refChild
node. If refChild is null, newChild
is inserted at the end of childNodes[], just as with the appendChild( ) method. Note that it is
illegal to call this method with a
refChild that is not a child of this
node.
If newChild is already in the
document tree, it is removed from the tree and then reinserted at
its new position. If newChild is a
DocumentFragment node, it is not inserted itself; instead, each of
its children is inserted, in order, at the specified
location.
The following function inserts a new paragraph at the
beginning of a document:
function insertMessage(message) {
var paragraph = document.createElement("p"); // Create a <p> Element
var text = document.createTextNode(message); // Create a Text node
paragraph.appendChild(text); // Add text to the paragraph
// Now insert the paragraph before the first child of the body
document.body.insertBefore(paragraph, document.body.firstChild)
}
Node.appendChild( ),
Node.removeChild( ), Node.replaceChild( )
Node.appendChild( )
Node.isSupported( ): determine if a node supports a
feature — DOM Level 2 Core
boolean isSupported(Stringfeature,
String version);
The name of the feature to test.
The version number of the feature to test, or the
empty string to test for support of any version of the
feature.
true if the node supports
the specified version of the specified feature, and false if it does not.
The W3C DOM standard is modular, and implementations are not
required to implement all modules or features of the standard. This
method tests whether the implementation of this node supports the
specified version of the named feature. See DOMImplementation.hasFeature( ) for a list
of values for the feature and
version arguments.
DOMImplementation.hasFeature( )
DOMImplementation.hasFeature(
)
DOMImplementation.hasFeature(
)
Node.normalize( ): merge adjacent Text nodes and remove
empty ones — DOM Level 1 Core
void normalize( );
This method traverses all descendants of this node and
"normalizes" the document by removing any empty Text nodes and
merging all adjacent Text nodes into a single node. This can
simplify the tree structure after node insertions or
deletions.
Text
Node.removeChild( ): remove (and return) the specified
child of this node — DOM Level 1 Core
Node removeChild(NodeoldChild)
throws DOMException;
oldChild
The child node to remove.
The node that was removed.
This node is read-only and does not allow children to
be removed.
oldChild is not a child of
this node.
This method removes the specified child from the childNodes[] array of this node. It is an
error to call this method with a node that is not a child. removeChild( ) returns the
oldChild node after removing it.
oldChild continues to be a valid node and
may be reinserted into the document later.
You can delete the last child of the document body with this
code:
document.body.removeChild(document.body.lastChild);
Node.appendChild( ),
Node.insertBefore( ), Node.replaceChild( )
Node.replaceChild( ): replace a child node with a new
node — DOM Level 1 Core
Node replaceChild(NodenewChild,
Node oldChild)
throws DOMException;
The replacement node.
The node to be replaced.
The node that was removed from the document and
replaced.
This node does not allow children, it does not allow
children of the specified type, or
newChild is an ancestor of this
node (or is this node itself).
newChild and this node have
different values for ownerDocument.
This node is read-only and does not allow replacement,
or newChild is the child of a
node that does not allow removals.
This method replaces one node of the document tree with
another. oldChild is the node to be
replaced and must be a child of this node.
newChild is the node that takes its place
in the childNodes[] array of this
node.
If newChild is already part of the
document, it is first removed from the document before being
reinserted at its new position. If
newChild is a DocumentFragment, it is not
inserted itself; instead each of its children is inserted, in order,
at the position formerly occupied by
oldChild.
The following code replaces a node n with a <b> element and then inserts the
replaced node into the <b>
element, which reparents the node and makes it appear in
bold:
n
// Get the first child node of the first paragraph in the document
var n = document.getElementsByTagName("p")[0].firstChild;
var b = document.createElement("b"); // Create a <b> element
n.parentNode.replaceChild(b, n); // Replace the node with <b>
b.appendChild(n); // Reinsert the node as a child of <b>
Node.appendChild( ),
Node.insertBefore( ), Node.removeChild( )
Node.selectNodes( ): select nodes with an XPath
query — IE 6
NodeList selectNodes(Stringquery)
query
The XPath query string.
A single Node that matches the
query, or null if there are none.
This IE-specific method evaluates an XPath expression using
this node as the context node. It returns the first matching node
found, or null if no nodes match.
The selectSingleNode( ) method
exists only on the nodes of XML documents, not HTML documents. Note
that since Document objects are themselves nodes, this method can be
applied to entire XML documents.
For a cross-browser alternative, see Document.evaluate( ).
Document.evaluate( ),
XPathExpression; Chapter 21, JavaScript and XML
Node.transformNode( ): transform a node to a string using
XSLT — IE 6
String transformNode(Documentxslt)
xslt
An XSLT stylesheet, parsed to a Document
object.
The text produced by applying the specified stylesheet to
this node and its descendants.
This IE-specific method transforms a Node and its descendants
according to the rules specified in an XSLT stylesheet and returns
the result as an unparsed string. The transformNode( ) method exists only on the
nodes of XML documents, not HTML documents. Note that since Document
objects are themselves nodes, this method can be applied to entire
XML documents.
For similar functionality in other browsers, see XSLTProcessor.
XSLTProcessor, Node.transformNodeToObject( ); Chapter 21, JavaScript and XML
Node.transformNodeToObject( )
Node.transformNodeToObject( ): transform a node to a
document using XSLT — IE 6
Document transformNodeToObject(Documentxslt)
The result of the transformation, parsed to a Document
object.
This IE-specific method transforms a Node and its descendants
according to the rules specified in an XSLT stylesheet and returns
the result as a Document object. The transformNodeToObject( ) method exists
only on the nodes of XML documents, not HTML documents. Note that
since Document objects are themselves nodes, this method can be
applied to entire XML documents.
transformNodeToObject( )
XSLTProcessor, Node.transformNode(); Chapter 21, JavaScript and XML
Node.transformNode()
NodeList: a read-only array of nodes — DOM Level 1 Core: Object → NodeList
The number of nodes in the array.
item()
Returns the specified element of the array.
The NodeList interface defines a read-only, ordered list (i.e., an array) of
Node objects. The length property
specifies how many nodes are in the list, and the item( ) method allows you to obtain the
node at a specified position in the list. The elements of a NodeList
are always valid Node objects: NodeLists never contain null elements.
In JavaScript, NodeList objects behave like JavaScript arrays,
and you can query an element from the list using square-bracket
array notation instead of calling the item(
) method. However, you cannot assign new nodes to a
NodeList using square brackets. Since it is always easier to think
of a NodeList object as a read-only JavaScript array, this book uses
the notation Element[] or
Node[] (i.e., an Element array or
Node array) instead of NodeList. The methods Document.getElementsByTagName( ), Element.getElementsByTagName( ), and
HTMLDocument.getElementsByName( )
are all documented in this book as returning a Element[] instead of a NodeList object.
Similarly, the childNodes
property of the Node object is technically a NodeList object, but
the Node reference page defines
it as a Node[], and the property
itself is usually referred to as "the childNodes[] array."
item(
)
Element[]
Node[]
Element.getElementsByTagName( )
HTMLDocument.getElementsByName( )
Note that NodeList objects are live: they are not static
snapshots but immediately reflect changes to the document tree. For
example, if you have a NodeList that represents the children of a
specific node and you then delete one of those children, the child
is removed from your NodeList. Be careful when you are looping
through the elements of a NodeList: the body of your loop can make
changes to the document tree (such as deleting nodes) that can
affect the contents of the NodeList!
Document, Element
NodeList.item(): get an element of a NodeList — DOM Level 1 Core
Node item(unsigned long
index);
The position (or index) of the desired node in the
NodeList. The index of the first node in the NodeList is 0,
and the index of the last Node is length−1.
The node at the specified position in the NodeList, or
null if
index is less than zero or greater than
or equal to the length of the NodeList.
This method returns the specified element of a NodeList. In
JavaScript, you can use the square-bracket array notation instead of
calling item( ).
Option: an option in a Select element — DOM Level 2 HTML: Node → Element → HTMLElement →
HTMLOptionElement
Option objects can be created with Document.createElement( ), like any other
tag. In the DOM Level 0, Option objects can also be dynamically
created with the Option( )
constructor, as follows:
Option( )
new Option(Stringtext, String value,
boolean defaultSelected, boolean selected)
defaultSelected
selected
An optional string argument that specifies the text property of the Option
object.
An optional string argument that specifies the value property of the Option
object.
An optional boolean argument that specifies the defaultSelected property of the
Option object.
An optional boolean argument that specifies the selected property of the Option
object.
boolean
defaultSelected
The initial value of the selected attribute of the <option> element. If the form
is reset, the selected
property is reset to the value of this property. Setting this
property also sets the value of the selected property.
If true, this
<option> element is
disabled, and the user is not allowed to select it. Mirrors
the disabled
attribute.
readonlyHTMLFormElementform
A reference to the <form> element that contains
this element.
readonly long
index
The position of this <option> element within the
<select> element that
contains it.
String label
The text to be displayed for the option. Mirrors the
label attribute. If this
property is not specified, the plain-text content of the
<option> element is
used instead.
boolean selected
The current state of this option: if true, the option is selected. The
initial value of this property comes from the selected attribute.
readonly String
text
The plain text contained within the <option> element. This text
appears as the label for the option.
The value submitted with the form if this option is
selected when form submission occurs. Mirrors the value attribute.
An Option object is created by an <option> tag within a <select> tag, which is within a
<form>. Multiple <option> tags typically appear
within the <select>
tag:
< form ...>
< option
[ value="value" ] // The value returned when the form is submitted
[ selected ] > // Specifies whether this option is initially selected
plain_text_label // The text to display for this option
[ < /option> ]
...
...
/form>
plain_text_label
The Option object describes a single option displayed
within a Select object. The properties of this object specify
whether it is selected by default, whether it is currently selected,
the position it has in the options[] array of its containing Select
object, the text it displays, and the value it passes to the server
if it is selected when the containing form is submitted.
options[]
Note that although the text displayed by this option is
specified outside the <option> tag, it must be plain,
unformatted text without any HTML tags so it can be properly
displayed in listboxes and drop-down menus that do not support HTML
formatting.
You can dynamically create new Option objects for display in a
Select object with the Option( )
constructor. Once a new Option object is created, it can be appended
to the list of options in a Select object with Select.add( ). See Select.options[] for further
details.
Select.add( )
Select.options[]
Select, Select.options[]; Chapter 18, Forms and Form Elements
Packages: see Packages in Part III
Password: see Input
Plugin: describes an installed plug-in — JavaScript 1.1; not supported by IE: Object →
Plugin
navigator.plugins[i]
navigator.plugins['name']
A read-only string that contains a human-readable
description of the specified plug-in. The text of this
description is provided by the creators of the plug-in and may
contain vendor and version information as well as a brief
description of the plug-in's function.
filename
A read-only string that specifies the name of the file
on disk that contains the plug-in program itself. This name
may vary from platform to platform. The name property is more useful than
filename for identifying a
plug-in.
Each Plugin object is also an array of MimeType objects that
specify the data formats supported by the plug-in. As with all
arrays, the length property
specifies the number of elements in the array.
The name property of
a Plugin object is a read-only string that specifies the name
of the plug-in. Each plug-in should have a name that uniquely
identifies it. The name of a plug-in can be used as an index
into the navigator.plugins[] array. You can
use this fact to determine easily whether a particular named
plug-in is installed in the current browser:
navigator.plugins[]
var flash_installed = (navigator.plugins["Shockwave Flash"] != null);
The array elements of the Plugin object are MimeType
objects that specify the data formats supported by the plug-in. The
length property specifies the
number of MimeType objects in this array.
A plug-in is a software module that can
be invoked by a browser to display specialized types of embedded
data within the browser window. Plug-ins are represented by the
Plugin object, and the plugins[]
property of the Navigator object is an array of Plugin objects
representing the installed plug-ins for the browser. IE does not
support the Plugin object, and the navigator.plugins[] array is always empty
on that browser.
navigator.plugins[] may be
indexed numerically when you want to loop through the complete list
of installed plug-ins, looking for one that meets your needs (for
example, one that supports the MIME type of the data you want to
embed in your web page). This array can also be indexed by plug-in
name, however. That is, if you want to check whether a specific
plug-in is installed in the user's browser, you might use code like
this:
The name used as an array index with this technique is the
same name that appears as the value of the name property of the Plugin.
The Plugin object is somewhat unusual in that it has both
regular object properties and array elements. The properties of the
Plugin object provide various pieces of information about the
plug-in, and its array elements are MimeType objects that specify
the embedded data formats that the plug-in supports. Don't confuse
the fact that Plugin objects are stored in an array of the Navigator
object with the fact that each Plugin object is itself an array of
MimeType objects. Because there are two arrays involved, you may end
up with code that looks like this:
navigator.plugins[i][j] // The jth MIME type of the ith plug-in
navigator.plugins["LiveAudio"][0] // First MIME type of LiveAudio plug-in
Finally, note that while the array elements of a Plugin object
specify the MIME types supported by that plug-in, you can also
determine which plug-in supports a given MIME type with the enabledPlugin property of the MimeType
object.
Navigator, MimeType
ProcessingInstruction : a processing instruction in an XML
document — DOM Level 1 XML: Node →
ProcessingInstruction
The content of the processing instruction (i.e., the
first nonspace character after the target up to but not
including the closing ?>).
?>
readonly String
target
The target of the processing instruction. This is the
first identifier that follows the opening <?; it specifies the "processor"
for which the processing instruction is intended.
<?
This infrequently used interface represents a processing
instruction (or PI) in an XML document. Programmers working with
HTML documents will never encounter a ProcessingInstruction
node.
Document.createProcessingInstruction()
Document.createProcessingInstruction()
Radio: see Input
Range: represents a contiguous range of a
document — DOM Level 2 Range: Object → Range
These constants specify how the boundary points of two Range
objects are compared. They are the legal values for the
how argument to the compareBoundaryPoints( ) method (see the
Range.compareBoundaryPoints( )
reference page):
how
compareBoundaryPoints( )
Range.compareBoundaryPoints( )
unsigned short START_TO_START =
0
Compares the start of the specified range to the start
of this range.
unsigned short START_TO_END =
1
Compares the start of the specified range to the end of
this range.
unsigned short END_TO_END =
2
Compares the end of the specified range to the end of
this range.
unsigned short END_TO_START =
3
Compares the end of the specified range to the start of
this range.
The Range interface defines the following properties. Note that all of
these properties are read-only. You cannot change the start or end
points of a range by setting properties; you must call setEnd( ) or setStart( ) instead. Note also that after
you call the detach( ) method of
a Range object, any subsequent attempt to read any of these
properties throws a DOMException with a code of INVALID_STATE_ERR:
setEnd( )
setStart( )
detach( )
INVALID_STATE_ERR
readonly boolean
collapsed
true if the start and
the end of the range are at the same point in the
document—that is, if the range is empty or "collapsed."
readonly Node
commonAncestorContainer
The most deeply nested Document node that contains
(i.e., is an ancestor of) both the start and end points of the
range.
readonly Node
endContainer
The Document node that contains the end point of the
range.
readonly long
endOffset
The position of the range's ending point within endContainer.
endContainer
readonly Node
startContainer
The Document node that contains the starting point of
the range.
readonly long
startOffset
The position of the range's starting point within
startContainer.
startContainer
The Range interface defines the following methods.
Note that if you call detach( )
on a range, any subsequent calls of any methods on that range throw
a DOMException with a code of
INVALID_STATE_ERR. Because this
exception is ubiquitous within this interface, it is not listed in
the reference pages for the individual Range methods:
cloneContents()
Returns a new DocumentFragment object that contains a
copy of the region of the document represented by this
range.
cloneRange( )
Creates a new Range object that represents the same
region of the document as this one.
collapse( )
Collapses this range so that one boundary point is the
same as the other.
compareBoundaryPoints(
)
Compares a boundary point of the specified range to a
boundary point of this range and returns −1, 0, or 1,
depending on their order. Which points to compare is specified
by the first argument, which must be one of the constants
listed in the Constants section.
deleteContents(
)
Deletes the region of the document represented by this
range.
Tells the implementation that this range will no longer
be used and that it can stop keeping track of it. If you call
this method for a range, subsequent method calls or property
lookups on that range throw a DOMException with a code of INVALID_STATE_ERR.
extractContents(
)
Deletes the region of the document represented by this
range, but returns the contents of that region as a
DocumentFragment object. This method is like a combination of
cloneContents( ) and
deleteContents( ).
cloneContents( )
deleteContents( )
insertNode( )
Inserts the specified node into the document at the
start point of the range.
selectNode( )
Sets the boundary points of this range so that it
contains the specified node and all of its descendants.
selectNodeContents(
)
Sets the boundary points of this range so that it
contains all the descendants of the specified node but not the
node itself.
Sets the end point of this range to the specified node
and offset.
setEndAfter( )
Sets the end point of this range to immediately after
the specified node.
setEndBefore( )
Sets the end point of this range to immediately before
the specified node.
Sets the start position of this range to the specified
offset within the specified node.
setStartAfter( )
Sets the start position of this range to immediately
after the specified node.
setStartBefore(
)
Sets the start position of this range to immediately
before the specified node.
surroundContents(
)
Inserts the specified node into the document at the
start position of the range and then reparents all the nodes
within the range so that they become descendants of the newly
inserted node.
Returns the plain-text content of the document region
described by this range.
A Range object represents a contiguous range or region of a
document, such as the region that the user might select with a mouse
drag in a web browser window. If an implementation supports the
Range module (at the time of this writing, Firefox and Opera support
it, Safari has partial support, and Internet Explorer does not
support it), the Document object defines a createRange( ) method that you can call to
create a new Range object. Be careful, however: Internet Explorer
defines an incompatible Document.createRange( ) method that
returns a nonstandard object similar to, but not compatible with,
the Range interface. The Range interface defines a number of methods
for specifying a "selected" region of a document and several more
methods for implementing cut-and-paste operations on the selected
region.
Document.createRange( )
A range has two boundary points: a start point and an end
point. Each boundary point is specified by a combination of a node
and an offset within that node. The node is typically an Element,
Document, or Text node. For Element and Document nodes, the offset
refers to the children of that node. An offset of 0 specifies a
boundary point before the first child of the node. An offset of 1
specifies a boundary point after the first child and before the
second child. If the boundary node is a Text node, however, the
offset specifies a position between two characters of that
text.
The properties of the Range interface provide a way to obtain
boundary nodes and offsets of a range. The methods of the interface
provide a number of ways to set the boundaries of a range. Note that
the boundaries of a range may be set to nodes within a Document or a
DocumentFragment.
Once the boundary points of a range are defined, you can use
deleteContents( ), extractContents( ), cloneContents( ), and insertNode( ) to implement cut, copy, and
paste operations.
extractContents( )
When a document is altered by insertion or deletion, all Range
objects that represent portions of that document are altered, if
necessary, so that their boundary points remain valid and they
represent (as closely as possible) the same document content.
Document.createRange( ),
DocumentFragment
DocumentFragment
Range.cloneContents(): copy range contents into a
DocumentFragment — DOM Level 2 Range
DocumentFragment cloneContents( )
throws DOMException;
A DocumentFragment object that contains a copy of the
document content within this range.
If this range includes a DocumentType node, this method
throws a DOMException with a code of HIERARCHY_REQUEST_ERR.
This method duplicates the contents of this range and returns
the results in a DocumentFragment object.
DocumentFragment, Range.deleteContents( ), Range.extractContents( )
Range.deleteContents( )
Range.cloneRange(): make a copy of this range — DOM Level 2 Range
Range cloneRange( );
A new Range object that has the same boundary points as this
range.
Document.createRange(
)
Document.createRange(
)
Range.collapse(): make one boundary point equal to the
other — DOM Level 2 Range
void collapse(booleantoStart)
throws DOMException;
toStart
If this argument is true, the method sets the end
point of the range to the same value as the starting point.
Otherwise, it sets the starting point to the same value as
the end point.
This method sets one boundary point of the range to be the
same as the other point. The point to be modified is specified by
the toStart argument. After this method
returns, the range is said to be collapsed:
it represents a single point within a document and has no content.
When a range is collapsed like this, its collapsed property is true.
collapsed
Range.compareBoundaryPoints(): compare positions of two
ranges — DOM Level 2 Range
short compareBoundaryPoints(unsigned shorthow,
Range sourceRange)
throws DOMException;
sourceRange
Specifies how to perform the comparison (i.e., which
boundary points to compare). Legal values are the constants
defined by the Range interface.
The range that is to be compared to this range.
The value −1 if the specified boundary point of this range
is before the specified boundary point of
sourceRange, 0 if the two specified
boundary points are the same, or 1 if the specified boundary point
of this range is after the specified boundary point of
sourceRange.
If sourceRange represents a range
of a different document than this range does, this method throws a
DOMException with a code of
WRONG_DOCUMENT_ERR.
This method compares a boundary point of this range to a
boundary point of the specified
sourceRange and returns a value that
specifies their relative order in the document source. The
how argument specifies which boundary
points of each range are to be compared. The legal values for this
argument, and their meanings, are as follows:
Range.START_TO_START
Compares the start points of the two Range nodes.
Range.END_TO_END
Compares the end points of the two Range nodes.
Range.START_TO_END
Compares the start point of
sourceRange to the end point of
this range.
Range.END_TO_START
Compares the end point of
sourceRange to the start point of
this range.
The return value of this method is a number that specifies the
relative position of this range to the specified
sourceRange. Therefore, you might expect
the range constants for the how argument
to specify the boundary point for this range first and the boundary
point for sourceRange second.
Counterintuitively, however, the Range.START_TO_END constant specifies a
comparison of the end point of this range with
the start point of the specified
sourceRange. Similarly, the Range.END_TO_START constant specifies a
comparison of the start point of this range
with the end point of the specified
range.
Range.deleteContents(): delete a region of the
document — DOM Level 2 Range
void deleteContents( )
throws DOMException;
If any portion of the document that is represented by this
range is read-only, this method throws a DOMException with a
code of NO_MODIFICATION_ALLOWED_ERR.
This method deletes all document content represented by this
range. When this method returns, the range is collapsed with both
boundary points at the start position. Note that the deletion may
result in adjacent Text nodes that can be merged with a call to
Node.normalize( ).
See Range.cloneContents( )
for a way to copy document content and Range.extractContents( ) for a way to copy
and delete document content in a single operation.
Node.normalize( ), Range.cloneContents( ), Range.extractContents( )
Range.detach(): free a Range object — DOM Level 2 Range
void detach( )
throws DOMException;
Like all Range methods, detach(
) throws a DOMException with a code of INVALID_STATE_ERR if it is called on a
Range object that has already been detached.
detach(
)
DOM implementations keep track of all Range objects created
for a document because they may need to change the range boundary
points when the document is modified. When you are certain that a
Range object isn't needed any more, call the detach( ) method to tell the
implementation that it no longer needs to keep track of that range.
Note that once this method has been called for a Range object, any
use of that Range throws an exception. Calling detach( ) is not required but may improve
performance in some circumstances when the document is being
modified. A Range object is not subject to immediate garbage
collection.
Range.extractContents( ): delete document content and
return it in a DocumentFragment — DOM Level 2 Range
DocumentFragment extractContents( )
throws DOMException;
A DocumentFragment node that contains the contents of this
range.
This method throws a DOMException with a code of NO_MODIFICATION_ALLOWED_ERR if any part
of the document content to be extracted is read-only or a code of HIERARCHY_REQUEST_ERR if the range
contains a DocumentType node.
This method deletes the specified range of a document and
returns a DocumentFragment node that contains the deleted content.
When this method returns, the range is collapsed, and the document
may contain adjacent Text nodes (which can be merged with Node.normalize( )).
DocumentFragment, Range.cloneContents( ), Range.deleteContents( )
Range.insertNode( ): insert a node at the start of a
range — DOM Level 2 Range
void insertNode(NodenewNode)
throws RangeException,
DOMException;
newNode
The node to be inserted into the document.
This method throws a RangeException with a code of INVALID_NODE_TYPE_ERR if newNode is an Attr, Document, Entity, or
Notation node.
INVALID_NODE_TYPE_ERR
This method also throws a DOMException with one of the
following code values under the
following conditions:
The node that contains the start of the range does not
allow children, it does not allow children of the specified
type, or newNode is an ancestor
of that node.
The node that contains the start of the range or any
of its ancestors is read-only.
newNode is part of
a different document than the range is.
This method inserts the specified node (and all its
descendants) into the document at the start position of this range.
When this method returns, this range includes the newly inserted
node. If newNode is already part of the
document, it is removed from its current position and then
reinserted at the start of the range. If
newNode is a DocumentFragment node, it is
not inserted itself, but all of its children are inserted, in order,
at the start of the range.
If the node that contains the start of the range is a Text
node, it is split into two adjacent nodes before the insertion takes
place. If newNode is a Text node, it is
not merged with any adjacent Text nodes after it is inserted. To
merge adjacent Text nodes, call Node.normalize( ).
DocumentFragment, Node.normalize( )
Range.selectNode(): set range boundaries to a
node — DOM Level 2 Range
void selectNode(NoderefNode)
throws RangeException, DOMException;
refNode
The node to be "selected" (i.e., the node that is to
become the content of this range).
A RangeException with a code of INVALID_NODE_TYPE_ERR if
refNode is an Attr, Document, or
DocumentFragment.
A DOMException with a code of WRONG_DOCUMENT_ERR if
refNode is part of a different document
than the one through which this range was created.
This method sets the contents of this range to the specified
refNode—i.e., it "selects" the node and
its descendants.
Range.selectNodeContents(
)
Range.selectNodeContents(
)
Range.selectNodeContents( ): set range boundaries to the
children of a node — DOM Level 2 Range
void selectNodeContents(NoderefNode)
throws RangeException, DOMException;
The node whose children are to become the contents of
this range.
A RangeException with a code of INVALID_NODE_TYPE_ERR if
refNode or one of its ancestors is a
DocumentType, Entity, or Notation node.
This method sets the boundary points of this range so that the
range contains the children of
refNode.
Range.selectNode( )
Range.selectNode( )
Range.setEnd( ): set the end point of a range — DOM Level 2 Range
void setEnd(NoderefNode,
long offset)
throws RangeException, DOMException;
The node that contains the new end point.
The position of the end point within
refNode.
A RangeException with a code of INVALID_NODE_TYPE_ERR if
refNode or one of its ancestors is a
DocumentType node.
A DOMException with a code of WRONG_DOCUMENT_ERR if
refNode is part of a different document
than the one through which this range was created, or a code of INDEX_SIZE_ERR if
offset is negative or is greater than
the number of children or characters in
refNode.
This method sets the end point of a range by specifying the
values of the endContainer and
endOffset properties.
endOffset
Range.setEndAfter( ): end a range after a specified
node — DOM Level 2 Range
void setEndAfter(NoderefNode)
throws RangeException, DOMException;
The node after which the end point of the range is to
be set.
A RangeException with a code of INVALID_NODE_TYPE_ERR if
refNode is a Document, DocumentFragment
or Attr node, or if the root container of
refNode is not a Document,
DocumentFragment, or Attr node.
This method sets the end point of this range to fall
immediately after the specified
refNode.
Range.setEndBefore( ): end a range before the specified
node — DOM Level 2 Range
void setEndBefore(NoderefNode)
throws RangeException, DOMException;
The node before which the end point of the range is to
be set.
This method throws the same exceptions in the same
circumstances as Range.setEndAfter(
). See that method for details.
Range.setEndAfter(
)
This method sets the end point of this range to fall
immediately before the specified
refNode.
Range.setStart( ): set the start point of a range — DOM Level 2 Range
void setStart(NoderefNode,
long offset)
throws RangeException, DOMException;
The node that contains the new start point.
The position of the new start point within
refNode.
This method throws the same exceptions, for the same
reasons, as Range.setEnd( ).
See that reference page for details.
Range.setEnd( )
This method sets the start point of this range by specifying
the values of the startContainer
and startOffset
properties.
startOffset
Range.setStartAfter( ): start a range after the specified
node — DOM Level 2 Range
void setStartAfter(NoderefNode)
throws RangeException, DOMException;
The node after which the start point of the range is
to be set.
This method throws the same exceptions in the same
circumstances as Range.setEndAfter(
). See that reference page for details.
This method sets the starting point of this range to be
immediately after the specified
refNode.
Range.setStartBefore( ): start a range before the specified
node — DOM Level 2 Range
void setStartBefore(NoderefNode)
throws RangeException, DOMException;
The node before which the start point of the range is
to be set.
This method sets the starting point of this range to be
immediately before the specified
refNode.
Range.surroundContents( ): surround range contents with the
specified node — DOM Level 2 Range
void surroundContents(NodenewParent)
throws RangeException, DOMException;
newParent
The node that is to become the new parent of the
contents of this range.
This method throws a DOMException or RangeException with one
of the following code values in
the following circumstances:
DOMException.HIERARCHY_REQUEST_ERR
The container node of the start of the range does not
allow children or does not allow children of the type of
newParent, or
newParent is an ancestor of that
container node.
DOMException.NO_MODIFICATION_ALLOWED_ERR
An ancestor of a boundary point of the range is
read-only and does not allow insertions.
DOMException.WRONG_DOCUMENT_ERR
newParent and this range
were created using different Document objects.
RangeException.BAD_BOUNDARYPOINTS_ERR
The range partially selects a node (other than a Text
node), so the region of the document it represents cannot be
surrounded.
RangeException.INVALID_NODE_TYPE_ERR
newParent is a Document,
DocumentFragment, DocumentType, Attr, Entity, or Notation
node.
This method reparents the contents of this range to
newParent and then inserts
newParent into the document at the start
position of the range. It is useful to place a region of document
content within a <div> or
<span> element, for
example.
If newParent is already part of the
document, it is first removed from the document, and any children it
has are discarded. When this method returns, this range begins
immediately before newParent and
ends immediately after it.
Range.toString( ): get range contents as a plain-text
string — DOM Level 2 Range
String toString( );
The contents of this range as a string of plain text without
any markup.
RangeException: signals a range-specific
exception — DOM Level 2 Range: Object → RangeException
The following constants define the legal values for the
code property of a RangeException
object. Note that these constants are static properties of
RangeException, not properties of individual exception
objects.
unsigned short
BAD_BOUNDARYPOINTS_ERR = 1
The boundary points of a range are not legal for the
requested operation.
unsigned short
INVALID_NODE_TYPE_ERR = 2
An attempt was made to set the container node of a range
boundary point to an invalid node or a node with an invalid
ancestor.
A RangeException is thrown by certain methods of the Range
interface to signal a problem of some sort. Note that most
exceptions thrown by Range methods are DOMException objects. A
RangeException is generated only when none of the existing
DOMException error constants is appropriate to describe the
exception.
Reset: see Input
Screen: provides information about the display — JavaScript 1.2: Object → Screen
screen
availHeight
Specifies the available height, in pixels, of the screen
on which the web browser is displayed. On operating systems
such as Windows, this available height does not include
vertical space allocated to semipermanent features, such as
the task bar at the bottom of the screen.
availWidth
Specifies the available width, in pixels, of the screen
on which the web browser is displayed. On operating systems
such as Windows, this available width does not include
horizontal space allocated to semipermanent features, such as
application shortcut bars.
colorDepth
Specifies the color depth of the screen in bits per
pixel.
Specifies the total height, in pixels, of the screen on
which the web browser is displayed. See also availHeight.
Specifies the total width, in pixels, of the screen on
which the web browser is displayed. See also availWidth.
The screen property of
every Window refers to a Screen object. The properties of this
global object contain information about the screen on which the
browser is displayed. JavaScript programs can use this information
to optimize their output for the user's display capabilities. For
example, a program can choose between large and small images based
on the display size and between 8-bit and 16-bit color images based
on the screen's color depth. A JavaScript program can also use the
information about the size of the screen to center new browser
windows on the screen.
The screen property of the
Window object
Select: a graphical selection list — DOM Level 2 HTML: Node → Element → HTMLElement →
readonly Form
form
The <form>
element that contains this <select> element.
The number of <option> elements contained by
this <select>
element. Same as options.length.
options.length
readonly HTMLCollection
options
An array (HTMLCollection) of Option objects that
represent the <option> elements contained in
this <select>
element, in the order in which they appear. See Select.options[] for further
details.
long
selectedIndex
The position of the selected option in the options array. If no options are
selected, this property is −1. If multiple options are
selected, this property holds the index of the first selected
option.
Setting the value of this property selects the specified
option and deselects all other options, even if the Select
object has the multiple attribute specified. When
you're doing listbox selection (when size > 1), you can deselect all
options by setting selectedIndex to −1. Note that
changing the selection in this way does not trigger the
onchange( ) event
handler.
multiple
selectedIndex
onchange( )
If multiple is
true, this property is
"select-multiple"; otherwise, it is "select-one". This
property exists for compatibilty with the type property of the Input
object.
In addition to the properties above, Select objects also
mirror HTML attributes with the following properties:
boolean
disabled
boolean
disabled
disabled
Whether the user element is
disabled
boolean
multiple
boolean
multiple
multiple
Whether more than one option may
be selected
Element name for form
submission
long
size
long
size
The number of options to display
at once
Position of Select element in the
tabbing order
Inserts a new Option object into the options array, either by appending
it at the end of the array or by inserting it before another
specified option.
Takes keyboard focus away from this element.
Transfers keyboard focus to this element.
Removes the <option> element at the
specified position.
Invoked when the user selects or deselects an
item.
A Select element is created with a standard HTML
<select> tag. Options to
appear within the Select element are created with the <option> tag:
<form>
...
name="name" // A name that identifies this element; specifies name property
[ size="integer" ] // Number of visible options in Select element
[ multiple ] // Multiple options may be selected, if present
[ onchange="handler" ] // Invoked when the selection changes
>
<option value="value1" [selected]>option_label1
<option value="value2" [selected]>option_label2// Other options here
...
</form>
integer
value1
option_label1
value2
option_label2
The Select element represents an HTML <select> tag, which displays a
graphical list of choices to the user. If the multiple attribute is present in the HTML
definition of the element, the user may select any number of options
from the list. If that attribute is not present, the user may select
only one option, and options have a radio-button behavior—selecting
one deselects whichever was previously selected.
The options in a Select element may be displayed in two
distinct ways. If the size
attribute has a value greater than 1, or if the multiple attribute is present, they are
displayed in a list box that is size lines high in the browser window. If
size is smaller than the number
of options, the listbox includes a scrollbar so all the options are
accessible. On the other hand, if size is specified as 1 and multiple is not specified, the currently
selected option is displayed on a single line, and the list of other
options is made available through a drop-down menu. The first
presentation style displays the options clearly but requires more
space in the browser window. The second style requires minimal space
but does not display alternative options as explicitly.
The options[] property of
the Select element is the most interesting. This is the array of
Option objects that describe the choices presented by the Select
element. The length property
specifies the length of this array (as does options.length). See Option for details.
For a Select element without the multiple attribute specified, you can
determine which option is selected with the selectedIndex property. When multiple
selections are allowed, however, this property tells you the index
of only the first selected option. To determine the full set of
selected options, you must iterate through the options[] array and check the selected property of each Option
object.
The options displayed by the Select element may be dynamically
modified. Add a new option with the add(
) method and the Option(
) constructor; remove an option with the remove( ) method. Changes are also
possible by direct manipulation of the options array.
add(
)
Option(
)
Form, Option, Select.options[]; Chapter 18, Forms and Form Elements
Select.add( ): insert an <option> element — DOM Level 2 HTML
void add(HTMLElementelement,
HTMLElement before)
throws DOMException;
before
The Option element to be added.
The element of the options array before which the new
element should be added. If this
argument is null,
element is appended at the end of
the options array.
This method throws a DOMException with a code of NOT_FOUND_ERR if the
before argument specifies an object
that is not a member of the options array.
This method adds a new <option> element to this <select> element.
element is an Option object that
represents the <option>
element to be added. before specifies the
Option before which element is to be
added. If before is part of an <optgroup>,
element is always inserted as part of
that same group. If before is null, element
becomes the last child of the <select> element.
Option
Select.blur( ): take keyboard focus away from this
element — DOM Level 2 HTML
This method takes keyboard focus away from this
element.
Select.focus( ): give keyboard focus to this
element — DOM Level 2 HTML
This method transfers keyboard focus to this <select> element so the user can
interact with it using the keyboard instead of the mouse.
Select.onchange: event handler invoked when the selection
changes — DOM Level 0
The onchange property of a
Select object refers to an event-handler function that is invoked
when the user selects or deselects an option. The event does not
specify what the new selected option or options are; you must
consult the selectedIndex
property of the Select object or the selected property of the various Option
objects to determine this.
Element.addEventListener(
), Option; Chapter 17, Events and Event Handling
Select.options[]: the choices in a Select object — DOM Level 2 HTML
readonly HTMLCollection options
The options[] property is
an array-like HTMLCollection of Option objects. Each Option object
describes one of the selection options presented within the Select
object.
The options[] property is
not an ordinary HTMLCollection. For backward compatibility with the
earliest browsers, this collection has certain special behaviors
that allow you to change the options displayed by the Select
object:
If you set options.length to 0, all options in
the Select object are cleared.
If you set options.length to a value less than
the current value, the number of options in the Select object is
decreased, and those at the end of the array disappear.
If you set an element in the options[] array to null, that option is removed from the
Select object, and the elements above it in the array are moved
down, changing their indices to occupy the new space in the
array (see also Select.remove(
)).
Select.remove(
)
If you create a new Option object with the Option( ) constructor (see Option), you can add that option to
the end of the options list in the Select object by appending it
to the options[] array. To do
this, set options[options.length] (see also
Select.add( )).
options[options.length]
Option
Select.remove( ): remove an <option> — DOM Level 2 HTML
void remove(longindex);
The position within the options array of the <option> element to be
removed.
This method removes the <option> element at the specified
position in the options array. If
the specified index is less than zero or
greater than or equal to the number of options, the remove( ) method ignores it and does
nothing.
Option
Style: see CSS2Properties
Submit: see Input
Table: a <table> in an HTML document — DOM Level 2 HTML: Node → Element → HTMLElement →
Table
HTMLElement
caption
A reference to the <caption> element for the
table, or null if there is
none.
readonly HTMLCollection
rows
An array (HTMLCollection) of TableRow objects that
represent all the rows in the table. This includes all rows
defined within <thead>, <tfoot>, and <tbody> tags.
readonly HTMLCollection
tBodies
An array (HTMLCollection) of TableSection objects that
represent all the <tbody> sections in this
table.
TableSection
tFoot
The <tfoot>
element of the table, or null if there is none.
TableSection
tHead
The <thead>
element of the table, or null if there is none.
In addition to the properties just listed, this interface
defines the properties in the following table to represent the HTML
attributes of the <table>
element:
deprecated String align
Horizontal alignment of table in
document
deprecated String bgColor
deprecated String bgColor
bgcolor
bgcolor
Table background
color
String
border
String
border
Width of border around
table
String
cellPadding
String
cellPadding
cellpadding
cellpadding
Space between cell contents and
border
String
cellSpacing
String
cellSpacing
cellspacing
cellspacing
Space between cell
borders
String
frame
String
frame
frame
Which table borders to
draw
String
rules
String
rules
rules
Where to draw lines within the
table
String
summary
String
summary
summary
Summary description of
table
Table width
Returns the existing <caption> for the table, or
creates (and inserts) a new one if none already exists.
Returns the existing <tfoot> element for the table,
or creates (and inserts) a new one if none already
exists.
Returns the existing <thead> element for the table,
or creates (and inserts) a new one if none already
exists.
Deletes the <caption> element from the
table, if it has one.
Deletes the row at the specified position in the
table.
Deletes the <tfoot> element from the
table, if it has one.
Deletes the <thead> element from the
table, if it has one.
Inserts a new, empty <tr> element into the table at
the specified position.
The Table object represents an HTML <table> element and defines a number
of convenience properties and methods for querying and modifying
various sections of the table. These methods and properties make it
easier to work with tables, but their functionality can also be
duplicated with core DOM methods.
TableCell, TableRow, TableSection
Table.createCaption( ): get or create a
<caption> — DOM Level 2 HTML
HTMLElement createCaption( );
An HTMLElement object representing the <caption> element for this table.
If the table already has a caption, this method simply returns it.
If the table does not have an existing <caption>, this method creates a
new (empty) one and inserts it into the table before returning
it.
Table.createTFoot( ): get or create a
<tfoot> — DOM Level 2 HTML
HTMLElement createTFoot( );
A TableSection representing the <tfoot> element for this table. If
the table already has a footer, this method simply returns it. If
the table does not have an existing footer, this method creates a
new (empty) <tfoot>
element and inserts it into the table before returning it.
Table.createTHead( ): get or create a
<thead> — DOM Level 2 HTML
HTMLElement createTHead( );
A TableSection representing the <thead> element for this table. If
the table already has a header, this method simply returns it. If
the table does not have an existing header, this method creates a
new (empty) <thead>
element and inserts it into the table before returning it.
Table.deleteCaption( ): delete the <caption> of a
table — DOM Level 2 HTML
void deleteCaption( );
If this table has a <caption> element, this method
removes it from the document tree. Otherwise, it does
nothing.
Table.deleteRow( ): delete a row of a table — DOM Level 2 HTML
void deleteRow(longindex)
throws DOMException;
Specifies the position within the table of the row to
be deleted.
This method throws a DOMException with a code of INDEX_SIZE_ERR if
index is less than zero or is greater
than or equal to the number of rows in the table.
This method deletes the row at the specified position from the
table. Rows are numbered in the order in which they appear in the
document source. Rows in <thead> and <tfoot> sections are numbered along
with all other rows in the table.
TableSection.deleteRow(
)
TableSection.deleteRow(
)
Table.deleteTFoot( ): delete the <tfoot> of a
table — DOM Level 2 HTML
void deleteTFoot( );
If this table has a <tfoot> element, this method removes
it from the document tree. If the table has no footer, this method
does nothing.
Table.deleteTHead( ): delete the <thead> of a
table — DOM Level 2 HTML
void deleteTHead( );
If this table has a <thead> element, this method deletes
it; otherwise, it does nothing.
Table.insertRow( ): add a new, empty row to the
table — DOM Level 2 HTML
HTMLElement insertRow(longindex)
throws DOMException;
The position at which the new row is to be
inserted.
A TableRow that represents the newly inserted row.
This method throws a DOMException with a code of INDEX_SIZE_ERR if
index is less than zero or greater than
the number of rows in the table.
This method creates a new TableRow representing a <tr> tag and inserts it into the
table at the specified position.
The new row is inserted in the same section and immediately
before the existing row at the position specified by
index. If
index is equal to the number of rows in
the table, the new row is appended to the last section of the table.
If the table is initially empty, the new row is inserted into a new
<tbody> section that is
itself inserted into the table.
You can use the convenience method TableRow.insertCell( ) to add content to
the newly created row.
TableRow.insertCell( )
TableSection.insertRow(
)
TableSection.insertRow(
)
TableCell: cell in an HTML table — DOM Level 2 HTML: Node → Element → HTMLElement →
TableCell
readonly long
cellIndex
The position of this cell within its row.
In addition to the cellIndex property, this interface defines
the following properties, which correspond directly to the HTML
attributes of the <td> and
<th> elements:
cellIndex
String
abbr
String
abbr
abbr
See HTML
specification
String
align
String
align
Horizontal alignment of
cell
String
axis
String
axis
axis
deprecated String bgColor
Background color of
cell
String
ch
String
ch
char
char
Alignment character
String
chOff
String
chOff
choff
choff
Alignment character
offset
long
colSpan
long
colSpan
colspan
colspan
Columns spanned by
cell
String
headers
String
headers
headers
id values for headers for this
cell
deprecated String height
deprecated String height
Cell height in
pixels
deprecated boolean noWrap
deprecated boolean noWrap
nowrap
nowrap
Don't word-wrap
cell
long
rowSpan
long
rowSpan
rowspan
rowspan
Rows spanned by
cell
String
scope
String
scope
scope
Scope of this header
cell
String
vAlign
String
vAlign
valign
valign
Vertical alignment of
cell
deprecated String width
deprecated String width
Cell width in
pixels
This interface represents <td> and <th> elements in HTML tables.
TableRow: a <tr> element in an HTML table — DOM Level 2 HTML: Node → Element → HTMLElement →
TableRow
readonly HTMLCollection
cells
An array (HTMLCollection) of TableCell objects
representing the cells in this row.
readonly long
rowIndex
The position of this row in the table.
readonly long
sectionRowIndex
The position of this row within its section (i.e.,
within its <thead>,
<tbody>, or <tfoot> element).
In addition to the properties just listed, this interface also
defines the following properties, which correspond to the HTML
attributes of the <tr>
element:
Default horizontal alignment of
cells in this row
Background color of this
row
Alignment character for cells in
this row
Alignment character offset for
cells in this row
Default vertical alignment for
cells in this row
Deletes the specified cell from this row.
Inserts an empty <td> element into this row at
the specified position.
This interface represents a row in an HTML table.
TableRow.deleteCell( ): delete a cell in a table
row — DOM Level 2 HTML
void deleteCell(longindex)
throws DOMException;
The position in the row of the cell to delete.
This method throws a DOMException with a code of INDEX_SIZE_ERR if
index is less than zero or is greater
than or equal to the number of cells in the row.
This method deletes the cell at the specified position in the
table row.
TableRow.insertCell( ): insert a new, empty <td>
element into a table row — DOM Level 2 HTML
HTMLElement insertCell(longindex)
throws DOMException;
The position at which the new cell is to be
inserted.
An TableCell object that represents the newly created and
inserted <td>
element.
This method throws a DOMException with a code of INDEX_SIZE_ERR if
index is less than zero or is greater
than the number of cells in the row.
This method creates a new <td> element and inserts it into the
row at the specified position. The new cell is inserted immediately
before the cell that is currently at the position specified by
index. If
index is equal to the number of cells in
the row, the new cell is appended to the end of the row.
Note that this convenience method inserts <td> data cells only. If you need to
add a header cell into a row, you must create and insert the
<th> element using Document.createElement( ) and Node.insertBefore( ), or related
methods.
TableSection: a header, footer, or body section of a
table — DOM Level 2 HTML: Node → Element → HTMLElement →
TableSection
An array (HTMLCollection) of TableRow objects
representing the rows in this section of the table.
In addition to the rows
property, this interface defines the following properties, which
represent the attributes of the underlying HTML element:
Default horizontal alignment of
cells in this section of the table
Default alignment character for
cells in this section
Default alignment offset for cells
in this section
Default vertical alignment for
cells in this section
Deletes the specified numbered row from this
section.
Inserts an empty row into this section at the specified
position.
This interface represents a <tbody>, <thead>, or <tfoot> section of an HTML table.
The tHead and tFoot properties of a Table are
TableSection objects, and the tBodies property is an array of
TableSection objects.
tHead
tFoot
tBodies
TableSection.deleteRow( ): delete a row within a table
section — DOM Level 2 HTML
The position of the row within this section.
This method throws a DOMException with a code of INDEX_SIZE_ERR if
index is less than zero or is greater
than or equal to the number of rows in this section.
This method deletes the row at the specified position within
this section. Note that for this method,
index specifies a row's position within
its section, not within the entire table.
Table.deleteRow( )
Table.deleteRow( )
TableSection.insertRow( ): insert a new, empty row into
this table section — DOM Level 2 HTML
The position within the section at which the new row
is to be inserted.
A TableRow that represents the newly created and inserted
<tr> element.
This method throws a DOMException with a code of INDEX_SIZE_ERR if
index is less than zero or is greater
than the number of rows in this section.
This method creates a new empty <tr> element and inserts it into
this table section at the specified position. If
index equals the number of rows currently
in the section, the new row is appended to the end of the section.
Otherwise, the new row is inserted immediately before the row that
is currently at the position specified by
index. Note that for this method,
index specifies a row position within a
single table section, not within the entire table.
Table.insertRow( )
Table.insertRow( )
Text: a run of text in an HTML or XML document — DOM Level 1 Core: Node → CharacterData →
Text
CDATASection
splitText( )
Splits this Text node into two at the specified
character position and returns the new Text node.
A Text node represents a run of plain text in an HTML or XML
document. Plain text appears within HTML and XML elements and
attributes, and Text nodes typically appear as children of Element
and Attr nodes. Text nodes inherit from CharacterData, and the
textual content of a Text node is available through the data property inherited from CharacterData
or through the nodeValue property
inherited from Node. Text nodes may be manipulated using any of the
methods inherited from CharacterData or with the splitText( ) method defined by the Text
interface itself. Create a new Text node with Document.createTextNode( ). Text nodes
never have children.
Document.createTextNode( )
See Node.normalize( ) for a
way to remove empty Text nodes and merge adjacent Text nodes from a
subtree of a document.
CharacterData, Node.normalize( )
Text.splitText( ): split a Text node in two — DOM Level 1 Core
Text splitText(unsigned longoffset)
throws DOMException;
The character position at which to split the Text
node.
The Text node that was split from this node.
This method splits a Text node in two at the specified
offset. The original Text node is
modified so that it contains all text content up to, but not
including, the character at position
offset. A new Text node is created to
contain all the characters from (and including) the position
offset to the end of the string. This new
Text node is the return value of the method. Additionally, if the
original Text node has a parentNode, the new node is inserted into
this parent node immediately after the original node.
The CDATASection interface inherits from Text, and this
splitText( ) method can also be
used with CDATASection nodes, in which case the newly created node
is a CDATASection rather than a Text node.
Node.normalize( )
Textarea: a multiline text input area — DOM Level 2 HTML: Node → Element → HTMLElement →
Textarea
The initial content of the text area. When the form is
reset, the text area is restored to this value. Setting this
property changes the displayed text in the text area.
The Form object that represents the <form> element containing this
Textarea, or null if this
element is not inside a form.
The type of this element, for compatibility with Input
objects. This property always has the value "textarea".
The text currently displayed in the text area. The
initial value of this property is the same as the defaultValue property. When the user
types into this element, the value property is updated to match
the user's input. If you set the value property explicitly, the
string you specify is displayed in the Textarea
object. This value
property contains the text that is sent to the server when the
form is submitted.
In addition to these properties, Textarea objects also mirror
HTML attributes with the following properties:
Keyboard shortcut
character
long
cols
long
cols
cols
The width in character
columns
Whether the Textarea is
disabled
Textarea name for form submission
and element access.
boolean
readOnly
boolean
readOnly
readonly
Whether the Textarea is
noneditable
long
rows
long
rows
rows
Height of Textarea in
lines
Position of Textarea in tabbing
order
Selects the entire contents of the text area.
Invoked when the user edits the text displayed in this
element and then moves the keyboard focus elsewhere. This
event handler is not invoked for every keystroke in the
Textarea element but only when the user completes an
edit.
A Textarea is created with standard HTML <textarea> and </textarea> tags:
</textarea>
<form>
...
<textarea
[ name="name" ] // A name that can be used to refer to this element
[ rows="integer" ] // How many lines tall the element is
[ cols="integer" ] // How many characters wide the element is
[ onchange="handler" ] // The onchange( ) event handler
>
plain_text // The initial text; specifies defaultValue
</textarea>
...</form>
plain_text
A Textarea object represents an HTML <textarea> element that creates a
multiline text input field (usually within an HTML form). The
initial contents of the text area are specified between the <textarea> and </textarea> tags. You can query and
set the text with the value
property.
Textarea is a form input element like Input and Select. Like
those objects, it defines form,
name, and type properties.
Form, Input; Chapter 18, Forms and Form Elements
Textarea.blur( ): take keyboard focus away from this
element — DOM Level 2 HTML
Textarea.focus( ): give keyboard focus to this
element — DOM Level 2 HTML
This method transfers keyboard focus to this element so the
user can edit the displayed text without having to first click on
the text area.
Textarea.onchange: event handler invoked when input value
changes — DOM Level 0
The onchange property of a
Textarea refers to an event-handler function that is invoked when
the user changes the value in the text area and then "commits" those
changes by moving the keyboard focus elsewhere.
Note that the onchange
event handler is not invoked when the value property of a Text object is set by
JavaScript. Also note that this handler is intended to process a
complete change to the input value, and therefore it is not invoked
on a keystroke-by-keystroke basis. See HTMLElement.onkeypress for information on
receiving notification of every key press event and Element.addEventListener( ) for another
way to register event handlers.
Element.addEventListener( )
Element.addEventListener(
), HTMLElement.onkeypress, Input.onchange; Chapter 17, Events and Event Handling
Input.onchange
Textarea.select( ): select the text in this
element — DOM Level 2 HTML
void select( );
This method selects all the text displayed by this <textarea> element. In most
browsers, this means that the text is highlighted and that new text
entered by the user replaces the highlighted text instead of being
appended to it.
TextField: see Input
UIEvent: details about user-interface events — DOM Level 2 Events: Event → UIEvent
KeyEvent, MouseEvent
readonly long
detail
A numeric detail about the event. For click, mousedown,
and mouseup events (see MouseEvent), this field is the click
count: 1 for a single-click, 2 for a double-click, 3 for a
triple-click, and so on. For DOMActivate events, this field is
1 for a normal activation or 2 for a "hyperactivation," such
as a double-click or Shift-Enter combination.
readonly Window
view
The window (the "view") in which the event was
generated.
Initializes the properties of a newly created UIEvent
object, including the properties inherited from the Event
interface.
The UIEvent interface is a subinterface of Event and defines the type of
Event object passed to events of type DOMFocusIn, DOMFocusOut, and
DOMActivate. These event types are not commonly used in web
browsers, and what is more important about the UIEvent interface is
that it is the parent interface of MouseEvent.
Event, KeyEvent, MouseEvent; Chapter 17, Events and Event Handling
UIEvent.initUIEvent( ): initialize the properties of a
UIEvent object — DOM Level 2 Events
void initUIEvent(StringtypeArg,
boolean canBubbleArg,
boolean cancelableArg,
Window viewArg,
long detailArg);
The event type.
Whether the event may be canceled with preventDefault( ).
The window in which the event occurred.
The detail property
for the event.
detail
This method initializes the view and detail properties of this UIEvent and also
the type, bubbles, and cancelable properties inherited from the
Event interface. This method may be called only on newly created
UIEvent objects, before they have been passed to Element.dispatchEvent( ).
view
Window: a web browser window or frame — JavaScript 1.0: Object → Global → Window
self
windowwindow.frames[i]
The Window object defines the following properties and also inherits
all the global properties of core JavaScript (see Global in Part III, “Core JavaScript Reference”):
Global
closed
A read-only boolean value that specifies whether the
window has been closed. When a browser window closes, the
Window object that represents it does not simply disappear;
it continues to exist, but its closed property is set to true.
defaultStatus
A read/write string that specifies the default message
that appears in the status line. See Window.defaultStatus.
Window.defaultStatus
A read-only reference to the Document object that
describes the document contained in this window or frame (see
Document for
details).
In Internet Explorer, this property refers to the Event
object that describes the most recent event. This property is
used in the IE event model. In the standard DOM event model,
the Event object is passed as an argument to event-handler
functions. See Event and
Chapter 17, Events and Event Handling for further details.
An array of Window objects, one for each frame or
<iframe> contained
within this window. The frames.length property contains the
number of elements in the frames[] array. Note that frames
referenced by the frames[]
array may themselves contain frames and may have a frames[] array of their own.
frames.length
A read-only reference to the History object of this
window or frame. See History for details.
innerHeight,
innerWidth
Read-only properties that specify the height and width,
in pixels, of the document display area of this window. These
dimensions do not include the size of the menu bar, toolbars,
scrollbars, and so on. These properties are not supported by
IE and return values that include scrollbar size in Firefox.
On those browsers use the clientWidth and
clientHeight properties of
document.documentElement. See the section called “Window Geometry” for details.
clientWidth
clientHeight
document.documentElement
The Location object for this window or frame. This
object specifies the URL of the currently loaded document.
Setting this property to a new URL string causes the browser
to load and display the contents of that URL. See Location for further details.
A string that contains the name of the window. The name
is optionally specified when the window is created with the
open( ) method or with the
name attribute of a
<frame> tag. The name
of a window may be used as the value of a target attribute of an <a> or <form> tag. Using the target attribute in this way
specifies that the hyperlinked document or the results of form
submission should be displayed in the named window or
frame.
A read-only reference to the Navigator object, which
provides version and configuration information about the web
browser. See Navigator for
details.
opener
A read/write reference to the Window object that contained the script that called open( ) to open this browser window.
This property is valid only for Window objects that represent
top-level windows, not those that represent frames. The
opener property is useful
so that a newly created window can refer to properties and
functions defined in the window that created it.
outerHeight,
outerWidth
These read-only integers specify the total height and
width, in pixels, of the browser window. These dimensions
include the height and width of the menu bar, toolbars,
scrollbars, window borders, and so on. These properties are
not supported by IE, and IE offers no alternative
properties.
pageXOffset,
pageYOffset
Read-only integers that specify the number of pixels
that the current document has been scrolled to the right
(pageXOffset) and down
(pageYOffset). These
properties are not supported by Internet Explorer. In IE, use
the scrollLeft and scrollTop properties of document.documentElement or document.body (depending on the
version of IE). See the section called “Window Geometry” for details.
pageXOffset
pageYOffset
scrollLeft
scrollTop
document.body
parent
A read-only reference to the Window object that contains
this window or frame. If this window is a top-level window,
parent refers to the window
itself. If this window is a frame, the parent property refers to the window
or frame that contains it.
A read-only reference to a Screen object that specifies
information about the screen: the number of available pixels
and the number of available colors. See Screen for details.
Screen
screenLeft, screenTop, screenX,
screenY
Read-only integers that specify the coordinates of the
upper-left corner of the window on the screen. IE, Safari, and
Opera support screenLeft
and screenTop, while
Firefox and Safari support screenX and screenY.
screenLeft
screenTop
screenX
screenY
self
A read-only reference to this window itself. This is a
synonym for the window
property.
status
A read/write string that specifies the current contents
of the browser's status line. See Window.status for details.
Window.status
A read-only reference to the top-level window that
contains this window. If this window is a top-level window
itself, the top property
simply contains a reference to the window itself. If this
window is a frame, the top
property refers to the top-level window that contains the
frame. Contrast with the parent property.
The window property
is identical to the self
property; it contains a reference to this window.
The Window object defines the following methods, and
also inherits all the global functions defined by core JavaScript
(see Global in Part III, “Core JavaScript Reference”).
Adds an event-handler function to the set of event
handlers for this window. This method is supported by all
modern browsers except IE. See attachEvent( ) for IE.
alert( )
Displays a simple message in a dialog box.
Adds an event-handler function to the set of handlers
for this window. This is the IE-specific alternative to
addEventListener( ).
Takes keyboard focus away from the top-level browser
window.
clearInterval( )
Cancels periodic execution of code.
clearTimeout( )
Cancels a pending timeout operation.
Closes a window.
confirm( )
Asks a yes-or-no question with a dialog box.
Removes an event-handler function from this window. This
is the IE-specific alternative to removeEventListener( ).
Gives the top-level browser window keyboard focus; this
brings the window to the front on most platforms.
getComputedStyle(
)
Determines the CSS styles that apply to a document
element.
moveBy( )
Moves the window by a relative amount.
Moves the window to an absolute position.
Creates and opens a new window.
print( )
Simulates a click on the browser's Print button.
prompt( )
Asks for simple string input with a dialog box.
Removes an event-handler function from the set of
handlers for this window. This method is implemented by all
modern browsers except IE. IE provides detachEvent( ) instead.
resizeBy( )
Resizes the window by a specified amount.
resizeTo( )
Resizes the window to a specified size.
scrollBy
Scrolls the window by a specified amount.
scrollTo( )
Scrolls the window to a specified position.
setInterval( )
Executes code at periodic intervals.
setTimeout( )
Executes code after a specified amount of time
elapses.
Invoked when the window loses focus.
Invoked when a JavaScript error occurs.
Invoked when the window gains focus.
Invoked when the document (or frameset) is fully
loaded.
onresize
Invoked when the window is resized.
onunload
Invoked when the browser leaves the current document or
frameset.
The Window object represents a browser window or frame. It is
documented in detail in Chapter 14, Scripting Browser Windows. In
client-side JavaScript, the Window serves as the "global object,"
and all expressions are evaluated in the context of the current
Window object. This means that no special syntax is required to
refer to the current window, and you can use the properties of that
window object as if they were global variables. For example, you can
write document rather than
window .document. Similarly, you can use the
methods of the current window object as if they were functions:
e.g., alert( ) instead of
window .alert(
). In addition to the properties and methods listed here,
the Window object also implements all the global properties and
functions defined by core JavaScript. See Global in Part III, “Core JavaScript Reference” for details.
.document
.alert(
)
The Window object has window and self properties that refer to the window
object itself. You can use these to make the current window
reference explicit rather than implicit. In addition to these two
properties, the parent and
top properties and the frames[] array refer to other Window objects related to the
current one.
To refer to a frame within a window, use:
frames[i] // Frames of current window
self.frames[i] // Frames of current window
w.frames[i] // Frames of specified window w
w
To refer to the parent window (or frame) of a frame,
use:
parent // Parent of current window
self.parent // Parent of current windoww.parent // Parent of specified window w
To refer to the top-level browser window from any frame
contained (or nested multiple levels deep) within it, use:
top // Top window of current frame
self.top // Top window of current framef.top // Top window of specified frame f
New top-level browser windows are created with the Window.open( ) method. When you call this
method, save the return value of the open(
) call in a variable and use that variable to reference
the new window. The opener
property of the new window is a reference back to the window that
opened it.
Window.open( )
In general, the methods of the Window object manipulate the
browser window or frame in some way. The alert( ), confirm( ), and prompt( ) methods are notable: they
interact with the user through simple dialog boxes.
See Chapter 14, Scripting Browser Windows for an in-depth
overview of the Window object, and see the individual reference
pages for complete details on Window methods and event
handlers.
Document; Global in Part III, “Core JavaScript Reference” ; Chapter 14, Scripting Browser Windows
Window.addEventListener( ): see Element.addEventListener(
)
Window.alert( ): display a message in a dialog
box — JavaScript 1.0:
window.alert(message)
The plain-text (not HTML) string to display in a
dialog box popped up over
window.
The alert( ) method
displays the specified message to the
user in a dialog box. The dialog box contains an OK button the user can click to dismiss it.
The dialog box is typically modal, and the call to alert( ) typically blocks until the dialog
is dismissed.
Perhaps the most common use of the alert( ) method is to display error
messages when the user's input to some form element is invalid in
some way. The alert dialog box can inform the user of the problem
and explain what needs to be corrected to avoid the problem in the
future.
The appearance of the alert(
) dialog box is platform-dependent, but it generally
contains graphics that indicate an error, warning, or alert message
of some kind. While alert( ) can
display any desired message, the alert graphics of the dialog box
mean that this method is not appropriate for simple informational
messages like "Welcome to my blog" or "You are the 177th visitor
alert(
)
Note that the message displayed in
the dialog box is a string of plain text, not formatted HTML. You
can use the newline character "\n" in your strings to break your
message across multiple lines. You can also do some rudimentary
formatting using spaces and can approximate horizontal rules with
underscore characters, but the results depend greatly on the font
used in the dialog box and thus are system-dependent.
Window.confirm( ),
Window.prompt( )
Window.confirm( )
Window.prompt( )
Window.attachEvent( ): see Element.attachEvent( )
Window.blur( ): remove keyboard focus from a top-level
window — JavaScript 1.1:
window.blur( )
The blur( ) method removes
keyboard focus from the top-level browser window specified by the
Window object. It is unspecified which window gains keyboard focus
as a result. In some browsers and/or platforms, this method may have
no effect.
Window.focus( )
Window.focus( )
Window.clearInterval( ): stop periodically executing
code — JavaScript 1.2:
window.clearInterval(intervalId)
intervalId
The value returned by the corresponding call to
setInterval( ).
clearInterval( )
stops the repeated execution of code that was started by a call to
setInterval( ).
intervalId must be the value that was
returned by a call to setInterval(
).
setInterval(
)
Window.setInterval(
)
Window.setInterval(
)
Window.clearTimeout( ): cancel deferred execution — JavaScript 1.0:
window.clearTimeout(timeoutId)
timeoutId
A value returned by setTimeout( ) that identifies the
timeout to be canceled.
clearTimeout( ) cancels the
execution of code that has been deferred with the setTimeout( ) method. The
timeoutId argument is a value returned by
the call to setTimeout( ) and
identifies which deferred code to cancel.
Window.setTimeout( )
Window.setTimeout( )
Window.close( ): close a browser window — JavaScript 1.0:
window.close( )
The close( ) method closes
the top-level browser window specified by
window. A window can close itself by
calling self.close( ) or simply
close( ). Only windows opened by
JavaScript can be closed by JavaScript. This prevents malicious
scripts from causing the user's browser to exit.
self.close( )
Window.open( ), the
closed and opener properties of Window
Window.confirm( ): ask a yes-or-no question — JavaScript 1.0:
window.confirm(question)
question
The plain-text (not HTML) string to be displayed in
the dialog box. It should generally express a question you
want the user to answer.
true if the user clicks
the OK button; false if the user clicks the Cancel button.
The confirm( ) method
displays the specified question in a
dialog box. The dialog box contains OK and Cancel buttons that the user can use to
answer the question. If the user clicks the OK button, confirm( ) returns true. If the user clicks Cancel, confirm(
) returns false.
confirm(
)
The dialog box that is displayed by the confirm(
), and subsequent statements are not executed until the
user responds to the dialog box.
There is no way to change the labels that appear in the
buttons of the dialog box (to make them read Yes and No, for example). Therefore, you should
take care to phrase your question or message so that OK and Cancel are suitable responses.
Window.alert( ), Window.prompt( )
Window.defaultStatus: the default status line
text — JavaScript 1.0:
window.defaultStatus
defaultStatus is a
read/write string property that specifies the default text that
appears in the window's status line. Web browsers typically use the
status line to display the browser's progress while loading a file
and to display the destination of hypertext links that the mouse is
over. While it is not displaying any of these transient messages,
the status line is, by default, blank. However, you can set the
defaultStatus property to specify
a default message to be displayed when the status line is not
otherwise in use, and you can read the defaultStatus property to determine what
the default message is. The text you specify may be temporarily
overwritten with other messages, such as those that are displayed
when the user moves the mouse over a hypertext link, but the
defaultStatus message is always
redisplayed when the transient message is erased.
The defaultStatus property
has been disabled in some modern browsers. See Window.status for details.
Window.status
Window.detachEvent( ): see Element.detachEvent( )
Window.focus( ): give keyboard focus to a window — JavaScript 1.1:
window.focus( )
The focus( ) method gives
keyboard focus to the browser window specified by the Window
object.
On most platforms, a top-level window is brought forward to
the top of the window stack so that it becomes visible when it is
given focus.
Window.blur( )
Window.blur( )
Window.getComputedStyle( ): retrieve the CSS styles used to
render an element — DOM Level 2 CSS:
CSS2Properties getComputedStyle(Elementelt,
String pseudoElt);
elt
pseudoElt
The document element whose style information is
desired.
The CSS pseudoelement string, such as ":before" or
":first-line", or null if
there is none.
A read-only CSS2Properties object that represents
the style attributes and values used to render the specified
element in this window. Any length values queried from this object
are always expressed as pixel or absolute values, not relative or
percentage values.
An element in a document may obtain style information from an
inline style attribute and from
any number of style sheets in the stylesheet "cascade." Before the
element can actually be displayed in a view, its style information
must be extracted from the cascade, and styles specified with
relative units (such as percentages or "ems") must be "computed" to
convert to absolute units.
This method returns a read-only CSS2Properties object that
represents those cascaded and computed styles. The DOM specification requires that any styles
representing lengths use absolute units such as inches or
millimeters. In practice, pixel values are commonly returned
instead, although there is no guarantee that an implementation will
always do this.
Contrast getComputedStyle(
) with the style
property of an HTMLElement, which gives you access only to the
inline styles of an element, in whatever units they were specified,
and tells you nothing about stylesheet styles that apply to the
element.
getComputedStyle(
)
In Internet Explorer, similar functionality is available
through the nonstandard currentStyle property of each HTMLElement
object.
currentStyle
CSS2Properties, HTMLElement
Window.moveBy( ): move a window to a relative
position — JavaScript 1.2:
window.moveBy(dx, dy)
The number of pixels to move the window to the
right.
The number of pixels to move the window down.
moveBy( ) moves the
window to the relative position specified
by dx and dy.
See the security and usability considerations described under
Window.moveTo( ).
Window.moveTo( )
Window.moveTo( ): move a window to an absolute
position — JavaScript 1.2:
window.moveTo(x, y)
The X coordinate of the new window position.
The Y coordinate of the new window position.
moveTo( ) moves the
window so its upper-left corner is at the
position specified by x and
y. For security resasons, browsers may
restrict this method so it cannot move a window offscreen. It is
usually a bad idea to move a user's browser window unless he
explicitly request it. Scripts should typically use this method only
on windows that they created themselves with Window.open( ).
Window.onblur: event handler invoked when the window loses
keyboard focus — JavaScript 1.1:
The onblur property of a
Window specifies an event-handler function that is invoked when the
window loses keyboard focus.
The initial value of this property is a function that contains
the semicolon-separated JavaScript statements specified by the
onblur attribute of the <body> or <frameset> tags.
If your web page has animation or other dynamic effects, you
can use the onblur event handler
to stop the animation when the window doesn't have the input focus.
In theory, if the window doesn't have the focus, the user probably
can't see it or isn't paying attention to it.
Window.blur( ), Window.focus( ), Window.onfocus; Chapter 17, Events and Event Handling
Window.onerror: error handler invoked when a JavaScript
error occurs — JavaScript 1.1:
You register an onerror handler like this:
window.onerror=handler-func
handler-func
The browser invokes the handler like this:
window.onerror(message, url, line)
message, url, line
A string that specifies the error message for the
error that occurred.
A string that specifies the URL of the document in
which the error occurred.
line
A number that specifies the line number at which the
error occurred.
true if the handler has
handled the error and JavaScript should take no further action;
false if JavaScript should post
the default error message dialog box for this error.
The onerror property of the
Window object specifies an error-handler function that is invoked
when a JavaScript error occurs and is not caught with a catch statement. You can customize error
handling by providing your own onerror error handler.
catch
You define an onerror
handler for a window by setting the onerror property of a Window object to an
appropriate function. Note that onerror is an error handler and differs
from event handlers. In particular, an error handler cannot be
defined with an onerror attribute
on the <body> tag.
When the onerror handler is
invoked, it is passed three arguments: a string specifying the error
message, a string specifying the URL of the document in which the
error occurred, and a number that specifies the line number at which
the error occurred. An error handling function may do anything it
wants with these arguments: it may display its own error dialog box
or log the error in some way, for example. When the error-handling
function is done, it should return true if it has completely handled the
error and wants the browser to take no further action, or false if it has merely noted or logged the
error in some fashion and still wants the browser to handle the
error.
Window.onfocus: event handler invoked when a window is
given focus — JavaScript 1.1:
The onfocus property of a
Window specifies an event-handler function that is invoked when the
window is given keyboard focus.
The initial value of this property is a function that contains
the semicolon-separated JavaScript statements specified by the
onfocus attribute of the <body> or <frameset> tags.
If your web page has animation or other dynamic
effects, you might use the onfocus event handler to start the
animation and the onblur handler
to stop it, so it runs only when the user is paying attention to the
window.
Window.blur( ), Window.focus( ), Window.onblur; Chapter 17, Events and Event Handling
Window.onload: event handler invoked when a document
finishes loading — JavaScript 1.0:
The onload property of a
Window specifies an event handler function that is invoked when a
document or frameset is completely loaded into its window or
frame.
The initial value of this property is a function that contains
the semicolon-separated JavaScript statements specified by the
onload attribute of the <body> or <frameset> tags.
When the onload event
handler is invoked, you can be certain that the document has fully
loaded, and therefore that all scripts within the document have
executed, all functions within scripts are defined, and all document
elements have been parsed and are available through the Document
object.
You can use Window.addEventListener(
) or Window.attachEvent(
) to register multiple event-handler functions for onload
events.
Window.addEventListener(
)
Window.attachEvent(
)
Window.onunload; the section called “Manipulating the Document During Loading”, "Manipulating the Document
During Loading," Example 17-7, “Portable event registration for onload event handlers”, Chapter 17, Events and Event Handling
Window.onunload
Window.onresize: event handler invoked when a window is
resized — JavaScript 1.2:
Function onresize
The onresize property of
the Window object specifies an event-handler function that is invoked
when the user changes the size of the window or frame.
The initial value of this property is a function that contains
the JavaScript statements specified by the onresize attribute of the HTML <body> or <frameset> tag that defined the
window.
Window.onunload: the handler invoked when the browser
leaves a page — DOM Level 0:
Function onunload
The onunload property of a
Window specifies an event-handler function that is invoked when the
browser "unloads" a document in preparation for loading a new
one.
The initial value of this property is a function that contains
the semicolon-separated JavaScript statements specified by the
onunload attribute of the
<body> or <frameset> tags.
The onunload event handler
enables you to perform any necessary cleanup of the browser state
before a new document is loaded.
The onunload( ) handler is
invoked when the user has instructed the browser to leave the
current page and move somewhere else. Therefore, it is usually
inappropriate to delay the loading of the desired new page by
popping up dialog boxes (with Window.confirm( ) or Window.prompt( ), for example) from an
onunload event handler.
onunload( )
Window.onload; Chapter 17, Events and Event Handling
Window.open( ): open a new browser window or locate a named
window — JavaScript 1.0:
window.open(url, name, features, replace)
features
replace
An optional string that specifies the URL to be
displayed in the new window. If this argument is omitted, or
if the empty string is specified, the new window does not
display a document.
An optional string of alphanumeric and underscore
characters that specifies a name for the new window. This
name can be used as the value of the target attribute of <a> and <form> HTML tags. If this
argument names a window that already exists, the open( ) method does not create a
new window, but simply returns a reference to the named
window. In this case, the
features argument is
ignored.
A string that specifies which features of a standard
browser window are to appear in the new window. The format
of this string is specified in the Window Features section.
This argument is optional; if it is not specified, the new
window has all the standard features.
An optional boolean argument that specifies whether
the URL loaded into the window should create a new entry in
the window's browsing history or replace the current entry
in the browsing history. If this argument is true, no new history entry is
created. Note that this argument is intended for use when
changing the contents of an existing named window.
A reference to a Window object, which may be a newly
created or an already existing one, depending on the
name argument.
The open( ) method looks up
an existing window or opens a new browser window. If the
name argument specifies the name of an
existing window, a reference to that window is returned. The
returned window displays the URL specified by
url, but the
features argument is ignored. This is the only way in
JavaScript to obtain a reference to a window that is known only by
name.
If the name argument is not
specified, or if no window with that name already exists, the
open( ) method creates a new
browser window. The created window displays the URL specified by
url and has the name specified by
name and the size and controls specified
by features (the format of this argument
is described in the next section). If url
is the empty string, open( )
opens an empty window.
The name argument specifies a name
for the new window. This name may contain only alphanumeric
characters and the underscore character. It may be used as the value
of the target attribute of an
<a> or <form> tag in HTML to force
documents to be displayed in the window.
When you use Window.open( )
to load a new document into an existing named window, you can pass
the replace argument to specify whether
the new document has its own entry in the window's browsing history
or whether it replaces the history entry of the current document. If
replace is true, the new document replaces the old.
If this argument is false or is
not specified, the new document has its own entry in the Window's
browsing history. This argument provides functionality much like
that of the Location.replace( )
method.
Location.replace( )
Don't confuse Window.open(
) with Document.open(
); the two methods perform very different functions. For
clarity in your code, you may want to use Window.open( ) instead of open( ). In event handlers defined as HTML
attributes, open( ) is usually
interpreted as Document.open( ),
so in this case, you must use Window.open(
).
Window.open(
)
Document.open(
)
Document.open( )
The features argument is a
comma-separated list of features that appears in the window. If this
optional argument is empty or not specified, all features are
present in the window. On the other hand, if
features specifies any one feature, any
features that do not appear in the list do not appear in the window.
The string should not contain any spaces or other whitespace. Each
element in the list has the format:
feature[=value]
For most features, the value is
yes or no. For these features, the equals sign
and the value may be omitted; if the
feature appears, yes is assumed,
and if it doesn't, no is assumed.
For the width and height features,
value is required and must specify a size
in pixels.
yes
no
Here are the commonly supported features and their
meanings:
Specifies the height, in pixels, of the window's
document display area.
The X coordinate, in pixels, of the window.
The input field for entering URLs directly into the
browser.
menubar
The menu bar.
resizable
If this feature is not present or is set to no, the window does not have resize
handles around its border. (Depending on the platform, the
user may still have ways to resize the window.) Note that a
common bug is to misspell this feature as "resizeable," with
an extra "e."
scrollbars
Enables horizontal and vertical scrollbars when they are
necessary.
The status line.
toolbar
The browser toolbar, with Back and Forward buttons, etc.
The Y coordinate, in pixels, of the window.
Specifies the width, in pixels, of the window's document
display area.
Location.replace(
), Window.close( ), the
closed and opener properties of Window
Location.replace(
)
Window.close( )
Window.print( ): print the document — JavaScript 1.5:
window.print( )
Calling print( ) causes the
browser to behave as if the user had clicked the browser's Print button. Usually, this brings up a
dialog box that enables the user to cancel or customize the print
request.
Window.prompt( ): get user input with a dialog
box — JavaScript 1.0:
window.prompt(message, default)
default
The plain-text (not HTML) string to be displayed in
the dialog box. It should ask the user to enter the
information you want.
A string that is displayed as the default input in the
dialog box. Pass the empty string ("") to make prompt( ) display an empty input
box.
The string entered by the user, the empty string if the user
did not enter a string, or null
if the user clicked Cancel.
The prompt( ) method
displays the specified message in a
dialog box that also contains a text input field and OK and Cancel buttons. Platform-dependent graphics
in the dialog box help indicate to the user that her input is
desired.
If the user clicks the Cancel button, prompt( ) returns null. If the user clicks the OK button, prompt(
) returns the text currently displayed in the input
field.
prompt(
)
The dialog box that is displayed by the prompt(
), and subsequent statements are not executed until the
user responds to the dialog box.
Window.alert( ), Window.confirm( )
Window.removeEventListener( ): see
Element.removeEventListener( )
Window.resizeBy( ): resize a window by a relative
amount — JavaScript 1.2:
window.resizeBy(dw, dh)
dw
dh
The number of pixels by which to increase the width of
the window.
The number of pixels by which to increase the height
of the window.
resizeBy( ) resizes
window by the relative amounts specified
by dh and dw.
See the security and usability considerations discussed under
Window.resizeTo( ).
Window.resizeTo( )
Window.resizeTo( ): resize a window — JavaScript 1.2:
window.resizeTo(width, height)
The desired width for the window.
The desired height for the window.
resizeTo( ) resizes
window so it is
width pixels wide and
height pixels high. For security reasons,
the browser may restrict this method to prevent scripts from making
windows very small. For usability reasons, it is almost always a bad
idea to change the size of a user's window. If a script created a
window, the script can resize it, but it is bad form for a script to
resize the window that it is loaded into.
Window.scrollBy( ): scroll the document by a relative
amount — JavaScript 1.2:
window.scrollBy(dx, dy)
The number of pixels by which to scroll the document
to the right.
The number of pixels by which to scroll the document
down.
scrollBy( ) scrolls the
document displayed in window by the relative amounts specified by
dx and
dy.
scrollBy( )
Window.scrollTo( ): scroll the document — JavaScript 1.2:
window.scrollTo(x, y)
The document X coordinate that is to appear at the
left edge of the window's document display area.
The document Y coordinate that is to appear at the top
of the window's document display area.
scrollTo( ) scrolls the
document displayed within window so the
point in the document specified by the x
and y coordinates is displayed in the
upper-left corner, if possible.
Window.setInterval( ): periodically execute specified
code — JavaScript 1.2:
window.setInterval(code, interval)
interval
A function to be periodically invoked or a string of
JavaScript code to be periodically evaluated. If this string
contains multiple statements, they must be separated from
each other by semicolons. In IE 4 (but not later versions),
this argument must be a string.
The interval, in milliseconds, between invocations or
evaluations of code.
A value that can be passed to Window.clearInterval( ) to cancel the
periodic execution of code.
Window.clearInterval( )
setInterval( ) repeatedly
invokes or evaluates the function or string specified by
code, at intervals of
interval milliseconds.
setInterval( ) returns a
value that can later be passed to Window.clearInterval( ) to cancel the
execution of code.
setInterval( ) is related
to setTimeout( ). Use setTimeout( ) when you want to defer the
execution of code but do not want it to be repeatedly executed. See
Window.setTimeout( ) for a
discussion of the execution context of
code.
Window.clearInterval(
), Window.setTimeout(
)
Window.clearInterval(
)
Window.setTimeout(
)
Window.setTimeout( ): defer execution of code — JavaScript 1.0:
window.setTimeout(code, delay)
delay
A function to be invoked, or a string of JavaScript
code to be evaluated after the
delay has elapsed. If this
argument is a string, multiple statements must be separated
from each other with semicolons. In IE 4, this argument must
be a string; the function form of the method is not
supported in that browser.
The amount of time, in milliseconds, before the
code should be executed.
An opaque value ("timeout id") that can be passed to the
clearTimeout( ) method to
cancel the execution of code.
The setTimeout( ) method
defers the invocation of a JavaScript function or the evaluation of
a string of JavaScript code for delay
milliseconds. Note that setTimeout(
) executes code only once. If
you want multiple invocations, use setInterval( ) or have the
code itself call setTimeout( ) again.
setTimeout(
)
When code is executed, it is
executed in the context of the Window object. If
code is a function, the Window object is
the value of the this keyword. If
code is a string, it is evaluated in the
global scope with the Window object as the only object on the scope
chain. This is true even if the call to setTimeout( ) occurred within a function
with a longer scope chain.
Window.clearTimeout( ),
Window.setInterval( )
Window.clearTimeout( )
Window.setInterval( )
Window.status: specify a transient status-line
message — JavaScript 1.0:
String status
status is a
read/write string property that specifies a transient message to
appear in the window's status line. The message generally appears
only for a limited amount of time, until it is overwritten by
another message or until the user moves the mouse to some other area
of the window, for example. When a message specified with status is erased, the status line returns
to its default blank state or to the default message specified by
the defaultStatus
property.
At the time of this writing, many browsers have disabled
scripting of their status lines. This is a security measure to
protect against phishing attacks that hide the true destination of
hyperlinks.
Window.defaultStatus
XMLHttpRequest: An HTTP request and response — Firefox 1.0, Internet Explorer 5.0, Safari 1.2, Opera
7.60: Object → XMLHttpRequest
new XMLHttpRequest( ) // All browsers except IE 5 and IE 6
new ActiveXObject("Msxml2.XMLHTTP") // IE
new ActiveXObject("Microsoft.XMLHTTP") // IE with older system libraries
readonly short
readyState
The state of the HTTP request. The value of this
property begins at 0 when an XMLHttpRequest is first created
and increases to 4 when the complete HTTP response has been
received. Each of the five states has an informal name
associated with it, and the table below lists the states,
their names, and their meanings:
State
Name
0
0
Uninitialized
This is the initial state.
The XMLHttpRequest object has just been created or has been reset
with the abort( )
method.
abort( )
Open
The open( ) method has been
called, but send( )
has not. The request has not yet been
sent.
send( )
Sent
The send( ) method has been
called, and the HTTP request has been transmitted to
the web server. No response has been received
yet.
Receiving
All response headers have
been received. The response body is being received but
is not complete.
4
4
Loaded
The HTTP response has been
fully received.
The value of readyState never decreases, unless
abort( ) or open( ) are called on a request that
is already in progress. Every time the value of this property
increases, the onreadystatechange event handler is
triggered.
readyState
onreadystatechange
readonly String
responseText
The body of the response (not including headers) that
has been received from the server so far, or the empty string
if no data has been received yet. If readyState is less than 3, this
property is the empty string. When readyState is 3, this property
returns whatever portion of the response has been received so
far. If readyState is 4,
this property holds the complete body of the response.
If the response includes headers that specify a
character encoding for the body, that encoding is used.
Otherwise, the Unicode UTF-8 encoding is assumed.
readonly Document
responseXML
The response to the request, parsed as XML and returned
as a Document object. This property will be null unless all three of the
following conditions are true:
readyState is
4.
The response includes a Content-Type header of
"text/xml", "application/xml", or anything ending with
"+xml" to indicate that the response is an XML
document.
Content-Type
The response body consists of well-formed XML markup
that can be parsed without errors.
readonly short
status
The HTTP status code returned by the server, such as 200
for success and 404 for "Not Found" errors. Reading this
property when readyState is
less than 3 causes an exception.
readonly String
statusText
This property specifies the HTTP status code of the
request by name rather than by number. That is, it is "OK"
when status is 200 and "Not
Found" when status is 404.
As with the status
property, reading this property when readyState is less than 3 causes an
exception.
Cancels the current request, closing connections and
stopping any pending network activity.
getAllResponseHeaders(
)
Returns the HTTP response headers as an unparsed
string.
getResponseHeader(
)
Returns the value of a named HTTP response header
Initializes HTTP request parameters, such as the URL and
HTTP method, but does not send the request.
Sends the HTTP request, using parameters passed to the
open( ) method and an
optional request body passed to this method.
setRequestHeader(
)
Sets or adds an HTTP request header to an open but
unsent request.
Event-handler function invoked each time the readyState property changes. It may
also be invoked multiple times while readyState is 3.
The XMLHttpRequest object allows client-side JavaScript to
issue HTTP requests and receive responses (which need not be XML)
from web servers. XMLHttpRequest is the subject of Chapter 20, Scripting HTTP, and that chapter contains many
examples of its use.
XMLHttpRequest is quite portable and well supported by all
modern browsers. The only browser dependency involves the creation
of an XMLHttpRequest object. In Internet Explorer 5 and 6, you must
use the IE-specific ActiveXObject(
) constructor, as shown in the Constructor section
earlier.
ActiveXObject(
)
Once an XMLHttpRequest object has been created, you typically
use it like this:
Call open( ) to specify
the URL and method (usually "GET" or "POST") for the request.
When you call open( ), you
also specify whether you want the request to be synchronous or
asynchronous.
If you specified an asynchronous request, set the onreadystatechange property to the
function that will be notified of the progress of the
request.
Call setRequestHeader(
), if needed, to specify additional request
parameters.
Call send( ) to send
the request to the web server. If it is a POST request, you may
also pass a request body to this method. If you specify a
synchronous request in your call to open( ), the send( ) method blocks until the
response is complete and readyState is 4. Otherwise, your
onreadystatechange
event-handler function must wait until the readyState property reaches 4 (or at
least 3).
Once send( ) has
returned for synchronous requests, or readyState has reached 4 for
asynchronous requests, you can use the server's response. First,
check the status code to
ensure that the request was successful. If so, use getResponseHeader( ) or getResponseHeaders( ) to retrieve
values from the response header, and use the responseText or responseXML properties to obtain the
response body.
getResponseHeader( )
getResponseHeaders( )
responseText
The XMLHttpRequest object has not been standardized, but work
on a standard has begun at the W3C at the time of this writing. This
documentation is based on working drafts of the standard. Current
XMLHttpRequest implementations are quite interoperable but differ in
minor ways from the standard. An implementation might return
null where the standard requires
the empty string, for example, or might set readyState to 3 without guaranteeing that
all response headers are available.
Chapter 20, Scripting HTTP
XMLHttpRequest.abort( ): cancel an HTTP request
void abort( )
This method resets the XMLHttpRequest object to a readyState of 0 and aborts any pending
network activity. You might call this method, for example, if a
request has taken too long, and the response is no longer
necessary.
XMLHttpRequest.getAllResponseHeaders( ): return unparsed
HTTP response headers
String getAllResponseHeaders( )
If readyState is less
than 3, this method returns null. Otherwise, it returns all HTTP
response headers (but not the status line) sent by the server. The
headers are returned as a single string, with one header per line.
Lines are delimited by "\r\n" line terminators.
XMLHttpRequest.getResponseHeader( ): get the value of a
named HTTP response header
String getResponseHeader(Stringheader)
header
The name of the HTTP response header whose value is to
be returned. You may specify this header name using any
case: the comparison to response headers is
case-insensitive.
The value of the named HTTP response header, or the empty
string if no such header was received or if readyState is less than 3. If more than
one header with the specified name is received, the values of
those headers are concatenated and returned, using a comma and
space as the delimiter.
XMLHttpRequest.onreadystatechange: event handler function
invoked when readyState changes
Function onreadystatechange
This property specifies an event-handler function that is
invoked each time the readyState
property changes. It may also be invoked (but this is not required)
multiple times while readyState
is 3 to provide notification of download progress.
An onreadystatechange
handler typically checks the readyState of the XMLHttpRequest
object to see if it has reached 4. If so, it does something
with the responseText or responseXML properties.
It is unspecified whether any arguments will be passed to the
function. In particular, there is no standard way for the
event-handler function to get a reference to the XMLHttpRequest
object it is registered on. This means that it is not possible to
write a generic handler function that can be used for multiple
requests.
The XMLHttpRequest object is supposed to follow the DOM event
model and implement an addEventListener(
) method for registering handlers for readystatechange
events. (See Event.addEventListener(
), for example.) Since IE does not support the DOM event
model, and since it is rare to require more than one event handler
per request, it is safer to simply assign a single handler function
to onreadystatechange.
addEventListener(
)
Event.addEventListener(
)
XMLHttpRequest.open( ): initialize HTTP request
parameters
void open(Stringmethod,
String url,
boolean async,
String username, String password)
async
username
The HTTP method to be used for the request. Reliably
implemented values include GET, POST, and HEAD.
Implementations may also support methods as well.
The URL that is the subject of the request. Most
browsers impose a same-origin security policy (see the section called “The Same-Origin Policy”) and require that this
URL have the same hostname and port as the document that
contains the script. Relative URLs are resolved in the
normal way, using the URL of the document that contains the
script.
Whether the request should be performed asynchronously
or not. If this argument is false, the request is synchronous,
and a subsequent call to send(
) will block until the response is fully received.
If this argument is true
or is omitted, the request is asynchronous, and an onreadystatechange event handler
is typically required.
send(
)
username, password
These optional arguments specify authorization
credentials for use with URLs that require authorization. If
specified, they override any credentials specified in the
URL itself.
This method initializes request parameters for later
use by the send( ) method. It
sets readyState to 1; deletes any
previously specified request headers and previously received
response headers; and sets the responseText, responseXML, status, and statusText properties to their default
values. It is safe to call this method when readyState is 0 (when the XMLHttpRequest
object is just created, or after a call to abort( )) and when readyState is 4 (after a response has been
received). The behavior of open(
) is unspecified when it is called from any other
state.
statusText
Other than storing request parameters for use by send( ) and resetting the XMLHttpRequest
object for reuse, the open( )
method has no other behavior. In particular, note that
implementations do not typically open a network connection to the
web server when this method is called.
XMLHttpRequest.send( );
Chapter 20, Scripting HTTP
XMLHttpRequest.send( )
XMLHttpRequest.send( ): send an HTTP request
void send(Objectbody)
If the HTTP method specified by the call to open( ) is "POST" or "PUT", this
argument specifies the body of the request, as a string or
Document object, or null
if no body is necessary. For any other method, this argument
is unused and should be null. (Some implementations do not
allow you to omit this argument.)
This method causes an HTTP request to be issued. If there has
been no previous call to open( ),
or, more generally, if readyState
is not 1, send( ) throws an
exception. Otherwise, it issues an HTTP request that consists
of:
The HTTP method, URL, and authorization credentials (if
any) specified in the previous call to open( )
The request headers, if any, specified by previous calls
to setRequestHeader( )
setRequestHeader( )
The body argument passed to
this method
Once the request has been issued, send( ) sets readyState to 2 and triggers the onreadystatechange event handler.
If the async argument to the
previous call to open( ) was
false, this method blocks and
does not return until readyState
is 4 and the server's response has been fully received. Otherwise,
if the async argument is true or if that argument is omitted,
send( ) returns immediately, and
the server's response is processed, as described next, on a
background thread.
If the server responds with an HTTP redirect, the send( ) method or the background thread
follow the redirect automatically. When all HTTP response headers
have been received, send( ) or
the background thread sets readyState to 3 and triggers the onreadystatechange event handler. If the
response is long, send( ) or the
background thread may trigger the onreadystatechange more than once while in
state 3: this can serve as a download progress indicator. Finally,
when the response is complete, send(
) or the background thread sets readyState to 4 and triggers the event
handler one last time.
send(
)
XMLHttpRequest.open(
); Chapter 20, Scripting HTTP
XMLHttpRequest.open(
)
XMLHttpRequest.setRequestHeader( ): add a HTTP request
header to the request
void setRequestHeader(Stringname, String value)
The name of the header to be set. This argument should
not contain spaces, colons, linefeeds, or newlines.
The value for the header. This argument should not
contain linefeeds or newlines.
setRequestHeader( )
specifies an HTTP request header that should be included in the
request issued by a subsequent call to send( ). This method may be called only
when readyState is 1—i.e., after
a call to open( ) but before a
call to send( ).
If a header with the specified name
has already been specified, the new value for that header is the
previously specified value, plus a comma, a space, and the
value specified in this call.
If the call to open( )
specifies authorization credentials, XMLHttpRequest automatically
sends an appropriate Authorization request header. You can
append to this header with setRequestHeader( ), however. Similarly,
if the web browser has stored cookies associated with the URL passed
to open( ), appropriate Cookie or Cookie2 headers are automatically included
with the request. You can append additional cookies to these headers
by calling setRequestHeader( ).
XMLHttpRequest may also provide a default value for the User-Agent header. If it does this, any
value you specify for that header is appended to the default
value.
Authorization
Cookie
Cookie2
User-Agent
Some request headers are automatically set by the
XMLHttpRequest for conformance to the HTTP protocol and may not be
set with this method. These include proxy-related headers as well as
the following:
Host
Connection
Keep-Alive
Accept-Charset
Accept-Encoding
If-None-Match
If-Range
XMLHttpRequest.getResponseHeader( )
XMLHttpRequest.getResponseHeader( )
XMLSerializer: serializes XML documents and nodes — Firefox 1.0, Safari 2.01, Opera 7.60: Object →
XMLSerializer
new XMLSerializer( )
serializeToString(
)
This instance method performs the actual
serialization.
An XMLSerializer object
enables you to convert or "serialize" an XML Document or Node object
to a string of unparsed XML markup. To use an XMLSerializer,
instantiate one with the no-argument constructor, and then call its
serializeToString( )
method:
serializeToString( )
var text = (new XMLSerializer( )).serializeToString(element);
Internet Explorer does not support the XMLSerializer
object. Instead, it makes XML text available through the
xml property of the Node
object.
xml
DOMParser, Node; Chapter 21, JavaScript and XML
XMLSerializer.serializeToString( ): convert an XML document
or node to a string
String serializeToString(Nodenode)
node
The XML node to be serialized. This may be a Document
object or any Element within the document.
A string of XML markup that represents the serialized form
of the specified node and all its
descendants.
XPathExpression: a compiled XPath query — Firefox 1.0, Safari 2.01, Opera 9: Object →
XPathExpression
Evaluates this expression for a specified context
node.
An XPathExpression object is a compiled representation of an XPath query,
returned by Document.createExpression(
). Evaluate the expression against a particular document
node with the evaluate( ) method.
If you need to evaluate an XPath query only once, you can use
Document.evaluate( ), which
compiles and evaluates the expression in a single step.
Internet Explorer does not support the XPathExpression object.
For IE-specific XPath methods, see Node.selectNodes( ) and Node.selectSingleNode( ).
Document.evaluate(
)
XPathExpression.evaluate( ): evaluate a compiled XPath
query
XPathResult evaluate(NodecontextNode,
short type,
XPathResult result)
The node (or document) against which the query should
be evaluated.
The desired result type. This argument should be one
of the constants defined by XPathResult.
An XPathResult object into which the results of the query should be
stored, or null to have
the evaluate( ) method
create and return a new XPathResult object.
An XPathResult that hold the results of the query. This is
either the object passed as the result
argument or a newly created XPathResult object if
result was null.
This method evaluates the XPathExpression against a specified
node or document and returns the results in an XPathResult object.
See XPathResult for details on
how to extract values from the returned object.
Document.evaluate( ),
Node.selectNodes( ), XPathResult; Chapter 21, JavaScript and XML
XPathResult: the result of an XPath query — Firefox 1.0; Safari 2.01; Opera 9: Object →
XPathResult
The following constants define the possible types an XPath
query can return. The resultType
property of an XPathResult object holds one of these values to
specify which kind of result the object holds. These constants are
also used with Document.evaluate(
) and XPathExpression.evaluate(
) methods to specify the desired result type. The
constants and their meanings are as follows:
Document.evaluate(
)
XPathExpression.evaluate(
)
ANY_TYPE
Passes this value to Document.evaluate( ) or XPathExpression.evaluate( ) to
specify that any type of result is acceptable. The resultType property is never set to
this value.
XPathExpression.evaluate( )
NUMBER_TYPE
numberValue holds the
result.
numberValue
STRING_TYPE
stringValue holds the
result.
stringValue
BOOLEAN_TYPE
booleanValue holds
the result.
booleanValue
UNORDERED_NODE_ITERATOR_TYPE
The result is an unordered set of nodes, which can be
accessed sequentially by calling iterateNext( ) repeatedly until it
returns null. The document
must not be modified during this iteration.
iterateNext( )
ORDERED_NODE_ITERATOR_TYPE
The result is a list of nodes, arranged in document
order, which can be accessed sequentially by calling iterateNext( ) repeatedly until it
returns null. The document
must not be modified during this iteration.
UNORDERED_NODE_SNAPSHOT_TYPE
The result is a random-access list of nodes. The
snapshotLength property
specifies the length of the list, and the snapshotItem( ) method returns the
node at a specified index. The nodes may not be in the same
order they appear in the document. Since this kind of result
is a "snapshot," it remains valid even if the document is
changed.
snapshotLength
snapshotItem( )
ORDERED_NODE_SNAPSHOT_TYPE
The result is a random-access list of nodes, just like
UNORDERED_NODE_SNAPSHOT_TYPE, except
that this list is arranged in document order.
ANY_UNORDERED_NODE_TYPE
The singleNodeValue
property refers to a node that matches the query or null if no nodes matched. If more
than one node matches the query, singleNodeValue may be any one of
the matching nodes.
singleNodeValue
FIRST_ORDERED_NODE_TYPE
singleNodeValue holds
the first node in the document that matched the query, or
null if no nodes
matched.
Many of these properties are valid only when resultType holds a particular value.
Accessing properties that are not defined for the current resultType causes an exception.
readonly boolean
booleanValue
Holds the result value when resultType is BOOLEAN_TYPE.
readonly boolean
invalidIteratorState
Is true if resultType is one of the ITERATOR_TYPE constants and the
document has been modified, making the iterator invalid,
because the result was returned.
ITERATOR_TYPE
readonly float
numberValue
Holds the result value when resultType is NUMBER_TYPE.
readonly short
resultType
Specifies what kind of result the XPath query returned.
Its value is one of the constants listed earlier. The value of
this property tells you which other properties or methods you
can use.
readonly Node
singleNodeValue
Holds the result value when resultType is XPathResult.ANY_UNORDERED_NODE_TYPE
or XPathResult.FIRST_UNORDERED_NODE_TYPE.
XPathResult.ANY_UNORDERED_NODE_TYPE
XPathResult.FIRST_UNORDERED_NODE_TYPE
readonly integer
snapshotLength
Specifies the number of nodes returned when resultType is UNORDERED_NODE_SNAPSHOT_TYPE or
ORDERED_NODE_SNAPSHOT_TYPE.
Use this property in conjunction with snapshotItem( ).
readonly String
stringValue
Holds the result value when resultType is STRING_TYPE.
Returns the next node in the node set. Use this method
if the resultType is
UNORDERED_NODE_ITERATOR_TYPE or
ORDERED_NODE_ITERATOR_TYPE.
Returns the node at the specified index in the list of
result nodes. This method may be used only if resultType is UNORDERED_NODE_SNAPSHOT_TYPE or
ORDERED_NODE_SNAPSHOT_TYPE.
Use the snapshotLength
property in conjunction with this method.
An XPathResult object represents the value of an XPath
expression. Objects of this type are returned by Document.evaluate( ) and XPathExpression.evaluate( ). XPath queries
can evaluate to strings, numbers, booleans, nodes, and lists of
nodes. XPath implementations can return lists of nodes in several
different ways, so this object defines a slightly complex API for
obtaining the actual result of an XPath query.
To use an XPathResult, first check the resultType property. It will hold one of
the XPathResult constants. The value of this property tells you
which property or method you need to use to determine the result
value. Calling methods or reading properties that are not defined
for the current resultType causes
an exception.
Internet Explorer does not support the XPathResult API. To perform XPath queries
in IE, see Node.selectNodes( )
and Node.selectSingleNode(
).
Node.selectSingleNode(
)
Document.evaluate( ),
XPathExpression.evaluate(
)
XPathResult.iterateNext( ): return the next node that
matches an XPath query
Node iterateNext( )
throws DOMException
Returns the next node in the list of matching nodes, or
null if there are no
more.
This method throws an exception if the document has been
modified since the XPathResult was returned. It also throws an
exception if called when returnType is not UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE.
returnType
iterateNext( ) returns the
next node that matches the XPath query or null if all matching nodes have already
been returned. Use this method if resultType is UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE. If the type is
ordered, nodes are returned in the order they appear in the
document. Otherwise, they can be returned in any order.
If the invalidIteratorState
property is true, the document
has been modified, and this method throws an exception.
invalidIteratorState | http://archive.oreilly.com/pub/a/javascript/excerpts/javascript-tdg/client-side-javascript-reference.html | CC-MAIN-2015-40 | refinedweb | 61,795 | 53.92 |
Archive:DocsProject/Tasks/SingleSourceSummary
From FedoraProject
Tasks for SingleSourceSummary
SingleSourceSummary Tasks
SingleSourceSummary Uses
Map and Merge
- Find similar content (paragraph minimum size?)
- Map back to where it came from
- Merge it
- Wrap the new merge with comment blocks
- Use
Include()to pull in the block to the mapped-from location
Individual Mapped Points
Fedora Release Summary
This is in the Release/N/ namespace.
Fedora Release Overview
This is a newer people-friendly way to present the content. The content here sits in front of deeper content from Docs/Beats/. Comparable to the GNOME release pages, focusing on the new stuff for users / developers / contributors.
Release Overview
This format was used in the Alpha/Beta release notes for F9.
- Map and merge with the Fedora Release Overview
Press Release
Content here may have a different voice/style to other content. Some of this content may repeat content in other parts of this page, if the style needs adjusting for the press voice. To keep track of this, use an
Include() to pull in the other comment block for constant comparison. Use a nested sub-section with a common title structure.
Release Announcements
- Return to the canonical pages to ensure the process is updated
- Docs/Drafts/ReleaseAnnouncements needs to be moved to Releases/N/Announcements? or ... ?
- Update
- Announce the opening of release announcement fun for F9
Talking Points for Localized Summaries
Talking points need to give three to five short (one, two sentence) paragraphs that describes major points we want everyone talking about in their release announcements. A local team takes these points to write in their own language whatever style is appropriate (humorous, press release-like, technical, excited!, etc.). A local team can use other parts of the SSS to pull pieces to discuss, but that makes for very looooong release announcements, which we don't recommend. Maybe we want a way to localize the talking points to make it easier for Ambassadors?
- Create three to five short (one, two sentence) paragraphs that describes major points we want everyone talking about in their release announcements.
- Coordinate with the L10N team on potential localization
- Announce availability on f-marketing-l and f-trans-announce
- Announcement should have link back to canonical Releases/Announcements page that explains how-to
- Think of a way to get these annoucements staticly displayed on website (preferred) / wiki + get links to translated announcements in the official announcement
- Maybe display the localized version on the localized fedoraproject.org front page?
- Promotes dual-use beyond the immediate announcement purpose | https://fedoraproject.org/wiki/Archive:DocsProject/Tasks/SingleSourceSummary | CC-MAIN-2015-18 | refinedweb | 419 | 50.46 |
Data streams are used to write binary data. The DataOutputStream writes binary data of primitive types, while DataInputStream reads data back from the binary stream and converts it to primitive types. Here is an example program that writes data to a file and then reads it back into memory.
import java.io.DataInputStream import java.io.DataOutputStream import java.io.FileInputStream import java.io.FileOutputStream fun main(args : Array<String>){ val burgers = "data.burgers" //Open the file in binary mode DataOutputStream(FileOutputStream(burgers)).use { dos -> with(dos){ //Notice we have to write our data types writeInt("Bob is Great\n".length) //Record length of the array writeChars("Bob is Great\n") //Write the array writeBoolean(true) //Write a boolean writeInt("How many burgers can Bob cook?\n".length) //Record length of array writeBytes("How many burgers can Bob cook?\n") //Write the array writeInt(Int.MAX_VALUE) //Write an int for (i in 0..5){ writeByte(i) //Write a byte writeDouble(i.toDouble()) //Write a double writeFloat(i.toFloat()) //Write a float writeInt(i) //Write an int writeLong(i.toLong()) //Write a long } } } //Open a binary file in read mode. It has to be read in the same order //in which it was written DataInputStream(FileInputStream(burgers)).use {dis -> with (dis){ val bobSize = readInt() //Read back the size of the array for (i in 0 until bobSize){ print(readChar()) //Print the array one character at a time } println(readBoolean()) //Read a boolean val burgerSize = readInt() //Length of the next array for (i in 0 until burgerSize){ print(readByte().toChar()) //Print array one character at a time } println(readInt()) //Read an int for (i in 0..5){ println(readByte()) //Read a byte println(readDouble()) //Read a double println(readFloat()) //Read a float println(readInt()) //Read an int println(readLong()) //Read a long } } } }
The program creates a FileOutputStream object and passes the name of the file to its constructor. The FileOutputStream object is then passed to the constructor of DataOutputStream. We apply the use() function to ensure all resources are freed properly when we have finished. The file is now open for writing in binary mode.
When we wish to use the same object repeatedly, we can pass it to the with() function. In our case, we intend to keep using our DataOutputStream object, so on line 11, we pass it to the with() function. Inside of the with() function, all method calls will target the dos object because it was supplied to with().
Since we intend to write a string to the file, we need to record the length of the string. We do this using the writeInt function and passing the length of our string to it. Then we can use writeChars() to write a character array to the file. The String argument is converted to a character array and written to the file. Finally, we call writeBoolean to write true/false values to the file.
The next section is a repeat of the first. We intend to write another string to the file, but do so, we need to record the length of the file. Once again, we turn to writeInt() to record an int value. The next line, we use writeBytes() rather than writeChars() to demonstrate how we can write a byte array rather than a String. The DataOutputStream class sees to the details of turning a String into a byte array. Finally, we write another int value to the stream.
Next, we enter a for loop on line 21. Inside of the for loop, we demonstrate writing different primitive types to the file. We can use writeByte() for a byte, writeDouble() for a double, and so on for each primitive type. The DataOutputStream class knows the size of each primitive type and writes the correct number of bytes for each primitive.
When we are done writing the object, we open it again to read it. Line 33 creates a FileInputStream object that accepts the path to the file in its constructor. The FileInputStream object is chained to DataInputStream by passing it to the constructor of DataInputStream. We apply the use() function to ensure all resources are properly closed.
Reading the file requires the file to be read in the same order in which it is written. Our first order of business is to grab the size of the character array we wrote to the file earlier. We use readInt() on line 35 followed by a for loop that terminates at the size of the array on line 36. Each iteration of the for loop calls readChar() and the String is printed to the console. When we are finished, we read a boolean on line 39.
Our next array was a byte array. Once again, we need it’s final size so we call readInt() on line 41. Lines 42-44 run through the array and call readByte() until the loop terminates. Each byte is converted to a character object using toChar(). On line 45, we read an int using readInt().
The final portion of the program repeats the for loop found earlier. In this case, we enter a for loop that terminates after five iterations (line 47). Inside of the for loop, we call readByte(), readDouble(), readFloat(), and so on. Each call prints the restored variable to the console. | https://stonesoupprogramming.com/2017/11/24/kotlin-data-streams/ | CC-MAIN-2022-05 | refinedweb | 881 | 74.39 |
The function int feof(FILE *stream); checks the state of end-of-File indicator associated with stream. Once the file position indicator reaches the end of the file, any further read operations will return EOF.
End of file indicator for a stream can be cleared by a call to rewind, fseek, clearerr, freopen or fsetpos.
Function prototype of feof
int feof(FILE *stream);
- stream : A pointer to a FILE object which identifies a stream.
Return value of feof
This function returns a non-zero value if the end of file indicator for the stream is set, zero is returned otherwise.
C program using feof function
The following program shows the use of feof function to traverse the file from start till end of the file. Let file "textFile.txt" contains "feof C Standard Library function" string. The content of this file will get printed by the following program.
#include <stdio.h> int main(){ FILE *file; int c; file = fopen("textFile.txt","r"); if(file == NULL){ perror("Error: Unable to open a file"); } else { while(!feof(file)){ c = fgetc(file); printf("%c", c); } fclose(file); } return(0); }
Output
feof C Standard Library function | http://www.techcrashcourse.com/2015/08/feof-stdio-c-library-function.html | CC-MAIN-2018-17 | refinedweb | 192 | 65.22 |
Pandas is a prominent data-munging tool in Python. This data analysis library is well suited for various kinds of data. In this article, we list down 10 important interview questions on Python pandas one must know.
1| Define Python pandas
pandas is an open source, BSD-licensed library providing high-performance, easy-to-use data structures and data analysis tools for the Python programming language. This is a high-level data manipulation tool developed by Wes Mckinney and is built on the Numpy package. This package provides active and flexible data structures in order to make easy working with relational or labelled data.
REGISTER FOR OUR UPCOMING ML WORKSHOP
2| Mention The Different Types Of Data Structures In pandas?
There are two data structures supported by pandas library, Series and DataFrames. Both of the data structures are built on top of Numpy. Series is a one-dimensional data structure in pandas and DataFrame is the two-dimensional data structure in pandas. There is one more axis label known as Panel which is a three-dimensional data structure and it includes items, major_axis, and minor_axis.
3| Explain Series In pandas. How To Create Copy Of Series In pandas?
Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating point numbers, Python objects, etc.). The axis labels are collectively referred to as the index. The basic method to create a Series is to call:
>>> s = pd.Series(data, index=index), where the data can be a Python dict, an ndarray or a scalar value.
To create a copy in pandas, we can call copy() function on a series such that
s2=s1.copy() will create copy of series s1 in a new series s2.
4| What Is A pandas DataFrame? How Will You Create An Empty DataFrame In pandas?
pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). It consists of three principal components, the data, rows, and columns. pandas DataFrame can be created from the lists, dictionary, and from a list of dictionary, etc.
To create an empty DataFrame in pandas, type
import pandas as pd
df = pd.DataFrame()
5| Explain Reindexing In pandas.
Reindexing means to conform DataFrame to a new index with optional filling logic, placing NA/NaN in locations having no value in the previous index. It changes the row labels and column labels of a DataFrame.
6| What Are The Key Features Of pandas Library?
There are various features in pandas library and some of them are mentioned below
- Data Alignment
- Memory Efficient
- Reshaping
- Merge and join
- Time Series
7| What Is pandas Used For?
This library is written for the Python programming language for performing operations like data manipulation, data analysis, etc. The library provides various operations as well as data structures to manipulate time series and numerical tables.
8| Explain Categorical Data In pandas.. All values of categorical data are either in categories or np.nan.).
9| What Are The Different Ways A DataFrame Can Be Created In pandas?
DataFrame can be created in different ways here are some ways by which we create a DataFrame:
- Using List:
# initialize list of lists
data = [[‘p’, 1], [‘q’, 2], [‘r’, 3]]
# Create the pandas DataFrame
df = pd.DataFrame(data, columns = [‘Letter’, ‘Number’])
# print dataframe.
df
- Using dict of narray/lists:.
- Using arrays:
# DataFrame using arrays.
import pandas as pd
# initialise data of lists.
data = {‘Name’:[‘Tom’, ‘Jack’, ‘nick’, ‘juli’], ‘marks’:[99, 98, 95, 90]}
# Creates pandas DataFrame.
df = pd.DataFrame(data, index =[‘rank1’, ‘rank2’, ‘rank3’, ‘rank4’])
# print the data
df
10| What Is Time Series In pandas
A time series is an ordered sequence of data which basically represents how some quantity changes over time. pandas contains extensive capabilities and features for working with time series data for all domains.
pandas supports:
- Parsing time series information from various sources and formats
- Generate sequences of fixed-frequency dates and time spans
- Manipulating and converting date time with timezone information
- Resampling or converting a time series to a particular frequency
- Performing date and time arithmetic with absolute or relative time increments. | https://analyticsindiamag.com/10-important-pandas-interview-questions-every-beginner-must-know/ | CC-MAIN-2021-31 | refinedweb | 688 | 56.25 |
Difference between revisions of "Phooey"
Revision as of 21:40, 16 January 2007
Abstract
Phooey is an arrow-based functional UI library for Haskell.
- Read the Haddock docs (with source code, additional examples, and Comment/Talk links)
- Get the code repository: darcs get
- Or grab a distribution tarball.
- See the README..)
As an example,
There are more examples in the Haddock docs.
Motivation
Phooey came out of Pajama and .)
Switching from expressions to values raises a challenge for a declarative monadic approach. For instance, consider this (problematic) monadic UI.
factOopsUI :: UIM () factOopsUI = do n <- title "n" (islider 3 (0,20)) title "factorial" (showDisplay (fact n))
If
n :: Int, then the second half of the GUI depends on the dynamic run-time values flowing out of the first half, and so must be constructed for each new value of
n. The problem is a failure to separate a GUI into its static and dynamic parts. A solution with the monadic framework would be to give
n a different type, such as
Source Int, which captures the static nature of the input GUI while giving access to a source of dynamic values. Phooey provides this monadic solution in its MonadUI module. The awkwardness is that we can no longer use such simple formulations as
factOopsUI above, since expressions like
product [1..n] won't type-check. (We can play overloading tricks as in Fran, Pan, and Pajama, but they don't always work.) Instead, we could use
return,
liftM,
liftM2, etc.
factUI :: UIM () factUI = do n <- title "n" (islider 3 (return (0,20))) title "factorial" (showDisplay (liftM fact n))
Rather than introducing the complexity of the
Source type and the need for explicit lifting, we can solve the problem by replacing the Monad abstraction with one that separates static and dynamic aspects. Getting that separation is the point of the Arrow abstraction, and thus Phooey's primary interface is formulated as an arrow rather than a monad. Phooey's UI arrow is implemented on top of its UI monad using a simple, reusable pattern. See the ArrowUI module doc and its source code.
Phooey is also used in TV, a library for composable interfaces and "tangible values"."). | https://wiki.haskell.org/index.php?title=Phooey&diff=prev&oldid=10466&printable=yes | CC-MAIN-2021-31 | refinedweb | 365 | 61.97 |
salem let me explain, I went to delete the FIRST thread I made on byte alignment after I realized I posted two threads on the same topic (I forgot I made the first). Then, I couldn't find the most recent one I made so I assume you deleted it, now none exist but I still need to understand what this means.
Anyway I know that PACK_STRUCT expands to nothing, but I don't know what the rest of those '#' directives mean, and I would like someone to tell me. I don't know what the pack/push __attribute__((packed)) lines mean. When I just include the structures without the defines the application doesn't work properly.
yeah well salem don't beat me up plzyeah well salem don't beat me up plzCode:#ifdef _MSC_VER # pragma pack( push, packing ) # pragma pack( 1 ) # define PACK_STRUCT #elif defined( __GNUC__ ) # define PACK_STRUCT __attribute__((packed)) #else # error you must byte-align these structures with the appropriate compiler directives #endif typedef unsigned char byte; typedef unsigned short word; // File header struct MS3DHeader { char m_ID[10]; int m_version; } PACK_STRUCT; ....//MORE STRUCTS THAT DON'T NEED TO TAKE UP SPACE // Default alignment #ifdef _MSC_VER # pragma pack( pop, packing ) #endif #undef PACK_STRUCT | http://cboard.cprogramming.com/cplusplus-programming/31491-ok-i'm-dumb-byte-alignment-third-time.html | CC-MAIN-2015-32 | refinedweb | 205 | 60.58 |
for Loop in C# Programming
For Loop is a loop in programming languages like C# that repeats a block of statements until a condition provided is satisfied. Unlike other less structured loops like while and do..while, this loop contains initialization, condition and increment/decrement before the loop statement.
Syntax for For Loop:
for (initialization; condition; increment/decrement) { statements; }
Here, initialization, condition and increment/decrement are in same line which allows us to do three task in same line decreasing the length of code. These blocks in for are separated with a semicolon.
Initialization block is used to declare a variable for the loop. It is executed only once while entering the loop. Variable declared in this loop is only usable in the loop and it is possible to declare multiple variables in initialization block.
Condition block contains condition for the loop. The condition must be an expression that returns value in boolean result. This blocks evaluates the condition and runs the loop until the condition is satisfied and exits the loop otherwise.
Increment/decrement block is used to change the value of the variable. This block is accessed after loop body is executed.
Flowchart for For Loop:
Example 1: C# for Loop Example
C# Program to print first n natural numbers
using System; namespace loop { class Program { static void Main(string[] args) { Console.Write("Enter a number: "); int n = (int)Convert.ToInt32(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine(i); } Console.ReadLine(); } } }
Output:
Enter a number: 9 1 2 3 4 5 6 7 8 9 10
Additional Information about for Loop:
Initialization block can be left empty but the semicolon before condition block is compulsory
for (int i = 1; condition; increment/decrement) //valid for ( ; condition; increment/decrement) //valid
- Multiple variables can be used in initialization block as well. They must be separated with a comma.
for (int i = 1, j = 5; condition; increment/decrement) //valid
Condition block can also be left empty but the semicolon should be present after initialization block and before increment/decrement block but without a condition, infinite loop is created. But, condition can be set in the loop body as well using statements like if.
for (int i = 1; i <= 5; increment/decrement) //valid for (int i = 1; ; increment/decrement) //valid
- We cannot use multiple conditions separately but we can if we combine them using logical keywords.
for (int i = 1; i < 5; i == 5; increment/decrement) //invalid for (int i = 1; i < 5, i == 5; increment/decrement) //invalid for (int i = 1; i < 5 || i == 5; increment/decrement) //valid
Increment/decrement block can also be left empty but the semicolon should be present after condition block but without a changing value of variable, infinite loop is created. But increment or decrement can be set in the loop body as well.
for (int i = 1; i <= 5; i++) //valid for (int i = 1; i <= 5; ) //valid
- Multiple expressions can be used in increment/decrement block as well. They must be separated with a comma.
for (int i = 1, j = 5; i <= 5; i++, j--) //valid | https://www.programtopia.net/csharp/docs/for-loop-c-sharp | CC-MAIN-2019-30 | refinedweb | 515 | 52.39 |
import a PDF form with Jotform, it will only output as a fillable PDF not an editable web form but you can actually download the fillable PDF and use it to collect submissions. :)
If you want it to be a web form, you have to create the form from scratch or you can find forms with similar template on the form templates page. This will save you some time. If we can be of further assistance, let us know.
- Uploading and downloading is not my concern … since I uploaded it myself in the first place. What I want to know is the URL for the form so I can refer to it in emails and websites without having to upload the form over and over. Every form I created on JotForm has a direct URL. Just wondering. Thanks.
Greg Eberly
...
- JotForm Support
Hi Greg,
Thanks for your reply. Unfortunately, like I've mentioned, the uploaded PDF is not a web form. It will remain as a fillable PDF form when you upload it to Jotform. Therefore, you can't take it's form URL because it does not contain any fields unless you will download the PDF back and use it to collect submissions.
Hope this clarifies a bit. Thank you!
- Thanks for your response. I guess I just don’t get this … as much as you’ve tried to clarify. Why would I even bother to upload a form I created on my desktop if I just have to download it again? Guess I’ve learned a lesson here … create any future forms thru JF and forget uploading/downloading my own pdf creations. If I want to email a form I created locally, I’ll just have to attach it and forget JF in this regard. I’m not techie enough to understand this whole thing, but thank you for trying to explain.
Greg Eberly
...
- JotForm Support
When you upload PDF form to JotForm and then download same form and share it with your users, when your users submit the form you will be able to view your submission on JotForm.
However like my colleague mentioned Fillable PDF form is not web form and if you want to have URL of your form or embed your form to website you need to create the form from scratch in our Form Builder.
Feel free to contact us if you have any other questions.
- That answers my questions … I think. :) Will go back to creating all forms on JF.
Greg Eberly
...
- JotForm Support
Hi Greg,
Thank you for the confirmation that all is clear now.
Don't hesitate to contact us again anytime should you require further assistance on JotForm.
Cheers | https://www.jotform.com/answers/670970-Access-and-edit-uploaded-pdf-form | CC-MAIN-2016-50 | refinedweb | 450 | 78.99 |
03 December 2012 19:55 [Source: ICIS news]
NEW YORK (ICIS)--US-based Dow Chemical expects China GDP growth of 6-7% in 2013, its chief executive said on Monday.
“In the past few weeks we have seen an uptick in ?xml:namespace>
“We are not planning on any big bounce-back but are beginning to see better buying patterns emerge, and would expect 6-7% economic growth in China in 2013 – still less than in previous years,” he added.
For
The pick-up in
“We had been used to double-digit growth [in chemical demand] but in the past six months that slowed to stopped,” said Liveris.
The low point in
The CEO projects global GDP growth of 2.5% in 2012, with | http://www.icis.com/Articles/2012/12/03/9620699/dow-expects-china-gdp-growth-of-6-7-in-2013-ceo-liveris.html | CC-MAIN-2014-52 | refinedweb | 124 | 77.57 |
While working on my Python mp3 player I realized I needed to research what Python had to offer for parsing ID3 tags. There are tons of projects out there, but most of them appear to be either dead, don’t have documentation or both. In this post, you will discover the wild world of MP3 tag parsing in Python along with me and we’ll see if we can find something that I can use to enhance my mp3 player project.
For this exercise, we’ll try to get the following information from our parsers:
- Artist
- Title of Album
- Track Title
- Length of Track
- Album Release Date
We’ll probably need more metadata than that, but this is the usual stuff I care about in my mp3 playing experience. We will look at the following 3rd party libraries to see how they hold up:
Let’s get started!
Can Mutagen Save the Day?
One of the reasons to include Mutagen in this round up is because it supports ASF, FLAC, M4A, Monkey’s Audio, Musepack, Ogg FLAC, Ogg Speex, Ogg Theora, Ogg Vorbis, True Audio, WavPack and OptimFROG in addition to MP3 parsing. Thus, we could potentially expand our MP3 player quite a bit. I was pretty excited when I found this package. However, while the package appears to be actively developed, the documentation is almost non-existent. If you are a new Python programmer, you will find this library difficult to just jump into and use.
To install Mutagen, you’ll need to unpack it and navigate to its folder using the command line. Then execute the following:
python setup.py install
You may be able to use easy_install or pip as well, although their website doesn’t really say one way or the other. Now comes the fun part: trying to figure out how to use the module without documentation! Fortunately, I found a blog post that gave me some clues. From what I gather, Mutagen follows the ID3 specification pretty closely, so rather than abstracting it so that you would have functions like GetArtist, you actually end up reading ID3 text frames and use their terminology. Thus, TPE1 = Artist (or Lead Singer), TIT2 = Title, etc. Let’s look at an example:
>>> path = r'D:\mp3\12 Stones\2002 - 12 Stones\01 - Crash.mp3' >>> from mutagen.id3 import ID3 >>> audio = ID3(path) >>> audio >>> audio['TPE1'] TPE1(encoding=0, text=[u'12 Stones']) >>> audio['TPE1'].text [u'12 Stones']
Here’s a more proper example:
from mutagen.id3 import ID3 #---------------------------------------------------------------------- def getMutagenTags(path): """""" audio = ID3(path) print "Artist: %s" % audio['TPE1'].text[0] print "Track: %s" % audio["TIT2"].text[0] print "Release Year: %s" % audio["TDRC"].text[0]
I personally find this to be difficult to read and use, so I won’t be using this module for my mp3 player unless I need to add additional digital file formats to it. Also note that I wasn’t able to figure out how to get the track’s play length or album title. Let’s move on to our next ID3 parser and see how it fares.
eyeD3
If you go to eyeD3’s website, you’ll notice that it doesn’t seem to support Windows. This is a problem for many users and almost caused me to drop it from this round-up. Fortunately, I found a forum that mentioned a way to make it work. The idea was to rename the “setup.py.in” file in the main folder to just “setup.py” and the “__init__.py.in” file to “__init__.py”, which you’ll find in “src\eyeD3”. Then you can install it using the usual “python setup.py install”. Once you have it installed, it’s really easy to use. Check out the following function:
import eyeD3 #---------------------------------------------------------------------- def getEyeD3Tags(path): """""" trackInfo = eyeD3.Mp3AudioFile(path) tag = trackInfo.getTag() tag.link(path) print "Artist: %s" % tag.getArtist() print "Album: %s" % tag.getAlbum() print "Track: %s" % tag.getTitle() print "Track Length: %s" % trackInfo.getPlayTimeString() print "Release Year: %s" % tag.getYear()
This package does meet our arbitrary requirements. The only regrettable aspect of the package is its lack of official Windows support. We’ll reserve judgment until after we’ve tried out our third possibility though.
Ned Batchelder’s id3reader.py
This module is probably the easiest of the three to install since it’s just one file. All you need to do is download it and put the file into the site-packages or somewhere else on your Python path. The primary problem of this parser is that Batchelder no longer supports it. Let’s see if there’s an easy way to get the information that we need.
import id3reader #---------------------------------------------------------------------- def getTags(path): """""" id3r = id3reader.Reader(path) print "Artist: %s" % id3r.getValue('performer') print "Album: %s" % id3r.getValue('album') print "Track: %s" % id3r.getValue('title') print "Release Year: %s" % id3r.getValue('year')
Well, I didn’t see an obvious way to get the track length with this module without knowing the ID3 specification. Alas! While I like the simplicity and power of this module, the lack of support and a super simple API makes me reject it in favor of eyeD3. For now, that will be my library of choice for my mp3 player. If you know of a great ID3 parsing script, feel free to drop me a line in the comments. I saw others listed on Google as well, but quite a few of them were just as dead as Batchelder’s was. | http://www.blog.pythonlibrary.org/2010/04/22/parsing-id3-tags-from-mp3s-using-python/ | CC-MAIN-2018-13 | refinedweb | 918 | 75.1 |
5× in 5 Hours: Porting a 3D Elastic Wave Simulator to GPUs Using OpenACC
Scientists in the oil and gas industry often investigate large yet highly parallelizable problems that can adapt well to accelerators. SEISMIC_CPML is an example case. Developed by Dimitri Komatitsch and Roland Martin from University of Pau, France. From their website: "SEISMIC_CPML is a set of ten open-source Fortran 90."
In particular, we decided to accelerate the 3D Isotropic application which is "a 3D elastic finite-difference code in velocity and stress formulation with Convolutional-PML (C-PML) absorbing conditions." In addition to being highly compute intensive, the code uses MPI and OpenMP to perform the domain decomposition, giving us an opportunity to showcase the use of multi-GPU programming.
This tutorial will give you an understanding of the steps involved in porting applications to GPUs using OpenACC, some optimization tips, and ways to identify several potential pitfalls. It should be useful as a guide for how you can apply OpenACC directives to your own code. All source code for this tutorial can be downloaded as part of this tarball. After downloading, unpack and untar the file which will create a directory where you can work along with the tutorial if you like.
1. Step 0: Evaluation
The most difficult part of accelerator programing begins before the first line of code is written. Having the right algorithm is essential for success. An accelerator is like an army of ants. Individually the cores are weak, but taken together they can do great things. If your program is not highly parallel, an accelerator won't be of much use. Hence, the first step is to ensure that your algorithm is parallel. If it's not, you should determine if there are alternate algorithms you might use or if your algorithm could be reworked to be more parallel.
In evaluating the SEISMIC_CPML 3-D Isotropic code, we see the main time-step loop contains eight parallel loops. However, being parallel may not be enough if the loops are not computationally intensive. While computational intensity shouldn't be your only metric, it is a good indicator of potential success. Using the compiler flag -Minfo=intensity, we can see that the compute intensity, the ratio of computation to data movement, of the various loops is between 2.5 and 2.64. These are average intensities. As a rule, anything below 1.0 is generally not worth accelerating unless it is part of a larger program. Ideally we would like the average intensity to be above 4, but 2.5 is sufficient to move forward.
SEISMIC_CPML uses MPI to decompose the problem space across the Z dimension. This will allow us to utilize more than one GPU, but it also adds extra data movement as the program needs to pass halos (regions of the domain that overlap across processes). We could use OpenMP threads as well, but doing so would add more programming effort and complexity to our example. As a result, we chose to remove the OpenMP code from the GPU version. We may revisit that decision in a future article.
As an aside, with the MPI portion of the code the programmer manually decomposes the domain. With OpenMP, the compiler does that automatically if the program is running in a shared memory environment. Currently, OpenMP compilers aren't able to automatically decompose a problem across multiple discrete memory spaces as is the case when using multiple devices. As a result, the programmer must manually decompose the problem just like they would using MPI. Because this would basically require us to duplicate our effort, we decided to forgo using OpenMP here.
To build and run the original MPI/OpenMP code on your system do the following (make sure that the compiler (pgfortran) and MPI wrappers (mpif90) are in your path before building and running):
cd step0 make build make run make verify
2. Step 1: Adding Setup Code
Because this is an MPI code where each process will use its own GPU, we need to add some utility code to ensure that happens. The setDevice routine first determines which node the process is on (via a call to hostid) and then gathers the hostids from all other processes. It then determines how many GPUs are available on the node and assigns the devices to each process.
Note that in order to maintain portability with the CPU version, this section of code is guarded by the preprocessor macro _OPENACC, which is defined when the OpenACC directives are enabled in the HPC Fortran compiler through the use of the -acc command-line compiler option.
#ifdef _OPENACC # function setDevice(nprocs,myrank) use iso_c_binding use openacc implicit none include 'mpif.h' interface function gethostid() BIND(C) use iso_c_binding integer (C_INT) :: gethostid end function gethostid end interface integer :: nprocs, myrank integer, dimension(nprocs) :: hostids, localprocs integer :: hostid, ierr, numdev, mydev, i, numlocal integer :: setDevice ! get the hostids so we can determine what other processes are on this node hostid = gethostid() CALL mpi_allgather(hostid,1,MPI_INTEGER,hostids,1,MPI_INTEGER, & MPI_COMM_WORLD,ierr) ! determine which processors are on this node numlocal=0 localprocs=0 do i=1,nprocs if (hostid .eq. hostids(i)) then localprocs(i)=numlocal numlocal = numlocal+1 endif enddo ! get the number of devices on this node numdev = acc_get_num_devices(ACC_DEVICE_NVIDIA) if (numdev .lt. 1) then print *, 'ERROR: There are no devices available on this host. & ABORTING.', myrank stop endif ! print a warning if the number of devices is less then the number ! of processes on this node. Having multiple processes share devices is not ! recommended. if (numdev .lt. numlocal) then if (localprocs(myrank+1).eq.1) then ! print the message only once per node print *, 'WARNING: The number of process is greater then the number & of GPUs.', myrank endif mydev = mod(localprocs(myrank+1),numdev) else mydev = localprocs(myrank+1) endif call acc_set_device_num(mydev,ACC_DEVICE_NVIDIA) call acc_init(ACC_DEVICE_NVIDIA) setDevice = mydev end function setDevice #endif
To build and run the step1 code on your system do the following (make sure that the compiler (pgfortran) and MPI wrappers (mpif90) are in your path before building and running):
cd step1 make build make run make verify
3. Step 2: Adding Compute Regions
Next, we spent a few minutes adding six compute regions around the eight parallel loops. For example, here's the final reduction loop.
!$acc kernels do k = kmin,kmax do j = NPOINTS_PML+1, NY-NPOINTS_PML do i = NPOINTS_PML+1, NX-NPOINTS_PML ! compute kinetic energy first, defined as 1/2 rho ||v||^2 ! in principle we should use rho_half_x_half_y instead of rho for vy ! in order to interpolate density at the right location in the staggered grid ! cell but in a homogeneous medium we can safely ignore it total_energy_kinetic = total_energy_kinetic + 0.5d0 * rho*( & vx(i,j,k)**2 + vy(i,j,k)**2 + vz(i,j,k)**2) ! add potential energy, defined as 1/2 epsilon_ij sigma_ij ! in principle we should interpolate the medium parameters at the right location ! in the staggered grid cell but in a homogeneous medium we can safely ignore it ! compute total field from split components epsilon_xx = ((lambda + 2.d0*mu) * sigmaxx(i,j,k) - lambda * & sigmayy(i,j,k) - lambda*sigmazz(i,j,k)) / (4.d0 * mu * (lambda + mu)) epsilon_yy = ((lambda + 2.d0*mu) * sigmayy(i,j,k) - lambda * & sigmaxx(i,j,k) - lambda*sigmazz(i,j,k)) / (4.d0 * mu * (lambda + mu)) epsilon_zz = ((lambda + 2.d0*mu) * sigmazz(i,j,k) - lambda * & sigmaxx(i,j,k) - lambda*sigmayy(i,j,k)) / (4.d0 * mu * (lambda + mu)) epsilon_xy = sigmaxy(i,j,k) / (2.d0 * mu) epsilon_xz = sigmaxz(i,j,k) / (2.d0 * mu) epsilon_yz = sigmayz(i,j,k) / (2.d0 * mu) total_energy_potential = total_energy_potential + & 0.5d0 * (epsilon_xx * sigmaxx(i,j,k) + epsilon_yy * sigmayy(i,j,k) + & epsilon_yy * sigmayy(i,j,k)+ 2.d0 * epsilon_xy * sigmaxy(i,j,k) + & 2.d0*epsilon_xz * sigmaxz(i,j,k)+2.d0*epsilon_yz * sigmayz(i,j,k)) enddo enddo enddo !$acc end kernels
The -acc command line option to the HPC Accelerator Fortran compiler enables OpenACC directives. Note that OpenACC is meant to model a generic class of devices. While NVIDIA is the current market leader in HPC accelerators and default target for NVIDIA's OpenACC implementation, the model can, and will in the future, target other devices.
Another compiler option you'll want to use during development is -Minfo, which causes the compiler to output feedback on optimizations and transformations performed on your code. For accelerator-specific information, use the -Minfo=accel sub-option. Examples of feedback messages produced when compiling SEISMIC_CPML include:
1113, Generating copyin(vz(11:91,11:631,kmin:kmax)) Generating copyin(vy(11:91,11:631,kmin:kmax)) Generating copyin(vx(11:91,11:631,kmin:kmax)) Generating copyin(sigmaxx(11:91,11:631,kmin:kmax)) Generating copyin(sigmayy(11:91,11:631,kmin:kmax)) Generating copyin(sigmazz(11:91,11:631,kmin:kmax)) Generating copyin(sigmaxy(11:91,11:631,kmin:kmax)) Generating copyin(sigmaxz(11:91,11:631,kmin:kmax)) Generating copyin(sigmayz(11:91,11:631,kmin:kmax))
To compute on a GPU, the first step is to move data from host memory to GPU memory. In the example above, the compiler tells you that it is copying over nine arrays. Note the copyin statements. These mean that the compiler will only copy the data to the GPU but not copy it back to the host. This is because line 1113 corresponds to the start of the reduction loop compute region, where these arrays are used but never modified. Other data movement clauses you may see include copy where the data is copied to the device at the beginning of the region and copied back at the end of the region, and copyout where the data is only copied back to the host.
Notice that the compiler is only copying an interior subsection of the arrays. By default, the compiler is conservative and only copies the data that's actually required to perform the necessary computations. Unfortunately, because the interior sub-arrays are not contiguous in host memory, the compiler needs to generate multiple data transfers for each array. Overall GPU performance is determined largely by how well we can optimize memory transfers. That means not just how much data gets transferred, but how many transfers occur. Transferring multiple sub-arrays is very costly. For now we will just note it. Later, we'll look at improving performance by overriding the compiler defaults and copying entire arrays in one large contiguous block.
1114, Loop is parallelizable 1115, Loop is parallelizable 1116, Loop is parallelizable Accelerator kernel generated
Here the compiler has performed dependence analysis on the loops at lines 1114, 1115, and 1116 (the reduction loop shown earlier). It finds that all three loops are parallelizable so it generates an accelerator kernel. When the compiler encounters loops that can not be parallelized, it generally reports a reason why so that you can adapt the code accordingly. If inner loops are not parallelizable, a kernel may still be generated for outer loops; in those cases the inner loop(s) will run sequentially on the GPU cores.
The compiler may attempt to work around dependences that prevent parallelization by interchanging loops (i.e changing the order) where it's safe to do so. At least one outer or interchanged loop must be parallel for an accelerator kernel to be generated. In some cases you may be able to use the loop directive independent clause to work around potential dependences, or the private clause to eliminate a dependence entirely. In other cases, code may need to be restructured significantly to enable parallelization.
The generated accelerator kernel is just a serial bit of code that gets executed on the GPU by many threads simultaneously. Every thread will be executing the same code but operating on different data. How the threads are organized is called the loop schedule. Below we can see the loop schedule for our reduction loop. The do loops have been replaced with a three-dimensional gang, which in turn is composed of a two-dimensional vector section.
1114, !$acc loop gang ! blockidx%y 1115, !$acc loop gang, vector(4) ! blockidx%z threadidx%y 1116, !$acc loop gang, vector(32) ! blockidx%x threadidx%x
In CUDA terminology, the gang clause corresponds to a grid dimension and the vector clause corresponds to a thread block dimension. For new or non-CUDA programmers, we highly recommend reading Michael Wolfe's PGInsider article Understanding the Data Parallel Threading Model for GPUs.
Don't feel too overwhelmed by loop schedules. It's just a way to organize how the GPU threads act on data elements of an array. So here we have a 3-D array that's being grouped into blocks of 32×4 elements where a single thread is working on a specific element. Because the number of gangs is not specified in the loop schedule, it will be determined dynamically when the kernel is launched. If the gang clause had a fixed width, such as gang(16), then each kernel would be written to loop over multiple elements.
With CUDA, programming reductions and managing shared memory can be a fairly difficult task. In the example below, the compiler has automatically generated optimal code using these features. By the way, the compiler is always looking for opportunities to optimize your code.
1122, Sum reduction generated for total_energy_kinetic 1140, Sum reduction generated for total_energy_potential
OK, so how are we doing?
To build and run the step2 code on your system do the following (as mention above, make sure that the compiler (pgfortran) and MPI wrappers (mpif90) are in your path before building and running):
cd step2 make build make run make verify
After ten minutes of programming time, we've managed to make the program really really slow! Remember this is an article about speeding-up SEISMIC_CPML by 5× in 5 hours not slowing it down 3× in ten minutes. We'll soon overcome this slowdown but it's not uncommon to see this type of one step back experience when programming GPUs.
Don't get discouraged if this happens to you. So why the slowdown and how can we fix it?
4. Step 3: Adding Data Regions
You may have guessed that the slowdown is caused by excessive data movement between host memory and GPU memory. In looking at a section of our CUDA profile information, we see that each compute region is spending a lot of time copying data back and forth between the host and device. Because each compute region is executed 2500 times, this makes for a lot of data movement. Adding up all the data transfer times in the profile output for Step 2 shows that the vast majority, over 99%, of the time was spent copying data while only a small fraction was spent in the compute kernels. The remaining time is spent either in host code or blocked waiting on data transfers (both MPI processes must use the same PCIe bus to transfer data).
Note that the exact amout of time spent copying data or computing on the device will vary between systems. To see the time for your system, set the environment variable PGI_ACC_TIME=1 and run your executable. This option prints basic profile information such as the kernel execution time, data transfer time, initialization time, the actual launch configuration, and total time spent in a compute region. Note that the total time is measured from the host and includes time spent executing host code within a region.
To improve performance, we need to find a way to minimize the amount of time transferring data. Enter the data directive. You can use a data region to specify exact points in your program where data should be copied from host memory to GPU memory, and back again. Any compute region enclosed within a data region will use the previously copied data, without the need to copy at the boundaries of the compute region. A data region can span across host code and multiple compute regions, and even across subroutine boundaries.
In looking at the arrays in SEISMIC_CMPL, there are 18 arrays with constant values. Another 21 are used only within compute regions so are never needed on the host. Let's start by adding a data region around the outer time step loop. The final three arrays do need to be copied back to the host to pass their halos. For those cases, we use the update directive.
!--- !--- beginning of time loop !--- !$acc data & !$acc copyin(a_x_half,b_x_half,k_x_half, & !$acc a_y_half,b_y_half,k_y_half, & !$acc a_z_half,b_z_half,k_z_half, & !$acc a_x,a_y,a_z,b_x,b_y,b_z,k_x,k_y,k_z, & !$acc sigmaxx,sigmaxz,sigmaxy,sigmayy,sigmayz,sigmazz, & !$acc) do it = 1,NSTEP ... !$acc update host(sigmazz,sigmayz,sigmaxz) ! sigmazz(k+1), left shift call MPI_SENDRECV(sigmazz(:,:,1),number_of_values,MPI_DOUBLE_PRECISION, & receiver_left_shift,message_tag,sigmazz(:,:,NZ_LOCAL+1), & number_of_values, ... !$acc update device(sigmazz,sigmayz,sigmaxz) ... ! --- end of time loop enddo !$acc end data
Data regions can be nested, and in fact we used this feature in the time loop body for the arrays vx, vy and vz as shown below. While these arrays are copied back and forth at the inner data region boundary, and so are moved more often than the arrays moved in the outer data region, they are used across multiple compute regions instead of being copied at each compute region boundary. Note that we do not specify any array dimensions in the copy clause. This instructs the compiler to copy each array in its entirety as a contiguous block, and eliminates the inefficiency we noted earlier when interior sub-arrays were being copied in multiple blocks.
!$acc data copy(vx,vy,vz) ... data region spans over 5 compute regions and host code !$acc kernels ... !$acc end kernels !$acc end data
How are we doing on our timings?
To build and run the step3 code on your system do the following:
cd step3 make build make run make verify
This step took just about an hour of coding time and reduced our execution time significantly. We're making good progress, but we can improve the performance even further.
5. Step 4: Optimizing Data Transfers
For our next step we'll work to optimize the data transfers even further by migrating as much of the computation as we can over to the GPU and moving only the absolute minimum amount of data required. The first step is to move the start of the outer data region up so that it occurs earlier in the code, and to put the data initialization loops into compute kernels. This includes the vx, vy and vz arrays. Using this approach enables us to remove the inner data region used in our previous optimization step.
In the following example code, notice the use of the create clause. This instructs the compiler to allocate space for variables in GPU memory for local use but to perform no data movement on those variables. Essentially they are used as scratch variables in GPU memory.
!$acc data & !$acc copyin(a_x_half,b_x_half,k_x_half, & !$acc a_y_half,b_y_half,k_y_half, & !$acc a_z_half,b_z_half,k_z_half, & !$acc ix_rec,iy_rec, & !$acc a_x,a_y,a_z,b_x,b_y,b_z,k_x,k_y,k_z), & !$acc copyout(sisvx,sisvy), & !$acc create, & !$acc vx,vy,vz,vx1,vy1,vz1,vx2,vy2,vz2, & !$acc sigmazz1,sigmaxz1,sigmayz1, & !$acc sigmazz2,sigmaxz2,sigmayz2) & !$acc copyin(sigmaxx,sigmaxz,sigmaxy,sigmayy,sigmayz,sigmazz) ... ! Initialize vx, vy and vz arrays on the device !$acc kernels vx(:,:,:) = ZERO vy(:,:,:) = ZERO vz(:,:,:) = ZERO !$acc end kernels ...
One caveat to using data regions is that you must be aware of which copy (host or device) of the data you are actually using in a given loop or computation. The host and device copies of the data are not automatically kept coherent. That is the responsibility of the programmer when using data regions. For example, any update to the copy of a variable in device memory won't be reflected in the host copy until you specify that it should be updated using either an update directive or a copy clause at a data or compute region boundary.
Unintentional loss of coherence between the host and device copy of a variable is one of the most common causes of validation errors in OpenACC programs. After making the above change to SEISMIC_CPML, the code generated incorrect results. After nearly a half hour of debugging, we determined that the section of the time step loop that initializes boundary conditions was omitted from an OpenACC compute region. As a result we were initializing the host copy of the data, rather than the device copy as intended, which resulted in uninitialized variables in device memory.
The next challenge in optimizing the data transfers related to the handling of the halo regions. SEISMIC_CPML passes halos from six 3-D arrays between MPI processes during the course of the computations. Ideally we would simply copy back the 2-D halo sub-arrays using update directives or copy clauses, but as we saw earlier copying non-contiguous array sections between host and device memory is very inefficient. As a first step, we tried copying the entire arrays from device memory back to the host before passing the halos. This was also very inefficient, given that only a small amount of the data moved between host and device memory was needed in the eventual MPI transfers.
After some experimentation, we settled on an approach whereby we added six new temporary 2-D arrays to hold the halo data. Within a compute region we gathered the 2-D halos from the main 3-D arrays into the new temp arrays, copied the temporaries back to the host in one contiguous block, passed the halos between MPI processes, and finally copied the exchanged values back to device memory and scattered the halos back into the 3-D arrays. While this approach does add to the kernel execution time, it saves a considerable amount of data transfer time.
In the example code below, note that the source code added to support the halo gathers and transfers is guarded by the preprocessor _OPENACC macro and will only be executed if the code is compiled by an OpenACC-enabled compiler.
#ifdef _OPENACC # ! Gather the sigma 3D arrays to a 2D slice to allow for faster ! copy from the device to host !$acc kernels do i=1,NX do j=1,NY vx1(i,j)=vx(i,j,1) vy1(i,j)=vy(i,j,1) vz1(i,j)=vz(i,j,NZ_LOCAL) enddo enddo !$acc end kernels !$acc update host(vxl,vyl,vzl) ! vx(k+1), left shift call MPI_SENDRECV(vx1(:,:), number_of_values, MPI_DOUBLE_PRECISION, & receiver_left_shift, message_tag, vx2(:,:), number_of_values, & MPI_DOUBLE_PRECISION, sender_left_shift, message_tag, MPI_COMM_WORLD,& message_status, code) ! vy(k+1), left shift call MPI_SENDRECV(vy1(:,:), number_of_values, MPI_DOUBLE_PRECISION, & receiver_left_shift,message_tag, vy2(:,:),number_of_values, & MPI_DOUBLE_PRECISION, sender_left_shift, message_tag, MPI_COMM_WORLD,& message_status, code) ! vz(k-1), right shift call MPI_SENDRECV(vz1(:,:), number_of_values, MPI_DOUBLE_PRECISION, & receiver_right_shift, message_tag, vz2(:,:), number_of_values, & MPI_DOUBLE_PRECISION, sender_right_shift, message_tag, MPI_COMM_WORLD, & message_status, code) !$acc update device(vx2,vy2,vz2) !$acc kernels do i=1,NX do j=1,NY vx(i,j,NZ_LOCAL+1)=vx2(i,j) vy(i,j,NZ_LOCAL+1)=vy2(i,j) vz(i,j,0)=vz2(i,j) enddo enddo !$acc end kernels #else
The above modifications required about two hours of coding time, but the total execution time has been reduced significantly with only a small fraction of time spent copying data!
To build and run the step4 code on your system do the following:
cd step4 make build make run make verify
6. Step 5: Loop Schedule Tuning
The final step in our tuning process was to tune the OpenACC compute region loop schedules using the gang, worker and vector clauses. In many cases, including this code, the default kernel schedules chosen by the NVIDIA OpenACC compiler are quite good. Manual tuning efforts often don't improve timings significantly. However, in some cases the compiler doesn't do as well. It's always worthwhile to spend a little time examining whether you can do better by overriding compiler-generated loop schedules using explicit loop scheduling clauses. You can usually tell fairly quickly if the clauses are having an effect.
Unfortunately, there is no well-defined method for finding an optimal kernel schedule (short of trying all possible schedules). The best advice is to start with the compiler's default schedule and try small adjustments to see if and how they affect execution time. The kernel schedule you choose will affect whether and how shared memory is used, global array accesses, and various types of optimizations. Typically, it's better to perform gang scheduling of loops with large iteration counts.
!$acc loop gang do k = k2begin,NZ_LOCAL kglobal = k + offset_k !$acc loop worker vector collapse(2) do j = 2,NY do i = 2,NX
To build and run the step5 code on your system do the following:
cd step5 make build make run make verify
7. Conclusion
In a little over five hours of programming time we achieved about a 7× speed-up over the original MPI/OpenMP version running on our test system. On a much larger cluster running a much larger dataset speed-up is not quite as good. There is additional overhead in the form of inter-node communication, and the CPUs on the system have more cores and run at a higher clock rate. Nonetheless, the speed-up is still nearly 5×.. | https://docs.nvidia.com/hpc-sdk/archive/22.1/compilers/openacc-mpi-tutorial/index.html | CC-MAIN-2022-27 | refinedweb | 4,232 | 54.12 |
huey, a little task queue
Project description
a lightweight alternative.
huey is:
- a task queue (2019-04-01: version 2.0 released)
- written in python (2.7+, 3.4+)
- clean and simple API
- redis, sqlite, or in-memory storage
- example code.
huey supports:
- multi-process, multi-thread or greenlet task execution models
- schedule tasks to execute at a given time, or after a given delay
- schedule recurring tasks, like a crontab
- automatically retry tasks that fail
- task prioritization
- task result storage
- task locking
- task pipelines and chains
At a glance
from huey import RedisHuey, crontab huey = RedisHuey('my-app', host='redis.myapp.com') @huey.task() def add_numbers(a, b): return a + b @huey.task(retries=2, retry_delay=60) def flaky_task(url): # This task might fail, in which case it will be retried up to 2 times # with a delay of 60s between retries. return this_might_fail(url) @huey.periodic_task(crontab(minute='0', hour='3')) def nightly_backup(): sync_all_data()
Calling a task-decorated function will enqueue the function call for execution by the consumer. A special result handle is returned immediately, which can be used to fetch the result once the task is finished:
>>> from demo import add_numbers >>> res = add_numbers(1, 2) >>> res <Result: task 6b6f36fc-da0d-4069-b46c-c0d4ccff1df6> >>> res() 3
Tasks can be scheduled to run in the future:
>>> res = add_numbers.schedule((2, 3), delay=10) # Will be run in ~10s. >>> res(blocking=True) # Will block until task finishes, in ~10s. 5
For much more, check out the guide or take a look at the example code.
Running the consumer
Run the consumer with four worker processes:
$ huey_consumer.py my_app.huey -k process -w 4
To run the consumer with a single worker thread (default):
$ huey_consumer.py my_app.huey
If your work-loads are mostly IO-bound, you can run the consumer with threads or greenlets instead. Because greenlets are so lightweight, you can run quite a few of them efficiently:
$ huey_consumer.py my_app.huey -k greenlet -w 32
Storage
Huey’s design and feature-set were comes with builtin support for Redis, Sqlite and in-memory storage.
Documentation
Project page
See source code and issue tracker on Github.
Huey is named in honor of my cat:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages. | https://pypi.org/project/huey/ | CC-MAIN-2021-25 | refinedweb | 395 | 54.73 |
2 Answers
1 year ago.
Hello
I'm also have same question. The solution is temtative because its "TESTING".
I want to know, can I use SW TRNG with any crupto library ? if possible, how to configure ?
Best Regards
2 years ago.
I'm not sure what you're trying to do, but http-example uses F401RE with ESP8266 module and also includes mbed TLS, so maybe use it a starting point.
i want to test 'alexa-iot' example. and already test and work normally with DISCO-F746NG board. but this board has Ethernet(wired) only. so i change target board(F401RE) in my project and add 'ESP8266' library. but i can't compile. i saw error message( undefined reference mbedtls_ssl_init and other ).posted by 03 Aug 2017 this is connect with AWS IoT.posted by 03 Aug 2017
First, add the esp8266-driver library. Then, in the code, where it says
EthernetInterface (and #include EthernetInterface.h) replace with:
#include "ESP8266Interface.h" ESP8266Interface net(D8, D2, true);
And pass in SSID and password in the connect call.
But I can't compile the AWS-test program, so I can't verify if it actually works.posted by 03 Aug 2017
thanks for your help. i will try to make my repository. but i don't know how to do. I will share my current project with you.posted by 04 Aug 2017
my project uploaded in repository(). you have to export it( GCC_ARM/NUCLEO_F401RE ) first. then, add 'CXX_FLAGS += -std=gnu++11' at makefile. you can see error message.posted by 04 Aug 2017
You'll need to set an entropy source, otherwise the ssl functions are not linked in. For TESTING you can define a NULL entropy source by declaring these macros:
MBEDTLS_TEST_NULL_ENTROPY and MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
I've tested your code with these macros enabled and then the program compiles.
Side-note: you cannot use pin D1/D0 for UART on NUCLEO-F401RE because they are used by USB. Use D8/D2 instead.posted by 04 Aug 2017
ASM_FLAGS += -DMBEDTLS_TEST_NULL_ENTROPY & ASM_FLAGS += -DMBEDTLS_NO_DEFAULT_ENTROPY_SOURCES. added in Makefile. but compile can't. please tell me detail.posted by 07 Aug 2017
These macros need to be set under C_FLAGS and CXX_FLAGS, not under ASM_FLAGS. If you're building with mbed CLI you can also add them under the macros section in mbed_app.jsonposted by 07 Aug 2017
You need to log in to post a question | https://os.mbed.com/questions/78703/How-To-use-mbedTLS-with-ESP8266-01-in-NU/ | CC-MAIN-2019-35 | refinedweb | 402 | 78.55 |
I am trying to read each word from a file and put it in a pointer then send it to a vector.
Here is what I have so far. I am having a hard time sending the data to a function where I will add it to a vector.
Here is what I have so far. Right now the output is showing the last word of the file spelt out with one letter per line. It should be showing all the words from the text file with one word per line. (I will be counting the words later right now I am just trying to get this part done.) Thanks for your help.
#include <iostream> #include <fstream> #include <vector> #include <string> using namespace std; void WordFunction(string *pstr); int main() { ifstream file; string word; file.open("word.txt"); while (!file.eof()) { file >> word; WordFunction(&word); } file.close(); for (int i=0; i < word.size(); i++) { cout << word[i] << endl; } system ("pause"); return 0; } void WordFunction(string *pstr) { vector<string *> words; words.push_back(pstr); } | https://www.daniweb.com/programming/software-development/threads/438859/c-vector-question | CC-MAIN-2018-30 | refinedweb | 173 | 83.36 |
Xmonad/Config archive/John Goerzen's Configuration
I'm going to take you step-by-step through the process of configuring Xmonad, setting up a status bar with xmobar, setting up a tray with trayer, and making it all play nicely together. I use this exact configuration on everything from a 1024x600 Eee PC to a 1920x1200 24" workstation, and it works well on all of them.
I assume that you have read the About xmonad page as well as the xmonad guided tour already.
Before you begin, here is a screenshot of my desktop:
And here is a screenshot that points out what I'm talking about when I talk about the status bar and the tray:
Contents
Preliminaries
First you'll want to install xmonad. You can find instructions for that on xmonad.org. I'm going to assume xmonad 0.8 here.
This guide will work for any operating system. I happen to use Debian, so when I talk about installing software, I can give you Debian commands. But you can run xmonad all over the place; just substitute the appropriate commands for your system.
To install xmonad on Debian squeeze, you can just run:
apt-get install xmonad libghc6-xmonad-contrib-dev libghc6-xmonad-dev dwm-tools
For Debian wheezy (and recent above), run:
apt-get install xmonad libghc-xmonad-contrib-dev libghc-xmonad-dev suckless-tools
This installs xmonad itself, everything you need to configure it, and dwm-tools, which provides the Mod-P launching feature. If you're not on squeeze or wheezy, consult the xmonad download site -- note that there are etch binaries there, too. If you're downloading the etch binaries, you'll need the etch ghc6 and libghc6-*-dev*.deb binaries as well.
Set up xmonad in your .xsession as directed in the xmonad guided tour. You should have xmonad up and running before continuing.
Customizing xmonad
So the first thing you will want to do is customize xmonad.
Make a directory called ~/.xmonad, and in there, create a file named xmonad.hs. We'll start off with importing some of the utility modules we will use:
import XMonad import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Util.Run(spawnPipe) import XMonad.Util.EZConfig(additionalKeys) import System.IO
Next, a basic configuration -- which is the same as the default -- is this:
main = do xmonad $ defaultConfig
Over at the how to write a config file page -- which you should go read right now -- there are instructions for testing your config file. You should be able to save the above file, with the import lines plus the other two, and validate it with ghci, then press Mod-q to load it up. Another way to validate your xmonad.hs is to simply run `xmonad --recompile' in a terminal. You'll see errors if it's bad, and nothing if it's good.
Now how about something real? Replace the lines starting with main with:
main = do xmonad $ docks defaultConfig { layoutHook = avoidStruts $ layoutHook defaultConfig }
(Disclaimer: The author in reality does not use this 'comma first' style. However, since it is the style used in xmonad, xmonad-contrib and most all xmonad.hs files, he has kindly consented to allow your friendly wiki gardeners to convert the original Haskell from 'comma last' style. This should make copying pieces from other configs a bit easier.)
Also, ghc sees tab characters as eight spaces, so to prevent confusion ensure your editor produces eight space tabs or expands tabs to spaces when editing haskell files. XMonad convention is to always expand tabs and (mostly) indent by four space increments. Wikibooks has a great explanation of layout rules and indentation in haskell.
-- real Goerzen config style main = do xmonad $ docks defaultConfig { layoutHook = avoidStruts $ layoutHook defaultConfig }
What this does is take the default configuration (defaultConfig) and adds the support we need for a status bar and dock. This particular recipe comes from the [[1]]. For more ways to customize how and where windows are created, see the manageHook examples in XMonad General Configuration Tips.
I'll show my completed file at the end of this page, but for now let's add a few additional things in. By default, the Mod key is Alt, which is also used in Emacs. Sometimes Emacs and xmonad want to use the same key for different actions. Rather than remap every common key, I just change Mod to be the Windows key that's between Ctrl and Alt. So I add this line after layoutHook:
, modMask = mod4Mask -- Rebind Mod to the Windows key
The two dashes are a comment to the end of the line.
I also want to bind Mod-Shift-z to lock my screen with the screensaver, control-PrintScreen to take a snapshot of one window, and Printscreen to take a snapshot of the entire screen. My config file, starting with main, now looks like:
main = do xmonad $ docks defaultConfig { layoutHook = avoidStruts $ layoutHook defaultConfig , modMask = mod4Mask -- Rebind Mod to the Windows key } `additionalKeys` [ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock") , ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s") , ((0, xK_Print), spawn "scrot") ]
You can find the names for keys in the haskell-X11 source package in the files Graphics/X11/Types.hsc and Graphics.X11.ExtraTypes.hsc.
To support screen capture, run apt-get install scrot. I will cover setting up the screensaver later in this tutorial.
Did you notice the 0 in the xK_Print line? The first part of the (0, xK_Print) tuple states what modifier keys (ctrl, alt, etc.) have to be held down for a pattern to match. For the PrintScreen key, we don't need anything to be held down, and the zero indicates that. The 'sleep' before running the 'scrot -s' command is to leave time for keys to be released before scrot -s tries to grab the keyboard.
Installing xmobar
Next, it's time to get started with xmobar, the status bar. You can use xmobar or dzen2. dzen2 probably has a few more features, but xmobar has lower resource utilization and is considerably easier and more reliable to set up. I found it does more than everything I need, and recommend it.
You can download xmobar from its homepage, linked to above. That page also has compilation and installation instructions. As of Sept. 17, 2008, I also maintain a Darcs tree. Most patches have been merged back as of xmobar 0.9.1, but a couple patches that shorten the number formatting are unapplied. You can download my tree and merge with the official tree with:
darcs get
darcs pull --repodir=xmobar --all
If you darcs, apt-get install darcs or get it from your distribution or darcs.net.
Configuring xmonad to use xmobar
So, let's talk a little bit about how xmonad and xmobar fit together. You can piece them together in several different ways.
xmobar accepts input on its stdin, which it can display at an arbitrary position on the screen. It can also easily display other information. We want xmonad to send xmobar the stuff that I have at the upper left of my screenshot: information about available workspaces, current layout, and window manager.
We could, then, have xmonad write this stuff to its stdout, and write
xmonad | xmobar in ~/.xsession. But it's more elegant and useful, in my opinion, to have xmonad fire up xmobar itself. This is pretty simple. Our main part of xmonad.hs will now look like:
-- If xmobar is in your $PATH, and its config is in ~/.xmobarrc, otherwise -- xmproc <- spawnPipe "/path/to/xmobarbinary /path/to/.xmobarrc" main = do xmproc <- spawnPipe "xmobar" xmonad $ docks defaultConfig {") ]
We've added a line right after "main". We fire up xmobar, and pass to it a command-line argument giving the path to its config file -- we will create this file in a minute. Then we also define a logHook. We tell xmonad that the way we get output to xmobar is with the command hPutStrLn xmproc -- this transmits the data via a pipe to xmobar. We also tell it that we want to put the first 50 characters of the window title in the title area.
When using hPutStrLn in your logHook make sure to add StdinReader to your xmobarrc commands and template as described below or xmonad may freeze when the unread pipe fills up.
Save this and test it with ghci.
Configuring xmobar
Now, before this will work, we have to configure xmobar. Here's a slightly simplified version of what I use, which is mostly similar to the sample you can find in the xmobar source package.
For xmobar-0.9 or earlier%" }
Note: With 0.9 < xmobar-version <= 0.9.2 , you will need to add a lowerOnStart line just below position:
Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*" , bgColor = "black" , fgColor = "grey" , position = TopW L 90 , lowerOnStart = True ....<snip>
Note: With xmobar-version > 0.9.2 , any fields you leave out will be replaced by defaults, and the order doesn't matter.
First, I set the font to use for my bar, as well as the colors. The position options are documented well on the xmobar home page. This says to put my bar in the upper left of the screen, and make it consume 90% of the width of the screen.
In the
commands list you, well, define commands. The commands are the pieces that generate the content that is available to display, which will later be combined together in the template. I define a weather widget, a CPU widget, memory and swap widgets, a clock, and of course the data from xmonad via the StdinReader.
The template then combines them together. Stuff to be left-justified goes before the } character, things to be centered after it, and things to be right justified after {. I have nothing centered so there is nothing in between them.
Warning: even though the config file uses Haskell syntax, it doesn't accept comments, (and in versions earlier than 0.9.3 doesn't allow you to change the field order, or drop fields.) This is because older versions of xmobar use
reads to parse the config file.
Save that to ~/.xmobarrc. Now you should be able to press Mod-q and have xmonad load up xmobar, and have it work. (Note: until you add the trayer command to your .xinitrc, as described below, to fill up the other 10% of the screen width, and restart X Windows, your windows may cover the xmobar status bar.)
Replace both occurrences of EGPF with your choice of ICAO weather stations. There is a list of ICAO station codes maintained at ucar.edu. You can of course monitor more than one if you like, see the xmobar home page for more details.
Adding Keyboard LED Indication
My 9.1" Eee doesn't have capslock or numlock lights. Before xmonad, I had an applet to do that, but that's not very efficient now. If you want this, read this section, otherwise skip it.
You'll need two pieces of software for this to work:
1) xmobar >= 0.9.1
2) My ledmon tool, which you can obtain with:
git clone git://git.complete.org/ledmon
Or download from its gitweb page.
The CommandReader plugin will be used, which will cause xmobar to fork off ledmon. I compiled ledmon and put the binary in ~/.xmonad/ledmon, then modified my ~/.xmobarrc to look like this: , Run CommandReader "/home/jgoerzen/.xmonad/ledmon" "LED" ] , sepChar = "%" , alignSep = "}{" , template = "%StdinReader% }{ <fc=#ffff00>%LED%</fc> %cpu% | %memory% * %swap% <fc=#ee9a00>%date%</fc> | %EGPF%" }
That's all there is to it.
(for newer versions than xmobar-0.9, add lowerOnStart)
Configuring Related Utilities
So now you've got a status bar and xmonad. We still need a few more things: a screensaver, a tray for your apps that have tray icons, a way to set your desktop background, and the like.
For this, we will need a few pieces of software.
apt-get install trayer xscreensaver
If you want the Gajim instant messenger client, a battery meter, and a network applet, also:
apt-get install gajim nm-applet gnome-power-manager
First, configure xscreensaver how you like it with the xscreensaver-demo command. Now, we will set these things up in ~/.xsession. Your .xsession may wind up looking like this:
#!/bin/bash # Load resources xrdb -merge .Xresources # Set up an icon tray trayer --edge top --align right --SetDockType true --SetPartialStrut true \ --expand true --width 10 --transparent true --tint 0x191970 --height 12 & # Set the background color< xsetroot -solid midnightblue # Fire up apps gajim & xscreensaver -no-splash & if [ -x /usr/bin/nm-applet ] ; then nm-applet --sm-disable & fi if [ -x /usr/bin/gnome-power-manager ] ; then sleep 3 gnome-power-manager & fi exec xmonad
This uses xsetroot to set my background color. It can also use images; see its manpage for more.
Then we fire up trayer, the icon tray. The options tell it to go on the top right, with a default width of 10% of the screen (to nicely match up with the status bar, which we set to a width of 90% of the screen). We give it a color and a height.
Then we fire up gajim, the screensaver daemon, and if installed, the network manager applet and the power manager.
Finally, we start xmonad.
Mission accomplished!
Final Touches
There may be some programs that you don't want xmonad to tile. The classic example is Gimp. It pops up all sorts of new windows all the time, and they work best at defined sizes. It makes sense for xmonad to ignore them. Over at the general tips page, there are suggestions on how to accomplish this. The xmonad FAQ has instructions on using xprop to find the class (or other properties) of your window. In the following example if it doesn't work as is, replace Gimp with the class name of your particular install, such as Gimp-2.X or whatever it happens to be. Also note that manageHook runs when windows are created, so you will have to restart the program to be managed if you're dialing in the correct className.
We are going to compose a list like so:
myManageHook = composeAll [ className =? "Gimp" --> doFloat]
I also don't want xmonad to tile the VNC viewer, because I want to manage its size myself. Very well; I can add it:
myManageHook = composeAll [ className =? "Gimp" --> doFloat , className =? "Vncviewer" --> doFloat ]
Now, we tie that in with what we're already doing for the manageHook, so our manageHook bit of main looks like:
xmonad $ docks defaultConfig { manageHook = myManageHook <+> manageHook defaultConfig
The full ~/.xmonad/xmonad.hs now looks like this:ncviewer" --> doFloat ] main = do xmproc <- spawnPipe "xmobar" xmonad $ docks defaultConfig { manageHook = myManageHook <+> manageHook defaultConfig -- make sure to include myManageHook definition from above ,") ]
Tips on daily use
Here are a few things that occurred to me as I was learning xmonad.
Minimizing Windows
xmonad doesn't currently have a "minimize" feature. So I've designated workspace 9 for this purpose. When I want to hide a window, I Mod-Shift-9 it. That makes it go away. When I want it back, it's Mod-9, the Mod-j or Mod-k to select it, then Mod-Shift-1 Mod-1 or whatnot to zip it back and go back. It works surprisingly well.
Use of workspaces
I used to use KDE, and I used workspaces there too. But with the ability to so easily zip windows around to different workspaces, and to instantaneously change between them using only the keyboard, it's a lot easier to use.
Also, I find myself not wanting to have quite as many windows open on a given desktop at once. I generally have desktop 1 be for shells, 2 for email/IM, 3 for web, and 9 for music/minimized stuff. But I'm just learning this so far, and may find a better way. Don't hesitate to try different ways of organizing and use what works for you.
Trouble?
Check ~/.xsession-errors first.
Also, #xmonad on irc.freenode.net is very friendly and helpful. Ask questions and wait in channel for a while, eventually someone will answer if they have something helpful to say. Sometimes in 10 minutes, sometimes in 10 hours. | https://wiki.haskell.org/index.php?title=Xmonad/Config_archive/John_Goerzen%27s_Configuration&oldid=63317 | CC-MAIN-2021-17 | refinedweb | 2,718 | 64.81 |
Perhaps someone can help with this problem. For info - Choicebox is an enigma2 gui class - this is not important for my question.
- Code: Select all
SELECTION = " "
def main(session, **kwargs):
res = openTest(session)
print "res =", res
def openTest(session):
session.openWithCallback(test1, ChoiceBox, title="Select playlist item?", list=[(_("Video1"), "Video1"), (_("Video2"), "Video2"), (_("Video3"), "Video3"), (_("Video4"), "Video4"), (_("Video5!"), "Video5")])
return SELECTION
def test1(answer):
print "answer A:", answer
global SELECTION
SELECTION = answer[1]
Question :- This code prints res = None. Obviously the print line is executed before openTest is completed. Without changing def main - how can the correct reply 'res' be returned and printed ?
Regards, pcd. | http://www.python-forum.org/viewtopic.php?p=16473 | CC-MAIN-2015-14 | refinedweb | 109 | 59.4 |
Throughout this tutorial, we are going to see a detailed example showing how to open URLs in Ionic 2+ mobile apps using the Cordova plugin InAppBrowser and Ionic Native 3.x+.
SEE ALSO:
Full Ionic 2/Ionic 3 mobile app with Ionic Native 3.x and InAppBrowser
and
Ionic 2/3: Using Cordova SQLite and Barcode Scanner Plugins to Build a Product Inventory Manager
Now lets get started.
We will start by generating a new Ionic 2+ project with Ionic CLI so open up your terminal if your are developing under a Linux/MAC system or your command prompt under Windows then type.
ionic start ionic2-inappbrowser-example blank
N.B: Under Windows the recommended way to work with Ionic 2+ is through visual studio.
Next navigate inside your project folder
cd ionic2-inappbrowser-example
And add your target platform with
cordova platform add android
I'm developing under a Ubuntu system so I can only target Android devices. If you are under a MAC you can target iOS too with
cordova platform add iOS
N.B: If you don't have cordova already installed you can easily install it via npm with
npm install -g cordova
Next, you just need to add InAppBrowser with
cordova plugin add cordova-plugin-inappbrowser
Now we are ready to add some code to our project to open external URLs, so go ahead and open home.ts and modify it to look like:
import { Component } from '@angular/core'; import { NavController , Platform} from 'ionic-angular'; import { InAppBrowser } from 'ionic-native'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { constructor( public platform: Platform,public navCtrl: NavController) { } openUrl() { this.platform.ready().then(() => { let browser = new InAppBrowser("",'_blank'); }); } }
So as you can see, we have started by importing the InAppBrowser plugin from ionic-native module then we have added the openUrl() method that will handle opening the specified url.
Next open your template and add a button to trigger the method
N.B: Don't use the old .open() method
InAppBrowser.open(url, "_system");
Many developers are getting this error
Uncaught Error: Can't resolve all parameters for InAppBrowser: (?, ?, ?).
Because it is deprecated with Ionic Native. Instead you should use
let browser = new InAppBrowser('YOUR_URL', "_system");
Next just execute
ionic serve
To play with your demo on the browser at
When you are finished testing build your app for you target platform with
ionic build android | iOS
You can also find the example app in GitHub{target:<< | https://www.techiediaries.com/mobiledev/cordova-inappbrowser-example-ionic2-native/ | CC-MAIN-2017-43 | refinedweb | 411 | 50.26 |
Hide Forgot
python-jedi fails to build with Python 3.10.0a2.
________________________ test_find_system_environments _________________________
def test_find_system_environments():
envs = list(find_system_environments())
> assert len(envs)
E assert 0
E + where 0 = len([])
test/test_api/test_environment.py:19: AssertionError
______________________ test_completion_param_annotations _______________________
def test_completion_param_annotations():
# Need to define this function not directly in Python. Otherwise Jedi is too
# clever and uses the Python code instead of the signature object.
code = 'def foo(a: 1, b: str, c: int = 1.0) -> bytes: pass'
exec(code, locals())
script = jedi.Interpreter('foo', [locals()])
c, = script.complete()
sig, = c.get_signatures()
a, b, c = sig.params
assert a.infer() == []
> assert [d.name for d in b.infer()] == ['str']
E AssertionError: assert [] == ['str']
E Right contains one more item: 'str'
E Use -v to get the full diff
test/test_api/test_interpreter.py:316: AssertionError
__________________ test_compiled_signature_annotation_string ___________________
def test_compiled_signature_annotation_string():
import typing
def func(x: typing.Type, y: typing.Union[typing.Type, int]):
pass
func.__name__ = 'not_func'
s, = jedi.Interpreter('func()', [locals()]).get_signatures(1, 5)
> assert s.params[0].description == 'param x: Type'
E assert "param x: 'typing.Type'" == 'param x: Type'
E - param x: Type
E + param x: 'typing.Type'
test/test_inference/test_mixed.py:113: AssertionError
===== 3 failed, 1451 passed, 20 skipped, 2 deselected, 5 xfailed in 42.38s =====
I understand the third failure: typing names/repor have been changed in Python 3.10.
For the first two failures, I have no clue.
For the build logs, see:
For all our attempts to build python-jedi.
Latest upstream commit behaves the same. Bumping the severity here, an entire stack ipython stack depends on it.
Petr, could you please take this upstream?
Upstream issue created:
Unfortunately, it seems that the fix will be much more complex than just adapting tests to new outputs.
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34. | https://bugzilla.redhat.com/show_bug.cgi?id=1898081 | CC-MAIN-2021-10 | refinedweb | 311 | 54.08 |
mohamed hassan2,079 Points
i have solved the challenge however i am not totally accepting my solution , i feel there is something missing
In this challenge, we have the following geographical coordinates
Eiffel Tower - lat: 48.8582, lon: 2.2945 Great Pyramid - lat: 29.9792, lon: 31.1344 Sydney Opera House - lat: 33.8587, lon: 151.2140
Declare a function named coordinates that takes a single parameter of type String, with an external name for, a local name of location, and returns a tuple containing two Double values (Note: You do not have to name the return values). For example, if I use your function and pass in the string "Eiffel Tower" as an argument, I should get (48.8582, 2.2945) as the value. If a string is passed in that doesn’t match the set above, return (0,0)
my answer is
// Enter your code below func coordinates (for location : String) -> (Double, Double) { switch location { case "Eiffel Tower": return (48.8582, 2.2945) case "Great Pyramid": return (29.9792, 31.1344) case "Sydney Opera House": return (33.8587, 151.2140) default: return (0, 0) } }
1 Answer
Jhoan ArangoTreehouse Moderator 12,179 Points
Hello Mohamed,
Your function looks good, and if it allows you to pass the challenge then you are good to go.
The requirements are there and everything seems perfect.
Good Job. | https://teamtreehouse.com/community/i-have-solved-the-challenge-however-i-am-not-totally-accepting-my-solution-i-feel-there-is-something-missing | CC-MAIN-2019-13 | refinedweb | 225 | 64.91 |
This Authentication module integrates the Moodle Learning Management System with MoinMoin. It allows the user to login on Moodle and use their Moodle LMS account for their identity on MoinMoin.
The Moodle LMS and MoinMoin must be running on the same domainname (so that the cookie can be shared between them). The domain name must be exactly the same (we found a cookie from couldn't be shared with hostname.com).
See also the other plugins in the AuthMarket.
Installation
Put moinoodle.py into the wiki directory, where it can be found by the configuration file
Add moodle_session_dir to your config file to point to the Moodle LMS moodledata/sessions directory, e.g.
moodle_session_dir = "/home/bob/moodledata/sessions"
Specify in the wikiconfig.py configuration file, e.g.
from moinoodle import moinoodle auth = [moinoodle] user_autocreate = True
Login in on Moodle and you will have that username on MoinMoin.
It may seem a bit weird, but you can't log off on MoinMoin, you must do that on Moodle too. Best thing to do is set show_login = False in your config file.
History
2007-05-20 : made changes suggested by ThomasWaldmann, and changed to work with Moodle 1.8 | http://www.moinmo.in/DavidMoore/Moinoodle | crawl-003 | refinedweb | 197 | 65.62 |
Arnd Bergmann wrote:> On Monday 29 January 2007 20:48, Maynard Johnson wrote:> >>Subject: Enable SPU switch notification to detect currently active SPU tasks.>>>>From: Maynard Johnson <maynardj@us.ibm.com>>>>>This patch adds to the capability of spu_switch_event_register so that the>>caller is also notified of currently active SPU tasks. It also exports>>spu_switch_event_register and spu_switch_event_unregister.>>>>Signed-off-by: Maynard Johnson <mpjohn@us.ibm.com>> > > I looked through it again, and think I found a serious bug, but that> should be easy enough to solve:> > >>+static void notify_spus_active(void)>>+{>>+ int node;>>+ /* Wake up the active spu_contexts. When the awakened processes >>+ * sees their notify_active flag is set, they will call>>+ * spu_switch_notify();>>+ */>>+ for (node = 0; node < MAX_NUMNODES; node++) {>>+ struct spu *spu;>>+ mutex_lock(&spu_prio->active_mutex[node]);>>+ list_for_each_entry(spu, &spu_prio->active_list[node], list) {>>+ struct spu_context *ctx = spu->ctx;> > > [side note]> There is a small whitespace breakage in here, please make sure you always> use tabs for indenting, not space characters.> [/side note]> > >>@@ -45,9 +45,10 @@>> u64 pte_fault;>> >> *stat = ctx->ops->status_read(ctx);>>- if (ctx->state != SPU_STATE_RUNNABLE)>>- return 1;>>+>> spu = ctx->spu;>>+ if (ctx->state != SPU_STATE_RUNNABLE || spu->notify_active)>>+ return 1;>> pte_fault = spu->dsisr &>> (MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED);>> return (!(*stat & 0x1) || pte_fault || spu->class_0_pending) ? 1 : 0;>>@@ -305,6 +306,7 @@>> u32 *npc, u32 *event)>> {>> int ret;>>+ struct spu * spu;>> u32 status;>> >> if (down_interruptible(&ctx->run_sema))>>@@ -318,8 +320,16 @@>> >> do {>> ret = spufs_wait(ctx->stop_wq, spu_stopped(ctx, &status));>>+ spu = ctx->spu;>> if (unlikely(ret))>> break;>>+ if (unlikely(spu->notify_active)) {>>+ spu->notify_active = 0;>>+ if (!(status & SPU_STATUS_STOPPED_BY_STOP)) {>>+ spu_switch_notify(spu, ctx);>>+ continue;>>+ }>>+ }> > > This is before spu_reacquire_runnable, so in case the spu got> preempted at the same time when oprofile was enabled, ctx->spu> is NULL, and you can't load the notify_active flag from it.> > On solution would be to move the notify_active flag from ctx->spu> into ctx itself, but maybe there are other ways to solve this.In an earlier review of this patch, Christopher Hellwig suggested I move the notify_active flag to be a bit in the sched_flags field that's added in his scheduler patch series. If this patch series will be a available in an "Arnd" tree that we'll be using for our current OProfile development, perhaps I should wait until that time to change this, since the window of vulnerability is quite small. What do you think?-Maynard> > Thanks,> > Arnd <><-To unsubscribe from this list: send the line "unsubscribe linux-kernel" inthe body of a message to majordomo@vger.kernel.orgMore majordomo info at read the FAQ at | http://lkml.org/lkml/2007/1/30/192 | CC-MAIN-2014-41 | refinedweb | 415 | 52.49 |
Hello,
I have created this dynamic page which includes blood testing information (image 1).
However, where the circle is, instead of "test code" i would like that to be for "Price".
Where the page itself is public, but if the client logins in then they can view pricing specific to them. Corresponding to the relevant test code.
There are over 100 tests and each price for every client is different.
I think what i need is a code that after they login will recognize and bind to their corresponding Client field key. How can i bind their login with their client field key so that it grabs their specific pricing?
I'm not sure I understand how you store the client data. Do you create a field per logged in user?
I just added "Client 1" and "Client 2" above as examples. I am not sure whether to store the client data separately or within the same sheet. Ideally it would be within the same sheet with a field per logged in user.
Any ideas on this? Thanks in advance
Hi David, I will try to help you out, I had a similar problem. The below answer assumes the following:
0) that every client logs into Wix using the Wix users standars dialog (you can OK them or not)
1) that every row into your database carries a unique identifier for a client (I propose email address)
2) that every row in your database is entered by you, so a future selection on row_owner is useless, because that will carry your ID, not the client´s (therefor email address)
3) that you have to do two lookups (actually a JOIN): first the correct row from your DB filtered by clients email address (which could have more than 1 result: a client could come back), then fetch the test code from this row and do another lookup, get the price and display it.
@0/1/2) when you enter a row into you database with results, you have to provide the clients email address and, to make it friendly, his name. When the user logs on, you retrieve his email address from Wix-users and you display all rows into a table. This would be somethjing like this: (snippet from a case-selection)
break;
case "Member":
user.getEmail()
.then((rsemail) => {
let userEmail = rsemail;
wixData.query("YourCollectionName_NotDatasetName")
.eq("email", userEmail)
.ascending("title")
.find()
.then((results) => {
$w("#tblName fot the table you are using").rows = results.items;
})
.catch((err) => {
let errorMsg = err;
});
});
break;
case "Admin":
@3) so now the client has selected one of his results from a table. That one is easy, you display all data on a dynamic page.
Then the join. You select the test code like this:
let thistestCode = $w('#datasetname').getCurrentItem().testcode;
assumiing that .testcode is the actual field name in your DB (and NOT the label name)
Now you build a new query, just like the one above, but this time on the Test code collection, with a .eq(thistestCode). You retrieve the Price from this row just like we retrieved the Test code above, you throw it to a text field (or in your case inside that balloon) and voila.
Hope this helps. Good luck.
Thanks so much Giri, unfortunately I'm not too code savy.
I just butchered the whole Code. Hopefully I can get some help.
I created 2 databases
1. CompleteMenu has all the test information stored
2. Client Has Client/Member Information: Name, Email, Price and Test Code (Test Code matches test codes in #1)
CompleteMenu Field Codes:
Test code field name= title_id
Client Field Codes:
Price_id
Test Code_id
Name_id
Code placed in the Dynamic Page:
David, I see what´s the problem, it´s my fault, I thought you would understand the switch/case part, but I see you assumed this would be a copy/paste thing. It´s not. I will correct the errors, but first you need to give me some pointers on how you want this to work:
a)who may enter your database and request results: if only registered users: who registers the user: you or they?(tip: to make it easier, I advise that you create an account for every client, so you don´t have to approve/deny access every day to every request)
b) who creates the client details, as you described: you or they? (tip: it´s easier if you did that)
c) can clients have more than one test result ( even if one if from a couple of years ago?
d) if more than one, would you like to show also the "old" ones, or just the "new" one. If last, what is definition of new (maybe when it was paid and delivered/sent)?
e) I do not understand your database setup: correct me if I am wrong, but if you define a test code per client, that means he can only have 1 test (thereby giving an answer to question c)
f) Don´t you need at least this: a client collection, a test code collection(that holds pricing per test code) and a test result collection, that holds info on the client, the test results and a link to the test code pricing to retrieve the price?
Sorry to put so many questions to you, but if we want to get it right quickly, I need to know how you envision it to work.
Watching your back.
David, one more thing: is this supposed to be an internal application (just for you and your employees) or also external (so clients can grab their results from your web site)?
Hi Giri,
I really appreciate the assistance. To clarify, this isn't for results. This is meant to just show test information. I placed an example below.
a) I will be creating the users
b) I create/input the client details
c) The pricing for the clients is viewable only. They will not be placing orders online. The test code isn't a result it's just the code that is unique to the each test. Every client will have the same test code, but different prices. (see example below)
d) They would not be ordering/paying online
e) See example below
f) I hope this clarifies/helps what I think I need is something like: after client logs in if the Test code matches in database 1&2 and also the email in database 2 then it will show the price corresponding to that email that corresponds to the test code.
I have 1 database with the test information this never changes unless new tests are added.
The second database includes the test code, price, email, client name, Client ID.
The unique identifier could be either the Email or Client ID (I think in terms of setting things up the email may be the easiest?)
So let's say "Client2" logs in and is viewing "test2". Now the system will know client2@gmail.com is logged in and that he is looking at Test code 5678 thus the price will show $3.69.
This is an example of what the page currently looks like:
Note: "Test code" will be moved to the left and instead will indicate "Price" in the circle.
Also, if no one is logged in then it would either be blank or indicate "Click here to login and view your pricing"
Let me know if you have any other questions I am more than happy to answer them
This is for External application; for clients to view their pricing
Hi David, sorry about late response, I had no Internet all morning. I think I understand what you mean, so what we are going to do is this:
1) when a user is not logged on, we are going to show a text box saying something like "PLease logon to view your pricing" and a logon button next to it.
2) if a user is logged on and there is pricing for a text code, we show the price insode the balloon and hide the textbox and button
3) if a user is logged on and there is no pricing for the test code, we change the text to something like "No pricing available, please contact us" and hide the logon button
How to do it
1) on the dynamic page, draw a box (container) which we will call "box1" (lets say below the balloon). INside it, put a text box and a button next to it. Textbox will be "txtRemarks", button will be "btnLogon". Using a box around these things has 2 purposes: the text and button will stay nicely together on a smartphone screen AND it will allow us to hide the box entirely (including text and button). Fill the text box with the default text for non-logged on visitors (see 1, above)
2) copy all your current code to a text file (we are going to need it later on) and then delete everything apart from the $w.onready and corresponding curly brace
3) at the top, thus above the $w.onready, do this
iimport wixUsers from 'wix-users';
import wixData from 'wix-data';
4) inside the $w.Onready, do this
let user = wixUsers.currentUser;
let userRole = user.role;
if (userRole = "Member") {
$w("#Box1).Hide()";
user.getEmail()
.then((rsemail) => {
let userEmail = rsemail;
let thistestCode = $w('#datasetname').getCurrentItem().testcode; // TODO:replace datasetname with your dataset name of the dynamic page
wixData.query("Clients") // change this to the Collection name of your clients db
.eq("email_id", userEmail)
.eq("testCode_id", thistestCode )
.descending("date_created") //TODO ;lookup the real name in the Admin grid
.find()
.then((results) => {
if ( results.totalCount [TODO:see below]) {
let items = results.items ;
let firstItem = items[0];
$w("#txtPrice") = firstItem.price_Id ;// this puts the price into the balloon
else {
$w("#Box1).Show()";
$w("#btnLogon).Hide()";
$w("#txtRemarks = "Sorry, no pricing available, please contact us";
}
}
})
.catch((err) => {
let errorMsg = err; // bogus, never used
});
});
}
5) I do not know what results.totalCount returns if there is no test code for this user (empty resultset). It could be 0, -1, Null or undefined. You will have to try this out by using a bogus email address and do a console-log of results.totalCount Then test accordingly on 1 of those 4 possibilities.
Also, you see we allow that a user can have two equal test codes. This could happen when you change your prices per user/testcode and you don´t want to destroy the old info OR you make a mistake and put in two rows with same email/same test code. In this case THE mostrecent is selected , because we sort on creation date
6) on the onClick event of the button, code a a promptLogin(). That will force a login window.
NOTE: I did not test this code, I typed it in into this forum text window , so it might have a missing ; or } here and there or it needs a little tweek.. You will have to find that out for yourself, but this should get you going. The TODO´s are easy. If not, look at w3school for javascripts help and look at the API docs here on Wix. You will have to put some effort into it, otherwise you are not going to understand what you are doing. Believe me when I say that problems that first seemed insurmountable will look pathetically trivial after a couple of weeks of reading and horsing around.
Good luck.
PS do NOT forget to put a dataset.onready inside the page onready (it´s docuemnted everywhere). I did.
Another thing: when testing, you will have to do that on a Published site. As Andreas once explained to me, user-stuff doesnot work in Preview Mode | https://www.wix.com/corvid/forum/community-discussion/client-specific-pricing-for-dynamic-page | CC-MAIN-2019-47 | refinedweb | 1,958 | 77.67 |
In this tutorial I'll teach you how to use three different texture filters. I'll teach you how to move an object using keys on the keyboard, and I'll also teach you how to apply simple lighting to your OpenGL scene. Lots covered in this tutorial, so if the previous tutorials are giving you problems, go back and review. It's important to have a good understanding of the basics before you jump into the following code.
We're going to be modifying the code from lesson one again. As usual, if there are any major changes, I will write out the entire section of code that has been modified. We'll start off by adding a few new variables to the program.
#include <windows.h> // Header File For Windows
bool fullscreen=TRUE; // Fullscreen Flag
The lines below are new. We're going to add three boolean variables. BOOL means the variable can only be TRUE or FALSE. We create a variable called light to keep track of whether or not the lighting is on or off. The variables lp and fp are used to store whether or not the 'L' or 'F' key has been pressed. I'll explain why we need these variables later on in the code. For now, just know that they are important.
BOOL light; // Lighting ON / OFF
BOOL lp; // L Pressed?
BOOL fp; // F Pressed? crate is.
GLfloat xrot; // X Rotation
GLfloat yrot; // Y Rotation
GLfloat xspeed; // X Rotation Speed
GLfloat yspeed; // Y Rotation Speed
GLfloat z=-5.0f; // Depth Into The Screen
Now we set up the arrays that will be used to create the lighting. We'll use two different types of light..
Light is created the same way color is created. If the first number is 1.0f, and the next two are 0.0f, we will end up with a bright red light. If the third number is 1.0f, and the first two are 0.0f, we will have a bright blue light. The last number is an alpha value. We'll leave it at 1.0f for now.
So in the line below, we are storing the values for a white ambient light at half intensity (0.5f). Because all the numbers are 0.5f, we will end up with a light that's halfway between off (black) and full brightness (white). Red, blue and green mixed at the same value will create a shade from black(0.0f) to white(1.0f). Without an ambient light, spots where there is no diffuse light will appear very dark.
GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f }; // Ambient Light Values ( NEW )
In the next line we're storing the values for a super bright, full intensity diffuse light. All the values are 1.0f. This means the light is as bright as we can get it. A diffuse light this bright lights up the front of the crate nicely.
GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; // Diffuse Light Values ( NEW )
Finally we store the position of the light. The first three numbers are the same as glTranslate's three numbers. The first number is for moving left and right on the x plane, the second number is for moving up and down on the y plane, and the third number is for moving into and out of the screen on the z plane. Because we want our light hitting directly on the front of the crate, we don't move left or right so the first value is 0.0f (no movement on x), we don't want to move up and down, so the second value is 0.0f as well. For the third value we want to make sure the light is always in front of the crate. So we'll position the light off the screen, towards the viewer. Lets say the glass on your monitor is at 0.0f on the z plane. We'll position the light at 2.0f on the z plane. If you could actually see the light, it would be floating in front of the glass on your monitor. By doing this, the only way the light would be behind the crate is if the crate was also in front of the glass on your monitor. Of course if the crate was no longer behind the glass on your monitor, you would no longer see the crate, so it doesn't matter where the light is. Does that make sense?
There's no real easy way to explain the third parameter. You should know that -2.0f is going to be closer to you than -5.0f. and -100.0f would be WAY into the screen. Once you get to 0.0f, the image is so big, it fills the entire monitor. Once you start going into positive values, the image no longer appears on the screen cause it has "gone past the screen". That's what I mean when I say out of the screen. The object is still there, you just can't see it anymore.
Leave the last number at 1.0f. This tells OpenGL the designated coordinates are the position of the light source. More about this in a later tutorial.
GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f }; // Light Position ( NEW )
The filter variable below is to keep.
GLuint texture[3] creates storage space for the three different textures. The textures will be stored at texture[0], texture[1] and texture[2].
GLuint filter; // Which Filter To Use
GLuint texture[3]; // Storage for 3 textures
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
Now we load in a bitmap, and create three different textures from it. This tutorial uses the glaux library to load in the bitmap, so make sure you have the glaux library included before you try compiling the code. I know Delphi, and Visual C++ both have glaux libraries. I'm not sure about other languages. I'm only going to explain what the new lines of code do, if you see a line I haven't commented on, and you're wondering what it does, check tutorial six. It explains loading, and building texture maps from bitmap images in great detail.
Immediately after the above code, and before ReSizeGLScene(), we want to add the following section of code. This is the same code we used in lesson 6 to load in a bitmap file. Nothing has changed. If you're not sure what any of the following lines do, read tutorial six. It explains the code below in detail.
}
This is the section of code that loads the bitmap (calling the code above) and converts it into 3 textures. Status is used to keep track of whether or not the texture was loaded and created.
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
Now we load the bitmap and convert it to a texture. TextureImage[0]=LoadBMP("Data/Crate.bmp") will jump to our LoadBMP() code. The file named Crate.bmp in the Data directory will be loaded. If everything goes well, the image data is stored in TextureImage[0], Status is set to TRUE, and we start to build our texture.
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage[0]=LoadBMP("Data/Crate.bmp"))
{
Status=TRUE; // Set The Status To TRUE
Now that we've loaded the image data into TextureImage[0], we'll use the data to build 3 textures. The line below tells OpenGL we want to build three textures, and we want the texture to be stored in texture[0], texture[1] and texture[2].
glGenTextures(3, &texture[0]); // Create Three Textures
In tutorial six, we used linear filtered texture maps. They require a hefty amount of processing power, but they look real nice. The first type of texture we're going to create in this tutorial uses GL_NEAREST. Basically this type of texture has no filtering at all. It takes very little processing power, and it looks real bad. If you've ever played a game where the textures look all blocky, it's probably using this type of texture. The only benefit of this type of texture is that projects made using this type of texture will usually run pretty good on slow computers.
You'll notice we're using GL_NEAREST for both the MIN and MAG. You can mix GL_NEAREST with GL_LINEAR, and the texture will look a bit better, but we're intested,GL_NEAREST); // ( NEW )
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); // ( NEW )
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
The next texture we build is the same type of texture we used in tutorial six. Linear filtered. The only thing that has changed is that we are storing this texture in texture[1] instead of texture[0] because it's our second texture. If we stored it in texture[0] like above, it would overwrite the GL_NEAREST texture (the first);
Now for a new way to make textures. Mipmapping! You may have noticed that when you make an image very tiny on the screen, alot of the fine details disappear. Patterns that used to look nice start looking real bad.).
I had said in tutorial six there was a way around the 64,128,256,etc limit that OpenGL puts on texture width and height. gluBuild2DMipmaps is it. From what I've found, you can use any bitmap image you want (any width and height) when building mipmapped textures. OpenGL will automatically size it to the proper width and height.
Because this is texture number three, we're going to store this texture in texture[2]. So now we have texture[0] which has no filtering, texture[1] which uses linear filtering, and texture[2] which uses mipmapped textures. We're done building the textures for this tutorial.
// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); // ( NEW )
The following line builds the mipmapped texture. We're creating a 2D texture using three colors (red, green, blue). TextureImage[0]->sizeX is the bitmaps width, TextureImage[0]->sizeY is the bitmaps height, GL_RGB means we're using Red, Green,, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); // ( NEW )
}
}
Finally we return the status. If everything went OK, the variable Status will be TRUE. If anything went wrong, Status will be FALSE.
return Status; // Return The Status
}
Now we load the textures, and initialize the OpenGL settings. The first line of InitGL loads the textures using the code above. After the textures have been created, we enable 2D texture mapping with glEnable(GL_TEXTURE_2D). The shade mode is set to smooth shading, The background color is set to black, we enable depth testing, then we enable nice perspective calculations.
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
if (!LoadGLTextures()) // Jump To Texture Loading Routine
{
return FALSE; // If Texture Didn't Load Return FALSE
}
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
Now we set up the lighting. The line below will set the amount of ambient light that light1 will give off. At the beginning of this tutorial we stored the amount of ambient light in LightAmbient. The values we stored in the array will be used (half intensity ambient light).
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
Next we set up the amount of diffuse light that light number one will give off. We stored the amount of diffuse light in LightDiffuse. The values we stored in this array will be used (full intensity white light).
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
Now we set the position of the light. We stored the position in LightPosition. The values we stored in this array will be used (right in the center of the front face, 0.0f on x, 0.0f on y, and 2 unit towards the viewer {coming out of the screen} on the z plane).
glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
Finally, we enable light number one. We haven't enabled GL_LIGHTING though, so you wont see any lighting just yet. The light is set up, and positioned, it's even enabled, but until we enable GL_LIGHTING, the light will not work.
glEnable(GL_LIGHT1); // Enable Light One
return TRUE; // Initialization Went OK
}
In the next section of code, we're going to draw the texture mapped cube. I will comment a few of the line only because they are new. If you're not sure what the uncommented lines do, check tutorial number six.
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View,0.0f,1.0f,0.0f) uses the variable yrot to rotate the cube on the y axis.
The next line is similar to the line we used in tutorial six, but instead of binding texture[0], we are binding texture[filter]. Any time we press the 'F' key, the value in filter will increase. If this value is higher than two, the variable filter is set back to zero. When the program starts the filter will be set to zero. This is the same as saying glBindTexture(GL_TEXTURE_2D, texture[0]). If we press 'F' once more, the variable filter will equal one, which is the same as saying glBindTexture(GL_TEXTURE_2D, texture[1]). By using the variable filter we can select any of the three textures we've made.
glBindTexture(GL_TEXTURE_2D, texture[filter]); // Select A Texture Based On filter
glBegin(GL_QUADS); // Start Drawing Quads
glNormal3f is new to my tutorials. A normal is a line pointing straight out of the middle of a polygon at a 90 degree angle. When you use lighting, you need to specify a normal. The normal tells OpenGL which direction the polygon is facing... which way is up. If you don't specify normals, all kinds of weird things happen. Faces that shouldn't light up will light up, the wrong side of a polygon will light up, etc. The normal should point outwards from the polygon.
Looking at the front face you'll notice that the normal is positive on the z axis. This means the normal is pointing at the viewer. Exactly the direction we want it pointing. On the back face, the normal is pointing away from the viewer, into the screen. Again exactly what we want. If the cube is spun 180 degrees on either the x or y axis, the front will be facing into the screen and the back will be facing towards the viewer. No matter what face is facing the viewer, the normal of that face will also be pointing towards the viewer. Because the light is close to the viewer, any time the normal is pointing towards the viewer it's also pointing towards the light. When it does, the face will light up. The more a normal points towards the light, the brighter that face is. If you move into the center of the cube you'll notice it's dark. The normals are point out, not in, so there's no light inside the box, exactly as it should be.
// Front Face
glNormal3f( 0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Point 1 (Front)
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Point 2 (Front)
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Point 3 (Front)
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Point 4 (Front)
// Back Face
glNormal3f( 0.0f, 0.0f,-1.0f); // Normal Pointing Away From Viewer
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Point 1 (Back)
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Point 2 (Back)
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Point 3 (Back)
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Point 4 (Back)
// Top Face
glNormal3f( 0.0f, 1.0f, 0.0f); // Normal Pointing Up
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Point 1 (Top)
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Point 2 (Top)
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Point 3 (Top)
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Point 4 (Top)
// Bottom Face
glNormal3f( 0.0f,-1.0f, 0.0f); // Normal Pointing Down
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Point 1 (Bottom)
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Point 2 (Bottom)
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Point 3 (Bottom)
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Point 4 (Bottom)
// Right face
glNormal3f( 1.0f, 0.0f, 0.0f); // Normal Pointing Right
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Point 1 (Right)
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Point 2 (Right)
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Point 3 (Right)
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Point 4 (Right)
// Left Face
glNormal3f(-1.0f, 0.0f, 0.0f); // Normal Pointing Left
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Point 1 (Left)
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Point 2 (Left)
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Point 3 (Left)
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Point 4 (Left)
glEnd(); // Done Drawing Quads
The next two lines increase xrot and yrot by the amount stored in xspeed, and yspeed. If the value in xspeed or yspeed is high, xrot and yrot will increase quickly. The faster xrot, or yrot increases, the faster the cube spins on that axis.
xrot+=xspeed; // Add xspeed To xrot
yrot+=yspeed; // Add yspeed To yrot
return TRUE; // Keep Going
}
Now we move down to WinMain(). Were going to add code to turn lighting on and off, spin the crate, change the filter and move the crate into and out of the screen. Closer to the bottom of WinMain() you will see the command SwapBuffers(hDC). Immediately after this line, add the following code.
This code checks to see if the letter 'L' has been pressed on the keyboard. The first line checks to see if 'L' is being pressed. If 'L' is being pressed, but lp isn't false, meaning 'L' has already been pressed once or it's being held down, nothing will happen.
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
if (keys['L'] && !lp) // L Key Being Pressed Not Held?
{
If lp was false, meaning the 'L' key hasn't been pressed yet, or it's been released, lp becomes true. This forces the person to let go of the 'L' key before this code will run again. If we didn't check to see if the key was being held down, the lighting would flicker off and on over and over, because the program would think you were pressing the 'L' key over and over again each time it came to this section of code.
Once lp has been set to true, telling the computer that 'L' is being held down, we toggle lighting off and on. The variable light can only be true of false. So if we say light=!light, what we are actually saying is light equals NOT light. Which in english translates to if light equals true make light not true (false), and if light equals false, make light not false (true). So if light was true, it becomes false, and if light was false it becomes true.
lp=TRUE; // lp Becomes TRUE
light=!light; // Toggle Light TRUE/FALSE
Now we check to see what light ended up being. The first line translated to english means: If light equals false. So if you put it all together, the lines do the following: If light equals false, disable lighting. This turns all lighting off. The command 'else' translates to: if it wasn't false. So if light wasn't false, it must have been true, so we turn lighting on.
if (!light) // If Not Light
{
glDisable(GL_LIGHTING); // Disable Lighting
}
else // Otherwise
{
glEnable(GL_LIGHTING); // Enable Lighting
}
}
The following line checks to see if we stopped pressing the 'L' key. If we did, it makes the variable lp equal false, meaning the 'L' key isn't pressed. If we didn't check to see if the key was released, we'd be able to turn lighting on once, but because the computer would always think 'L' was being held down so it wouldn't let us turn it back off.
if (!keys['L']) // Has L Key Been Released?
{
lp=FALSE; // If So, lp Becomes FALSE
}
Now we do something similar with the 'F' key. If the key is being pressed, and it's not being held down or it's never been pressed before, it will make the variable fp equal true meaning the key is now being held down. It will then increase the variable called filter. If filter is greater than 2 (which would be texture[3], and that texture doesn't exist), we reset the variable filter back to zero.
if (keys['F'] && !fp) // Is F Key Being Pressed?
{
fp=TRUE; // fp Becomes TRUE
filter+=1; // filter Value Increases By One
if (filter>2) // Is Value Greater Than 2?
{
filter=0; // If So, Set filter To 0
}
}
if (!keys['F']) // Has F Key Been Released?
{
fp=FALSE; // If So, fp Becomes FALSE
}
The next four lines check to see if we are pressing the 'Page Up' key. If we are it decreases the variable z. If this variable decreases, the cube will move into the distance because of the glTranslatef(0.0f,0.0f,z) command used in the DrawGLScene procedure.
if (keys[VK_PRIOR]) // Is Page Up Being Pressed?
{
z-=0.02f; // If So, Move Into The Screen
}
These four lines check to see if we are pressing the 'Page Down' key. If we are it increases the variable z and moves the cube towards the viewer because of the glTranslatef(0.0f,0.0f,z) command used in the DrawGLScene procedure.
if (keys[VK_NEXT]) // Is Page Down Being Pressed?
{
z+=0.02f; // If So, Move Towards The Viewer
}
Now all we have to check for is the arrow keys. By pressing left or right, xspeed is increased or decreased. By pressing up or down, yspeed is increased or decreased. Remember further up in the tutorial I said that if the value in xspeed or yspeed was high, the cube would spin faster. The longer you hold down an arrow key, the faster the cube will spin in that direction.
if (keys[VK_UP]) // Is Up Arrow Being Pressed?
{
xspeed-=0.01f; // If So, Decrease xspeed
}
if (keys[VK_DOWN]) // Is Down Arrow Being Pressed?
{
xspeed+=0.01f; // If So, Increase xspeed
}
if (keys[VK_RIGHT]) // Is Right Arrow Being Pressed?
{
yspeed+=0.01f; // If So, Increase yspeed
}
if (keys[VK_LEFT]) // Is Left Arrow Being Pressed?
{
yspeed-=0.01f; // If So, Decrease yspeed
}
Like all the previous tutorials, make sure the title at the top of the window is correct.'s Textures, Lighting & Keyboard Tutorial",640,480,16,fullscreen))
{
return 0; // Quit If Window Was Not Created
}
}
}
}
}
// Shutdown
KillGLWindow(); // Kill The Window
return (msg.wParam); // Exit The Program
}
By the end of this tutorial you should be able to create and interact with high quality, realistic looking, textured mapped objects made up of quads. You should understand the benefits of each of the three filters used in this tutorial. By pressing specific keys on the keyboard you should be able to interact with the object(s) on the screen, and finally, you should know how to apply simple lighting to a scene making the scene appear more realistic. D Language Code For This Lesson. ( Conversion by Familia Pineda Garcia ) * GLUT Code For This Lesson. ( Conversion by Andy Restad ) * DOWNLOAD Irix Code For This Lesson. ( Conversion by Lakmal Gunasekara ) * DOWNLOAD Java Code For This Lesson. ( Conversion by Jeff Kirby ) * DOWNLOAD Jedi-SDL Code For This Lesson. ( Conversion by Dominique Louis ) * DOWNLOAD JoGL Code For This Lesson. ( Conversion by Kevin J. Duling ) * Nico (Scalp) ) * DOWNLOAD Visual C++ / OpenIL Code For This Lesson. ( Conversion by Denton Woods ) * DOWNLOAD Power Basic Code For This Lesson. ( Conversion by Angus Law ) * DOWNLOAD Pelles C Code For This Lesson. ( Conversion by Pelle Orinius ) * DOWNLOAD Scheme Code For This Lesson. ( Conversion by Brendan Burns ) * DOWNLOAD Solaris Code For This Lesson. ( Conversion by Lakmal Gunasekara ) * DOWNLOAD Visual Basic Code For This Lesson. ( Conversion by Peter De Tagyos ) * DOWNLOAD Visual Fortran Code For This Lesson. ( Conversion by Jean-Philippe Perois ) * DOWNLOAD Visual Studio .NET Code For This Lesson. ( Conversion by Grant James )
< Lesson 06Lesson 08 >
NeHe™ and NeHe Productions™ are trademarks of GameDev.net, LLC
OpenGL® is a registered trademark of Silicon Graphics Inc. | http://nehe.gamedev.net/tutorial/texture_filters,_lighting_&_keyboard_control/15002/ | CC-MAIN-2016-36 | refinedweb | 4,240 | 75.3 |
Dear monks;
Is there any generally accepted wisdom as to the ordering of use statements in the header of a .pm? Here's the header of one of my modules:
use strict;
use warnings;
use utf8;
use namespace::autoclean;
use Coro;
use AnyEvent;
use LWP::Protocol::AnyEvent::http;
use Net::Twitter;
use AnyEvent::Twitter::Stream;
use YAML::Any;
use DateTime::Format::Strptime;
use Data::Visitor::Callback;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($DEBUG);
use Moose;
has 'twitter' => (is => 'rw', required => 1, isa => 'Net::Twitter');
has 'listener' => (is => 'rw', required => 1, isa => 'AnyEvent::Twitte
+r::Stream');
has 'mongo' => (is => 'rw', required => 0, isa => 'MongoDB::Databas
+e');
[download]
As you can see, it grew quite organically. I could sort it alphabetically (which at least puts namespaces together), but then that throws Net::Twitter and AnyEvent::Twitter::Stream apart (for instance), which isn't great for determining what sorts of things I'm pulling in.
Any advice is appreciated.
Anneli
You could group by "association" then sort within groups. I tend to separate groups by a blank line in such a case.
use utf8 is a bug? These source files happen to contain a lot of non-ASCII, but maybe I'm misunderstanding you...
I've seen alphabetical, but I tend to do it like this:
To me the idea is to start with the generalities that may be most applicable to all scripts, and then work my way toward the most specific modules to this particular application. At the same time I try to cluster modules that work together... together.
As I think about it, that's sort of a bottom up approach. Perhaps I should reverse the order to add clarity in reading the source, but I'm in this habit, and would probably only change if strong benefits are shown to be embodied in another approach.
One caveat is that there are a few modules which specifically state that you must use this one before that one. Inline::Files has to be listed before Inline::C, for example. In such cases it's important to # document the need, because today it may be obvious but tomorrow you (or I) will forget.
If I'm using a module for one small portion of a program, and not specifying an import list, I often # comment on what specific need this module is filling. That way if the program changes and that use is removed, I can quickly identify the module that is no longer necessary.
That's a habit that came from C, where it's common to list a whole bunch of header files to #include, and then quickly forget why they're being included.
I've considered # documenting along side my module uses which ones came from core, which I installed from CPAN, and which I wrote myself, but that level of documentation is more ambitious than I've been able to self-enforce.
Update:
I just checked, and unless I'm missing it, Perl Best Practices is silent on the issue of order of using modules. I recently re-read the book too, but that still doesn't mean I haven't forgotten. :) I wonder if the omission is because it doesn't matter, because it's too obvious to mention, or because it just wasn't considered.
Dave
#!]
I put both strict & warnings pragmas listed first on a single line. Rest are alphabetically sorted.
That will be followed by other pragmas in a group, which will be followed by group of modules. If the list is "large enough" and/or list has highly unrelated modules, modules will be divided into subgroups by function.
Above could be then ...
use strict; use warnings;
use utf8;
use namespace::autoclean;
use AnyEvent;
use AnyEvent::Twitter::Stream;
use Coro;
use LWP::Protocol::AnyEvent::http;
use Net::Twitter;
use Data::Visitor::Callback;
use DateTime::Format::Strptime;
use YAML::Any;
use Log::Log4perl qw(:easy);
[download]
I. :)
Fireworks
Stars/planets
Lanterns
Distant Aircraft/Seacraft
Fireflies
The moon
Glowsticks
City lights
Aurorae
The ISS (or other satellites)
Campfires
Blinkenlights
Other
Results (250 votes). Check out past polls. | http://www.perlmonks.org/?node_id=935070 | CC-MAIN-2018-09 | refinedweb | 683 | 59.03 |
Exercises 4 requires us to do some dimensional analysis. This can get confusing when trying to convert among the various quantities through programming techniques. I did do one thing different, I used constants that were already in seconds-per-quantity rather that exactly what the question asked. It seemed pointless going the book way as you would have to write code to convert the values to the seconds values when they are really manageable enough to make them constants themselves. Also, the question is inherently flawed, if you ask for a seconds value below a day, your data will be truncated. For instance, the book answer for 31600000 seconds is actually missing 17 hours of time from the display. This is significant. Nevertheless, here is what I was able to come up with:
4. Write a program that asks, 40 seconds
#include <iostream> using namespace std; // Required constants as per text, sort of const int day = 86400; const int hour = 3600; const int minute = 60; int main() { long seconds; int days, minutes, hours, secondsLeft; cout << "Enter the number of seconds: "; cin >> seconds; // Convert seconds to respective units days = seconds / day; hours = (seconds % day) / hour; minutes = (seconds - days * day - hours * hour) / minute; secondsLeft = seconds - days * day - hours * hour - minutes * minute; cout << seconds << " Seconds = " << days << " days, " << hours << " hours, " << minutes << " minutes, " << secondsLeft << " seconds" << endl; cin.get(); return 0; } | https://rundata.wordpress.com/2012/10/13/c-primer-chapter-3-exercise-4/ | CC-MAIN-2017-26 | refinedweb | 225 | 57.4 |
Struts dispatch action - Struts
Struts dispatch action i am using dispatch action. i send the parameter="addUserAction" as querystring.ex:
at this time it working fine... not contain handler parameter named 'parameter'
how can i overcome
Struts Dispatch Action Example
Struts
struts - Struts
struts how to solve actionservlet is not found error in dispatch action
Struts
Struts What is called properties file in struts? How you call the properties message to the View (Front End) JSP Pages
java struts DAO - Struts
java struts DAO hai friends i have some doubt regarding the how to connect strutsDAO and action dispatch class please provide some example to explain this connectivity.
THANKS IN ADVANCE 1) Difference between Action form and DynaActionForm?
2) How the Client request was mapped to the Action file? Write the code and explain
STRUTS ACTION - AGGREGATING ACTIONS IN STRUTS
action. In this article we will see how to achieve this. Struts provides four...STRUTS ACTION - AGGREGATING ACTIONS IN STRUTS... of Action classes for your project. The latest version of struts provides classes
Struts
Struts why in Struts ActionServlet made as a singleton what is the specific reason how it useful in the webapplication development?
Basically in Struts we have only Two types of Action classes.
1.BaseActions
no action mapped for action - Struts
no action mapped for action Hi, I am new to struts. I followed...: There is no Action mapped for action name HelloW Forward Action Example
Struts Forward Action Example
.....
Here in this example
you will learn more about Struts Forward Action... an Action Class
Developing the Action Mapping in the struts-config.xml
code - Struts
code How to write the code for multiple actions for many submit buttons. use dispatch Action Chaining
Struts Action Chaining Struts Action Chaining
Java - Struts
in DispatchAction in Struts.
How can i pass the method name in "action" and how can i map at in struts-config.xml;
when i follow some guidelines... on DispatchAction in Struts visit to : it is thread safe? if no, how to make it thread safe? Please give me with good...://2.2.1 Action Tag Example
Struts2.2.1 Action Tag Example
The Action tag is used to call action class directly from a JSP page.
We can call action directly by specifying... the results from the Action.
The following Example will shows how to implement... for later use in in any other jsp or servlet(action class) until session exist
Action Configuration - Struts
Action Configuration I need a code for struts action configuration in XML
Understanding Struts Action Class
Understanding Struts Action Class
In this lesson I will show you how to use Struts Action...
- if the application business logic throws an exception
Adding the Action Mapping in the struts
Struts Action Class
Struts Action Class What happens if we do not write execute() in Action class
Struts
Struts how to learn struts
Struts
Struts How to retrive data from database by using Struts
STRUTS
STRUTS Request context in struts?
SendRedirect () and forward how to configure in struts-config.xml
Struts(1.3) action code for file upload
application using HttpUrlConnection.
How can i write my struts(1.3) action code... action or let me how the upload request is post to struts action.
Thanks
... way to handled request stream in struts action or let me how the upload request
getting null value in action from ajax call
getting null value in action from ajax call Getting null value from ajax call in action (FirstList.java)... first list is loading correctly. Need..." "">
<%@taglib uri="/struts-tags" prefix
Migration of Struts and Hibernate - Struts
Migration of Struts and Hibernate How to struts can call... Friend,
Please visit the following link:
Hope that it will be helpful for you.
Thanks
struts code - Struts
struts code how to call lookup dispatchAction class method using on change of JavaScript
what is struts flow of 1.2 version struts?
i have struts applicatin then from jsp page how struts application flows
Thanks
Kalins Naik
Please visit the following link:
Struts Tutorial hi
i would like to have a ready example of struts using "action class,DAO,and services" for understanding.so please guide for the same.
thanks Please visit the following link:
Struts Tutorials
struts
struts how to write Dao to select data from the database"
so please help
Built-In Actions |
Struts
Dispatch Action |
Struts
Forward... to the Apache Struts |
MVC
Architecture |
Struts
Architecture |
How Struts
Works? |
Struts Controller |
Struts Action Class |
Struts
ActionFrom Class Servlet - Struts
action Servlet What is the difference between ActionServlet ans normal servlet?
And why actionServlet is required
struts
struts how to handle exception handling in struts reatime projects?
can u plz send me one example how to deal with exception?
can u plz send me how to develop our own exception handling
How Struts 2 Framework works?
How Struts 2 Framework works?
This tutorial explains you the working.... In this tutorial you will learn How Struts 2 works with the
help of an easy....
Controller maps the user request to specific action. In
Struts 2
Struts - Struts
Struts how to handle errors in struts
struts - Struts
struts How to use back button in struts
struts - Struts
Struts dispatchaction vs lookupdispatchaction What is struts...; Hi,Please check easy to follow example at
struts - Struts
struts when the action servlet is invoked in struts? Hi Friend,
Please visit the following link:
Thanks
Dynamic method dispatch
Dynamic method dispatch
Dynamic dispatch is a process of selecting, which methods to call
at run-time. It is a mechanism by which a call to overridden method.... Now we are creating a reference of parent class through which we
call parent
struts - Struts
struts get records in Tabular format How do i get result in tabular format using JSP in struts
Dispatcher Result Example
the same to the
dispatch the request data to the desired action. To use...;
<action name="login">
<...Dispatcher Result Example
The Dispatcher Result forwarded the action
struts
struts <p>hi here is my code can you please help me to solve...;
<p><html>
<body></p>
<form action="login.do">...*;
import org.apache.struts.action.*;
public class LoginAction extends Action
Struts Tutorial
the
information to them.
Struts Controller Component : In Controller, Action class...In this section we will discuss about Struts.
This tutorial will contain the various aspects of Struts such as What is Struts, features of struts
struts validation
struts validation Sir
i am getting stucked how to validate struts using action forms, the field vechicleNo should not be null and it should...://
In Struts 2 how to pass the <s: property value=''
In Struts 2 how to pass the s: property value' In Struts 2 how... need to call another jsp say "datafwd.jsp". This action will get data about this data.jsp from that DB and display the same in a page. How do i send
struts <html:select> - Struts
struts i am new to struts.when i execute the following code i am getting this exception .how to solve this problem .please rectify the problem... :
1. Remove name attribute altogether and specify only an action attribute
struts
struts <p>hi here is my code in struts i want to validate my...;gt;
<html:form
<pre>... RegisterAction extends Action
{
public RegisterAction()
{
how to forward select query result to jsp page using struts action class
how to forward select query result to jsp page using struts action class how to forward select query result to jsp page using struts action 2 Tutorials - Struts version 2.3.15.1
for making
developer work easy.
Removing default Struts 2 action suffix - How... in Struts 2.3.15.1
Lifecycle/Architecture of Struts 2 framework
How Struts....
Multiple Struts configuration files - Learn how to
include multiple Struts
struts
struts how to display data from database on jsp using struts1.0
struts
struts how make my dummy project live..plz send me step's.
kya yaar
Struts 2 action-validation.xml not loading
Struts 2 action-validation.xml not loading Hi All,
I am getting... error
SERVER : Caught exception while loading file package/action-validation.xml
Connection refused: Connect - (unknown location)
The path of my action
Advertisements
If you enjoyed this post then why not add us on Google+? Add us to your Circles | http://www.roseindia.net/tutorialhelp/comment/77449 | CC-MAIN-2015-27 | refinedweb | 1,377 | 65.12 |
Technical Support
On-Line Manuals
RL-ARM User's Guide (MDK v4)
#include <rtl.h>
OS_TID os_tsk_create_user(
void (*task)(void), /* Task to create */
U8 priority, /* Task priority (1-254) */
void* stk, /* Pointer to the task's stack */
U16 size ); /* Number of bytes in the stack */
The os_tsk_create_user os_tsk_create_user function is in the RL-RTX library.
The prototype is defined in rtl.h.
Note
The os_tsk_create_user function returns the task identifier
value (TID) of the new task. If the function fails, for example due
to an invalid argument, it returns 0.
os_tsk_create, os_tsk_create_ex, os_tsk_create_user_ex
#include <rtl.h>
OS_TID tsk1,tsk2;
static U64 stk2[400/8];
__task void task1 (void) {
..
/* Create task 2 with a bigger stack */
tsk2 = os_tsk_create_user (task2, 1, &stk2, sizeof(stk2));
..
}
__task void task2 (void) {
/* We need a bigger stack here. */
U8 buf. | https://www.keil.com/support/man/docs/rlarm/rlarm_os_tsk_create_user.htm | CC-MAIN-2020-34 | refinedweb | 134 | 57.98 |
Plus: Huge potential with new yieldco
Get the truth about credit unions
Join the NASDAQ Community today and get free, instant access to portfolios, stock ratings, real-time alerts, and more!
Consistently, one of the more popular stocks people enter into
their
stock options watchlist
at Stock Options Channel is American Capital Agency Corp (Symbol:
AGNC). So this week we highlight one interesting put contract, and
one interesting call contract, from the June expiration for AGNC.
The put contract our YieldBoost algorithm identified as
particularly interesting, is at the $23 strike, which has a bid at
the time of this writing of 65 cents. Collecting that bid as the
premium represents a 2.8% return against the $23 commitment, or a
22.4% annualized rate of return (at Stock Options Channel we call
this the
YieldBoost
).
Turning to the other side of the option chain, we highlight one
call contract of particular interest for the June expiration, for
shareholders of American Capital Agency Corp (Symbol: AGNC) looking
to boost their income beyond the stock's 11.3% annualized dividend
yield. Selling the covered call at the $23.50 strike and collecting
the premium based on the 14 cents bid, annualizes to an additional
4.8% rate of return against the current stock price (this is what
we at Stock Options Channel refer to as the
YieldBoost
), for a total of 16.1% annualized rate in the scenario where the
stock is not called away. Any upside above $23.50 would be lost if
the stock rises there and is called away, but AGNC shares would
have to advance 2.1% from current levels for that to happen,
meaning that in the scenario where the stock is called, the
shareholder has earned a 2.7% return from this trading level, in
addition to any dividends collected before the stock was
called.
Top YieldBoost AGNC? | http://www.nasdaq.com/article/interesting-june-stock-options-for-agnc-cm352274 | CC-MAIN-2015-11 | refinedweb | 313 | 62.88 |
I have an HMC6343 tilt-compensated magnetometer
a number of its features require me to write values to specific registers (eg to alter the variation angle you write to registers 0x0D & 0x0C).
The documentation for Wire doesn't mention anything about this.
What command causes it to know that the data is for a specific register?
I would be surprised if writing to specific registers of I2C devices wasn't a very common requirement for people using the Wire library.
QuoteI would be surprised if writing to specific registers of I2C devices wasn't a very common requirement for people using the Wire library.The Wire documentation could be expanded a thousand-fold, and still wouldn't cover half the devices that I2C can be used to communicate with.
#include <Wire.h>#define HMC6343_ADDRESS 0x19//==================================================================================== void setup() { Wire.begin(); Serial.begin(115200); /* * Set the 'variation angle correction' (magnetic declination), see p8 in datasheet. * At the cathedral in St Andrews on 07/08/2012 this was 3 degrees 16 seconds West * which is -3.2667 decimal degrees, or -33 tenths of a degree, so MSB/LSB in two's * complement is 11111111/11011111. This is written to EEPROM so technically doesn't * need to be done every time if the device isn't moving to a drastically new * location inbetween use. */ byte deviationMSB = B11111111; Wire.beginTransmission(HMC6343_ADDRESS); Wire.write(0xF1); // 'Write to EEPROM' command Wire.write(0x0D); // EEPROM address of deviation angle MSB Wire.write(deviationMSB); Wire.endTransmission(); byte deviationLSB = B11011111; Wire.beginTransmission(HMC6343_ADDRESS); Wire.write(0xF1); Wire.write(0x0C); // EEPROM address of deviation angle LSB Wire.write(deviationLSB); Wire.endTransmission(); /* * Set the measurement rate to 10Hz (0x02) from default of 5Hz (0x01). * Again this is EEPROM so shouldn't need re-doing unless it is explicitly reset * at some point. */ Wire.beginTransmission(HMC6343_ADDRESS); Wire.write(0xF1); Wire.write(0x05); // EEPROM address of Operational Mode Register 2 Wire.write(0x02); // (OM2_1 = 1 && OM2_0 = 0) == 10Hz operation Wire.endTransmission(); /* * Set the Heading Infinite Impulse Response (IIR) filter from its default of 0 * to something a bit more than 0. Again, this is EEPROM so shouldn't need re-doing * unless it is explicitly reset at some point. */ Wire.beginTransmission(HMC6343_ADDRESS); Wire.write(0xF1); Wire.write(0x14); // EEPROM address of the Heading IIR filter LSB Wire.write(0x00); // 0 is no filtering, 15 is filtered with 15 previous readings Wire.endTransmission(); /* * Set the HMC6343 to 'upright front' orientation. This is temporary, but can be * written to an EEPROM register if required. */ Wire.beginTransmission(HMC6343_ADDRESS); Wire.write(0x74); Wire.endTransmission(); }//==================================================================================== void loop() { /* * Set the HMC6343 to return the information that we want (HeadMSB, HeadLSB, * PitchMSB, PitchLSB, RollMSB, RollLSB). */ Wire.beginTransmission(HMC6343_ADDRESS); Wire.write(0x50); // Command to return the data we want Wire.endTransmission(); byte MSByte, LSByte; Wire.requestFrom(HMC6343_ADDRESS, 6); // request 6 bytes (see command 0x50) while(Wire.available() < 1); // busy wait while no bytes to receive MSByte = Wire.read(); LSByte = Wire.read(); float heading = ((MSByte << 8) + LSByte) / 10.0; // the heading in degrees MSByte = Wire.read(); LSByte = Wire.read(); float pitch = ((MSByte << 8) + LSByte) / 10.0; // the pitch in degrees MSByte = Wire.read(); LSByte = Wire.read(); float roll = ((MSByte << 8) + LSByte) / 10.0; // the roll in degrees Serial.print(heading); Serial.print(" "); Serial.print(pitch); Serial.print(" "); Serial.println(roll); delay(100);}//====================================================================================
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
Thank you for subscribing!
Arduino
via Egeo 16
Torino, 10131
Italy | http://forum.arduino.cc/index.php?topic=147002.0;prev_next=next | CC-MAIN-2016-44 | refinedweb | 584 | 51.44 |
Created 02-22-2018 04:45 PM
Hi There,
I am trying to lookup records from a CSV file using LookupRecord and SimpleCsvFileLookupService but I am unable to get the final record with both values. Please find below details.
Input File
ID, Name 1,Elon 2,Mark 3,Jeff
Lookup File
ID,Company 1,Tesla 2,Facebook 3,Amazon
Expected Output
ID,Name,Company 1,Elon,Tesla 2,Mark,Facebook 3,Jeff,Amazon
AvroSchema
{ "name": "ceodata", "namespace": "nifi", "type": "record", "fields": [ { "name": "ID", "type": "string" }, { "name": "NAME", "type": "string" }, { "name": "COMPANY", "type": "string" } ] }
LookupRecord Processor Config
CSVReader Config
CSVWriter Config
LookupFromCSVFileService
Please let me know what's wrong in these configurations.
@jfrazee @Bryan Bende @Abdelkrim Hadjidj @Timothy Spann @Aldrin Piri
Your input and output CSV schema for the LookupRecord should be different. In the output schema you should add a field 'Company' that the processor will populate.
Take a look at this example where I added the field city in the output schema :
If that is your output schema, then the Result RecordPath in LookupRecord should be /COMPANY not /Company.
Created on 02-22-2018 06:04 PM - edited 08-17-2019 06:57 PM
Thanks for replying @Abdelkrim Hadjidj @Matt Burgess. Now I have two different schemas for input and output CSV for LookupRecord. I modified Result RecordPath to /COMPANY. When I start LookupRecord it takes in 6 flow files but doesn't return anything. | https://community.cloudera.com/t5/Support-Questions/LookUpRecord-and-SimpleCsvFileLookupService-in-NiFi/m-p/223219 | CC-MAIN-2020-24 | refinedweb | 236 | 58.62 |
Code Loading different packages named
Xin each dependency. More on this below.
Code inclusion is quite straightforward: it simply parses and evaluates a source file in the context of the caller. Package loading is built on top of code inclusion and is a lot more complex. Therefore, the rest of this chapter focuses on the behavior and mechanics of package loading.
You only need to read this chapter if you want to understand the technical details of package loading. If you just want to install and use packages, simply use Julia's built-in package manager to add packages to your environment and write
import X or
using X in your code to load packages that you've added.. The effect of
import X depends on two questions:
- What package is
Xin this context?
- Where can that
Xpackage be found?
Understanding how Julia answers these questions is key to understanding package loading.
Federation of packages
Julia supports federated management of packages. This means that multiple independent parties can maintain both public and private packages and registries of them, and that projects can depend on a mix of public and private packages from different registries. Packages from various registries are installed and managed using a common set of tools and workflows. The
Pkg package manager ships with Julia 0.7/1.0 and lets you install and manage your projects' dependencies. It does this by creating and manipulating project files that describe what your project depends on, and manifest files that can quite possibly end up depending on different packages that have the same name. Julia's package loading mechanism handles this by not requiring package names to be globally unique, even within the dependency graph of a single project. Instead, packages are identified by universally unique identifiers (UUIDs) which are assigned to them before they are registered. The question "what is
X?" is answered by determining the UUID of
X. that name. Subsequently, however, an unrelated package also named
Priv has been published and become popular. In fact, the
Pub package has started to use it. Therefore, when you next upgrade
Pub to get the latest bug fixes and features,
App will end up—through no action of yours other than upgrading—depending on two different packages named
Priv.
App has a direct dependency on your private
Priv package, and an indirect dependency, through
Pub, on the new public
Priv package. Since these two
Priv packages are different but both required for
App to continue working correctly, the expression
import Priv must refer to different
Priv packages depending on whether it occurs in
App's code or in
Pub's code. Julia's package loading mechanism allows this by distinguishing the two
Priv packages by context and UUID. How this distinction works is determined by environments, as explained in the following sections.
Environments
An environment determines what
import X and
using X mean in various code contexts and what files these statements cause to be loaded. Julia understands three kinds of environments:
- A project environment is a directory with a project file and an optional manifest file.. This kind of environment was the only kind that existed in Julia 0.6 and earlier. If
Xis a subdirectory of a package directory and
X/src/X.jlexists, then the package
Xis available in the package directory environment and
X/src/X.jlis the source file by which it is loaded.
- A stacked environment is an ordered set of project environments and package directories, overlaid to make a single composite environment in which all the packages available in its constituent environments are available. Julia's load path is a stacked environment, for example.
These three kinds of environment each serve a different purpose:
- Project environments provide reproducibility. By checking a project environment into version control—e.g. a git repository—along with the rest of the project's source code, you can reproduce the exact state of the project and all of its dependencies since the manifest file captures the exact version of every dependency.
- Package directories provide low-overhead convenience when a project environment isn't needed. Package directories are handy when you have a set of packages that you just want to put somewhere and use them as they are, without having to create and maintain a project environment for them.
- Stacked environments allow for augmentation of the primary environment with additional tools. You can push an environment including development tools onto the stack and they will be available from the REPL and scripts but not from inside packages.
As an abstraction, an environment provides three maps:
roots,
graph and
paths. When resolving the meaning of
import X,
roots and
graph are used to determine the identity of
X and answer the question "what is
X?", while the
paths map is used to locate the source code of
X and answer the question "where is
X?" The specific roles of the three maps are:
roots:
name::Symbol⟶
uuid::UUID
An environment's
rootsmapis a multilevel map which assigns, for each
contextUUID, a map from names to UUIDs, similar to the
rootsmap
pathsmap assigns to each package UUID-name pair, the location of that package's entry-point source file. After the identity of
Xin
import Xhas been resolved to a UUID via
rootsor
graph(depending on whether it is loaded from the main project or a dependency), Julia determines what file to load to acquire
Xby looking up
paths[uuid,:X]in the environment. Including this file should create a module named
X. Once this package is loaded, i.e. after its first import, any subsequent import resolving to the same
uuidwill simply create a new binding to the original already-loaded package module.
Each kind of environment defines these three maps differently, as detailed in the following sections.
For ease of understanding, the examples throughout this chapter show full data structures for
roots,
graph and
paths. However, for efficiency, Julia's package loading code does not actually create them. Instead, it queries them through internal APIs, including for each one, its
Privpackages that the application needs—a private one which is a direct dependency and a public one which is an indirect dependency through
Pub:
- The private
Privdepends on the
Puband
Zebrapackages.
- The public
Privhas no dependencies.
- The application also depends on the
Pubpackage, which in turn depends on the public
Privand the same
Zebrapackage which the private
Privpackage depends on.
This dependency
graph represented as a dictionary, looks like this:
graph = Dict{UUID,Dict{Symbol,UUID}}( # Priv – the private one: UUID("ba13f791-ae1d-465a-978b-69c3ad90f72b") => Dict{Symbol,UUID}( {Symbol,UUID}(), # Pub: UUID("c07ecb7d-0dc9-4db7-8803-fadaaeaf08e1") => Dict{Symbol,UUID}( {Symbol,UUID}(), ) also determined by the manifest file if present and is empty if there is no manifest. The path of a package
uuid named
X is determined by these two rules:
- If the manifest stanza matching
uuidhas a
pathentry, use that path relative to the manifest file.
- Otherwise, if the manifest stanza matching
uuidhas a
git-tree-sha1entry, compute a deterministic hash function of
uuidand
git-tree-sha1—call it
slug—and look for
packages/X/$slugin each directory in the Julia
DEPOT_PATHglobal array. Use the first such directory that exists.
If applying these rules doesn't find a loadable path, the package should be considered not installed and the system should raise an error or prompt the user to install the appropriate package version.r (the exact details of this computation aren't important, but it is consistent and deterministic). This means that the path to this
Priv package will be
packages/Priv/HDkr/src/Priv.jl in one of the package depots. Suppose the contents of
DEPOT_PATH is
["/users/me/.julia", "/usr/local/julia"]; then Julia will look at the following paths to see if they exist:
/home/me/.julia/packages/Priv/HDkr/src/Priv.jl
/usr/local/julia/packages/Priv/HDkr/src/Priv.jl
Julia uses the first of these that exists to load the public
Priv package.
Here is a representation of the
paths map for the
App project environment:
paths = Dict{Tuple{UUID,Symbol},String}( # kind of environment that approximates package loading in Julia 0.6 and earlier, and which resembles package loading in many other dynamic languages. The set of packages available in a package directory corresponds to the set of subdirectories it contains that look like packages: if
X/src/X.jl is a file in a package directory, then
X is considered to be a package and
X/src/X.jl is the file Julia loads to get
X. Which packages can "see" each other as dependencies depends on whether they contain project files, and if they do, on what appears in those project files'
[deps] sections.
The roots map is determined by the subdirectories
X of a package directory for which
X/src/X.jl exists and whether
X/Project.toml exists and has a top-level
uuid entry. Specifically
:X => uuid goes in
roots for each such
X where
uuid is defined as:
- If
X/Project.tomlexists and has a
uuidentry, then
uuidis that value.
- If
X/Project.tomlexists and but does not have a top-level UUID entry,
uuidis a dummy UUID generated by hashing the canonical path of
X/Project.toml.
- If
Xand import statements in its code are treated as top-level, the same as the main project and REPL.
- If a package subdirectory has a project file, then the
graphentry{Symbol,UUID}( {UUID,Dict{Symbol,UUID}}( # Bobcat: UUID("85ad11c7-31f6-5d08-84db-0a4914d4cadf") => Dict{Symbol,UUID}( {Symbol,UUID}( {Symbol,UUID}(), ){Tuple{UUID,Symbol},String}( pushing an environment containing these tools onto the load path, you immediately have access to them in top-level code without needing to add them to your project.
The mechanism for combining the
roots,
graph and
paths data structures of the components of an environment stack is simple: they are simply
stack. The
reverse is present because
merge favors the last argument rather than first when there are collisions between keys in its argument dictionaries. That's all there is to stacked environments..
Since the primary environment is typically the environment of a project you're working on, while environments later in the stack contain additional tools, this is the right tradeoff: it's better to break your dev. Fortunately, most Julia users can remain oblivious to the technical details of code loading and simply use the built-in package manager to add a package
X to the appropriate project and manifest files and then write
import X to load
X without a further thought. | https://docs.julialang.org/en/v1.0/manual/code-loading/ | CC-MAIN-2021-39 | refinedweb | 1,767 | 52.49 |
-1
Hello everyone,
I was working on a program that was meant to open something the user put in. Basically, the user would put in the path and then the program would open whatever was there. I can't work it though, every time I put in the file path, it says "CreateProcess failed (2)". Anyways, here is the code, and thanks in advance for the help.
#include <cstdlib> #include <iostream> #include <cstring> #include <stdio.h> #include <string.h> #include <string> #include <windows.h> #include <fstream> #include <tchar.h> using namespace std; int main() { cout << "What would you like to open?"; char way[50]; cin >> way[50]; char *path = way; // the createprocess code starts ); } // createprocess code ends here system("PAUSE"); return EXIT_SUCCESS; }
Edited 6 Years Ago by some: n/a | https://www.daniweb.com/programming/software-development/threads/271702/createprocess-help | CC-MAIN-2016-50 | refinedweb | 130 | 76.11 |
.
Stating encoder rpm without stating encoder lines is completely meaningless. My rough estimate is a polled loop in a PIC10F2xx should be able to track about 1.5 million lines/minute.
/* * Rotary encoder handler. * * This assumes wiper is ground, and 2 outputs are on PB0 and PB1. * * More info: */const char ttable[6][4] = { {0x3 , 0x2, 0x1, 0x0}, {0x83, 0x0, 0x1, 0x0}, {0x43, 0x2, 0x0, 0x0}, {0x3 , 0x5, 0x4, 0x0}, {0x3 , 0x3, 0x4, 0x40}, {0x3 , 0x5, 0x3, 0x80}};volatile char state = 0;void rotary_init() { DIRB = 0x0; // PortB is input PORTB = 0x3; // Weak pullup on PB0/PB1.}/* Read input pins and process for events. Call this either from a * loop or an interrupt (eg pin change or timer). * * Returns 0 on no event, otherwise 0x80 or 0x40 depending on the direction. */char rotary_process() { state = ttable[state & 0xf][PORTB & 0x3]; return (state & 0xc0);}
for lookup table as bux's method, pic10f will not be able to do, it only has 24 registers, no eeprom.
Quote
if we are at state 2, the only acceptable next state is either 1 and 3. jump to state 4 will be ignored right? well, in my case its possible. so we are working on different system. on high speed system, if it happens state 2 jumps to state 4, i will count as two click (count) and rotation direction is based on previous rotation. based on momentum law.
or the MCU is not fast enough... Let me know if you'd like me to show the changes necessary.
Quote from: baljemmett on October 10, 2011, 03:44:14 AMQuotei know about two registers. but how do you access program space?
//lookup table in program spaceprogAddr:retlw 0x03retlw 0x02....retlw 0x80// the applicationmain:;// do something to get somethingPC = progAddr + state * 4 + PORTB ;//change program address to point to the lookuptable (retlw table)state = W ;// new state
This is my encoder routine for AVR. 2 lines of C code logic
.... * Revision 1.1 1992/12/03....static Byte bdata encstate; // Encoder statesbit eap = encstate^3;sbit ebp = encstate^2; sbit eac = encstate^1; sbit ebc = encstate^0;.... // Absolute position change indexed by new encstate static char code absdelta[] = {0, 1, -1, 0, -1, 0, 0, 1, 1, 0, 0, -1, 0, -1, 1, 0}; // Maintain absolute position from encoder inputs eap = eac; ebp = ebc; eac = ENCAI; ebc = ENCBI; abspos += absdelta[encstate]; | http://www.eevblog.com/forum/chat/quadrature-encoder-decoder-chip/ | CC-MAIN-2016-36 | refinedweb | 393 | 73.47 |
Hey,
The reason i am posting this 'snippet' is because a while back i encountered
such a problem and i asked a question but never really received an answer. Basically
i stumbled upon this snippet by luck when just browsing the web. I have searched the
forums but found nothing of a similar nature to what i was posting.
Basically you have to put that snippet in the form class.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace NISOFENT { public partial class Form1 : Form { private const int CS_DROPSHADOW = 0x20000; protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ClassStyle |= CS_DROPSHADOW; return cp; } } public Form1() { InitializeComponent(); } } }
If i wasn't clear above all this does is put a small drop shadow on the right hand
and bottom side of the BORDERLESS Form. making the form borderless can be achieved
by going into the properties of your form and setting the 'Form Border Style'
setting to none.
If i have left something out or you have any question's feel free to ask
I hope this helped somebody out.
NSSLTD
P.s I hope i wrote this snippet correctly because this my first snippet post :) | https://www.daniweb.com/programming/software-development/code/361072/adding-drop-shadow-on-a-border-less-form | CC-MAIN-2017-13 | refinedweb | 212 | 58.89 |
From: Erik Wien (wien_at_[hidden])
Date: 2004-10-19 11:32:50
----- Original Message -----
From: "Rogier van Dalen" <rogiervd_at_[hidden]>
> I've recently started on the first draft of a Unicode library.
>
Interesting. Is there a discussion going about this library that I have
missed, or haven't you posted anything about it yet? I'd hate to start
something like this, if there is already being made an effort on the
subject.
> An assumption I think is wrong is that wchar_t would be suitable for
> Unicode. Correct me if I'm wrong, but IIRC wchar_t has 16 bits on
> Microsoft compilers, for example. The utf8_codecvt_facet
> implementation will on these compilers cut off any codepoints over
> 0xFFFF. (U+1D12C will come out as U+D12C.)
>
I agree. The "unicode is wide strings" assumption is wrong in my opinion,
and I would stribe to provide a correct implementation based on the Unicode
standard if I were to go ahead with this.
> I think a definition of unicode::code as uint32_t would be much
> better. Problem is, codecvt is only implemented for wchar_t and char,
> so it's not possible to make a Unicode codecvt without manually adding
> (dummy) implementations of codecvt<unicode::code,char,mbstate_t> to
> the std namespace. I guess this is the reason that Ron Garcia just
> used wchar_t.
>
I don't really feel locking the code unit size to 32bits is a good solution
either as strings would then become unneccesarily large. In a test
implementation I have recently made, I templated the entire encoding scheme
(using an encoding_traits class) and made a common interface for strings
that lets you iterate over the code points it controls, no matter what the
underlying encoding is. (I will post another message with more details of
this library.) This does of course make for problems with other parts of the
standard, but solutions to these problems is what I want my thesis to be all
about.
> About Unicode strings:
> I suggest having a codepoint_string, with the string of code units as
> a template parameter. Its interface should work with 21 (32) bits
> values, while internally these are converted to UTF-8, UTF-16, or
> remain UTF-32.
> template <class CodeUnitString> class codepoint_string {
> CodeUnitString code_units;
> // ...
> };
>
> The real unicode::string would be the character string, which uses a
> base character with its combining marks for its interface.
> template <class CodePointString> class string {
> CodePointString codepoints;
> // ...
> };
>
> So unicode::string<unicode::codepoint_string<std::string> > would be a
> UTF8-encoded string that is manipulated using its characters.
>
> unicode::string should take care of correctly searching for a
> character string, rather than a codepoint string.
>
Thanks. I will take that into consideration. I'm glad to hear any
design/implementation ideas since I want this library to be useable for the
largest amount of people possible.
> operator< has never done "the right thing" anyway: it does not make a
> difference between uppercase and lowercase, for example. Probably,
> locales should be used for collation. The Unicode collation algorithm
> is pretty well specified.
>
Yes. I hope to be able to add support for the collation algorithm to enable
proper, locale specific collation.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk | https://lists.boost.org/Archives/boost/2004/10/74395.php | CC-MAIN-2019-30 | refinedweb | 544 | 63.9 |
10 Visual Studio features to turbocharge your codingPosted Jul 12, 2017 | 7 min. (1470 words)
Here is a list of the top 11 Visual Studio features that I use just about every day (yes, including the weekend). If you’re new to using Visual Studio, I recommend giving these a go and then get into the rhythm of using them often. If you’ve been coding in Visual Studio for years, this list may serve as a refresher, or you may even learn something new.
1. Open IntelliSense popup
Let’s start off with a simple one – opening the IntelliSense popup. IntelliSense is Visual Studio’s way of auto-completing names based on what you type and what’s available in the current context. If you’re calling a method, for example, you’ll see a popup containing only method names accessible on the class you’re calling on. (And any available extension methods), filtered by what you’ve typed so far. The popup allows you to hit the Return key generally after typing a few characters to complete the method name and swiftly start typing the parameters. The IntelliSense popup automatically opens as you type, but sometimes you may lose it – say if you are navigating away and back. Or sometimes you may want to open it without having typed anything yet. Use the Ctrl+Space keyboard shortcut to manage this.
2. Renaming
Naming can be hard to get right the first time. Sometimes naming something is always hard. Renaming, on the other hand, is super easy in Visual Studio. By replacing the name of a class, interface, method, namespace, property, variable, constant, delegate, event and so on, the name will be surrounded by a dotted line. While the caret is still within the name, you can press Ctrl+. and Visual Studio will ask if you want to rename that member. Hit Return to apply the rename which will update all the references to that member too – saving a lot of otherwise manual work. You will lose the option to rename if you make any other changes to the file while the dotted line surrounds the name.
Renaming a file in the solution explorer will often cause Visual Studio to ask you if you want to perform a rename in the class within that file. Make sure to rename files first if you intend to rename the class to save a bit of time.
3. Conditional breakpoints
A breakpoint is a flag that you can set on a line of code that will cause the Visual Studio debugger to pause code execution when the running process reaches that line of code. You can also view the application state to check that everything is fine or to debug why something is not working as expected. A breakpoint can be added by either clicking the gray margin to the left of the line of code or by pressing F9 while the caret is on the line of code. If a line of code is hit many times, such as within a loop, while you’re trying to debug, getting to the breakpoint while the application is in the state that you want to investigate can be a time sink.
Conditional breakpoints help save time here. Right-click a breakpoint and select “Condition” or use the Alt+F9 keyboard shortcut. With the popup, you can check for all sorts of conditions such as if a particular value equals an expected value, or if it has hit a breakpoint. The text box for entering a condition even has IntelliSense to help avoid coding typos. Instead of manually stepping through a breakpoint many times this is a great way to avoid coding errors.
4. Find all
Ctrl+F is great but only gives you the option to step through each search result one at a time. Once you lose focus from the search dialog, you need to loop through all the search results again, rather than continuing from where you were. Find all is where it’s at, which you can initiate using the Ctrl+Shift+F keyboard shortcut. The Ctrl+Shift+F shortcut will open a different dialog with more search options, the main one I use of which is to specify what types of files to search through. By clicking Find All, you’ll get a list of all search results ordered by file, allowing you to scan through them however you like. Once you’ve found the right result, click on it to navigate to the code. The search list persists in the find results window allowing you to examine other results whenever you need to.
5. Go To Definition
As a project grows, navigating around code within many many files can start to become time-consuming. Fortunately, Visual Studio has many simple features to speed up and simplify code navigation. “Go To Definition” is one of the navigation features that I use the most. Within your code, click on any usage of a member, such as a class or a method, then hit F12 to navigate the definition of that member. The F12 shortcut is used to revise the implementation of a method or to jump to a class where you plan to add a new member.
6. Go To Implementation
A lot of my code implements interfaces, and those implementations use interfaces to call other code. Hitting F12 on a method that’s only known by its interface will land you in the interface definition, which sometimes isn’t what you want. To get to an implementation of that interface, use Ctrl+F12 instead. If Visual Studio only knows of one implementation to that interface, it will take you there straight away. If there are multiple implementations, Visual Studio will present you with a list.
7. View all references
In more recent versions of Visual Studio, displaying the definition of a class or method will show the number of references to that class or method just above the name. Clicking this number will open a popup displaying a list grouped by file name. Alternatively, or in older Visual Studio versions, click on the class or method name, and then either use the Ctrl+K, R shortcut or right-click and select “Find All References.” Visual Studio 2017 will be bringing further improvements to the find all references feature which you can read about here.
8. NavigateTo
NavigateTo allows you search for something without knowing or remembering where it is (or any of its references). Scott Hanselman also names this as one of his favorite features of Visual Studio, and it’s one I use all the time, too.
“Absolutely high on the list of useful things is Ctrl+, for NavigateTo. Why click around with your mouse to open a file or find a specific member or function?”
To get a filtered list of options quickly, use the shortcut Ctrl+, :
9. Navigate backward and forward
As you navigate around your code, be it via the solution explorer, or using any of the navigation features described above, Visual Studio remembers the path you’ve taken, much like navigating the Internet in a browser. Navigate backward and forward along this path quickly using the keyboard shortcuts Ctrl+- to go backward and Ctrl+Shift+- to go forward. Visual Studio displays the “Standard” toolbar by default. The backward button has a drop down allowing you to jump to a particular point, rather than one at a time. If you’ve got a mouse that has backward and forward buttons, then you can use those in place of the keyboard shortcuts which is much faster.
10. Sync with active document
Once you’ve found a class, you may want to find or add a class to the same folder that it lives within. If you have no idea where the class lives in the solution explorer, just get Visual Studio to guide you. Use the keyboard shortcut Ctrl+[, S or hit the double arrows icon in the solution explorer toolbar. The toolbar will expand, scroll to and highlight the file you’re currently editing:
11. (Bonus feature) Customize keyboard shortcuts
One of the most useful Visual Studio features is the ability to customize your keyboard shortcuts. In the menu, click “Tools” and then “Options…”. Head to the sidebar, expand “Environment” and then select “Keyboard.” Use the search box to type part of the name of the feature you’re editing with no spaces, such as activedocument for the above feature. Focus on the “Press shortcut keys” box and input the keyboard shortcut you want. The box below will display the feature(s) that are also using that keyboard shortcut so that you can avoid any unwanted conflicts. Hit OK and try it out.
It’s all about saving time
Most of these features, for me, are all about saving time. Which Visual Studio features do you use all the time that help save time and supercharge your coding skills? Comment below!
Further reading
Raygun integrates with Visual Studio Online
Raygun and Visual Studio Team Services
How to design better unit tests | https://raygun.com/blog/visual-studio-features/ | CC-MAIN-2020-40 | refinedweb | 1,516 | 68.6 |
The next feature the customer wants to add to our ultimate flashlight is a data-logging facility. This will track the times when the flashlight has been switched on as well as the duration of each use. This tracking information will allow the performance of different batteries to be evaluated, and allows us to explore the manipulation of dates and times in the .NET Micro Framework. It will also let us see how we can build custom classes to store data, and how we can create a structure to hold a collection of data items.
Of course, the information is useless if it stays inside the flashlight, so we will need a way of transmitting the data to the outside world. Fortunately, the device we are using is fitted with an RS-232 connection, which we can use to transfer the data.
The following information will be stored:
The date and time at which the flashlight was turned on
The duration of the use of the flashlight
The .NET Framework (and also the .NET Micro Framework) provides a DateTime structure to manage the date and time and a TimeSpan structure to hold a given time interval. What we need to do is find a way of holding two of these items together in a lump that we can then store within the flashlight. The best way to do this is to create a class to hold the information.
public class FlashlightUse { public DateTime switchedOn; public TimeSpan litDuration; }
The FlashlightUse class holds information about a given use event. The time the flashlight was switched on and the duration for which it was lit are held in DateTime and TimeSpan structures. These are members of the class that provides the data payload.
One other aspect of class design is giving classes behaviors that allow them to function with other classes in the system. There are a number of actions that an instance of a class should be able to perform, and one of them is to provide a textual description of its contents. In the case of our data-logging flashlight, this would make it possible to ask an instance of FlashlightUse to provide a string that gives the values it holds.
We do this by adding a ToString method to the class. This method overrides the method in the parent class.
public override string ToString() { return "On : " + switchedOn.ToString() + " for : " + litDuration.ToString(); }
This ToString method returns a string of text giving the time the lamp was switched on and the duration information. Note that it makes use of the ToString methods in the two data members to produce the required output.
A constructor is a method that is called when an instance of a class is being created. Constructor methods let us get control and set initial values for instances of our classes. If a class is given explicit constructor methods by the programmer, one of these methods must be called when an instance is created. In other words, we can force users of our classes to give us information when the class comes into being.
public class FlashlightUse { public DateTime switchedOn; public TimeSpan litDuration; public FlashlightUse(DateTime inSwitchedOn, DateTime inSwitchedOff) { switchedOn = inSwitchedOn; litDuration = inSwitchedOff.Subtract(switchedOn); } public FlashlightUse(DateTime inSwitchedOn,TimeSpan inLitDuration) { switchedOn = inSwitchedOn; litDuration = inLitDuration; } }
There are two ways by which we might want to create an instance of FlashlightUse. We might store the time that the flashlight was switched on and the time it was switched off. Alternatively, we might store the time the flashlight was switched on and the timespan giving the duration of its use. We can cater to both of these situations by providing two constructor methods that accept the appropriate parameters. This is a technique called overloading, by which a given action is implemented in a number of different ways. The idea is to make the use of our classes as easy and flexible as possible.
You can see the constructors in the preceding code; they are the methods with the same name as the class. They are called when the new keyword is used.
FlashlightUse record = new FlashlightUse(switchedOn,DateTime.Now);
This code will create an instance of the FlashlightUse class using two DateTime instances, that is, it will call the first of the two constructors created earlier in this section.
One of the reasons we use classes is that they can contain code that makes sure instances never contain invalid data. For example, in the case of our FlashlightUse class, we don't want to have any instances that contain a negative value for the duration the lamp was lit. If programmer error ever created any such instances, they would cause all our reading values to be incorrect. The solution to this seems simple: we just add to the constructor code that checks to see if the time interval we have been given is negative. However, the problem is that we have to do something if the constructor receives a negative value.
Normally, we can make a method refuse to use an invalid input and return a flag value indicating that a parameter is invalid, but a constructor cannot do this. The class instance exists as soon as a constructor completes. This means that the constructor must resort to drastic measures to signal a problem; it must throw an exception.
C# uses exceptions to signal the occurrence of a very bad event. The normal flow of execution stops, and an exception instance is created that describes what has gone wrong. If the programmer does not provide an exception handler, the exception is caught by the runtime system and the execution thread ends.
Exceptions are thrown by using the throw keyword.
public FlashlightUse(DateTime inSwitchedOn, TimeSpan inLitDuration) { if (inLitDuration.Ticks < 0) { throw new Exception("Invalid FlashlightUse timespan"); } switchedOn = inSwitchedOn; litDuration = inLitDuration; }
This version of the constructor uses the Ticks property of the TimeSpan structure. On the .NET Micro Framework, a tick is 100 nanoseconds. The Ticks property gives the length of the timespan in ticks of this duration. The constructor can test this value to determine whether the incoming duration is negative. If the duration value is found to be invalid, the constructor throws an exception with a message describing the error. With this test in place, it is impossible to create an instance of FlashlightUse that has a negative duration.
If a method throws an exception, the execution is transferred to the nearest exception handler. If the programmer has not provided a handler, the exception is caught by the runtime system. To get control when an exception is thrown, you enclose a block of statements in a try-catch construction.
try { FlashlightUse record = new FlashlightUse(switchedOn,DateTime.Now); Debug.Print("time record created OK"); } catch { Debug.Print("time record creation failed"); }
If the constructor throws an exception, the code in the catch block will run. If we want to retry the code in the try block, we must place the whole construction in a loop of some form, because once an exception has been thrown in a statement, the block containing it is abandoned.
The try-catch in the preceding section is the simplest form of construction. It is also possible to get hold of the exception that has been thrown and inspect it for details about what went wrong.
try { FlashlightUse record = new FlashlightUse(switchedOn,DateTime.Now); } catch (Exception e) { Debug.Print("Time record creation failed: " + e.Message); }
By explicitly catching the exception rather than just handling it, we can obtain the message that we created when the exception was thrown. This code would print the following when the instance construction fails:
Time record creation failed: Invalid FlashlightUse timespan
The exception also holds other information, including a stack trace that can be used to find out what was happening when the exception was thrown.
An exception causes our program to branch to the code in the catch clause. This will then handle the exception and transfer execution to another part of the program, perhaps by performing a return or a break out of the current code. However, frequently, things need to happen whether an exception is thrown or not. An example of this would be the use of a particular device. Whatever happens during the use of that device, you want to execute the code that closes the device so that the code can be used in other parts of the program.
Place this code in the finally block.
try { // code that connects to the device here } catch { // code that handles any exceptions } finally { // code that tidies up here // executed whether or not an exception is thrown // and irrespective of what happens in the try and // catch blocks }
Whatever happens in the try and catch blocks (even if they use a return to exit the method in which the code is running), the code in the finally block will run. The catch clause can be left out if you want to ensure that only a resource is released.
If you are wondering why you need finally when the program will perform the statement following the try-catch construction anyway, consider the following:
static void exceptionFun() { try { Debug.Print("Inside the try block"); return; } finally { Debug.Print("Inside the finally clause"); } }
In this code, the method exceptionFun contains a try-catch construction. Within the body of the method, a return statement will cause execution to leave the method. However, the finally clause executes before the return executes. In other words, if the method executes, it will print.
Inside the try block Inside the finally clause
The finally clause executes, irrespective of anything else.
The way in which error handling is performed in a system is best decided at the start of the development. At the very beginning, you should plan how to generate and propagate exceptions through your system, along with a means to test each of the exceptions.
One of the most important aspects of any embedded system is the way it responds in such situations. Error management should be integrated into the program at design time, as should test code that throws the exceptions, to ensure that the device behaves correctly.
Now we need to add the code that performs the logging. When the flashlight is turned on, the program must record the time, and then when the flashlight is turned off, the program must create an instance of the FlashLightUse class to record this. The software must hold a collection of these log items for retrieval later for analysis.
One way to log the data would be to create an array of FlashLightUse instances held in the memory of the flashlight:
static private FlashlightUse[] FlashlightUseLog;
This declares a reference that can refer to array instances. At the moment, we have not created an array; we have just created a tag that can refer to an array instance. We must use new to create the actual array.
FlashlightUseLog = new FlashlightUse[1000];
This statement creates an array instance that can hold references to 1000 objects of type FlashlightUse. However, just as with the reference to the array at the beginning of this section, we have not yet created any log item instances, just an array that contains references that can point at instances. We can now go ahead and make an actual reading instance.
FlashLightUseLog[0] = new FlashlightUse(switchedOn, DateTime.Now);
This code creates a log item instance and then sets the element at the start of the array to refer to it.
Figure 4-4 shows the effect of the preceding code. The array reference refers to an array instance that contains 1,000 elements, each of which is a reference that can refer to an instance of the FlashlightUse class. The element with subscript 0 (that is, the one at the start of the array) refers to an actual log instance. The remaining 999 references do not refer to anything. In a C# program, this value is called null.
Figure 4-4: Filling up an array of references.
When the program needs to add another log item to the array, it can search for an element that contains a null reference and then set that to refer to the new log item.
private static bool storeUseRecord(FlashlightUse useLog) { for ( int i = 0 ; i < FlashLightUseLog.Length ; i++ ) { if ( FlashLightUseLog[i] == null ) { FlashLightUseLog[i] = useLog; return true; } } return false; }
The method storeUseRecord receives a parameter that is the reference to the log item to be stored. It searches for an entry in the array that is set to null, and if it finds one, it makes that entry refer to the log item. If the method reaches the end of the array without finding a null entry, the method is not able to store the data and returns false to indicate that it has failed.
When we want to retrieve the records from the array, we can search for all the non-null elements in the array.
static void dumpLog() { for (int i = 0; i < FlashLightUseLog.Length; i++) { if (FlashLightUseLog[i] == null) { continue; } Debug.Print(FlashLightUseLog[i].ToString()); } }
The method dumpLog uses a for loop to work through the array and print out each of the non-null elements. An array instance uses a property called Length, which gives the number of elements in the array. This code will therefore work for any array size. Note that the C# language allows us to declare a control variable directly inside the for loop construction.
If we know in advance exactly how many records we need to save, an array will work well. However, we might require more flexibility so that size of the storage used increases with the number of records to be held. C# also provides a collection class called an ArrayList that can be used in this situation. Rather than having to specify the storage size at the start of the program, an ArrayList will grow as the program adds more data. The ArrayList class is in the System.Collections namespace, so if we wish to use it without giving the fully qualified name each time, we must add a using directive to ask the compiler to check this namespace each time we identify a class.
using System.Collections;
Now we can create an instance of an ArrayList.
private static ArrayList UseLog = new ArrayList();
This code creates an instance of an ArrayList and sets the reference UseLog to refer to it. Note that, at the moment, the ArrayList does not contain any references to log instances, but we can add instances by calling the Add method.
FlashlightUse record; record = new FlashlightUse(switchedOn, DateTime.Now); UseLog.Add(record);
The record is added to the end of the ArrayList collection. Note that we do not need to manage this addition; if the storage needs to be extended, the extension will happen automatically.
When we want to retrieve the data from ArrayList, we can work through it in exactly the same way we worked through the array.
for (int i = 0; i < UseLog.Count; i++) { if (UseLog[i] == null) { continue; } Debug.Print(FlashLightUseLog[i].ToString()); }
This code is very similar to the loop that works through the array. The ArrayList provides an indexer mechanism whereby users of the collection can provide a subscript to identify the item that is to be returned. In this context, the ArrayList behaves exactly as an array. There is one difference between the use of the two types, though: an ArrayList uses a property named Count that gives the number of items in the list, whereas the Length property of an array does not.
When you create an array, you can give the elements in it a particular type. The compiler will then make sure that you store only elements of that type in the array. Earlier we made a FlashlightUse array, which holds references to FlashlightUse instances. If we add code that stores a reference to any other type in the array, the compiler will refuse to compile the code. During the execution of the code, the runtime system also checks that references are used appropriately, so within the .NET Micro Framework a class will never be used in a context in which it would be invalid to do so.
However, the ArrayList collection needs to be able to hold references to any class. It does this by managing its contents using references to the Object class. Object is the parent of all classes, which means that a reference that is able to refer to Object can also refer to any class that is derived from it. Thus, when we retrieve a reference from the collection, what we actually get is a reference to an instance of an object. The problem with this is that we may wish to use the object as it really is; in this case, an instance of the FlashlightUse class. As an example, we may wish to print out a list of all the times that the flashlight was switched on.
for (int i = 0; i < UseLog.Count; i++) { if (UseLog[i] == null) { continue; } FlashlightUse use = (FlashlightUse) UseLog [i]; Debug.Print(use.switchedOn.ToString()); }
We need to declare a reference to the appropriate type and then use a cast to set this to refer to the element in the ArrayList. We can then retrieve the property using this reference. This code will work correctly only if the ArrayList actually contains references of the correct type. If an attempt is made to use the cast to convert an element of an incorrect type, the program will fail at runtime by throwing an exception.
A C# program can check the type of a reference by using the operator is.
if (UseLog[i] is FlashlightUse) { FlashlightUse use = (FlashlightUse)UseLog[i]; Debug.Print(use.switchedOn.ToString()); }
This code will attempt to perform the cast only if it works correctly.
If you are sure that an ArrayList collection contains only references of the correct type, you can simplify the code to extract the items from the collection by using the foreach construction.
foreach (FlashlightUse logItem in UseLog) { Debug.Print(logItem.switchedOn.ToString()); }
This construction will iterate through a collection and perform the loop with the reference logItem being set to each item in turn.
We now have a flashlight that can store data for us. However, we have no way of getting the logged data out of the flashlight and into another system for analysis. Fortunately, the flashlight has been fitted with an RS-232 serial port that can be used for input and output. When the flashlight software receives a request, it can then transmit the contents of the log to a connected device via this port.
A physical serial port is managed by an instance of the SerialPort class. This provides methods that can be used to write a stream of bytes to the port and read incoming data. The constructor for the class is provided with a reference to an instance of the SerialPort.Configuration class, which is used to set the baud rate, the physical device to be used, and whether the port is to perform handshaking.
SerialPort.Configuration config; config = new SerialPort.Configuration( SerialPort.Serial.COM2, SerialPort.BaudRate.Baud9600, false); // no flow control
This code creates an instance of the SerialPort.Configuration class, which selects the second serial port and sets it to 9600 baud with no flow control. We can now create the serial port itself.
SerialPort port; port = new SerialPort(config);
We can now call methods on the serial port to receive and transmit data.
The serial port provides a Write method that will send information to a remote device. The information to be sent is supplied to the Write method as an array of bytes, a start position in the array, and a number of bytes to transfer. However, the ToString method of LogItem supplies the information about a log event as a string. The program must convert this string into an array of bytes. The .NET Micro Framework provides a utility method to perform this conversion. The Encoding.UEF8.GetBytes method is supplied with a string and returns a byte array.
static void exportData() { foreach (FlashlightUse logItem in UseLog) { byte[] buffer = Encoding.UTF8.GetBytes(logItem.ToString()); port.Write( buffer, // data source 0, // start position in buffer buffer.Length// number of byes to write ); } port.Flush(); }
Now that we can send serial data out of the serial port, we might need a way for the remote device to trigger the transmission. The serial port provides a method named Read that will fetch a number of characters from the serial port.
byte[] buffer = new byte[1]; int count = port.Read( buffer, // destination 0, // start position 1, // 1 byte 1000 // wait 1 second );
The Read method receives a reference to the byte buffer that will hold the received characters, along with the start position in the buffer and the number of characters that are to be read. It also receives a timeout value, given in milliseconds. A call to the Read method will block the thread that makes the call until either the requested number of bytes have arrived or the timeout expires. The code will pause until a character arrives or a second passes. The Read value returns the number of bytes that have been read, and we can test this to see if anything has arrived at the serial port.
private static void monitorLogRequests() { byte[] buffer = new byte[1]; while (true) { int count = port.Read( buffer, // destination 0, // start position 1, // 1 byte 1000 // wait 1 second ); if (count > 0) { if (buffer[0] == 'D') { exportData(); } } } }
The method monitorLogRequests repeatedly reads the serial port waiting for a single character to arrive. If it receives a character and the character is D, it calls the exportData method to transmit the information.
The best way to ensure that the log data is sent out on request is to create another thread.
System.Threading.Thread serialThread = new System.Threading.Thread(monitorLogRequests);
This thread will run the method so that whenever the flashlight receives the character D, it will export the data. | https://flylib.com/books/en/3.308.1.37/1/ | CC-MAIN-2021-17 | refinedweb | 3,678 | 61.77 |
10,:01001 Full Text Dozen do HIGH FORECAST: 88 Storms throughout LOW the day. Chance 76 of rain 70 percent PAGE 4A > 0 roge i7- Federer continues Open assault /1B SEPTEMBER 10, 2007 BATTERED: Bucs beat down Shaun Alexander and Matt Hasselbeck, plus big hits from the Seahawks' defense past the Bucs in Jeff Garcia's debut./Page 1B HEALTHY APPETITE: Church hosting 9/11 tribute Event will be Tuesday evening at Heritage Baptist in Beverly Hills NANCY KENNEDY nkennedy@chronicleonline.com Chronicle It was the defining event of our nation's recent history and the day that should never be for- gotten, say the organizers of the annual Sept 11 remembrance service. Beginning at 7 p.m. Tuesday at Heritage Baptist Church in Beverly Hills, the community is invited to participate in a patri- otic program thanking local emergency first responders and saluting local military veterans and active duty members. This year, the featured guest speaker will be Chaplain Maj. Ken Stone, USAE "He's back from Iraq and now lives in Atlanta," said the Rev. David Hamilton, pastor of Heritage Baptist Church. "He spoke at our first program and people remember him." The program will also include the patriotic musical, "The Land of the Free," as well as the pres- entation of a plaque to Wayne Martin, chief of Nature Coast Emergency Medical Services, on behalf of all local EMS per- sonnel. In years past, the community has honored Sheriff Jeff Dawsy and Fire Chief Richard Stover. "We present them with a plaque and they explain what they do (on the job)," Hamilton said. A moving part of the service each year is a tribute to those who are currently serving or have served in the military. As the different military hymns play and the corresponding emblem from that branch of the service is shown on a video screen, military members fill Please see TRIBUTE/Page 5A Wing winner A 105-pound competitive " eater known as "The Black Widow" bested a dozen beefy rivals to win a wing-eating contest./Page 8A FATAL WRECK: Charges filed An Inverness man was charged with homicide after a deadly traffic crash last week that killed one person. /Page 3A ORANGE HARVEST: Sour expectations State's orange harvests look bleak with citrus greening affecting thousands of acres of the No. 1 agricultural product in Florida./Page 3A OPINION: Get involved this year and help make a difference. S . 14A. Little damage Tropical Storm Gabrielle causes few problems along the Carolina Coast./Page 16A GOVERNMENT WANTS HELP: Iraq security The Iraqi government said �,Sunday was not ready for a timetable on the withdrawal of American forces./Page 16A APPLE A DAY: Get served i e.-r i ,r or l ,th ., eer 1 ) A pgoernnient reco menl Z mcre fs''.r.,irig . 0o truit arid ve tablee, or . , r ..,rle, e@?r y Tuesday , Annie's Mailbox ........ 6B Comics .............. 7B Crossword .......... . 6B Editorial ............ 14A Entertainment ......... 5B Horoscope ........... 6B .:-.t ter v Payouts ........ 5B Movies .......... 7B Obituaries ........ ... . 6A Weird Wire ............ 8A Two Sections 6 E8457i 8 200!2 5 DAVE SIGLERICr...:.n,cie Chris and Sierra Stahl, 3. play a game of peek-a-boo Saturday at Whispering Pines Park in Inverness. The father and daughter had nice weather for the day at the park with lower humidity caused by Tropical Storm Gabrielle churning toward North Carolina in the Atlantic Ocean. Rapist wants life sentence reduced TERRY WITT terrywitt@chronicleonline.com Chronicle A twice-convicted rapist who spent much of life in state prison will appear today in Citrus County Circuit Court to plead for his freedom. Randy Ray Arnett, 43, has filed a motion asking Circuit Judge Ric Howard to correct an illegal life sen- tence imposed on him in 1991 for.the rapes. Arnett argues in his motion for re- sentencing that he was unaware in 1991 that if he had been sentenced under 1983 state guidelines he would have received a lighter sentence. He is asking Howard to give him 12 years in prison with credit for time served, a sentence he believes would result' in his release from prison. Arnett was convicted in 1980 of rap- ing a 78-year-old Floral City woman at gunpoint He was convicted in 1985 of Please see RAPIST/Page 4A District likely to approve budget Public input sought at school board meeting KERI LYNN MCHALE kmchale@chronicleonline.com Chronicle It's the last call for public input about the 2007-08 Citrus County school budget and millage rate. At 5:30 p.m. Tuesday, a public hearing will take place at the District Services Center in Inverness. Citrus County citi- zens will have the chance to voice their opinions to school board members before they adopt the final tax rate and budget, Finance Director Kenny Blocker said no *significant adjustments have been made to the tentative, $233 million school budget, but the final budget up for adoption may amount to slightly m WHAT: less than $233 mil- Citrus County lion, because offi- School Board cials continue to meeting. make small modifi- cations. WHERE: No changes have District been made to the Service 2007-08 tentative Offices, tax rate, 7.413 mills, 1007Main St up for adoption. A Main St., millage rate is a tax Inverness. rate measured in N WHEN: mills. One mill 3 p.m. equals $1 for every Tuesday, $1,000 of assessed followed by property value. the public Based on the school hearing district's total tenta- at 5:30. tive tax rate, a homeowner who pays the full-assessed value of a $150,000 home, with home- stead exemption, would pay about $926. The capital millage rate is the only portion of the total proposed tax rate controlled by school board members and the maximum 2 mills for the capital fund will be up for adoption. Money raised for the capital budget is used to pay for new schools, buses and other expenses. Authorities for the state Department of Education decided the general fund tax rate, 5.143 mills, which is the majority of the total tax rate up for adoption. Money raised from this portion of the total tax rate is used for the school district's oper- ational budget, also known as the gener- al fund. The general fund is used to pay salaries, insurance, utilities, etc. The school board meeting will begin at 3 p.m. Tuesday, and 2007-08 salaries are up for approval by board members. During the past few weeks, district offi- cials negotiated salary and benefit increases with employee unions such as the Citrus County Education Association and Teamsters Local No. 79. Members of Please see BUDGET/Page 5A Numbers cloud debate as Congress awaits Iraq commander Testimony before Congress begins today Associated Press WASHINGTON - In vertical bars of blue, green, gray and red, a briefing chart prepared by the Defense Intelligence Agency says what Gen. David Petraeus won't. Insurgent attacks against Iraqi civilians, their security forces and U.S. troops remain high, according to the docu- ment obtained by The Associated Press. It is a conclu- sion that the well-regarded Army officer who is the top U.S. commander in Iraq is expected to try to counter when he and Ryan Crocker, the U.S. ambas- sador in Baghdad, testify before Congress today and Tuesday. More than four years into a conflict initially thought to be a cakewalk, the war has become a battle of statistics, graphs and conflicting assessments of progress in a country of more than 27 million people. The defense intelligence chart makes the point, with fig- ures from Petraeus' command 4 ,0 00 attacks .... .......... ..... ..................................................................... .1 "1 Most Insurgent attacks 3,000 2,000 1,000 0 2006 2007 target U.S. forces Iraqi security Iraqi civilians forces 2007 2006 2007 Please see NUMBERS/Page 7A SOURCE: Defense Intelligence Agency AP _.. . ..... . ...:.. ...... .,. , :?;-.. . . . 119 2A MONDAY, SlPTEMBER 10, 2007 _ Council members attend conference Inverness officials praise event Special to the Chronicle ,,All five Inverness City Council recently attended the Florida League of Cities annu- al educational conference in Orlando. Council members volun- teered to attend the Aug. 16 to 1 conference at the Orlando :World Center Marriot. They were joined by Mayor Bob .plaisted, City Manager Frank DiGiovanni and City Clerk Debbie Davis. .. The conference provided a networkingg opportunity to interact with city leaders and planners to gain more skills and knowledge toward improv- ing government operations. It was a new experience for sev- eral recently elected council members. ; Fred Ramlow, who was unanimously picked by the council June 5 to fill a council vacancy, said he came away with ideas that can help improve the lives of local citi- zens. He attended workshops that dealt with such critical issues as reclaimable water usage and the future of proper- ty taxes. Ramlow said local concerns must be known in Tallahassee. "The local people's voices have to be heard because we're the ones closest to the people in our city," he added. Councilwoman Marti Consuegra said she came away with a greater understanding of laws, management and how she, as a woman, can be an effective leader in the commu- nity. She added, "Strides are being made to make sure that the voices of the citizens of Inverness are heard in Tallahassee on taxes, insur- ance and property values." Jacquie Hepfer, elected last November to serve the remain- ing two years of a four-year term for an open council seat, also valued information on reclaimed water, as well as dis- cussions about county seats and city revitalizations. "The Inverness community is greatly benefited when elect- ed officials take time away from work to voluntarily attend a situation where they interact with leaders of every corner of the state," DiGiovanni said, "to share ideas, discuss concerns, and develop responsible solu- tions to best position Inverness for its future." Cr'TUS COUNTY (FL) CIHRONIclE __.--- _ _ --County . Inglis to discuss police chief contract The Inglis Town Commission will consider giving its police chief a five-year contract at Tuesday's reg- ular meeting. Chief Timothy Bible currently has no contract, nor does any other police chief in Levy County. The commission meeting begins 'at 7 p.m. in Town Hall. 9/11 tribute planned for Tuesday - The World Trade Center memo- rial exhibit and tribute will be open from noon to 6 p.m. Tuesday. Republican group to meet today National Federation of Republican Assemblies (NFRA) will meet at 7 p.m. today in the Caf6 at Vineyard Church in Inverness. Renee McPheeters, candidate for Citrus County Commission District 1, will speak about account- ability of county government, including taxing authorities and other issues concerning Citrus County. Also, John Parsons, past president of NFRA, will send infor- mation regarding several Constitutional Amendment Petitions that have been approved for signatures. The public is invited; conserva- tives are encouraged to attend. Call Shirley Sanservino, district president, at 637-3126, or e-mail nfra@tampabay.rr.com. - From staff reports .;I: *... r.,,,. . - E :.ve yb dy -,,~f-sb, fi Aotthe c poi -below, relative who would li'e to -. . e l , 3 . . .: 1 " :e w R ,'.q -put - . _, .i -?*-,.' 't:im - owt _ .[' naxi fe ' ' o a o. a peto wrbei "i'y ue ., iP , Chronicle Comics Cal] ,. relai.v, .dle - Ask, ,F,,.., I I Your Name Phone_ List of Names Name_ I Name Phone_ Phone_ , Name Phone -..,m--- ,,--- : 563-5665. or 1: 563-3295 k for code PL r ma Please mail to: Citrus County Chronicle 1624 N. Mead:,wcreit Blvd. Cry-tal River, FL 34429 Fax to: 563-5665 or Call: 563-3295 .. ... . GET THE WORD OUT * Nonprofit organizations are invited:l to submit news releases about upcoming community events. * Write the name of the event, wh. sponsors it, when and where it will take place and other details: include a contact name and phone number to be printed in the paper; news release es are subject to editing * Call 563-5660 for details. SFINSIDE cI [ AI Free CCC Hearing Aid Repairs SI all makes and models' Crystal River Mail _In .B.....nly. .rp... c-up."n 795-1484 Battery Sale i Paddock Mall, Ocala 89 237-1665 c cc (Limit2packs) A hero's welcome DAVE SIGLER/Chronicle The Withlacoochee Chapter of the Sons of the American Revolution presented Walter Nichols III, 27, a medal for heroism Saturday at the Inverness Golf and Country Club. Back row, from left, are: Richard Sumner, vice president, and Harley Nelson, secretary; front row, Caleb Nichols, Walter Nichols and John Camillo, president. Nichols was on his way back to work after his lunch break on July 17. He spotted a home engulfed in flames at the Mossy Oak Mobile Home Park in Inverness and pulled his car over on U.S. 41. Nichols jumped out and rescued Sue Abraham, a 63-year-old Inverness resident, from her burning home. He left to return to his construction job at the new elementary school in Citrus Springs soon after he tossed Abraham over his shoul- der and carried her out. Furniture Repair Furniture Repair & Restoration * Finish Repairs * Complete Refinishing * Chair Caning Structural Repairs * Antique Repairs * Chair Regluing reisine Refinish Line is the expert in furniture repair and refinishing. For an estimate, call 352-400-5277 HURRICANE PROTECTION 'Don't Wait Until It's Too Late" * Hurricane Panels * Accordian Shutters ,' * Winguard Impact Glass Windows ',' V ALL PRODUCTS MEET DADE COUNTY APPROVAL CODES . M asrfear II I .-., Aluminum, Inc. Hwy. 44, Crystal River I W inGuar 795-9722 * 1-888-474-2269 IMACT-SANT WINDOWS & 7959722 * 88874-22 PROFESSIONALS INSTALL ATION 31 YersasYorllmeo DaerCoplt -Aluiu Srie Reason #7!2 to join Suncoast. If you're a customer at a bank, there's something you should know. The bank doesn't work for you; they work for stockholders - owners with their eyes on the bottom line. That's not the case with WHO'S ELIGIBLE TO Suncoast Schools Federal Credit Union. JOIN SUNCOAST? We're not-for-profit and are owned by the Children attending public school in Citrus County, employees very members we serve. That's why they get of schools and many local businesses, hospitals, cities and counties and lower rates on loans, higher earnings on people age 55 and over. Immediate deposits and many free services that banks family members can join too. like to charge for. So why would anyone stay with a bank, unless they're a stockholder? To learn more about the advantages of switching to Suncoast call 800-999-5887 or visit joinsuncoast.org. 1 Suncoast Schools Federal Credit Union WHERE SMART PEOPLE KEEP THEIR MONEY. ~ssss .G.. m 7m s0.__________________________________________� ^ � ^ ^ ^ ^ ^ ^ ^ Licensed 8 InSUred Lic. #RR004238E LOCAL ILMAP 3A MONDAY SEPTEMBER 10, 2007 CITRUS COUNTY CHRONICLE Around THE STATE Citrus County Floral City man, 57, dies in crash A57-year-old Floral Olty marn died in a crash Saturday when his car hit a tree. The Florida Highway Pjatrol identified the man as Clifford W. Wie't ha-pe t ' abo :41 p.m while ltheman was driving his 1989 red Dodge Colt east on County Roao 39A, also known as East Gobbler Drive, in Floral City. As h was apprpaphjhg South Pike Way: his 'ar.failed t.'follow the'rbad's curve ahd hit a tree, according to FHP. Pensacola Judge: Truant kids' parents could face jail Parents of kids who habitually skip school could find them- selves locked up under an aggressive plan to curb truancy in this Florida Panhandle com- munity. Parents who ignore several warnings and offers of help will have to explain to a judge why they shouldn't face jail time for misdemeanor charges. Escambia County school offi- cials worked with Circuit Judge Ross Goodman to toughen the consequences. "If the parent is not sending the child to school, then I can send the parent to jail," Goodman said. Truancy, defined as 10 unex- cused absences in 90 days, is a misdemeanor. But Escambia County school officials said it rarely results in arrests. The program will first focus on elementary students because the problems and learning deficits are harder to overcome ,as the children get older. School officials said 177 of the district's roughly 40,000 stu- dents already have missed at least five days in the first two weeks of school. Miami County officials trying to account for missing art Auditors are trying find out why dozens of pieces of art are missing from Miami-Dade County's extensive collection. The county collected more than 700 pieces of notable works over three decades to display in courthouses, libraries and other public buildings. The program cost about $33 million. A review found administrators lost track of 87 pieces - includ- ing works by Romare Bearden and Robert Rauschenberg - and that recordkeeping was often inadequate. may have been lost in 1993's Hurricane Andrew. "We have it under control now," said Cindi Nash, chair- woman of the independent Public Art Trust, which oversees expenditures. "Whatever is missing was missing a long time ago, and things haven't gone missing in a lot of years." Tallahassee No ticket wins Lotto, producing rollover No ticket matched all six Florida Lotto numbers, produc- ing an estimated $6 million jack- pot for the next drawing, lottery ^ officials said Sunday. A total of 106 tickets matched five ! numbers to win $3,566; 5,420 tick- ets matched four numbers for $56.50; and 101,718 tickets matched three numbers for $4. The winning Florida Lotto numbers selected Saturday were: 6-10-18-23-27-34. - From staff, wire reports Charges filed in fatal crash Man faces felony count of homicide CRUSTY LOFTIS cloftis@chronicleonline.com Chronicle A.n l e.;i \I\ x% was charged with hbmicid after a deadly traffic crash last week that killed one person and sent ohe other : and himself to a Gainsyilile hospital by helicopter. Willie. Lee Baker, 39, of Inverness, was charged with the following feiotnies:.cpmmitting homicide during the course of another'felony; failing to give information and render aid during a homicide/vehicular manslaughter; fleeing or eluding death with a disre- gard for safety camiing death or injury; and driving with a suspended license when causing death or serious injury. He was arrested Friday afternoon at the Alachua Counn Adult Detention Center after -peiiding a fe\v days at. Shands Hospital due to injuries. * The charges relate to what began as a Citrus County Sheriff's Office deputy attempting to pull Baker -o\er Ibr speed- ing this past Tuesday night Baker was clocked by a deputy going more than 70 mph in a 35 miph zone on U.S. 41 near the Roller Barn in Inverness. Traffic initially separated the deputy from pulling Baker over. As the deputy was trying to catch up to Baker, he saw that the car also was missing a license tag. He activated his emergency lights and about that time Baker pulled into a center turn lane and sped up, according to a news release. Baker steered into a long, sweeping curve on U.S. 41, just south of East Windmill Drive. The tires on the side of Baker's car momentarily left the road- way and went onto the road's shoulder. He returned the car to the road and when he did, Baker hit 74-year-old Rita S. Wyant - who was driving in the Sour expectations Associated Press ABOVE: Southern Gardens Citrus horticulturist Timothy C. Gast looks for citrus greening on a tree at the Southern Gardens Citrus Grove in Clewiston. Southern Gardens Citrus, among the state's top producers, is paying $300 to $400 more an acre on citrus greening detection, a one-third increase in production costs. . A row of trees cut down because they were infect- ed with citrus greening is shown at the Southern Gardens Citrus Grove. So far the company has cut down nearly 100,000 trees because of citrus greening crop disease. Florida orange harvests look bleak with greening Associated Press That requires a lot of work and money The early signs of greening are CLEWISTON - Dozens of dead subtle - yellowing, or mottled leaves - orange trees lay stacked here among and easily confused for other problems. vast green rows of grove. Southern Gardens Citrus, a Hendry Farmers felled them still bearing County company owned by U.S. Sugar fruit, but these trees were really killed Corp. and among the state's top produc- some time ago. All it took was a tiny ers, is paying $300 to $400 more an acre insect's bite to deliver a fatal crop dis- to fight greening, a one-third increase in ease called citrus greening, a bacteria production costs. harmless to humans but deadly for the In October 2005, the Clewiston-basedi thousands of trees infected since its company became one of the first coir- recent arrival in Florida. mercial producers to test positive for The disease has set off a fervor among greening. researchers and growers, already "We were hoping it was limited to a weary after weathering the hurricanes couple hundred acres. We realized of 2004 and 2005 and two decades bat- there were thousands of acres," said tling a less-severe bacteria called Tim Gast, citrus horticulturist for canker. Southern Gardens. Florida's $9 billion, nation-leading Gast said so far the company has cut citrus industry has been suffering some down nearly 100,000 trees - enough to of its worst harvests even before green- affect production, but still a fraction of" ing showed up, sending juice prices sky- its estimated 2.3 million total. rocketing. The disease's further spread Southern Gardens previously relied makes them seem unlikely to recede on oils and copper sprays, but greening any time soon. has forced them to use stronger pesti- Greening has bedeviled other areas cides, Gast said. of the world for decades and is believed The application only happens five to have arrived in Florida on infected times a year. The rest of the time, teams Asian plant material. The disease grad- of scouts inspect each tree in the grove. ually kills a plant's vascular system and The workers are specially trained, sours fruit, making it unusable. walking into the groves or driving small There are no natural enemies here to vehicles that resemble golf carts and the foreign insect that spreads greening standing on platforms to catch symp- - the Asian citrus psyllid - and preda- toms high in adult trees. tors can't easily be introduced. They flag suspect branches with Pesticides that kill the psyllid also kill bright plastic ties for further inspection. beneficial insects that trim other bugs. Confirmed cases are logged into a GPS Genetic solutions are in the works, unit onsite, their leaves and trunks but for now farmers can do little but spray painted to earmark them for watch groves closely and clip infected incineration. trees. The inspection takes patience and It~% delicate care to comb through each fold of a leaf. Young trees are more suscepti- ble because they produce new foliage (or "flush") several times a year, sprout- ing tender leaves psyllids love to nibble, Gast said. "Younger trees take three to six months to develop symptoms after the infection," Gast said, adding that it can take a year or more in older trees. So far greening has tested positive in 26 Florida counties, including most major commercial citrus areas. Michael E. Rogers, an assistant University of Florida professor of entomology, said it has probably spread almost statewide, it just isn't yet confirmed. Commissioners to talk about space needs Board will discuss hiring consultant MIKE WRIGHT mwright@chronicleonline.com Chronicle Space needs will again be front and center when Citrus County commissioners meet Tuesday Commissioner John Thrumston has scheduled a 2:30 p.m. discussion. Thrumston wants the commis- sion to discuss whether to hire a consultant to conduct a space-needs study for consti- tutional officers and the coun- ty commission. The regular meeting begins at 1 p.m. in the courthouse. Commissioners have dis- cussed space needs for months, but haven't agreed how to proceed. Commission Chairman Dennis Damato said the county should plan for 'new offices in downtown Inverness, but commissioners are divided whether to go that route or build offices else- where. Commissioner Vicki Phillips recently said the board should conduct a study to see if space now occupied by county government is being used efficiently. * WHAT: Citrus County Commission meeting. * WHEN: 1 p.m. Tuesday. * WHERE: Courthouse, 110 N. Apopka Ave., downtown Inverness. Also Tuesday, the board will have a workshop that address- es affordable housing in the land development code. The workshop begins at 3 p.m. opposite direction. The chase lasted less than a minute, destroyed both cars and killed Baker's passenger. Passenger Sean Bernard Clark, 37, was riding in Baker's 1989 Mercury Grand Marquis and died at the scene of the crash. Baker and Wyant were flown to Shands for their injuries. Charges against Baker are still pend- ing investigation from the sheriff's office, according to sheriff's spokes- woman Gail Tierney Wyant's condition was described as "good" by Shands officials Friday after- noon. Noriega's release halted Battle continues over ex-leader's extradition Associated Press MIAMI - Manuel Noriega's drug racketeering prison sen- tence ended Sunday, but the for- mer Panamanian dictator remained in the same institu- tion hirim sent to Paris, where he would face trial for allegedly launder*- ing drug proceeds through French banks. The legal arena shifted Friday to the 11th U.S. Circuit Court of Appeals in Atlanta after Senior U.S. District Judge William Hoeveler rejected 4 second attempt by Noreiga's lawyers to block the extradition They claim Noriega is entitled to return to Panama because lie was previously declared a pris- oner of war by Hoeveler Noriega's attorneys filed notice of an expected appeal with the Atlanta-based couit and said Noriega will stay in tlhe U.S. at a minimum-security prison near Miami for the time being. The appeals process could take several weeks. "The government has agreed to keep General Noriega here until all appeals are exhaust- ed," said Noriega attorney Frank Rubi no. "It's going to be a slo%% pre- sented to us that you'll see some pretty quick action on the department's part," said deputy State Department spokesman Tom Casey on Friday. Noriega was tried and con- victed in 1992 on drug racket- eering charges for essentially allowing Panama to become a transit point and money laun- dering, center for Colbmbian drug cartels. Hoeveler declared him a POW shortly after that because Noriega was captured by U.S. forces following a 1989 inva- sion of Panama intended to drive him from power. Since then, Noriega -:pris- oner No. 38699-079 - has served his time in an apart- mentlike cell in the Miami prison, complete with exercise equipment, television and tele- phone. He's also been allowed to wear his military uniform and insignia, with the International Committee of the Red Cross monitoring his treat- ment as required for POWs under the Geneva Conventions. France has agreed to contin- ue treating Noriega as a POW, according to U.S. officials. F ~ .-~ -.--.. .'. Li A "I.-'' } _)'. I. - AN CITRUS COUNTY (FL) CHRONICLE 4A MONDAY SRP'I'TEMR 10O 2007 Poll workers sought for 2008 election The Supervisor of Elections office is seeking enthusiastic voters to join the Election Team, to serve as Poll Workers for the upcoming 2008 election cycle. Applicants must be registered vot- ers in Citrus County, able to read RAPIST Continued from Page 1A raping a teenage Floral City girl at knifepoint. He received life sentences in both cases, but was re-sentenced in 1991. His case is a complicated one, filling six thick files at the Citrus County Clerk of Circuit Court The case is so old that some of the files were on micro- film and had to be copied to paper. Arnett has been re-sentenced more than once, making his case even more complex. Assistant State Attorney Rich Buxman responded in writing to Arnett's motion to correct an illegal sentence by explaining Arnett's complicated history in .a 15-page brief. 2 Buxman disagreed with Arnett's claim that the sentence was illegal, noting that Arnett is not disputing the fact he com- Imitted the crime of sexual bat- tery while armed, a crime pun- ishable by life in prison. Buxman said because the sentence does not exceed the state maximum under 1983 guidelines, it cannot be consid- ered an illegal sentence, according to the Florida Supreme Court. "Defendant's motion should be denied based on this argu- ment alone," Buxman wrote. This is Arnett's history in brief. On April 9, 1980, Arnett was sentenced to 15 years in prison County BRIEF and write the English language, complete online computer training, attend mandatory training classes in addition to the online training, pass a written exam, be able to work at least 14 hours on Election Day, be a responsible team player and be able to deal pleasantly with the public. for the burglary of an elderly woman's house in Floral City. He surprised the 78-year-old as she was going to bed, pointed a pistol at her, tore her clothes off, and forced her to have sex with him, court records said. Arnett, who was 15 at the time, threw away her glasses and false teeth. He took her captive, drove around with her in the trunk of her car and left her on a remote road in the car. His ca When neighbors heard the car's COmpl horn blowing, d eputi es one, fil responded and found her bat- thick fil( tered and bruised from the Citrus ordeal. Arnett Clerk o lived next door to the woman. Co Thirty-four months after he was sentenced for the first rape, and while he was still on probation, court records said Arnett, then 19, struck again, this time abducting and raping a 15-year-old girl in a car. He used a folding knife to hold her captive. .On Feb. 27, 1985, Arnett, following a jury trial, was sentenced to life in prison for the rape of the girl. Arnett was re-sentenced when the Fifth District Court of Appeals found the lower courts in Citrus County had made errors. On Feb. 22, 1991, Arnett was once again re-sentenced for the 1979 and 1984 cases. Arnett, Poll Workers are paid according to the position for which they are hired. If you are interested in joining the team, visit, select Poll Worker Information and complete the online application. If you have any questions, call MaryAnn Boline, poll worker coor- dinator, at 341-6747. - From staff reports 3i li f U represented by an attorney, chose to receive a "non-guide- lines sentence," according to Buxman's brief. The judge gave him life in prison for the 1984 rape case of the 15-year-old girl. But Arnett said because of a recent change in law, he is aware that if he had chosen in 1991 to be sentenced under 1983 sentencing guidelines, a life sentence would not have been possible, unless se is a the judge depart- ed from the cated guidelines and imposed a harsh- ing six er sentence. He said the circum- 's at the stances resulted in an illegal sen- COunty tence. iHe is claiming, Circuit Buxman wrote, irt. that had he known better, he would have not have chosen the route that left him open to a life sentence. But Buxman said Arnett was repre- sented by an attorney and was specifically asked by the judge if he wanted a guidelines or non-guidelines sentence. Arnett chose the non-guidelines sen- tence. Buxman said he believes Arnett chose a non-guidelines sentence because it gave him a chance to be paroled at some point, an option that would not have been available to him if he had chosen to be sentenced under state guidelines. The hearing is set for 9 a.m. today. Citrus County Sheriff's Office Domestic battery arrest a James A. Williams, 48, Crystal River, at 8:41 p.m. Friday on a domestic battery charge. A woman said that she and Williams were arguing when he hit her in the face and tore her shirt off. No bond. DUI arrests * Ryan Joseph Carroll, 18, 8170 W. Woodbury Court, Crystal River, at 12:48 a.m. Saturday on charges of driving under the influence, possession of drug paraphernalia, providing false information to a law enforcement officer and having an unlawfully issued driver license. Carroll was pulled over after deputies saw him driving without his headlights on at night and driving over curbs. He failed field sobriety tests and gave the deputy a fake birthday. A deputy also found a digital scale with a marijuana shake inside a purple bag. Bond $3,500. * Jami Patricia Moriarty, 36, 9173 N. Mendos Way, Citrus Springs, at 10:38 p.m. Saturday on a charge of driving under the influence. She was pulled over for driv- ing 63 mph in a 50 mph-zone. She failed field sobriety tests and would not submit to a blood alcohol con- ON T centration test. Bond $500. * For more inr if Other arrests about arrest * Melissa L. Simms, 24, 12375 the Citrus C E. Walton Drive, Floral City, at 5 p.m. Sheriff's Off Thursday on a felony charge of vio- lation of probation. According to the click on the arrest report, Simms was sentenced Information in September 2006 to five years of Reports. Pasco County drug offender proba- tion on the original charges of utter- ing forged bills, checks, drafts or notes. On Thursday, Simms violated her probation because a drug test revealed marijuana in her system and she was in pos- session of the drug. No bond. * Angela Marie Smith, 25, 3989 E. Jessie Lane, Invemess, at 4:08 p.m. Friday on a charge of retail theft. According to an arrest report, Smith tried to take $343.58 worth of food and other items from Wal-Mart. Bond $2,000. 1i Todd J. Smith, 34, 2604 W. Woodland Ridge Drive, Lecanto, at 5:30 p.m. Friday on felony and mis- demeanor charges from Hillsborough County for failure to appear in reference to original charges of driving with a suspended/revoked license and driving under the influence. Bond $2,000. * Charles Keith Phillips, 43, 9315 E. Windwood Loop, Invemess, at 9:11 Friday on charges of criminal mischief with damage amounting between $200 and $1,000 and battery. According to an arrest report, a man said his uncle was evicting him from his house. He thought that they had agreed to give him some time to get his things out of the house. A few days later the man said his uncle, Phillips, had burned his clothes. When the man confronted Phillips, he said Phillips put him in a headlock. Bond $1,000. M Donald Lee Dotson, 23, 4608 W. Costello Lane, at 10:20 p.m. Friday on a Citrus County warrant charge for failure to appear in reference to original felony charge of driving with a suspended/revoked license. No bond. * Dale Leon Mrkvicka, 63, of an unknown address, at 11:06 a.m. Saturday on a charge of driving with a sus- pended/revoked license. Bond $10,000. * Clayton Lee Vickers, 18, 7610 Viewcrest Loop, Floral City, and Crystal L. Cole, 18, 125 Arnold Road, Kenanaville, at about 4:30 p.m. Saturday on charges of burglary of a conveyance and petit theft. According to arrest reports, the two stole two metal gas cans from a boat. Bond $7,000 each. Crystal River Police DUI arrest * Edward Davis Lewis, 37, 7350 N.E. 138th Terrace, Williston, at 9:10 p.m. E NET Saturday on a charge of driving under the influence. Lewis was ormation pulled over for driving 62 mph in a s made by 45 mph-zone. He failed field sobri- ounty ety tests, according to an arrest ice, go to report. His blood alcohol concentra- ;itrus.org and tion was 0.150 and 0.144 percent. link to Public The legal limit is 0.080. Bond $500. then Arrest Other arrest * Joseph Anthony Kapp, 23, 11080 W. Gem St., Crystal River, at 4:39 p.m. Friday on a charge of providing false informa- tion to a law enforcement officer and violation of proba- tion. An officer saw Kapp duck into his car when he saw the officer nearby. When the officer approached Kapp, he gave the officer a fake name. The officer recognized Kapp as being wanted for violation of probation. No bond. State probation Arrests * David Frank Rizzo, 35, 18 Truman Blvd., Beverly Hills, at 5:30 p.m. Thursday on a felony charge of viola- tion of probation. According to the arrest report, Rizzo was sentenced on July 31 to a new period of two years drug offender probation for original charges of resisting an officer with violence and battery on a law enforce- ment officer. He violated his Marion County probation because he left Citrus County, his county of residence, without permission from his probation officer. Also, he admitted to consuming alcoholic beverages, according to the report. No bond. CITRUS COUNTY WEATHER A AI 1 lu n FLORIDA TEMPERATURES City H Daytona Bch. 87 Ft. Lauderdale 88 Fort Myers 88 Gainesville 87 Homestead 87 Jacksonville 89 Key West 88 Lakeland 87 Melbourne South winds from 5 to 10 knots. Seas 1 to 2 feet. Bay and inland waters have a light chop. mostly cloudy with scattered showers and thunderstorms today. THREE DAY OUTLOOK VW, W TODAY Exclusive daily forecast by: High: 88 Low: 76 Mostly cloudy, numerous showers and thunderstorms. TUESDAY " , High: 87 Low: 76 Mostly cloudy, numerous showers and thunderstorms., WEDNESDAY High: 89 Low: 78 Partly to mostly cloudy, scattered showers and thunderstorms. Gulf water temperature 860 Taken at Egmont Key L, AKE LEVELS Location Sat. Sun. Full Withlacoochee at Holder 28.44 28.42 35.52 Tsala Apopka-Hernando 34.38 34.38 39.25 Tsala Apopka-lnverness 34.81 34.80 40.60 Tsala Apopka-Floral City 35.98 35.98 ALMANAC TEMPERATURE* .Sunday S Record - Normal � Mean temp. Departure from mean PRECIPITATION* Sunday Total for the month Total for the year Normal for the year 92/72 101/63 71/90 82 +1 0.19 in. 1.12 in. 35.42 in. 41.56 in. *As of 6 p.m.from Hernando County Airport UV INDEX: 9 -0-2 minimal, 3-4 low, 5-6 moder- ate, 7-9 high, 10+ very high BAROMETRIC PRESSURE Sunday at 3 p.m. 29.97 in. DEW POINT Sunday at 3 p.m. 71 HUMIDITY Sunday at 3 p.m. 54% POLLEN COUNT** Trees were light, grasses were moderate and weeds were absent. **Light - only extreme allergic will show symp- toms, moderate - most allergic will experience symptoms, heavy - all allergic will experience symptoms. AIR QUALITY Sunday was good with pollutants mainly ozone. SOLUNAR TABLES MONDAY TUESDAY MINOR MAJOR (MORNING) 5:08 11:19 5:49 11:59 MINOR MAJOR (AFTERNOON) 5:29 11:40 6:10 - CELESTIAL OUTLOOK SEPT. 20 OCT. 3 OCT.S BURN CONDITIONS Today's Fire Danger Rating is: LOW. There is no burn ban. For more information call Florida Division of Forestry at (352) 754-6777. For more information on drought conditions, please visit the Division of Forestry's Web site: weather/kbdi. Monday Tuesday High/Low High/Low High/Low High/Low 6:10 a/1:47 a 5:50 p/1:37 p 6:31 a/2:17 a 6:29 p/2:14 p 4:31 a/10:59 a 4:11 p/11:39 p 4:52 a/11:36a - 4:50 p/--- 2:18 a/8:47 a 1:58 p/9:27 p 2:39 a/9:24 a 2:37 p/9:53 p 5:20 a/12:46 a 5:00 p/12:36 p 5:41 a/1:16 a 5:39 p/1:13 p C: ~t tU S C. C. ?, i t." V 1 - cH ONICLL Florida's Best C m n t newspaper Serving Florida's Best Commninty To start your subscription: Call now for home delivery by our carriers: Citrus County: (352) 563-5655 Marion County: 1-888-852-2340 or visit us on the Web at .html to subscribe. 13 wks.: $34.00* - 6 mos.: $59.50* - I Dur N --- FORECAST FOR 3:00 P.M. MONDAY Sunday City H L Pcp. Albany 68 611.02 Albuquerque 79 68 Asheville 88 56 Atlanta 88 69trace Atlantic City 84 61 Austin 93 72 Baltimore 88 63 Billings 56 43 .02 Birmingham 90 69 Boise 79 44 Boston 76 61 .03 Buffalo 69 64 .74 Burlington, VT 61 55 .22 Charleston, SC 90 67 Charleston, WV 87 67 Charlotte 94 62 Chicago 80 63 Cincinnati 89 72 .19 Cleveland 75 68 .47 Columbia, SC 95 63 Columbus, OH 81 70 .47 Concord, N.H. 73 57 .47 Dallas 93 78 .08 Denver 73 45 Des Moines 73 60 Detroit 81 64 .13 El Paso 86 70 .17 Evansville, IN 88 73 .02 Harrisburg 85 66 Hartford 87 71 .01 Houston 92 76 Indianapolis 84 71 .14 Jackson 92 72 Las Vegas 10279 Little Rock 83 74 .05 Los Angeles 72 64 Louisville 84 73 .47 Memphis 84 75 .32 Milwaukee 74 60 Minneapolis 66 52 .03 Mobile 91 69 Montgomery 93 65 Nashville 83 73 .11 Monday Fcst H L shwrs 76 56 ptcldy 86 61 tstrm 82 61 ptcldy 90 70 tstrm 80 68 ptcldy 96 70 tstrm 82 61 ptcldy 76 49 ptcldy 92 69 sunny 78 51 tstrm 77 63 ptcldy 71 53 ptcldy 73 51 ptcldy 89 75 tstrm 81 64 ptcldy 92 67 shwrs 67 52 cldy 81 59 cldy 71 57 ptcldy 93 70 cldy 77 61 shwrs 79 53 tstrm 91 70 shwrs 57 42 shwrs 58 50 cldy 72 59 tstrm 89 67 cldy 82 63 tstrm 83 61 tstrm 84 60 ptcldy 93 76 cldy 78 60 ptcldy 93 72 sunny 10077 tstrm 83 69 sunny 74 63 cldy 82 66 tstrm 88 72 shwrs 60 50 ptcldy 65 50 sunny 91 72 sunny 94 69 tstrm 85 70 Sunday Monday City H L Pcp. Fcst H L New Orleans 91 74 ptcldy 91 76 New York City 85 71 tstrm 84 68 Norfolk 87 74 tstrm 89 73 Oklahoma City 87 75 tstrm 80 57 Omaha 70 57 shwrs 57 47 Palm Springs 10476 sunny 10879 Philadelphia 88 69 tstrm 85 69 Phoenix 10684 sunny 10584 Pittsburgh 75 69 .10 ptcldy 77 57 Portland, ME 72 57 .12 shwrs 73 56 Portland, Ore 87 54 sunny 94 55 Providence, R.I. 80 65 tstrm 80 64 Raleigh 95 60 ptcldy 92 69 Rapid City 50 45 .07 sunny 70 45 Reno 87 56 sunny 86 49 Rochester, NY 68 63 .62 ptcldy 71 52 Sacramento 83 54 sunny 92 58 St. Louis 87 71 cldy 83 61 St. Ste. Marie 66 57 .03 ptcIdy 64 44 Salt Lake City 77 57 sunny 73 48 San Antonio 92 77 ptcldy 92 72 San Diego 74 66 sunny 75 67 San Francisco 70 59 sunny 70 54 Savannah 87 67 tstrm 91 72 Seattle 77 55 sunny 81 55 Spokane 75 48 sunny 81 49 Syracuse 68 64 .54 ptcldy 75 52 Topeka 73 62 shwrs 69 51 Washington 88 68 tstrm 82 65 YESTERDAY'S NATIONAL HIGH & LOW HIGH 109 Needles, Calif. LOW 24 Stanley, Idaho WORLD CITIES MONDAY CITY H/L/SKY Acapulco 88/78/ts Amsterdam 65/46/sh Athens 84/66/s Beijing 86/77/pc Berlin 64/47/r Bermuda 82/75/pc Cairo 87/73/s Calgary .. , 70/39/pc Havana' 87/74/ts Hong Kong 90/78/ts Jerusalem 85/64/s Lisbon London Madrid Mexico City Montreal Moscow Paris Rio Rome Sydney Tokyo Toronto Warsaw 83/63/pc 67/47/pc 89/62/pc 72/56/ts 75/55/pc 59/41/pc 71/48/pc 85/67/pc 75/55/pc 71/57/pc 84/75/ts 74/53/pc 61/43/sh Where to find us: SNorvell Bryant Hwy Ane r~ .--- Cannonridale Dr. Ave , Meadowcrest Blvd iTompkins St ~square CD 1 .41 f ' 0 PERIODICAL POSTAGE PAID AT INVERNESS, FL V SECOND CLASS PERMIT #114280 For the RECORD :DATE DAY 9/10 : 9/11 SEPT. I SEPT. 9 SUNSET TONIGHT........................... 7:42 P.M. SUNRISE TOMORROW .....................7:13 A.M. MOONRISE TODAY...........................6:19 A.M. MOONSET TODAY ............................7:18 P.M. KEY TO CONDITIONS: c=cloudy; dr=drizzle; f-falr; h=hazy; pcspartly cloudy; r=raln; rs=rain/snow mix; s=sunny; sh-showers; sn=snow; ts=thunderstorms; w=wlndy. 02007 Weather Central, Madison, Wi. -Aff-I -A I -9 I I VI I I I l Illl t Ic 1, I I R MONDAY, SEH'EMBnR 10, 2007 5A CTRus COUNTY (FL) CHRONICLE BUDGET Continued from Page 1A the Teamsters represent bus driv- ers, as well as cafeteria, mainte- nance and custodial workers. Union members of the CCEA rep- resent mainly teachers, school nurses, teachers' aides and secre- taries. The contracts between the Citrus County School Board and the Teamsters, CCEA and admin- istrators, include a 4.5 percent pay raise. That brings a starting teacher's salary from $32,400 to $33,858. If board members approve the contracts, district employees will receive about a 5 percent increase in salaries and benefits this year Last year, the increase was 7.2 percent Also at the meeting: * Support Services Director Mike Mullen will provide an Elementary "A' progress update. * Officials will recognize stu- TRIBUTE Continued from Page 1A the area in the front of the church and in the aisles. "Some of them have said they have never been honored like that before," Hamilton said. This is the fifth year of the remembrance service; the suc- cession of hurricanes that dis- rupted Florida in 2004 caused that year's program to be can- celed. He added that enthusiasm for dents with perfect scores on either the reading or math por- tions of the Florida Comprehensive Assessment Test Out of the 62 students dis- trictwide with perfect scores, two achieved perfect scores on both the reading and math sections. * Rock Crusher Elementary Principal Nancy Simon is up for approval by board members to be appointed as the first principal at Elementary 'A" for the 2008-09 school year. * The Five-Year Work Plan, presented by Planning and Growth Management Director Chuck Dixon, is up for approval. The plan was formed to prepare and budget for necessary facility projects during the next five years to address anticipated pop- ulation growth within the district For more information about Tuesday's school board meeting and public hearing, call 726-1931, ext. 2206, or log onto citrus.kl2. fl.us and click on the School Board link the event has remained strong. '"We've had standing room only - this service has taken on a life of its own." Members from Heritage Baptist Church and Faith Baptist Church in Homosassa Springs are the program's organizers, but others are involved, including a community choir "We want this to be a commu- nity event, to say thank you as a community to our first respon- ders," Hamilton said, "and we seek to honor God through all of this." For information, call 746-6171. Downtown Dems to meet Tuesday The Downtown Democratic Club will meet at noon Tuesday at B&W Rexall Drugstore in Inverness. All Democrats are welcome. For information or questions, call Phronsie Stokeley at 344-4707. Friends of the Dunnellon Ubrary to meet Tuesday The Friends of the Dunnellon Public Library will meet at 10 a.m. Tuesday at the Rainbow Springs Country Club. Members, old friends and newcomers are invited to attend this first meeting of the season. For details or directions, call the library at (352) 489-4196. Friends' president Gloria Petit encourages interested supporters to join this dynamic group and help support our local library. Several literary events and fundraisers are planned for the coming season with the annual Fall Book Sale scheduled for Nov. 2 through 3 at the historic Dunnellon Depot. The Friends continue to look for your donations of good condition books, audio books, videos and CDs for the sale. Please drop donations off at the Dunnellon Public Library, 20804 W. Pennsylvania Ave., any- time during regular hours, or arrange a home pick-up in the Dunnellon area by calling the library at (352) 489-4196 and leaving a message for the Friends. Genealogical society to meet in Lecanto The Citrus County Genealogical Society will be meeting at 10 a.m. Tuesday at the Church of Jesus Christ of the Latter-day Saints, 3474 W. ____ 7257 BLI N DS Aje WE'LL MEET OR BEAT ANY COMPETITORS PRICE* - The Savings Are Yours Because The Factory Is Ours! FAST DELIVERY * PROFESSIONAL STAFF I',BOUMiWUND FACTORY TOTALTLAWN&GOND5 IA PR EMITMLAWNTQ A�TT,7~ rA A k7 �- *' *1 1 Mowing Edging Trimming Plugging Mulching 6 Insect Spray 3 Granular Fertilizer 3 Liquid Fertilizer 3 Weed Control (1) Granular Pre-Emergent Application (21 Liauid Applications S527-9373 FREE INSPECTION FREE ESTIMATE Southern St., Lecanto. Guests are always welcome. The topic for the day will be Funeral Home Records and what type of information can be found in them. The speaker will be Charles E. Davis of the Chas. E. Davis Funeral Home. For information, go to the Web site at rootsweb.com/~flccgs2. EDC barbecue slated for Sept. 20 The county's biggest barbecue blast is planned for Thursday, Sept. 20, and attendees have the added opportunity to win four tickets to a Tampa Bay Buccaneer winner will have the opportb, nity to select which group of tickets they want from one five of the upcoming Buc's games. Tickets to the barbecue are $30 per person and can be obtained by calling 795-2000. - From staff reports STI LEY STEE ERO STHNLEY STEM1ER AIR DUCT WANING. SAIR HOURRESTORATION At the first sign of flooding call the Water Extraction experts at Stanley Steemer. Our trained technicians use M io.#"023-iNhlaSHOUT CLEANING EXPERTS Call 726-4646 or for outlying areas 1-800-STEEMER (783-3637) You can also schedule appointments 24 hours a day at Locally owned & operated. County BRIEFS Drive to School ______ " -BRUSHLESS 100' TUNNEL o - FREE UNDER CARRIAGE WASH ' Hand-Wx $1oOFSPEC LA,5 fnp1F,59,o#o7 Gift Certificates Availabid L 11Hw . 4 W s (e. o , �t IVRNSS ,34-36 AIRPORT TAXI 746-2929 V-0 REDUCE YOUR TAXES All Are Welcome, No Reservations Required DATE: TUESDAY, SEPTEMBER 11T" PLACE: Beverly Hills Community Center (At end of Beverly Hills Blvd., next to Surveillance Office) TIME: 10:05 a.m. Sharp INCOME TAX Loopholes revealed. Reduce/Eliminate tax on Social Security Income. Qualified dividends L/T capital gains. Learn what income is taxed at Lowest Rate, and more. (352) 527-2866 Calabro Financial Management, Inc. Securities offered through Cadaret Grant & Co., Inc. ,24928 Members NASD - SIPC g STANLEY STEEMERl .- 1ARPEt CLEAN "" '..) . :.::, :: : : _ , , 5 , . .. . . - : - . - . . . . . .. ............. .......... I- LAWN CUTTING t II - . . .. . ..--- - . ..... VIS4 Ofl AVlIMINDiAY, il I ISVIoISIS. E1, �.tfl----j , ,-IObituaries Dorothy Benvenuto, 78 CITRUS SPRINGS Dorothy E. Benvenuto, 78, Citrus Springs, died Wednesday, Sept 5, 2007, in Inverness. She lived in the area for 19 years. She was Catholic and enjoyed volunteering at Seven Rivers hospital in Crystal River Survivors include her hus- band of 57 years, Nicholas Anthony Benvenuto; brother, Edward Bauer and wife Mary of Hicksville, N.Y; and many nieces and nephews. Roberts Funeral Home, Dunnellon. Rose Rudolph, 80 INVERNESS Rose Marie Rudolph, 80, Inverness, died Saturday, Sept 8,2007, in Leesburg. She was born Nov. 16, 1926, in Key West to Edison and Ruth Bernice Archer. She moved here from Stuart 16 years ago. She worked as a registered nurse at Visiting Nurses Association and Jupiter Hospital in Jupiter. She attended the First Baptist Church of Inverness where she volunteered at C.S.M. She was preceded in death by her son, Randall Roy Rudolph, who died in 2005. Survivors include her son, Ron R. Rudolph and wife Kelli of Leesburg; daughters, Teresa Stephenson and husband Bruce of Port Orange, and Gail Moore and husband Tim of Hedgesville, WVa.; brother, Edison Archer of Palm Beach Gardens; sister, Wilma Baughman of Inverness; 12 grandchildren; and five great grandchildren. Hooper Funeral Homes, Inverness. Paul Sicari, 84 HOMOSASSA Paul F Sicari, 84, died Saturday, Sept. 8, 2007, In Lecanto. He was born Jan. 29, 1923, in Palermo, Italy to Anthony and Frances (Abenante) Sicari. He moved here 16 years ago from Vernon, Conn. He was a retired aircraft production controller for United Technology in Windsor Locks, Conn. He was a member of St. Benedict Catholic Church of Crystal River. Survivors include his wife of 60 years, Theresa E. (Bizzoco) Sicari of Homosassa; and daughter Pia Sicari of Homosassa. Wilder Funeral Home, Homosassa Springs. Terry Wells, 51 HERNANDO Terry Wells, 51, Hernando, died Saturday, Sept 8, 2007, in Ocala. He was born Aug. 29, 1956, in Middletown, Ohio. He moved here 15 years ago from Ohio. He was an auto mechanic. Mr Wells was preceded in death by his parents, Clarence and Helen Wells; brother, Jim Wells; and sister, Kim Wells. Survivors include a daugh- ter, Tara Lee Wells of Citrus Springs; brothers, Mike Wells of Middletown, Ohio, and Ed Wells and wife Allison of Citrus Hills; sisters, Pat McDaniel and husband Greg of Homosassa, and Doty Rosebrock and husband Dave of Homosassa; and five nephews and three nieces. Wilder Funeral Home, Homosassa Springs. Rex Williams, 89 LECANTO Rex B. Williams, 89, Lecanto, died Saturday, Sept 8, 2007, at Brentwood under the care of his family and Hospice of Citrus County. He was born May 12, 1918, in B o n h a m, [Texas, to Curtis S and Rebecca S (Garner) Will- iams. He moved here in May from Dallas, Texas. Mr Williams was a retired real estate salesman. He served in the U.S. Navy during World War II. He was a graduate of Texas Tech, were he played college football and later went on to play professional football for the Detroit Lions and the New York Giants. His enjoyments in life were fishing, gardening and watching televised football and baseball games. He was Methodist Survivors include his wife of 34 years, Alice (Nance) Williams; stepson, Richard Lee Trotter of Neodesha, Kan.; step- daughter, Sandi and her hus- band Meryl Smith of Lecanto; three step-grandchildren, Kim, Sherri and Lesli; and three step-great-grandchildren, McKenzi, Kylie and Tiera. Chas. E. Davis Funeral Home with Crematory, Inverness. Funeral NOTICES Rose Marie Rudolph. The service of remembrance for Rose Marie Rudolph, 80, of Inverness, will be at 1 p.m. Wednesday, Sept 12, 2007, at First Baptist Church of Inverness with the Rev. Donnie Seagle officiating. Interment will follow at Stage Pond Cemetery, Inverness. Friends may call from 5 to 7 p.m. Tuesday at the Inverness chapel of Hooper Funeral Homes. Paul F. Sicari. Visitation for Paul E Sicari, 84, Homosassa, will be from 6 to 8 p.m. Wednesday, Sept 12, 2007, at Wilder Funeral Home in Homosassa Springs. A funeral Mass will be at 10 am. Thursday, Sept 13, 2007, at St Benedict Catholic Church in Crystal River with the Father Michael Suszynski as celebrant Inurnment will be held at a later date. In lieu of flowers, memori- als may be given to Hospice of Citrus County. Deaths ELSEWHERE Madeleine Stern, 95 part- nership with Rostenberg in 1945. Four years later she became a founding member of the Antiquarian Booksellers Association of America& "Madeleine did more to fur- ther the association and estab- lish its prestige than anyone I can think of," said Bernard M. Rosenthal, a rare book dealer in Berkeley, Calif, and a longtime colleague of Stern. "She was very dynamic; she got things done." Stem. Stern and Rostenberg were co-authors of several memoirs, including "Old & Rare, Thirty Years in the Book Business" (1974), "Old Books, Rare Friends, Two Literary Sleuths and Their Shared Passion" (1997) and "Bookends, Two Women, One Enduring Friendship" (2001). They insist- ed that they were not lesbians and included a chapter in their last memoir titled, "The Men We Didn't Marry." Stern has no immediate sur- vivors. Citrus County Courier Airport Transportation OUR COMMITMENT TO YOU: Comfort and Care with a personal touch I FUNERAL HOMES & CREMATORY Beverly Hills - Inverness - Homosassa (352)726-227c1 1-888-7HOOPER (74-737) Smoke screen Associated Press Personnel confer in a room at the National Targeting Center of the Customs and Border Protection at an undisclosed location in the Washington suburbs of Northern Virginia. Rejecting most criticisms, the government has decided to continue to subject every American who travels abroad to a computerized risk assessment of whether he or she is a potential terrorist. Only modest changes in computerized rating of travelers for terrorism potential Associated Press WASHINGTON - Rejecting a wave of criticisms, the govern- ment has agreed to only gov- ernment contract Nevertheless, travelers still will not be allowed to see their actual assessments or the rea- sons for them. Federal agents still will be looking at an array of information about international travelers - Americans and for- eigners; cat- alog of federal regulations that is read mostly by lawyers and lob- byists. The computerized system is used by Customs and Border Protection officers to screen 400 million passengers a year who arrive from or depart for foreign locations by air, sea or rail. A sep- arate part of the system is used for vehicles crossing the border Members of Congress, busi- ness travel associations, privacy and civil liberties groups and even European legislators protested after Homeland Security disclosed details of the system last fall for the first time; Carol's AIRPORT TAXI 352.746-7595 Cf9n 4. E. 2Wbavii Funeral Home With Crematory * Burial * Shipping * Cremation b international Order I f the For Information and costs, call 726-8323 Why should the government keep massive databases about people it has decided are innocent? James Dempsey policy director of the Center for Democracy and Technology. it had gone in service in 1999. Some critics said the entire program was illegal; others wanted parts of it changed. But the department said the system was crucial to preventing terrorists and other criminal from entering the United States, and helps border officers decide which travelers to pull aside for further scrutiny. The department acknowl- edges com- pare travel information - known as Passenger Name Records obtained from airlines, cruise lines, and Amtrak - with government watchlists of known and suspected terrorists and other wanted or barred individ- uals. Beyond that, Teufel said, the system tries "to identify other high risk travelers previously unknown to law enforcement" This is done by comparing the passenger's data with a secret list of "rules" - theories con- ceived by department analysts based on intelligence reports and past terrorist attacks - describing behavior that might indicate someone is a terrorist or other type of criminal. The government will not release these rules because that would tip off terrorists and crim- inals to what agents look for The i All About Baths A WHOLENEW1 WORLD OF SOUNDS Jerlllyn Clark Board Certified Licensed Hearing Aid Specialist Advanced Family Hearing Aid Center ifq. S - "A Uie Approach To Haring Se prices" 644 Wt Norel Bryant Hwy. Crystal River 795-1775 - - -i - --lr i i il likeli- hood of immigration fraud." Privacy advocate David Sobel, counsel at Electronic Frontier Foundation, said the rules "are nothing more than the agency's best guess about what behavior might indicate a risk of terrorist activity." The passenger name records contain the passenger's name and usually address and tele- phone trav- eling companions and hotel reservations, including the num- ber of rooms and beds request- ed. poten- tial risk becomes clearer." After seven years, agents will need high-level permission to see the passenger name records unless those records have been associated with active lookouts, investigations or travel "routes of. concern," according to the department 70N50 726-3931 LUMINETTE' Privacy Sheers Luminette� Privacy Sheers: Limitless widths. Infinite light control. The sheerest sheers. Contact us today to see how stylish your home can be. Citrus Paint & Decor Decorating Center 12 Years In P A I N " S ARowIl (352) 795-3613 724 N.W. Hwy. 19 * Crystal River (352) 873-1300 7470 S.W. 60th Ave. * Ocala HOURS: MON-FRI 7:30AM - 5PM SAT 8AM - NOON HunterDouglas S2007 Huter Dou W I m. � Re t koed f radeank or Hrt Dous. CITRus CouNTY (FL) CHRoNicLE IRA M��"A� �qVP't'%,MfAPR ln 7.nn7 I CiTRUS COUN'IY (FL) CHRONICLE NUMBERS Continued from Page 1A in Baghdad, the Multinational Force-Iraq. Congressional audi- tors used the same numbers to conclude that Iraqis are as unsafe now as they were six months ago; the Bush adminis- tration and military officials also using those figures say that finding is flawed. With so much depending on how the statistics are collected and interpreted, policymakers in Washington are confused. Rep. Ike Skelton, chairman of the House Armed Services Committee, summed up the sit- uation during a hearing last week oh the report by congres- sional auditors at the Government Accountability Office. "What is really going on? What standards should we look at? Where do we go from here?" asked Skelton, D-Mo. For every positive step, a negative one follows. Progress by the Iraqi army is offset by the failures of the national police, which an inde- pendent assessment rates as "operationally ineffective." Nearly 77 percent of Iraqis want the militias in Iraq to be dissolved, according to the GAO, yet their government has not written legislation to do so. While the rights of Iraq's minority political parties are protected in the legislature, the GAO said violence against minority religious and ethnic groups continues "unabated" in most areas of Iraq. The report used the defense intelligence's countrywide fig- ures to conclude that the aver- age number of daily attacks against civilians has remained "about the same" during the past six months. The auditors could not deter- mine if sectarian violence had declined since the start of the president's troop increase. The agency's findings are contentious because the Bush administration and military officials in Iraq have said secu- rity has improved over the same period due to the addi- tional 30,000 U.S. troops in Baghdad and other trouble spots. In July, the White House, cit- ing "trends data" from Petraeus' command, said sec- tarian violence, particularly in Baghdad, had declined since the troop increase began in February. "There's a difference of opinion - a strong difference Plaza Health Foodsi SENIOR DISCOUNTS Vitamins * Minerals * Herbs 8022 West Gulf-to-Lake Highway Crystal River, Florida 34429 352-795-0911 23 Years In Citrus County MONIAY, Sli'Tl:NiMiit 10, 2007 7A Associated Press House Armed Services Committee Chairman Rep. Ike Skelton, D- Mo., speaks on Capitol Hill in Washington in this July 27 file photo. "What is really going on? What standards should we look at? Where do we go from here?" asked Skelton in a later hearing - questioning which statistical analysis about Iraq to believe. of opinion - as to whether or not sectarian violence has decreased," David Walker, who heads the auditing agency, said last week. In a letter to his troops Friday, Petraeus acknowledged progress has been "uneven," but said sectarian violence has fallen considerably The num- ber of attacks across the coun- try has declined in eight of the past 11 weeks, he said. The let- ter from Petraeus does not pro- vide any figures. According to the DIA chart, there were 897 attacks against Iraqi civilians in January and 808 in July. There were 946 attacks against Iraqi security forces in January and 850 in July An attack is defined as a vio- lent act that may or may not produce casualties. Coalition forces, . which include more than 160,000 U.S. troops, were attacked the most Slightly more than 3,300 attacks were recorded in January and 3,143 were report- ed in July, the DIA said. Charts from the Multinational Corps-Iraq, the war-fighting unit headed by Army Lt. Gen. Raymond Odierno, tell a different story with bar graphs and arrows. The charts contain no numbers and they focus on Baghdad, where the bulk of the addition- al U.S. troops went. The number of roadside explosions in the Iraqi capital dropped sharply between June and the beginning of August, according to one chart; so, too, have monthly car bomb attacks. APFARIS @ Air Boat Rides * Boat Rentals e Pontoon Boat Tours a Scalloping * Gift Shop . YVuee Dr. Htmo$assa.. ,, ..-i52ga2 One chart shows a decline in monthly casualties in Baghdad, a trend that U.S. military offi- cials attribute to the "diminish- ing effectiveness on the part of the enemy," according to the chart. Telephone and e-mail mes- sages left with Odierno's unit seeking more clarity about the charts were not immediately returned. Critics say those gains amount to "cherry-picking" the most favorable data. But U.S. officials, including the head of U.S. Central Command, which oversees military operations in the Middle East and Central Asia, cite the gains as evidence Iraq is moving in the right direction. "In the less than six months I've been in this job, I have seen a substantial change and it gives me some significant optimism that this place may just. work out the way we had envisioned, or some had envi- sioned, when the tasks were undertaken," Adm. William Fallon told the Commonwealth Club of California, a public affairs forum, last week. Fallon took over in March as head of the command. Gordon Adams, a former Clinton administration official who specializes in defense issues, said all the statistics coming from Iraq need to be questioned. "When you really care about something, you're really tempt- ed to use the numbers that look best to you," said Adams, a pro- fessor at American University's School of International Service. Adams drew a parallel to Vietnam, when body counts became a measure of success. "There have been too many claims of victory. Too many claims of progress. No one trusts it anymore," he said. An independent panel led by former Marine Corps Gen. James Jones found much to criticize in a report it released last week. Jones and other retired mili- tary and law enforcement offi- cials concluded that Iraqi secu- rity forces would be unable to take control of their country in the next 18 months. Among the shortcomings are a national police force that is so flawed it should be disband- ed and reorganized, and a cor- rupt border patrol that leaves Iraq's boundaries "porous and poorly defended." The tension and violence is "fed by the slow and disap- pointing pace" of political rec- onciliation, according to the 20- member panel, which spent three weeks in Iraq. Nonetheless, they said there are "signs of encouraging tacti- cal success" in and around Baghdad. Michael Heidingsfield, a member of the panel, said he does not expect Petraeus to tell Congress he is satisfied with the current level of violence in Baghdad. It is, however, lower than it has been since 2004 due to the infusion of troops, Heidingsfield said. "That process works," said Heidingsfield, who spent 14 months in Iraq as a police adviser. "The challenge is, can you sustain it?" * A . & Serving Citrus County for 15 years! * - visit Our Showroom SE^TRVICES CUTOii cM iBUILT B Will heal rompetitors pricing Authorimtd Heal & Clow Dealkr & Fire Macic BBQ * Chimnv) S'reeps * Ouldoor BBQ kichlin * Firt-placi' * Dryer Vent Cleaning * Fireplace Facing * Brick Work * Stonework * Fireplace Startups * Supplies * Free Local Estimates * Gas Logs Vented or SParts * Repairs Unvented * Electric Fireplaces " Accessories (352) 795-7976 Crystal River Crystal Plaza (Behind Dillon's Inn) Free fireplace inspection w/dryer vent cleaning! W726-8822 1-800-832-8823 Heritage Propane ^^ Q Serving America With Pride $ INSTALLATION SPECIAL 1 Price subject to change without notice . INSALLTIN ICLDES�_201b. Cylinder Filled $10.00 Fredy Hepfl.eric -Buge Py la 4275 W. Gulf to Lake Hwy. (Hwy. 44), Lecanto, FL * Serving All Of Citrus County i Bon --UALITY FREE ESuMATES! CALL TODAY fiST IB QUALITY I, ANI SHUTTERS 726-4457O llll---m------ mll Body found likely missing student, authorities say Associated Press PROVO, Utah - A woman's body believed to be missing Brigham Young University stu- dent Camille Cleverley was found Sunday, authorities said. The body was found in Provo Canyon, said sheriff's spokesman Sgt. Spencer Cannon. Authorities were try- ing to confirm the woman's identity, but Cannon said inves- tigators believed it was Cleverley, a 22-year-old senior from Boise, Idaho. Cleverley was last seen Aug. 30, and her mountain bike also was gone. Authorities had been searching mountain trails and the Provo River for her, believ- ing she may have parked her bike and hiked one of the many trails leading into the Wasatch Mountains. Her bike was turned in by two people who admitted they had snatched it after finding it locked to a rack at Bridal Veil Falls along the Provo River, officials have said. The area is popular for hiking, but can also be treacherous with sheer drop-offs of hundreds of feet. Cleverly's debit card was used the day after she van- ished to buy doughnuts and fruit drinks at a Provo store. Police have said the buyer was a young woman but they could- n't confirm it was Cleverley. Police gave her boyfriend a lie-detector test, which he vol- unteered to take and passed, although an FBI regional supervisor was to review the polygraph results. Provo, home to BYU, is about 40 miles south of Salt Lake City. TO BUY A PHOTO * Phot.ot: shot by Chronicle staff ph,,tog hr .aphei ar-e available for sale as 8-by-10 color prints. * To rider reprints, go to and click or, the d for.j dotPh:t,:,. Follir.w the in:.trr.J,'tions to choose the image and pic: lac our order. * If ,,.u d1- not have access to the Internet, orders can be plac:.e,:- from the Cfl, toicle office .'with a credit card. * Photos submitted t, the Chronicle are ncot available for reprint. Gardening Supplies P i products Natural & Organic Soil Conditioner Composted Worm Castings & Bat Guano. Add to Regular Soil to Add Awesome Boost & Growth. Only $18.95 a bale covers 6x6 area HAPPY FROG r ~ Larg Slctono* Vgtale&Flweees 3640 Hy. 19 omosa saFL377 35) 2-25 Acos FrmEffsBoln 4...f . . A111 ii.GESrTHlE FTirestone WE CARRY IN STOCK TIRES TO FIT MOST CARS. SUV's & TRUCKS AIR CONDITIONING I TUNE-UP Test for system pressure and leaks. ' Inspects fan belts, compressor and hoses. $ .-95 Most Vehicles Refrigerant Extra. U L COMPUTER DIAGNOSTIC Don't Know Why That Service Engine Light Is On? Computer $ Scan f41 m 4 WHEEL ALIGNMENT Helps prevent early tire wear with computerized accuracy, plus we inspect steering/suspension. $ 95 MOSvehicles. I VHSe Pars and rear shims exora if needed. OIL CHANCE & FILTER SMostCars Of Quality 1OW-30Oil o YOU'LL LOVE OUR FOOD... OR IT'S FREE! - EDUNCHOR lt ' RnEE DINNER S. Buy any lunch or diner entr6e and two beverages and receive the " . secondd lunch or dinner, of equal or lesser value FREE (upto $9.95) Not valid witll any other discounts LimUnit one coupon per table. . ; " 1 HURRY IN!iOfferExpires Sopt 30,l zMw The Frankie's Grill Difference * Free Anniversary Club , * Free Birthday Club 7 * Signature weekly specials \BE/ * 54 seat banquet facility .*1I, * Beautiful outdoor patio 725044 Call or Stop by Today! Hwy. 41 in Inverness, Just North of KMart To Go!! 344-4545 4Seenit" ' FOR BEAUTY & WELLNESS S p "Best of the Best Day Spa" Thanks For Your Support! 30MnteMsag paFcal-Casi edcr BE ST 1031 N. Commerce Terr., Lecanto, FL 34461 On Hwy. 44, Next To Key Training Center (.Look for the Purple Roof) "Valid Monday - Wednesday only. Limited Availability. Not good with any other discounts or specials. Offer expires October 31, 2007. #MM9B 1. -I r SCHEDULED SCHEDULED MAINTENANCE SERVICE MAINTENANCE SERVICE I. I RAM M l ,.1ri , SPPTIM ., 0. / 2007 EC Wing winner BUFFALO, N.Y. -When it comes to wolfing wings, Sonya Thomas is a wiz. The 105-pound competitive eater known as "The Black Widow" bested a dozen beefy rivals Sept. 1, scarfing 173 wings in 12 minutes to win the wing-eating contest at 'the National Buffalo Wing Festival. "That's 5.17 pounds of wings," said Brian Kahle, spokesman for the annual Labor Day weekend event in the city where Buffalo wings were born. Thomas, 40, of Alexandria, Va., also held the festival's previous record of 161 wings in 12 minutes, set in 2004. "She's the crowd favorite," Kahle said. "It was 12 huge guys and her." Thomas has set numerous rec- ords in competitive eating events, including 37 hot dogs in 12 min- utes; 35 bratwursts in 10 minutes; 11 pounds of cheesecake in 9 min- utes; 44 lobsters in 12 minutes; and 250 Tater Tots in 5 minutes. She is ranked No. 5 by the International Federation of Com- petitive Eating. According to the federation's Web site, No. 1-ranked Joey Chestnut holds the 12-minute record for chicken wings, downing 7.5 pounds of them May 21. Cat extortion NORTH KINGSTOWN, R.I. -A man has been charged with extort- ing more than $20,000 from his el- derly mother by repeatedly threat- ening to kidnap her beloved cat and demanding ransom, police said. Garry Lamar, 47, was arrested Aug. 31 and released on $200 bail. He has been ordered to stay away from his 78-year-old mother, Mary Lamar Grancher. He started threatening to kidnap the cat just over a year ago, after his mother kicked him out of her home, accusing him of abuse, North Kingstown Police Sgt. Daniel Associated Press Sonya Thomas, center, swallows another chicken wing Sept. 1 during the National Buffalo Wing Festival eating contest held in Buffalo, N.Y. Thomas won the event by eating 5.17 pounds of chicken wings in 12 minutes. Joe LaRue is on the left and Chip "Burger" Simpson is on the right. Ormond said. "This isn't just a family cat," Ormond said. "She actually called this cat her companion since she lived alone." Rolling roadblock BIGGS, Ore. - Three commer- cial. Trucker Edwin Beach said he heard police radio traffic and said, "OK, where's the high-speed chase at?" He coordinated with two other drivers over CB and placed his truck in the middle on Interstate 84. The chase began Sept. 1 near Boardman and ended near the John Day Dam on the Columbia River about 100 miles east of Portland, police said. Speeds dur- ing the chase exceeded 100 mph. The fleeing car had been report- ed to have been involved in a hit- and-run. Castle quarrel MYRTLE BEACH, S.C.- The man who currently holds the world's record for the tallest sand castle is pouring cold sea water on Myrtle Beach's attempt to dethrone him. Ed Jarrett, from Casco, Maine, said the 43-foot castle built in June in Myrtle Beach failed to follow Guinness World Records guide- lines per- missionin- ness that the city would not allow us to hand deliver the sand, and they said it would be OK to use machinery to bring the sand castle in." The Guinness organization has- n't yet decided whether the Myrtle Beach castle should be considered an official record. For Jarrett, the world record is a personal crusade. His 29-foot cas- tle is the current record holder and he spent about two months build- ing the 32-foot tall castle with the help of 1,500 volunteers to raise money for a retreat for children with life-threatening illnesses. - From wire reports m y .. & What is potentially the world's tallest sand castle was being built in Myrtle Beach, S.C., as seen in this June 1 photo. [ , "i l rp , . .. ' *" 'i f - Ed Jarrett collapses in exhaustion after completing his world- record 31.7-foot-high sand castle, Sept. 1 at the Point Sebago Resort in Casco, Maine. I. $99 4 Rooms and a Hallway Haii\\ 11c & ~fIns.m^ Gulf Coast and Rehabilitation Center Meadowcrest Professional Center 6043 W. Nordling Loop, Crystal River CITRUS MEMORIAL .' . ^' ^ - / CAC057119 CELEBRATING OUR 34TH ANNIVERSARY O>> CURRIER COOLING S & HEATING, INC. \ (352) 628-4645 (352) 628-7473 ' S4855 S. Suncoast Blvd. (Hwy. 19 So.) Homosassa, Florida 34446 [ R p -pi-. 3 3, - S PA. Who will be the next Citrus County Enter your pet in the Citrus County Chronicle's Pet Idol Contest and support student and teachers through the Newspaper in Education (NIE) program. I f - At I, LA r- 4-"- / -- -m-mmm mmm Please Print I Owner's Name I Pet'Name Address I Phone - - - - - - - - - - - m TL E LE83-I. Please mail to: Citrus County Chronicle Attn: NIE 1624 N. Meadowcrest Blvd. Crystal River, FL 34429 C I I I Ei' EI C- - - - - -b SAMONDAY, SEPTEMBER 10, 2007 4 WEIRD) WIRE CITRUS COUNTY (FL) CHRONICLF - l---l --l-.1.1 Exacting donors reshape giving Some college gifts Geri Cecil loved Randolph-Macon Woman's College from the moment she met people on the Lynchburg, Va., campus, and every year after she graduated in 1968 she gave the school money She believed in its system of education, made lifelong friends, even served on the board of trustees for several years. That's all over now. Last year, Cecil felt blindsided by a major change at the college: plans to admit men. She said she didn't hear of the proposal until shortly before it was approved and saw alumnae such as her- self stonewalled when they objected. So she stopped donating-- forever, she said. When she drives by campus, Cecil, a boarding-school teacher who still lives in Lynchburg, tries not to look. It feels like she has lost a close friend, she said. "I certainly have learned one thing," Cecil said. "I will never make an unre- stricted pledge to anyone, ever again." Cecil is part of a new generation of col- lege donors - savvy, activist and willing to stop giving if they don't like the way their money is being used. Donating "has become a much more engaged process," said Stephen Joel Trachtenberg, who just stepped down from his long presidency at George Washington University. "Increasingly, peo- ple have points of view. The put-the- money-on-the-stump-and-run benefactors of earlier days are diminishing." Alumni now are far more likely to give to specific projects rather than the operating funds that keep universities running and to expect detailed reports on how the money is spent. Some ask to meet the students who win the scholarships, select the professors; who get the chair, scrutinize financial reports, weigh competing construction bids, choose the paintings for the gallery walls. an unrestricted pledge to anyone, ever again. Gern t.:-: ,a former donor to Randolph-Macon Woman's College in Lynchburg, Va. And if the donors are dead, their heirs are intervening in how the money is spent, said Joe Bull, who recently stepped down as director of planned giving at Ohio State University. "That's a wave that is coming and com- ing fast. I think in general we're a much more distrusting society than we used to be - and some of these gifts are so large, they should be scrutinized." One closely watched case that sends chills down administrators' spines is play- ing out at Princeton University, where school officials have spent years tussling with donors' heirs over a fund that has grown to more than $840 million. The Robertson Foundation started in 1961 with $35 million of stock in the A&P supermarket company given to the Woodrow Wilson School of Public and International Affairs - at the time, one of the largest gifts ever to higher education. Marie Robertson was clear about her intent: "to establish ... a Graduate School, where men and women dedicated to pub- lic service may prepare themselves for careers in government service," particu- larly international relations. They set up a foundation to administer the gift and gave three of seven seats on the board to family members. Five years ago, several Robertson fami- ly members filed suit, pointing out that very few Wilson graduates were going into, government service, and seeking to sever the foundation's relationship with Princeton. During the years of the lawsuit, they SUSAN KINZIE The Washington Post I will never make turn (JL futl Ltoi) L have claimed that Princeton has improp- erly spent more than $207 million and has hidden spending from family members and that between 1990 and 2003, only about 10 percent of the graduates funded by the foundation went into international affairs jobs with the federal government. The Robertsons say the money should go to other institutions that do a better job of sending people into government. * Princeton has so far failed to get the suit dismissed, and this spring it repaid nearly $800,000 to the foundation, money it said had been used for graduate students in departments related to, but outside of, the Wilson school. The university has portrayed the battle as being about academic freedom, arguing that the plaintiffs want to limit the Wilson school to a kind of vocational program for a few federal agencies. As years have passed and legal fees have mounted, unusually sharp language has erupted on both sides. "This case is about the descendants of a donor trying, 46 years after a gift was made, to seize con- trol of funds that their parents chose to give to Princeton and not to them," said Princeton spokeswoman Cass Cliatt. Meanwhile, family spokesman Bill Robertson, a Princeton graduate like his father, described administrators of his alma mater as "really no better than your typical con artist." He says evidence shows Princeton "intended to disregard my parents' wishes all along." Cliatt said Princeton has a long history of honoring donors' wishes. Yet some of the arguments made by its attorneys have drawn attention. The Robertson case "is being watched by institutions with grave concern," said Sheldon Steinbach, a lawyer specializing in higher education. 'An adverse determi- nation could lead to litigation by a variety of donors across the nation." It's also being watched by prospective donors. BRUSHLESS CAR WASH Full Service Car Wash & Self Service Bays Available Detailing Available! The Washington Post execu- tive, is still open. Some schools are wary of gifts such as antiques and col- lections that could become a burden to maintain, especially years down the road. Tulane University in New Orleans is facing a lawsuit over a wooden sailboat, donated along with cash in 1956 by Albert Baldwin Wood, an alum- nus who invented the pump system that drains New Orleans; he died on board. The money was unrestricted, but the gift stipulated that the boat be maintained and dis- played on campus. His heirs claim that it was neglected - which the school denies - and they are asking Tulane to return both the boat and the cash. TUESDAY ONLY I LADIES' DAY I 15 %OFF1: S Not Valid W/AnyOther Coupons Expires 9/25/07 I WEDNESDAY ONLY I I GENLEMEN'SDAY 15% OFF Not Valid W/Any Other Coupons Expires 9/26/07 ,.- .-- -- -- 7- -7A- S750 SE US Hwy. 19 *Crystal River * 795-WASH Urology Center of Florida in conjunction with the Cancer Treatment Center is pleased to announce a New Office in Citrus County Call 746-5000 IMMEDIATE APPOINTMENTs AVAILABLE 3406 N. LECANTo HWY. SUITE A BEVERLY HILLS e FLORIDA 34465 OVA =a Friends of the Library, map rr:12'. WWOMALL BOOK SALE as - Fundraiser Oflaher 5-9 Citrus County Auditorium US 41 S., Inverness Sale Hours Fri. 5-8 p.m. with $5 donation m w No admission charge for the following Sat. 8 a.m. - 4 p.m. Sun.'l p.m. - 4 p.m. Mon. 10 a.m. - 7 p.m. (half price day) Tue. 10 a.m. - 3p. M. ($3 a bag) Great bargains in recycled -reading! Thousands of best sellers, Westerns, romance, computer, large print, history, 11 '-" 70 crafts, cooking, health & fitness, children's, awl% travel, foreign language, vintage & collectible, etc. iii:;"1 09m; Proceeds benefit Friends of Coastal Region, Central Ridge and Lakes Region Libraries and Citrus County Library System. ON For book sale information call 746-1334 or 527-8405 ..- - FREEZE & PLUSH: Joe 's Cpe $ 99 1ang S.... Y . q.Yd.I S/ */, 1o't ISIt Ca nil t � Installed Complete Installed Comiplete Sju. ..r. AI.........I...........I \7BtEST7 Your Complete AREA RU CERAMIC ' -BES'T/� ,; Flooring Store! *: y.::: IASa tingAtL S.. ,,OFF 89 : 19962007 (Crystal River store on1 Sq. Ft. .--- ......... . ,- - LARGEST REMNANT COLLECTION IN T E. 1NTY LE.AMINATE CdomPeBy COUNTY'S LARGEST AREARUGS 7 & 8MIL FREE Carpet59 SamplFY3 Sq. Ft. Installed - Twris Extra BEVERLY HILLS LIONS BINGO The Friendliest Bingo in Town! Hours: Mon. 6:00 1 . - Thurs.12:301 m. Doors Open 2 Hours Earlier We are open Labor Day Refreshments Served at a Nominal Cost Both Monday and Thursday at 72 Civic Circle * Beverly Hills Info 527-2614 c HOMOSASSA LIONS r BINGO R9l Bc st Mond-ay8 '15 Every Month at 6pm Package $20 Pkg. $50 Payout (5) $250 Per Game Jackpots j Free Coffee& Tea * Non-SmokingRoom HOMOSASSA LIONS CLUB HOUSE Rt. 490 * Al Becker 563-0870 bene- factors." Visit Our NEW "PINK HOUSE" SHOWROOM! VERTICAL BL1ND) FACTORY 2968 W. Gulf to Lake Highway 44, Lecanto, FL 34461 352-746-1998 1 g TonFree 877-"202-1991 A---i All Types of Window Treatments 713233 Family Owned and Serving the Area Since 1980 IF I IfA� f l IfA-l IFrld^ ^FI e z IZZZ7 77� HOMOSASSA LIONS AUXILIARY S"Q.I Friday Nights @ 6:30pmr 3 JACKPOTS WINNER TAKES ALL KING & QUEEN * Refreshments Avail. * FREE Coffee and Tea * Smoking & Non-smoking Rooms * $15pkg. Homosassa Lions Club House, RT 490 Bob Mitchell 628-5451 5th Friday Night $10 Pk I]E ] n Z ZZZ]ZZE] ] ] KNIGHTS OF COLUMBUS II N' Abbott Francis Sadlier #6168 s352/746-6921 ALL PAPER L: Id County Rcd 46 & Pine Con*- Lecanio FL I* . ,.,�� Blil - 1 I il ;.'ZMilleEa ii tC,uv,-rv ,R.R- 44,i BINGO PRIZES --- - - th.Coupon-.- ISln S't I BUY 1 BONANZA : 50 TO U250 L GET 1 FREE J I ~ OUR LADY OF FATIMA CHURCH 550 HWY. U.S. 41 SOUTH, INVERNESS, FL $2050 PAYOUT EACH NIGHT TUESDAY AT NOON & THURSDAY AT 6:30PM $50 PRICES A PAYOUTS 2PACK............... 10 JACKPOTS 3 PACK2..................... 12 so50$150 20 REGULAR 4 PACK ..............$.......14 $350* GAMES 5 PACK....................$15 (*3 PROGRESSIVE GAMES) 8 SPEED SPEED PACK.............$5 ii...ioo GAMES XTRA PACK..............$2 arcs, a pze . F If, !I Smok*-Ree Environment FM Coffee & Tea TV Monilors for Ybui Convenience - Sandwiches & Snacks - I MONDAY, SEPTEINIBER 10, 2007 9A NATION Cii-Rus Coumn, (FL) CHRONICLE IOA MONDAY, SIEPFMBER 10, 2007 CnRus COUNTY (FL) CHRONICLE A A--4;---- Ad , tiq nt I Advertisment Advertisement consumers the lowest cost digital service pay TV transmissions now available to Florida residents there is no longer the need to depend on cable companies that have over priced service. With this improved service Florida consumers can get the channels they want at prices that are up to 50% less then their current wonderful music channels. Also the most watched local channels like ABC, NBC, CBS, FOX, CW, UPN, PBS, and others are included. Over 100 channels for about a dollar a day. BUT WAIT IT GETS EVEN BETTER For about a $11. WHO WANTS THE GOOD STUFF? How about 43 HID channels, the best DVRS in the industry, free installation (up to 4 rooms). Best of all there is no equipmentBO Channels or Showtime, Starz, Cinemax, The Movie Channel, Encore Westerns and the Encore Theme Channels are all available for low bundled and ala cart prices. You even get 3 months free of HBO & Cinemax LOS ANGELS, WOR NEW YORK, KWGN DENVER (JUST 499 FOR SUPERSTATIONS) Want to switch service from Comcast/ Brighthouse/ Cox/ Florida cable and Direct tv? Call 1-888-851-7283 You will be glad you did!! Thes arejustsomeof.te.shws.tat yu cold hveCHET,IY 724092 rver sLISme10L MONDAY, SEPTEMBER 10, 2007 11A Taxpayer's money The Federal Reserve (Fed) pumped $62 billion into the financial markets the second week of August. The money was used for repurchase agreements reposs), a transac- tion in which the Fed buys securities from the dealers who agree to buy them back in a few days. The beneficiaries are the dealers' clients. The "Plunge Protection Team" (a term coined in a 1997 Washington Post article by reporter Brett Fromson), comprising key government agencies, stock exchange and large Wall Street firms, was a group formed supposedly in the prevention of destabilizing stock market decline. In the 1970s, prior to taking the oath of office as supervisor and chief financial officer of an upstate New York munici- pality, I did extensive research. in the financial markets. Our municipality had $2.5 million in checking accounts, a procedure that was not ben- eficial to the taxpayers.. I rec- ommended to our governing board the three banks that would work with our munici- pality to help implement sound financial policies; the recommendation was approved. Municipal employees were paid bimonthly; working with our comptroller, we formulat- ed a plan whereby employees were paid on schedule and creditors on a different date ., within 30 days of the obliga- tion, withdrawing funds from the interest bearing accounts only as needed. Certificates of deposit were used for longer- term investments, repurchase agreements reposs), which paid slightly less interest than a CD, for shorter term. A one- month financial obligation was maintained in a savings account. This permitted main- taining minimum funds deposited in checking accounts. Repos can be a high-risk transaction if safeguards are not implemented. To safe- guard our municipality, we required the banks to secure our investment with govern- ment bonds. When one bank informed us they would not continue to secure our repos, we stopped doing business with that bank. This raises a very interest- ing question about the $62 bil- lion that the Fed pumped in the financial markets to be used for repurchase agree- ments. If there is a failure on Wall Street and the dealers cannot buy back the repos, how will the Fed recover the funds? Only one place, the tax- payers. Darrell W. Weston Beverly Hills Chief's duties Re: Ms. Day's letter, "Treasonous presidency," Aug 28. Congrats to Marilyn Day for getting it right that the presi- dent's power is to protect the Constitution, not from all ene- mies. However, there is much room as to what the duties of Commander-in-Chief are and what his or her responsibility would be versus Congress. The War Powers Resolution leaves room to argue one way or the other I also congratulate Day for her soothsayer abilities in her comment: "Had we not invad- ed Iraq, Iraq would have exist- ed just as it had been - no danger to us or neighboring countries." Maybe she could sell that trash to Kuwait. Her prophetic powers continued in her statement, "that we would have stabilized Afghanistan and captured Osama bin Laden." Maybe she should talk to Bill Clinton about Osama. And ' :' :'" " " " " " "."19 that she believes what Saddam's son-in-law said only goes to prove that she is still writing half-truths or fabrica- tions. Shame! Shame! Bob Wardrop Inverness Churning the muck I myself use an ATV and have run from Gospel Island to Turner Camp using the existing airboat trails. Four years ago, I took a group of SWFWMD wetland biologists on a tour using the same trails. We drove 4x4s! It was astound- ing to witness a transforma- tion of wetland species give way to upland plants and ani- mals. I live on a dry canal and welcome the ATV riders. They blazed trails through forests of dog fennel, a prolific noxious weed that will thrive until the water returns. There they will stand as ugly dead stems cre- ating a navigational nightmare and ultimately create more muck! The ATVs churn the muck and expose it to aerobic processes that ultimately con- sume muck! If people took notice, they would have found a healthy population of yellow flies these past two years. Muck is the breeding ground for those bloodsuckers! Let the ATVs ride and enjoy the outdoors. There is no last- ing harm. A tropical storm will change the existing use and give rise to airboats and the whiners will scream and shout once again. Paul Pilny Inverness Local focus While I was as horrified as everyone else to learn of the poor conditions of our nation's bridges, I think the people who criticized the Chronicle for not carrying it on the front page were slightly out of line. I especially have a problem with people who are upset that the Chronicle, a local newspaper, places so much emphasis on Citrus County news. That happens to be the Letters to the EDITOR major reason I subscribe to the Chronicle. It's important to be informed of what is going on close to home due to the fact that local politics, taxes, crime and weather forecasts are really what affect every- day life, no matter what county one lives in. I feel there was plenty of coverage regarding the bridge collapse, including the fact that there are hundreds of bridges that should have been repaired or replaced years ago, via television and the Internet. People who simply must have a daily fix of all the blood and gore associated with all disasters, worldwide, and expect to be able to indulge their addiction to other peo- ple's misery, should be able to get enough without expecting the Chronicle, or any other local newspaper, to keep it on the front page. As for those of us out here concerned with what effects us in our real day-to-day lives, I say keep up the good work by keeping all the local news in the Chronicle. Thank you. Anita Saunders Citrus Springs Bus service We spent an enlightening few hours at the county com- missioners meeting Aug. 17. We wish a lot of Citrus County voters would do the same. This was about the bus serv- ice, or lack thereof. They final- ly appointed a committee to report back on Nov. 2. There were several people complain- ing, as we were, that they could not get service or had been put off. We were told they could only handle med- Interior Accents, Inc. ! Crystal Springs Plaza, Hwy. 44 * (next to Publix) Crystal River * (352) 563-2711 Affordable Elegance Majestic, Heirlooms, Laurel, & Princess - Only $499 i L - 123 Majestic Heirlooms Laurel Princess - . - . - ' Affordable upgrades for your EXISTING entryway in about an hour S- - with an EntryPoint doortransformation! * Malch.ng Sidelights and Transoms SSchlage locks and hardware * Hundreds of design options available through our custom program. S. Visit our showroom and pick the perfect doorglass for your home! 224 'Etd. '. N valid with y , oLrolr, PN i, IncludesI nstallton and le. YOUR DOOR * OUR GLASS Perry's Custom Glass & Doors 352-726-6125 T13797 2780 N. Florida Ave. (Hemando Plaza) Hemnando, FIL --- 352-564-WASH -*--.- Must present ad. -. 352- 56 ..SA" ~m F - - 4 **. Citrus County's award-winning Lifestyle Magazine .I , ur eth /eo.: of putl.l-i tin :.- rings hy advertise? 0 Full Chronicle Sunday circulation D i c oe Jreaching over 95,000 readers. * Additional year-round distribution in Chamber offices, hotels and many other locations throughout Citrus and surrounding counties. " Used as a relocation guide in all Citrus County Chamber of Commerce office' C ,': i.:,r.D _ .Jr :.l- _.- " ,j,:1., - r r ,, r,w. -, - -ii i -. -1 ,i-., ,:l-. Ii , L ,.lj.irn-, : 1 , 1: '-" n''n L. n ,11-1 -1 . 3D :1 r l .- r : CQ RN i S SC -0 . U . N - 1 v I IONICLE www chranicleonline com iI 'I :. . l. . .. ,, I 1. , . '. II 44 '" ,1 ." ,' " ^ ,,r A .a - , CITRUS COUNTY SUNDAY, OCTOBER 28, 2007 Call 563-5592 for more information Iii s., Me'v.~ J7 Vk I~ __________________________________~~~hAW.'~I5I * More letters to the editor PAGE 14A ical calls primarily There are five senior cen- ters that are supported by the county that offer available computers, entertainment, games and other programs. Food also is supplied every day for these people at a nomi- nal fee, but they cannot get there unless they have a ride. What is wrong with this county? Citrus County is grow- ing and the bus service should grow with it, not lie down and die. I was appalled when someone said, "This is a pub- lic service," and the comment was made, "No this is a busi- ness." Then it should be run as a business, and we voters of Citrus County should get behind it and see that they do their job. I am a resident of a nursing home, and in the past we had always had good bus service and it is still desperately need- ed. Dorothy Wilkinson Inverness Pack bags Mike Wright: With the facts you presented in your article in (a recent) Chronicle, June Fisher needs to immediately hand in her resignation, pack her little bags and head back to where she came from. What a disgrace! - Not only will taxpayers foot the bill for the unfair termina- tion lawsuit, now we'll be pay- ing more for her slander of Tom Dick Judith Rausch Beverly Hills tsr M~i.-# !ZL-_ SALE EVER!! 40% - 64% OFF St�wide CITRUS COUN7-Y (FL) CITRONICIE OPINION .2A IVOINDAY, SEPWMB 0IlS~tAAAfJ Sound OFF Gap in new road I don't know if I should be calling county commissioners regarding this, but they just paved, I guess, U.S. 19 in front of Homosassa, in front of Publix in Homosassa. When you cross the highway, there's a very big lip where you're going up Halls River Road, and it's just tearing our tires apart. It's like a 5-inch gap that nobody has bothered to mend. You'd think any person driving across there would feel that and know to file a little bit more out to cushion the blow of the tires. I'm sur- prised it hasn't been fixed up 'til now. It's been at least eight or nine days and I was just won- dering if somebody could look into fixing that bump at Halls River Road and U.S. 19. Glorified pond Wow, another article in print about the glorified retention pond called Cooter Pond. Just . who is it who considers it to be the crown jewel of Inverness or the gateway to Inverness? Cer- tainly not the residents or the visitors to Inverness, that's for sure. Lake Tsala Apopka is what brings people here and keeps people here. That's a fact. But they ignore the big lake as if it doesn't exist. The sinkholes in Morrison Pool keep draining the lake water. Nothing is done, Why? Because of Cooter Pond, that's why. If they used the money they spent on boardwalks, landscap-. ing and weed removal in Cooter Pond on repairing the sinkholes in Morrison pond permanently, they'd have enough money left over to fill Morrison pond with bottled spring water. Wake up to reality. We all care about our lake system, not an irrelevant retention pond. Lines hanging I'm from Floral City,and I live on Great Oaks Drive. Our name has been put in several times FREE Ti -o." M to have cleanup on our road, OK? Two years ago, when we first had the first hurricane, my lines were hanging from my cable and from my telephone. I have called them 20 times. The line is still hanging and the cable is still hanging. What is wrong with this picture? We have to pay the taxes. We pay the taxes, but who does the work? And if they're not going to work, then get somebody else to do it for them. Eatery closed This is in response to the "What happened" Sound Off in (a recent) paper. Due to irrec- oncilable differences, Nicole's Fine Dining had to close its doors. I would like to thank my customers for their loyalty and was flattered by the inquiry. Maybe Nicole's will resurface in the future. Thanks again. Just as powerless You don't live in Sugarmill Woods, but you need power. Three weeks ago on two con- secutive Fridays, our power was out from 8 'til midnight. We had no storms or even the po- tential of one. Only approxi- mately 40 to 50 homes were blacked out. So your problem is what? Highest points I hate to dispute the editor who thought the highest eleva- tion iri the county was 90 .feet over in Pine Ridge. My own house here in Kensington Estates sits at 130 feet, and the topography map shows nearby elevations up to 155 feet. I've heard from several people over the years that the water tower over at Beverly Hills sits on the third highest elevation in the state. However, I couldn't Google the confirma- tion on that. Useful tools Our sheriff needs every one of his cars, motorcycles, air- IN OFFICE REPAIRS! VIDEO EAR INSPECTION! HEARING TEST! CONSULTATION! CLEANING & PERFORMANCE CHECK OF YOUR HEARING AIDS! Jason & Roger Throneburg Over 60 Years of Combined Experience 3 Generations of Hearing Aid Specialists .... .. -----..------------- TRY THEM BEFORE YOU BUY! Wear them for a week .T smlI I i -- It's like not having a hearing aid at all. Rexton Calibra Free Open Fit; hearing Aids Virtually Invisible & Very Comfortable. .fOnfr ExpSrep Sepl .'0 2007 Coupo.rn m r .n1l V' coTimorne, Lii w ni oiter 'otier m - -" a i 9 HVAIV &A N r.%-,rn&T,,FR A&SSONSIHEARING 352-628-909 i3i28c0A110 planes, helicopters, horses, bicycles and boats to keep us free from radical Islamic terror- ists and to find burglars who hide in Dumpsters. Hurricane experts Since I've lived in Florida, the so-called hurricane experts always forecast an active hurri- cane season and are always wrong. Their forecasts scare people who might consider liv- ing here and the people who already do, unnecessarily. People should be prepared and there is always plenty of time to get ready as the hurricane slowly makes its way from Africa to wherever. Since weath- ermen can't -predict the track of a known storm perfectly, how can they come up with a forecasted number and then when they are wrong, claim they were more accurate than "last year"? They may own stock in plywood or generator companies. Ha, ha. Mature drivers, it's our policy to save you money. What's the buzz? I'd like to know if someone could please find out whatever happened to mosquito control. There's no one coming around for several years in downtown Inverness, and the mosquitoes are just terrible. Do they have to wait for people to start getting sick before they do something? Also, Inverness is getting so dirty. It used to be the cleanest town around Central Florida. It was so beautiful and now you can't even go for a walk. There's broken beer bottles and shat- tered glass and garbage all over the place. It's terrible. How about getting some kind of a campaign going to clean up our beautiful city? Sponsor's products I watch the Devil Rays ball- games and they also say the next portion is brought to you by Ricoh. What and who is Ricoh? It never does explain it. When you insure your car with us, through Auto-0Owners Insurance Company, we'll save you money! Statistics show that mature drivers expe- rience ' fewer, less-costly accidents, allowing us to pass the savings on to you. Contact us today, and let us earn your loyalty through our quality service and products at "No Problem" prices! ,.auto-Owners Insurance Life Home Car ~ -~n , VanAllen INSURANCE AGENCY 352-637-5191 OR 1-800-988-5191 S *AUTO * HOME * BUSINESS * LIFE Cheri Harris said she uses a cast- iron skillet on her glass-top stove frequently with no problem. But don't drag or drop the skillet. It would be best to follow your stove manufacturer's recommendation. Bring back tribute No 9/11 tribute? Is this true? It has come to my attention (a funeral home) will not be host- ing a 9/11 tribute this year. The 9/11 tribute not only re- members those who lost their lives in the World Trade Center, Pentagon and those on the planes, but those rescuers who continue to die from lung dis- eases from our World Trade Center fallout, and our boys and girls fighting for our free- dom in the Middle East. Would the person or people in charge... please reconsider? Changes disliked I'm very disappointed that you've stopped carrying the "Everyday Cheapskate" and "Mr. Handyperson's" columns. Those were the two that I really looked forward to every week - particularly "Everyday Cheapskate." I'm really sorry you're not going to have that. I don't like the new ones you've got in, but thank you. Croft property Toward the end of Wooten's term in office, the county com- missioners released informa- tion about property being pur- chased on Croft for light indus- try. What happened to that deal? Is it another pipedream that went up in smoke? Grassy medians Don't waste your money on a GPS navigation system if you want to find Citrus County. Just drive north through Hernando County and when you see the grass about 2 feet tall in the median strip, you are in Citrus. TWELTH ANNUAL Chridstas Il $eptebr Saturday, September 22 9:00AM-4:00PM Crystal River Armory US 19 and Venable SStreet, Crystal River Over 85 exhibitors with hand crafted items, decorations, food available and gifts galore! $1 Donation appreciated Nature Coast Knights Car Club Presented . By the Pilot Niii_ _iE | Club of Crystal River For more information call BJ at 795-5223. Proceeds from this event will be used to benefit local charities throughout Citrus County. ~r"~o.kU. cam "Know Where It Flows" Scheduled Activities Friday, September 14, Doors open at 6:00 p.m. SAVE OUR WATERS WEEK FUNDRAISER SPONSORED BY CITRUS 20/20 INC. West Citrus Elk Lodge Dinner at 7pm followed by "Know Where It Flows" play created by Mac Harris and vocal & dance music provided by Debi-G. Cost $35 per person. For ticket purchase and more information call 527-0800 or 344-5955. Saturday, September 15, 8 a.m.-12 noon ADOPT-A-SHORE AND PROFESSIONAL ASSOCIATION OF DIVING INSTRUCTORS .CLEANUP Countywide. Call County Aquatic Services at 527-7620 for information. Saturday, September 15, post-cleanup APPRECIATION COOKOUTS FOR VOLUNTEERS East side - Lake Hernando Beach; sponsored by Apopka Marine. West side - American Pro Diving Center; sponsored by American Pro Diving Center. Saturday, September 15, 3 p.m. and 7 p.m.with important Florida water issues. Call 563-0540 for information. Free. Sunday, September 16, 1:30-6 p.m. NATURE COAST VOLKSSPORT GUIDE HIKES. 5/10KM HIKES. Starting point is Fort Cooper State Park. $1 per person/$2 carload. Call 628-4543 for information. Monday, September 17 KAYAKING WITH MATT CLEMONS County Boat Ramp at Pirates' Cove, Ozello. Call 795-5650 for times and registration, or visit hltp://floridakayakcompany.com/eregistration.himl. $10 per person. Tuesday, September 18, 9 a.m.-12 noon HOMOSASSA RIVER SPRINGS TOUR Start point: River Safaris; 10823 W. Yuee Dr. Homosassa Springs. Call 628-5222 for reservations. Capadly: 30 persons. Free. Wednesday, September 19, 6 p.m. "OUR WATERS IN JEOPARDY" Interactive game with local high schools competing on water issues using the Jeopardy game format. Jerome Multi-Purpose Room Central Room, Central Florida Community College, Citrus Campus, Lecanto. Pubic invited. Call 527-7648 for information. Thursday, September 20, 8 a.m.-1 2 noon CRYSTAL RIVER SPRINGS TOUR Start point Fort Island Trail Park. Call 795-4393 for reservations. Capacity: 40 persons per tour. Free. Thursday, September 20, 8:30 a.m. and 10 a.m. CRYSTAL RIVER ECO WATER TAXI TOUR Start point: 3rd St. Pier (267 NW 3rd St, Crystal River). Call 564-9197 for reservations. Capacity: 40 persons per tour. Free. Friday, September 21, 8 a.m. KAYAKING WITH KAYAKS & BEYOND Launch from Hunter Springs. Kayaks will be available to use for the dean up. Call 795-2255 for directions and registration. Free. Saturday, September 22, 9-11 a.m. and 12 noon-2 p.m. FORT COOPER STATE PARK AND FLORIDA PARK SERVICE - "MUCK ABOUT" in cooperation with Academy of Environmental Science students. Start point: Fort Cooper State Park, Inverness. Call 726-0315 for information. Public invited. Saturday, September 22, 4-9 p.m. SUNSET FESTIVAL Fort Island Trail Pier at Fort Island Trail Beach For more information call Parrot Heads of Citrus: Jimmy Brown, 795-9090 or 422-7910. Free. Would sure like to know. Editor's note: According to its Web site - A pioneer in digital office equipment, Ricoh offers a broad range of digital, networked products, including copiers, print- ers, fax machines, CD-R/RW and DVD+RW/+R drives and media. Ricoh also competes in the cam- era field, both conventional and digital. Glass-top stoves In Thursday, Sept. 6's paper, you have a delicious recipe for skillet cakes, and I know it makes a difference if you cook it in a cast-iron skillet because it does taste better and the sugar browns better. But peo- ple with glass-top stoves can't use an iron skillet, so that recipe is completely worthless to a lot of people. Editor's note: Features Editor FINALLY, A HEARING DEVICE FOR PEOPLE WHO HATE HEARING AIDS! I Onus CouNTY (FL) CHRoNicLE OPINION Is A x - -. . .... . 1I ?0 --7 .. e.-Y t (imus CouNm' (FL) CHRONIcLE MONDAY, StIr'jr~MBI R 10, 2007 13A to try new"DIGITAL"Technology in Hearing Aids Are you, or someone you know struggling with hearing loss? We need 42 people with difficulty hearing, especially in noisy situations, to evaluate the latest in digital digital miniature hearing aids in assistive hearing technology for 30 days. . Candidates selected will receive tremendous savings, due to their participation. If your evaluation shows hearing improvement with the new instruments, you may chose to retain them and receive $2,000 W OFF the regular price. Participants who choose to keep the hearing Instruments will also receive FREE batteries for life of the instruments. Hearing Tests to determine candidacy will be held from September 5th through September 30th. Please call immediately. Spaces are limited. PS: Participants who complete the 30 day Hearing Aid Evaluation will Receive a 50.00 VISA Gift Card as our Thank You for your time and I effort. I Those interested must call today. . ' I . .' AUDIBEL Sor e Crystal River Mall I \ 1801 NWUS 19 N Near JC Penny 352-564-8884 w: l ' �."ik MONDAY, S E, PTEM BER 10, 200713A RTIC US COUNTY (FL E I :14A SEPTMBER 4 A. v SEPTEMBER 10, 2007 - , . , t / . ',,, . i-.. -.._ �./..- . ... . -- ^ / -J__ ^ ^ _ .- __ _ 1 _ -- * ^... = . __ -3 ,.__ .. :"- "True success is S overcoming theafee of being unsuccessful. Osaui Sweemuey ICITRU'.. COLUNT-1 CHRI)NICLEI C TRUS COUNTY CHRONICLE EDITORIAL, BOARD Gerry M ulligan;................................publisher Charlie Brennan ... . ........ ....... editor Neale Brennan ...... promotions/community affairs Kathie Stewart ....................circulation director . Mike Arnold ........................ managing editor Founded in 1891 Curt Ebitz . ............ . . .... citizen member by Albert M. , :C Williamson ;: Mac Harris... . citizen member S --.~ .,'eoti mdy differ udth my choice, bitt )it my eight to choose. " -~ . ..~-'- HAT M..TTERS United Way plays a leadership role T throughout Florida, Citrus County is kaiwv..as. a place where people vol uin-' teer and contribute to help those in need. SThe,.most efficient and effec- tive way to make a charitable contribution in Citrus County is through the local United Way organization. Linited W\ay THE II kicked off its annu- al fundraising effort The Uni last week with the campaign intention of raising COL money for 21 non- profit social service OUR 01 agencies that serve Help our community, a diffe Sam Himmel, the county school YOUR OPIA superintendent and ihrr.oni,,.:.:r, chairwoman of this .:,r,,ent year's campaign, <-rr'n:e .made it clear that .the only way suc- cess will be v ol donat achieved will be if United , thousands of area 527 889- residents volunteer the WebS �and contribute. The citrusuni theory behind or pa, tici United Way is that your emn-p the nonprofit agen- pay.rill di cies shouldn't etiort spend all of their time trying to raise money. The agencies need to provide servic- es to people in need. If they �pend all their volunteer time put searching for money, it's the people in need who end up suf- fering. ' United Way manages to have access to the tens of thousands of employees at most of the caring, companies in our community and asks employees to use pay-" roll deductions to help support those in need. Those efforts raised more 'than $600',000 in contributions last year. 'While many businesses make direct contributions of their Sown, it's the employees who make the big difference. It's that Highest elevation The person who asked: The high- :est elevation in Citrus County is 28 degrees North, 40 minutes, 32 sec- onds, 82 degrees, 21 minutes and ,04 seconds West. It will be 200 feet above sea level. That's down (County Road) 581 South. ' Help Boys & Girls I'm looking in reference o to the "Citrus County needs a 'Y'," that a survey wasdone in'the county 1hat'we'neded a YMCA. I spbke to about, 15 to 25 people and they said they heard something about a YMCA about a year ago, CALL but there was no survey done. And if it was, it was 563 done by a special interest group. I'd like to know who Mc is profiting from this ... M SThis is ridiculous, a $10 million facility. We don't PAl need a YMCA. Give the money to the Boys & Girls Clubs. Taxes doubled I'd like to comment on "Upward mobility," that was in the paper on Wednesday, Sept. 2. Whoever called hit the nail night on the head. I live in Hernando and I'd like to see any of the commissioners or bag boy at Publix or the cus- tomer service representative at, Progress Energy, the lunchroom worker at Citrus High School and. the .bank employee in, Beverly Hills who makesthe dif-, ference. With thousands of peo- ple giving a siiall amount each week through payroll deduc- tions, huge prob- SSUE: lems in our commu- nity get resolved. ted Way During the past i in Citrus year, our United rity. Way has taken an even larger role in PINION: attempting to iden- make tify and deal with rence. the major social service issues in lION: G.. to our community. ,,e com t, Working with the ,',ut t:a3 ' Homosassa Civic e, torai. Association and nonprofits that feed the hungry,. United e or Way is involved in call the i d ay offr:e at trying to build a 4. log onto 5.000-square-foot site at wvw facility where food tedway.org can be collected pate in and stored for ouir lo/yer's. local residents. eductiorn A community pharmacy is being developed to help the thousands of area seniors and working families that can't afford the cost of medications. Working with county govern- ment, United Way took the lead role in creating the 211 informa- tion effort where information and advice is a just a telephone ,call away for area residents. United Way is involved in rais- ing money and solving problems When volunteers come around' this year and ask for your contri- bution, we each need to open up and give what we can. By every- one working together, the quality of life in Citrus County can be improved. Get involved this year and help make a difference. the property appraiser trying to sell this house for $97,000 with my mobile home and an acre and a quarter lot. It's absolutely ridicu- lous. They're going to get their money one way or another. Talk about taxes going down - mine have doubled. Absolutely ridiculous. -0579 >re und Off. GE 12A Who's the victim? I would like to know why people who call animal control are made the vic- tims. I have a pit bull run- ning loose in my neighbor- hood. He's harassing my cats that are in a fenced-in yard. They will not take a com- plaint unless you give them your name, address, phone number, etc., which is then made available to the public, and then who- ever you made the com- plaint on can harass you. Who's the victim here? Save water I think it's about time to close these golf courses around here and some of these car washes. They take an awful lot of water. It's time to save our water. Let's close some of them. Sept. 11: Six years later ... S ept. 11 falls on a Tuesday this year. It will be the first time since that other Sept. 11, six years ago. Do you remember? Can you recall how difficult it was to even conceive of going forward from that moment? The events of that day had, so thoroughly lac- erated us that it seemed as Leonar if, in some small corner-of . OT"r our collective soul, the V-1i clock had stopped. In that corner, it would forever be 8:46 EDT on the morning of September 11, 2001. Do you remember? If so, then the world as it stands six years later must come as something of a shock. Six years ago, we saw people rush- ing to the World Trade Center site to search for survivors and recover bod- ies. Heroes, we said. Six years later, largely removed from public attention, many of those same heroes are sick and even dying, poisoned by the soot and dirt they breathed. Six years ago, appalled and infuriat- ed, the world rallied to our side. Candles and cards were left at our eembass-ies The French newspaper Le'. Monde declared "We Are All Americans Now." The Masai, a tribe in rural Kenya, sent us 14 cows, a gift regarded by their culture as sacred. Six years later, angry demonstrators trail our president wherever he trav- els; and it is headline news when he is actually cheered in Albania. Thanks for help I would like top take this opportuni- ty to thank the following organizations and businesses for their participation in the recent Predator Awareness Expo that was held June 16. If not for their help, the day would not have been possible: Antonelli Martial Arts, CASA, Citrus County School Board, Citrus County Sheriff's Office, Dignity Memorial Escape School, FDLE, Global Radio, Girl Scouts Heart of Florida, Head Start, Isaiah's Place, Jessie's Place, KIDS Foundation, National Center for Missing and Exploited Children, rad KIDS, Chuck Everidge State Farm, and Mr. Winn Webb. Also Terri's Taxi, Buddy's Home Furnishings, Donut Town, WOW 104.3, Bay News 9, American Speedy Printing, All About Promotions, Extreme Fun, Publix and the IR-RU Social Club of Floral City. Special thanks to Mr. Mark Lunsford and the Jessica Marie Lunsford Foundation: I appreciate everyone's assistance in making this day a rewarding expe- rience, as well as a resource for all that attended. Kelley Burns Girl Scout Troop 576 Thanks for wallet I was shopping in Sears at the Crystal River Mall Aug. 9. I acciden- tally left my pink wallet with a mon- key on it in the shopping cart. When I went back to the store to see if anyone had turned it in, I was told no. Then my mom said to wait awhile to see if someone will turn it in. I am only 11 years old, and I did a lot of chores to earn this money, but I was more worried about my picture of my grandpa who is now in heaven. It's Six years ago, we vowed Worst of all, it squandered the revenge on Osama bin moment, threw away a historic chance Laden, the. wealthy Saudi to build a national - and internation- who masterminded the al - consensus that could have mar- a attacks. We would bring ginalized the architects of terror, S._ him in, said the president, maybe even reshaped the world, more , "dead or alive." Six ,years effectively thantall the bombs.and bul- later, binLaden is still free, lets used to date in Iraq. and the president has said This anniversary, then, laments not he is not particularly con- simply the loss of life, but of opportu- cerned about that. nity. And perhaps the worst thing is, d Pitts Do you remember? one senses most Americans are like VER The terrorist attacks of their president: We dp"t th .iabput r" .; six years ago this week are bin Laden that much ffiese days.-Ie is sometimes compared to the not front-of-mind anymore. Japanese attack on Pearl So it is worth pausing here to Harbor 66 years ago this Dec. 7. That remember that just six years ago, we is, of course, a reference to the shock, were attacked.: disbelief and anger Americans of both Six years ago, people leaped from eras felt. flaming skyscrapers.. But there is a telling difference ,Six %ears ago, flaming skyscrapers between 12/7 and 9/11. From the 1941 fell. attack, there was forged a sense of nationall mission and purpose. Those Six years ago, dust-caked people feelings of shock, disbelief and anger'wanlered the streets of New York City. became the building blocks of a con- Six years ago, an airplane tore a sensus that we would do whatever, hole in the Pentagon. spend whatever, sacrifice whatever, Six years ago, a hijacked plane until victory was won. After the attacks crashed. of 2001, by contrast, we talked national Six years ago, searing, airless shock mission and purpose, but it soon was followed by resolve. Clear, cold, became apparent that it was only talk. iron-fisted resolve. , Those feelings ,of shock,. disbelief Six years later, the shock is gone and and anger became instead the building it seems like the resolve is, too. blocks of a political machine that Do we remember? You couldn't duped the nation into a war of choice prove it by me. that had nothing to do with the terror- ist attacks, eroded American civil lib- erties under the guise of protecting Write to Leonard Pitts Jr. at 1 Herald American lives and branded as traitors Plaza, Miami, FL 33132 or via e-mail those who said, 'Hey, wait a minute.' at lpitts@herald.com. � to the OPINIONS SMn3?ias .EV� " The opinions expressed in Crr.in,:- d' trials are the opinions of tri :tl; rial. board of the newspaper. * Viewpoints depicted in political car- toons; columns or letter; d,. not rnecep,. sarily represent trie .:.prnni:,r, t the edit. the only one I have of him. My mom and I went back to Sears 20 minutes later and asked the lady behind the jewelry counter if anyone turned in a lost wallet She asked me to describe it, and much to my sur- prise someone had turned it in, and it even had my money in it I am writing this letter to say thank you 100 times over to the honest per- son who turned my wallet in. Since I do not know who you are, I am send- ing you the biggest hug ever and say- ing thank you from the bottom of my heart It is so nice to truly believe that there are still some really great peo- ple left in this world. It is people like you who can teach children like me to make this world a better place. Thank you again and God Bless You! Mackenzie Abrams Beverly Hills Editor Waiting for bonus I am a little upset right now, I just got off the phone with Direct TVe I called them in reference to their ad the'\e )been advertising to get new customers. Some time ago, I thought their adver- * More tising sounded like a letters good deal, so I called PAGE 11A them and switched to Direct TV Part of their promise was I was to receive a new portable DVD player. I filled out all the necessary paperwork and sent it in. I was promised I would receive the portable DVD player in six to eight weeks. Well, it's been over eight weeks and I have received noth- ing. Today I called them to inquire about the whereabouts of the DVD player they promised in six to eight weeks. The first person I spoke.With I couldn't understand; I asked to speak with a supervisor. After a half hour, a supervisor gets on the phone. I go through everything with her, again. She tells me that it may be another six weeks before 'I 1 receive the DVD player. I told her I should have had'it by.now and Direct TV is not living up to its promise. I asked what would happen if I can- celled their services because I'm not receiving what I was promised. She told me I would be charged for early disconnection even though I'm not getting what I was promised. Wow, a big business makes promis- es to get your business and when they don't deliver what they promise, you say I don't want to deal with your company, they say we're charging you if you cancel your account Jake Little Homosass. ? is I n it. te 1a I .3 'I 1111 L~HIc~~'WHEELS, 2~~~1-18- ~ab d trl>.. -..~ K BATLE ~0 A CU '~IrnJL9 I)II .1EIE MSRP $62,160 VWXI Al .. .W I IJtYIL 1 1?iA ~t1Ii A - 4 2002 OLDSMOBILE IN TRIGUE IINRII I: L[ AiI IR AillP .I. W 1 lil , I. MILI: TOWh 1996 Toyota Corolla, 55K miles .............................3,yA 1998 Cadillac Deville....................................7,999 r'uaLN CAR 2003 Mercury Grand Marquis..................9,900 2004 Subaru Forester SX, 23K miles ........... 16,90 ZIUUU HEI LI415- 2003 Cadillac Deville DHS, 2007 Pontiac Torrent, 600 Mile ..D .- 2003 BMW Y 5- 1 t 3; 4 i 2007 CADILLAC White Diamond,...... 16,900 2007 Buick Lucerne CXL.......................24,9 , ..................... 20, 2007 GMC Yukon ..................................$27,900 2431 SUNCOAST BLVD, US HWY 19 VI LLAGE *HOMOSASSA, FL 34448 352-628-5100 ('rc'^vWtW~wa wMOY"3I VILLJaE' 'IOnOmaig I Sroqs 'I . LIBERTY. AND THE PURSUIT", TAGl[ I*:I, L TI'IL .E Ja'"A $ ... . E FR so P E OL o. P "39 MO ONE PAY LEASE 10K YR. PLUS TAX TAG AND DEALER FEE. '$2616 DOWN PLUS TAX, TAG AND DEALER FEES 1OK MILES A YEAR FOR 39 MONTHS. SALE PRICES & DISCOUNTS INCLUDE ALL INCENTIVES PLUS TAX, TAG, TITLE & $399 DEALER FEE (PRE-OWNED EXCLUDED). PICTURES FOR ILLUSTRATION PURPOSES ONLY. EXPIRES 9/15/07 CITRUS COUNTY (FL) CHRONICLE MONDAY, SEPTEMBIE 10, 2007 15A / It --- '- * IMF ;-4w.11HI - 7-i �,-. 16A _A- M ONDAY" SEPTEMBER 10, 2007 n CITRUS COUNTY CHRONICLE Nation BRIEFS Rally -, .104% Associated Press Owner Carol Albert speaks to some of her staff Sunday at Astroland in Coney Island, New York. A rally was held to keep Astroland open on what was potentially Astroland's last day. With the property already sold to Thor Equities, Albert is in negotiations with tjdeveloper to keep the 4ai-Open one more season. Texas poli offerss shot, Killed :' '^ SA, ,Texas 7yo ",::.' pollc6ffiW94t*ondihg to -a domestic disturbance were killed and a third was critically wound- ed by a gunman who led Texas authorities on an hours-long standoff, authorities said. The suspected gunman in the shooting Saturday night, 58- year-old Larry White, will likely face two counts of capital mur- der and attempted murder of an officer, a spokeswoman said. White was shot in the ab- domen and was in stable condi- tion at a hospital under police guard. Crews continue search for Fossett RENO, Nev. - Rescue crews s~~hiifhig for fried rmillidnaire adventurer Steve Fossett stum- bled upon another false lead Sunday when they discovered what they thought was a downed airplane - but didn't find the missing aviator. 'The false alarm further damp- ened spirits of the rescuers, whose chances of finding the. 63-year-old Fossett alive in the rugged, concealing landscape of western Nevada are becoming more and more slim. World BRIEFS Guerilla Associated Press This video grab made from an undated video distributed Friday by the Colombian Army allegedly shows Tanja Nij- meijer, 29, of the Nether- lands, an alleged member of the Revolutionary Armed Forces of Colombia, FARC. Army officials say they obtained the video in a laptop they found abandoned during anjarmy raid on a rebel camp. PrevaeNg rape e hi I " go N ROBI 3Ken - Th' ' preva ence and intensity of sex- ual.violence against wamen in eastern Congoare "almost unimaginable," the top U.N. humanitarian official said this weekend after visiting the coun- try's most fragile region, where militia groups have preyed on the civilian population for years. John -Iolmes, who coordi- nates-Jn. emergency relief operations, said Saturday 4,500 cases of sexual violence have been reported in just one east- ern province since January, though the actual number is surely much higher. Rape has become "almost a cultural phe- nomenon," he said. - From wire reports Iraq defends security efforts Government says it still needs help Associated Press BAGHDAD - The Iraqi government defended its efforts to stabilize the country on the eve of a key U.S. progress report but said Sunday it needs more help and was not ready for a timetable on the withdrawal of American forces. Iraq also issued a new appeal to neighboring countries to step up assis- tance at a conference that drew dele- gates from across the Middle East and representatives of the U.S., the U.N. and the Group of Eight industrialized Gabrielle washes ashore in North Carolina Associated Press HATTERAS, N.C. - Tropical Storm Gabrielle washed ashore and crawled slowly along the North Carolina's Outer Banks Sunday, but caused few problems and failed even to chase vacationers away from the beach. Warnings of gusty wind and rain did- n that there had been no requests for assistance, and that Gabrielle likely would be remembered mostly as an inconvenience. "We'll be glad to help out if anybody needs it, but right now, we're not hear- ing anything. It's been kind of quiet," said Julia Jarema, a spokeswoman for the state Department of Crime Control and Public Safety. Gabrielle brought gusty winds that howled at 50 mph, churning up the Atlantic surf to the delight of surfers and kiteboarders. Despite that, the storm failed to dump much rain inland, where much of North Carolina is experiencing severe drought "We're glad we didn't have any flood- ing or wind damage, but the rain would have been nice," Jarema said. "The coast got some rain, but they were the ones with the least problems from the drought." At 5 p.m., the center ofthe storm was about 30 miles southwest of Kill Devil Hills, headed north near 12 mph. Its maximum sustained winds were close to 50 mph, with stronger gusts, and it was expected to weaken slightly in the next 12 hours. Forecasters expected it to pass over the Outer Banks near Nags Head on Sunday night on its way back out to sea. Forecasters kept a tropical storm agree- ments kidnapping, report- ed that an American soldier was killed Sunday in fighting in western Baghdad.' A Marine died Friday in Iraq's Anbar, province in a non-combat related inci-! dent, the command said. At least 35 Iraqis also were reported killed or found dead on Sunday, includ- ing 12 bullet-riddled bodies that were handcuffed Aind blindfolded and showed signs of torture. The deadliest attack was a raid by gunmen against a police station that killed at least nine people in the pre- dominantly Sunni village of Hajaj, some 155 miles north of Baghdad. Associated Press Waves crash against the Oceanna Pier at Atlantic Beach on Sunday as Tropical Storm Gabrielle makes landfall in Atlantic Beach, N.C. Gabrielle made landfall on North Carolina's Outer Banks, packing 50 mph winds and rain, but it wasn't enough of a threat to scare vacationers from the shore and surfers from the beach. This NOAA satellite image taken Sunday shows Tropical Storm Gabrielle off the Carolina Coast. warning in effect from SurfCity north dh I V1 Vl-ght V A\vatWh Was in effect for the area extending to New\ Point Comfort peninsula. along the Chesapeake Bay. Officials preached caution through- out ciiirents threatening swimmers who ventured into the ocean. "We had heavy surf, but you could tell from looking at it the currents were strong." said Dare County spokes% oman Dorothy Toolan. "People took the advice and stayed out of it today." Officials in Dare, Hyde and Currituck counties, which cover most of the Outer Banks, said Sunday they had no reports of any water rescues tied to Gabrielle. While some spots did get some decent rain - nearly 5 inches in Harlow in rural Carteret County, and about an inch in nearbyNew Bern and Beaufort - the storm was mostly a tease.... J Dave Rakes kite surfs Sunday as waves and wind from Tropical Storm Gabrielle reach Hatteras Island near Frisco, N.C. Reconstituted al-Qaida proves an elusive foe The Washington Postaida's core leadership - dubbed al-Qaida Central by intelligence analysts - has grown stronger, rebuilding the organi- zational framework that was badly damaged after the U.S.-led invasion of Afghanistan, according to counterter- rorism fam- ily to the CIA. Dodging the U.S. military in Afghanistan after the Sept 11, 2001, attacks, al-Qaida Central reconstituted itself across the Pakistani border, returning to the rugged tribal areas sur- rounding the organization's birthplace, the dusty frontier city of Peshawar. In the first few years, Pakistani and U.S. authorities captured many senior leaders; in the past 18 months, no major figure has been killed or caught in Pakistan. Osa bin La appeal video F after abse Al-Qaida Central moved quickly to overcome extensive leadership losses by promotirig loyalists who had served alongside bin Laden for years. It restarted fundraising, recruiting and training. And it expanded its media arm into perhaps the most effective propaganda machine ever assembled by a terrorist or insurgent network. Today, al-Qaida operates much the way it did before 2001. The network is governed by a shura, or leader- ship council, that meets regular- ly and reports to bin Laden, who continues to approve some major decisions, according to a senior U.S. intelligence official. About 200 people belong to the core group and many receive regular salaries, anoth- ma er senior U.S. intelligence offi- aden cial said. Friday in "They do appear to meet with long a frequency that enables them nce.. Many U.S., Pakistani and European: intelligence officials now agree that al-: Qaida's ability to launch operations around the globe did not diminish after the invasion of Afghanistan as much asi previously thought Further investigation has shown, for example, that al-Qaidaaida brain trust for orchestrat- ing dozens of other failed plots, includ- ing a plan to blow up transatlantic flights from Britain in August 2006. N - *4 8 NFL/2B, 3B * NASCAR/3B M TV Schedule/3B * MLB/4B B MVIONDAY SEPTEMBER 10, 2007 Tiger An American quartet roars at BMW Woods now in control ofFedEx Cup Playoff Associated Press LEMONT, Ill. - Playing next to Tiger Woods for two days was daunt- ing enough. It was when Steve Stricker watched him from 200 yards away on an elevated tee that he real- ized how tough it would be to beat him Sunday in the BMW Championship. He arrived on the par-3 12th tee in time to see Woods, in his customary black pants and red shirt, rap a putt that trav- eled from one side of the green to the other until the ball disap- peared after a 50-foot journey and gave Woods an unlikely Woods birdie, won BMW "It looked like he Championship.y over Aaron Baddele. Along tile way. Wood n shat- tered the tournament scoring record, collected his 60th career victory on the PGA Tour and inmoed atop the ;.andings in the FedEn Cup with one week remaining. "If you wanted to win this tourna- ment, you had to make putts," Woods said. '"And I just happened to make them today." The 63 matched Woods' lowest final round to win, and he finished at 22- Please see /Page 4B Associated Press Roger Federer celebrates after winning the US Open men's finals against Novak Djokovic in New York on Sunday. The title was Federer's fourth US Open in a row. Federer wins fourth straight US Open title and 12th career major Sunday in New York Associated Press . overall. Federer is the first man since Bill NEW YORK - Roger Federer sure Tilden in the 1920s to win the gave Novak Djokovic chances, all American Grand Slam four years run- sorts of chances, to pull..off a major ning, and4 he moved within two of Pete surprise in the "U.S. Open final Sampras' career record of 14 major Sunday. titles. Federer knows how to win these "Once again, he showed he's the things, while Djokovic is still learning, best," the No. 3-seeded Djokovic said. and that might have made the differ- "He deserved to win. He was the bet- ence. Hardly at the top of his game, ter player." Federer came through, beating The 20-year-old Djokovic was in his Djokovic 7-6 (4), 7-6 (2), 6-4 for his first Slam final, yet he led 6-5 in each fourth consecutive U.S. Open champi- of the opening two sets. In the first, he onship and 12th Grand Slam title held five set points. In the second, he held two. Federer erased all of those, show- ing the craft and cool that tran- spire. Shortly before walking out for Sunday's match, he said knowingly, "It'll be interesting to see how he han- dles the final." Surewas. Afterward, Federer was generous, though, noting that the scoreline did- n't necessarily reflect how close things were, saying, "Straight sets is brutal for Novak, to be honest" In the end, about the only category Djokovic won on this day was "Most Intriguing Guests," with 2006 Open champion Maria Sharapova and actor Please see OPEN/Page 3B Bucs suffer injuries, loss to Seattle Associated Press out," Julian Peterson said to team- mates on the bench. One of those SSEATTLE - First, they put the knock outs came from Peterson hit- S 3" Cadillac up on blocks. Then they ting Garcia low as Leroy Hill hit him l ' . w knocked out the driver of Tampa across the shoulders. Bulls knock off Auburn in OT but can't crack Top 25 Associated Press AUBURN, Ala. - It was just another South Florida upset special and one more September stumble for Auburn. Taking advantage of numerous blun- ders by the Tigers and overcoming a few of their own, the Bulls made a grab for more national respect with Saturday night's 26-23 overtime win. But coach Jim Leavitt was more con- cerned with another benefit besides the ranking and the latest entry into the Bulls' growing reputation for knocking off more well-known pro- grams. "It's going to give us confidence," said Leavitt, whose team had been 0-4 against the Southeastern Conference. "We've got the toughest schedule we've ever had this season. We've got North Carolina coming to our place and' they're going to be an outstanding team. We'll have to play just as well against them." And Auburn will have to play con- siderably better to avoid a disappoint- ing season. The Tigers committed five turnovers and managed just 290 yards - a measly two in their overtime pos- session, which ended with Wes Byrum's third field goal arid sixth in two games. The freshman has been the biggest weapon for an offense that has managed just three touchdowns in two games. The Tigers fell out of the Associated Press Top 25 poll from a No. 17 ranking. South Florida hosts North Carolina and No. 4 West Virginia in the next two weeks. The Tigers host Mississippi State and New Mexico State. Bay's offense. Shaun Alexander ran for E For 105 yards and a touch- Tamrn down, but the remade, box hard-hitting Seahawks and defense set the tone in NFL Seattle's 20-6 win over the Tampa Bay Buccaneers on Sunday. A big hit on lead runner Carnell "Cadillac" Williams, and a little later another hit on quarter- back Jeff Garcia, sent them to the sideline and stopped the Buccaneers' offense in its tracks in the third quarter. "Man, we're knocking people The AP Top 25 The Top 25 teams in The Associated Press col- lege football poll, with first-place votes in paren- theses, records through Sept. 8, total points based on 25 points for a first-place vote through one point for a 25th-place vote, and previous ranking: 1 Southern Cal (401 2 LSLWi251 3 O.kl3noma 4 West Virginia ,5 Florida 6 Texas 7 Wiconsn 8 California 9. Louisville 10. Ohio St. 11. UCLA 12. Penn St. 13. Rutgers 14. Nebraska 15. Georgia Tech 16. Arkansas 17. South Carolina 18. Virginia Tech 19. Oregon 20. Clemson 21. Boston College 22. Tennessee 23. Georgia 24. Hawaii 25. Texas A&M Record 1-0 2.0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 1-0 2-0 1-1 2-0 2-0 2-0 1-1 1-1 2-0 PIs 1,594 1.582 1,418 1 408 1,370 1,290 1,171 1,126 1,097 962 910 896 820 693 590 537 477 382 367 349 323 284 261 247 2-0 243 23 the npa Bay score other action PAGES 2B,3B The score was 10-6 mid- way through the third quarter when Garcia scrambled for three yards and a first down. Somewhat dazed, the quar- terback stayed on one knee before trainers helped him off the field and eventually to the locker room to clear his head. By the time Garcia returned mid- way through the fourth quarter after two dead-end drives with Luke McCown taking the snaps, Seattle Please see BUCS/Page 3B USA Tday Top 25 Poll The Top 25 teams in the USA Today college football coaches poll, with first-place votes in parentheses, records through Sept. 8, total points based on 25 points for a first-place vote through one point for a 25th-place vote, and pre- vious ranking: '' I Souihernr Cal 142) 2 LSU lii 3 Foida, 17I 4 West virginia 5. Oklahoma 6. Texas 7. Wisconsin 8. California 9. Louisville 10. Ohio State 11. UCLA 12. Penn State 13. Rutgers 14. Nebraska 15. Georgia Tech 16. Arkansas 17. Virginia Tech 18. Texas A&M 19. Boston College 20. Clemson 21. Oregon 22. Hawaii 23. South Carolina 24. Tennessee 25. Georgia Record 1-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 2-0 1-0 1-1 2-0 2-0 2-0 2-0 2-0 2-0 1-1 Pts 1,476 1,437 1,353 1,269 1,264 1,156 1,141 1,038 1,020 972 837 804 699 677 582 493 371 325 315 311 309 308 294 237 1-1 199 12 Frankly, it's Franchitti for the win Scotsman tops off crazy season with first IRL title Associated Press JOLIET, Ill. - Dario Franchitti topped off "a crazy season" with an unlikely victory Sunday at Chicagoland Speedway, winning his first IndyCar Series title in what might be his farewell to open-wheel racing. The difference for the Scot in the PEAK Antifreeze Indy 300 was his ability to squeeze out half W For a follow-up a lap more than on Saturday's Scott Dixon on NASCAR action their final load PAGE 3B of fuel, with the New Zealander running out of ethanol while leading two turns from the end of the 200-lap race. Franchitti, who nearly saw the chance of winning his first open- wheel title slip away with crashes in each of the four races leading up to the season finale, could hardly believe his good fortune after strug- gling with traffic and an ill-handling car most of the day "It's been a crazy season," said Franchitti, who also won his first Indianapolis 500 in May. "There were times when we thought we were look- ing really good and times when things just wouldn't go right. But we got some of our mojo back from the middle of the season, so I couldn't be happier." The 34-year-old Franchitti is expected to leave the IndyCar Series Please see IRL/Page 3B Associated Press Tampa Bay tight end Jerramy Stevens (86) is defended by Seattle's Jordan Babineaux (27) during the Bucs' 20-6 loss to the Seahawks on Sunday. USF savors huge victory orts _ I T C-- ACI OUNTY.(F.)... .. . .. . 2B MONDAY, SEPTEMBER 10, 2007 . Seahawks 20, Bucs 6 Tampa Bay 6 0 0 0 - 6 Seattle 0 10 0 10 - 20 First Quarter TB-FG Bryant 38, 8:56. TB-FG Bryant 32, :00 SSecond Quarter Sea-FG J.Brown 28, 2:39. Sea-Alexander 1 run (J.Brown kick), :50. Fourth Quarter Sea-FG J.Brown 46, 14:09. Sea-Morris 34 pass from Hasselbeck (J.Brown kick), 7:55. A-68,044. TB Sea First downs 13 17 Total Net Yards 284 343 Rushes-yards 23-90 34-139 Passing 194 204 Punt Returns 5-40 5-63 Kickoff Returns 4-90 3-38 Interceptions Ret. 0-0 0-0 Comp-Att-int 20-31-0 17-24-0 Sacked-Yards Lost 5-16 2-18 Punts 6-48.8 6-43.0 Fumbles-Lost 3-2 2-1 Penalties-Yards 5-37 3-35 Time of Possession 29:35 30:25 INDIVIDUAL STATISTICS RUSHING-Tampa Bay, C.Williams 12- 60, Graham 4-11, McCown 1-9, Pittman 3- 6, Garcia 1-3, Galloway 1-1, Clayton 1-0. Seattle, Alexander 27-105, Morris 3-15, Strong 1-9, Hasselbeck 2-7, Burleson 1-3. ' PASSING-Tampa Bay, Garcia 19-27-0- 201, McCown 1-4-0-9. Seattle, Hasselbeck 17-24-0-222. 7 RECEIVING-Tampa Bay, Galloway 5- 72, Pittman 5-32, Hilliard 4-49, A.Smith 2- 23, C.Williams 2-14, Clayton 1-11, Graham 1-9. Seattle, Pollard 5-43, Engram 3-64, Strong 3-21, Burleson 2-41, Alexander 2- 12, Morris 1-34, Hackett 1-7. Vikings 24, Falcons 3 Atlanta 0 0 0 3 - 3 Minnesota 7 0 3 14- 24 First Quarter Min-K.Williams 54 interception return (Longwell kick), 7:43. " Third Quarter Min-FG Longwell 49, 1:46. Fourth Quarter AtI-FG Prater 45, 9:23. Min-Peterson 60 pass from Jackson (Longwell kick), 7:19. ' Min-Winfield 14 interception return (Longwell kick), 2:37. - A--62,815. Atl Min first downs 17 15 Total Net Yards 265 302 Rushes-yards 28-96 27-139 passing 169 163 Punt Returns 2-1 3-20 Kickoff Returns 5-98 1-22 Interceptions Ret. 1-19 2-68 Comp-Att-Int 23-32-2 13-23-1 Sacked-Yards Lost 6-30 0-0 Punts 5-46.8 5-38.0 Fumbles-Lost 1-0 1-0 Penalties-Yards 6-40 4-35 Time of Possession 33:01 26:59 INDIVIDUAL STATISTICS � RUSHING-Atlanta, Dunn 22-55, Norwood 5-33, Harrington 1-8. Minnesota, Peterson 19-1031 Taylor 3-18, Jackson 2- 10, Tahi 2-5, Williamson 1-3. PASSING-Atlanta, Harrington 23-32-2- 199. Minnesota, Jackson 13-23-1-163. RECEIVING-Atlanta, Crumpler 4-40, White 4-29, Dunn 4-26, Robinson 3-32, Norwood 2-24, Blakley 2-18, Jenkins 2-13, Horn 1-14, Mughelli 1-3. Minnesota, Williamson 2-19, Shiancoe 2-18, Rice 2-10, Richardson 2-10, Peterson 1-60, Wade 1- 28, Allison 1-11, Kleinsasser 1-4, Taylor 1-3. MISSED FIELD GOAL-Atlanta, Prater 44 (WR). Broncos 15, Bills 14 Denver 3 3 6- 3 - 15 Buffalo 7 0 7 0 - 14 First Quarter .-Buf--Parrish 74 punt return (Lindell kick), 6:17. Den-FG Elam 21, :33. Second Quarter Den-FG Elam 48, 7:51. Third Quarter Buf-Lynch 23 run (Lindell kick), 6:24. Den-Marshall 5 pass from Cutler (run failed), :54. Fourth Quarter Den-FG Elam 42, :00. A-71,132. Den Buf First downs 23 13 Total Net Yards 470 184 Rushes-yards 32-171 26- 112 Passing 299 72 Punt Returns 4-10 2-88 Kickoff Returns 3-724-112 Interceptions Ret. 1-27 1-36 Comp-Att-Int 23-39-1 14- 21-1 Sacked-Yards Lost 1-5 2-25 Punts 3-41.0 6- 43.7 Fumbles-Lost 1-0 1-0 Penalties-Yards 3-31 5-40 Time of Possession 33:12 26:48 INDIVIDUAL STATISTICS RUSHING-Denver, Henry 23-139, Cutler 4-18, Sapp 3-7, Young 2-7. Buffalo, Lynch 19-90, Losman 2-13, Reed 1-12, Thomas 3-(minus 1), Parrish 1-(minus 2). PASSING-Denver, Cutler 23-39-1-304. Buffalo, Losman 14-21-1-97. RECEIVING-Denver, Walker 9-119, Marshall 5-52, Stokley 3-65, Henry 3-44, Graham 3-24. Buffalo, Reed 4-37, Parrish 2-25, Lynch 2-9, Evans 2-5, Royal 1-12, Thomas 1-8, Everett 1-3, Price 1-(minus 2). MISSED FIELD GOALS-Denver, Elam 50 (WL), 43 (WR). Buffalo, Lindell 45 (WL). Steelers 34, Browns 7 Pittsburgh 17 0 14 3 - 34 Cleveland 0 0 7 0 - 7 First Quarter Pit-Ward 5 pass from Roethlisberger (Reed kick), 11:55. Pit-FG Reed 26, 8:56. Pit-Holmes 40 pass from Roethlisberger (Reed kick), 1:05. Third Quarter Pit-Spaeth, 5 pass from Roethlisberger (Reed kick), 10:38. Cle-Vickers, 1 pass from Anderson (Dawson kick), 6:56. Pit-Miller, 22 pass from Roethlisberger (Reed kick), 2:23. Fourth Quarter Pit--FG Reed, 31 , 7:16. Drive: 13 plays, 72 yards, 8:00. A-73,089. Pit Cle First downs 17 13 Total Net Yards 365 221 Rushes-yards 42-206 16-46 Passing 159 175 Punt Returns 2-7 0-0 Kickoff Returns 2-44 4-98 Interceptions Ret. 2-23 0-0 Comp-Att-Int 12-23-0 17-38-2 Sacked-Yards Lost 1-2 6-43 Punts 6-37.2 7-36.6 Fumbles-Lost 2-1 4-3 Penalties-Yards 6-45 6-51 Time of Possession 36:16 23:44 INDIVIDUAL STATISTICS RUSHING-Pittsburgh, Parker 27-109, Davenport 8-43, Wilson 1-37, Holmes 1- 11, Davis 3-5, Roethlisberger 1-2, Batch 1- .(minus 1). Cleveland, Lewis 11-35, Vickers 2-8, Wright 1-3, Frye 1-1, Anderson 1- '(minus 1). PASSING-Pittsburgh, Roethlisberger 12-23-0-161. Cleveland, Anderson 13-28- 1-184, Frye 4-10-1-34. RECEIVING-Pittsburgh, Miller 4-35, Ward 3-51, Holmes 2-55, Davenport 1-17, Spaeth 1-5, Parker 1-(minus 2). Cleveland, Winslow 4-83, Edwards 3-49, Jurevicius 2- 28, Lewis 2-11, Vickers 2-7, Carter 1-22, Dinkins 1-8, Cribbs 1-7, Heiden 1-3. LT, Chargers sink Bears Associated Press SAN DIEGO - LaDainian Tomlinson and San Diego finally took control of a sloppy season opener, with the reign- ing NFL MVP throwing for one touchdown and rushing for another in a 14-3 win over Chicago. The Bears, who topped the NFC last year at 13-3 before losing in the Super Bowl to Indianapolis, were nothing short of brutal with four turnovers. Two of them set up the game's only two touch- downs. The Chargers, an NFL-best 14-2 in 2006 before their playoff pratfall against New England had two turnovers and allowed three sacks. Still, Norv Turner came away a winner in his debut as Chargers head coach, raising his overall head coach- ing record with three teams to 59-82-1. Tomlinson threw a 17-yard TD pass to All-Pro tight end Antonio Gates with 45 seconds left in the third quarter, then scored on a 7-yard run with 9:09 left to play. Packers 16, Eagles 13 GREEN sec- onds remaining. Green Bay's Jarrett Bush recovered at the Philadelphia 31. Reed had replaced returned Greg Lewis, whose muffed punt led to a Packers touchdown in the first quarter. . Brett Favre struggled with a young supporting cast on offense for most of the afternoon, but still was able to tie John Elway's record with his 148th career victory as a starting quarterback. Favre was 23-of-42 for 206 yards. It was a so-so return for Eagles quarterback Donovan McNabb, who tore a knee ligament last' November and finished the regular season on the sideline for the sec- ond straight year. McNabb was 15- of-33 for 184 yards with a touch- . down and an interception. New En Jags fall to Titans; Vikings rout Falcons Associated Press EAST RUTHERFORD, N.J. - Randy Moss, who missed most of camp with a hamstring injury, caught nine passes from Tom Brady for 183 yards and a touchdown in his New England debut during a 38-14 victory over the Jets. Ellis Hobbs set an NFL record by taking the second- half kickoff 108 yards for a score. Moss, obtained for a fourth- round choice in a draft-day trade with Oakland had two miserable years with the Raiders after being a perenni- al Pro Bowl receiver with Minnesota. He and Brady established an immediate con- nection, even with the receiv- er's missed time in training camp. Moss' 51-yard touch- down catch in the third quarter gave the Patriots a 28-7 lead. Brady, who faced little pres- sure from the Jets, was 22-of-28 for 297 yards and three touch- downs, including a 5-yarder to Benjamin Watson. He is 7-0 against the Jets at Giants Stadium, and 11-2 overall in starts against New York Uons 36, Raiders 21 OAKLAND Calif. - Jon Kitna threw a go-ahead, 32-yard touch- down pass to Shaun McDonald with 4:15 remaining and Dewayne White forced two late turnovers that helped Detroit rally to beat Oakland after blowing a 17-point lead. The matchup between the NFL's two worst teams from a year ago turned highly entertaining in the second half when former Lions backup quarterback Josh McCown led the Raiders on three touch- down drives to turn a 17-0 deficit into a 21-20 Oakland lead with 7:43 to go. Then Kitna took over and spoiled Lane Kiffin's coaching Associated Press San Diego Chargers running back LaDainian Tomlinson (21) beats Chicago's Charles Tillman (33) for a seven-yard touchdown in the fourth quarter Sunday in San Diego. The Chargers won 14-3.. It spoiled what had been a remark- ably poised effort for a young Bills defense that lost three starters dur-. ing the game. The Broncos had 470 yards of offense, including Travis Henry's 139 yards rushing, but managed only three field goals and a touch- down in eight trips into Bills territory. Cutler produced on the winning drive, twice converting fourth-down situations. Buffalo had 184 yards of offense. Rookie Marshawn Lynch ran for 90 yards, including a 23- yard touchdown in which he bulled Denver's Jeff Shoate backward for, the final 3 yards, to put the Bills up. 14-6 midway through the third quarter. Redskints ten- dinitis, ran 9 yards to Miami's 22 to.set up Suisham's kick, which camie on first down. ,'Antwaan Randle El, promoted O6No. 2 receiver this year, had five catches for a career-high 162 yards arid had a hand in every Redskins score in regulation. gland pounds Jets, 38-14 that he turned into a 60-yard touch- down and finished with 103 yards ihn n n o Pn 10 r-qrrioe qftpr startfr Patriots receiver Randy Moss, left, catches a 33-yard Jets cornerback Justin Miller (22) during the sec Sunday at Giants Stadium in East Rutherford, N.J. debut in Oakland. Kitna completed four of five passes for 67 yards on the game-winning drive, capping it with his third touchdown pass of the game. Titans 13, Jaguars 10 JACKSONVILLE - Chris Brown ran for 175 yards, Vince Young and LenDale White combined for another 88 on the ground and Tennessee ran roughshod over Jacksonville. Brown found big holes in Jacksonville's vaunted defense. Most of his big runs came up the middle as Tennessee's offensive line manhandled Pro Bowl tackles Marcus Stroud and John Henderson. Tennessee finished with 282 yards rushing, a franchise record for both teams. Jacksonville's pre- vious high allowed was 246 yards against Seattle in 2005. Tennessee's previous best was 279 against Miami in 1967. Fred Taylor ran six times for 16 yards. Maurice Jones-Drew had 32 yards on seven carries for the Jaguars. QB David Garrard, who was supposed to give the team a better chance to win in the wake of Byron Leftwich's departure, made several big plays. He finished 17-of- 30 for 204 yards and a touchdown. ff . Associated Press pass against ond quarter. The Steelers pounced on mis- takes by the bumbling Browns to open a 17-0 lead in the first quarter. Roethlisberger went 12-of-23 for 161 yards. He threw two TD pass- es in the first quarter and two more in the third period for the Steelers. Vikings 24, Falcons 3 MINNEAPOLIS - Somewhere, Michael Vick must have been shaking his head. The Minnesota defense over- whelmed Atlanta's Joey Harrington with six sacks and two interception returns for touchdowns, and rookie running back Adrian Peterson fin- ished off the Falcons. Kevin Williams returned an inter- ception 54 yards for a first-quarter score, and Antoine Winfield ran one back 14 yards in the fourth quarter for Minnesota. Peterson made an amazing catch out of the backfield lUOIIIIIT un i z ji IIv I areIIs OL Ite I Chester Taylor hurt his hip. Harrington? He certainly didn't do anything to make Atlanta forget about Vick, whose indefinite sus- pension and possible jail time for his role in a dogfighting ring - stunned the Falcons this summer. Harrington finished 23-for-32 for 199 yards, but without a score and the two interceptions.. The Texans led 10-0 when Jamar Fletcher knocked the ball out of Kris Wilson's hands that Williams recovered. The 6-foot-7, 285-pound defensive end got up and rumbled 38 yards for the touchdown. Both of Williams' sacks came after halftime, the second a 6-yard loss inside the 20 that forced the Chiefs to settle for a field goal. Justin Medlock's 27-yarder made it 17-3 in the third quarter. Panthers 27, Rams 13 ST. LOUIS - Steve Smith out- sprinted fea- tured back Steven Jackson the preseason off backfired. Jackson lost two fumbles on consecutive carries in the third quarter, equaling his season total from last season. The first fumble negated a scor- ing opportunity, with Julius Peppers recovering at the Carolina 26. The Rams' defense saved Jackson on the second fumble, with hits by Brandon Chillar and Corey Chavous stripping DeShaun Foster at the St. Louis 3. Panthers 27, Rams 13 Carolina 7 0 7 13 - 27 St. Louis 7 3 3 0 - 13 First Quarter Car-D.Carter 10 pass from Delhomme (Kasay kick), 9:20. StL-Holt 3 pass from Bulger (Wilkins kick), 2:00. Second Quarter StL---FG Wilkins 42, :00. Third Quarter StL-FG Wilkins 28, 12:51. Car-S.Smith 68 pass from Delhomme (Kasay kick), 8:33. Fourth Quarter Car-FG Kasay 34, 14:56. Car-D.Carter 9 pass from Delhomme (Kasay kick), 7:15. Car--FG Kasay 32,1:04. A-65,307. Car StL First downs 21 16 Total Net Yards 387 238 Rushes-yards 38-186 21-76 Passing 201 162 Punt Returns 3-21 2-5 Kickoff Returns 3-64 5-146 Interceptions Ret. 0-0 0-0 Comp-Att-Int 18-27-0 22-42-0 Sacked-Yards Lost 0-0 1-5 Punts 3-52.7 547.2 Fumbles-Lost 3-2 2-2 I Penalties-Yards 7-75 8-82 i Time of Possession 34:07 25:53 INDIVIDUAL STATISTICS RUSHING-Carolina, Foster 17-94, D.Williams 15-62, Hoover2-16, Delhomme 3- 12, S.Smith 1-2. St. Louis, S.Jackson 18-58, Bulger 3-18. PASSING-Carolina, Delhomme 18-27-0- 201. St. Louis, Bulger 22-42-0-167. RECEIVING-Carolina, S.Smith 7-118, King 5-35, D.Carter 3-19, D.Williams 1-13, Colbert 1-9, Foster 1-7. St. Louis, Holt 8-73, I Bruce 3-20, Leonard 3-12, McMichael 2-24, Hall 2-18, Looker 2-10, Hedgecock 1-7, S.Jackson 1-3. MISSED FIELD GOAL-Carolina, Kasay 47 (WR) Paftiots 38, Jets 14 I NewFnnland 7 7 14 10 - 38 NYJets 0 7 7 0 - 14 First Quarter NE-Welker 11 pass from Brady (Gostkowski kick), 5:15. Second Quarter NY-Coles 7 pass from Pennington (Nugent kick), 4:20. NE-Watson 5 pass from Brady (Gostkowski kick), 1:14. Third Quarter NE-Hobbs 108 kickoff return (Gostkowski kick), 15:00. NE-Moss 51 pass from Brady (Gostkowski kick), 7:11. NY-Coles 1 pass from Pennington (Nugent kick), 2:23. Fourth Quarter NE-FG Gostkowski 22, 6:54. NE-Evans, 1 run (Gostkowski kick), 2:00. A-77,900. First downs Total Net Yards Rushes-yards Passing Punt Retums Kickoff Returns Interceptions Ret. Comp-Att-Int Sacked-Yards Lost Punts Fumbles-Lost Penalties-Yards NE 28 431 37-134 297 2-6 3-156 0-0 22-28-0 0-0 1-53.0 1-0 4-16 NYJ 17 227 19-60 167 0-0 6-140 0-0 21-31-0 5-35 5-41.0 2-0 2-20 Time of Possession 33:09 26:51 INDIVIDUAL STATISTICS RUSHING-New England, Maroney 20- 72, Morris 11-54, Brady 1-4, Faulk 1-4, Evans 2-1, Cassel 1-0, Gutierrez 1-(minus 1). N.Y Jets, Jones 14-42, Washington 4-15, Pennington 1-3. , PASSING-New England, Brady 22-28-0- 297. N.Y. Jets, Pennington 16-21-0-167, Clemens'5-10-0-35. RECEIVING-New Ergland Moa, 9-183, Welker 6-61, Morris 2.11* Waion 2-9, Stallworth'1-19, Faulk 1-9, Gaffney 1-5. N.Y Jets, Coles 7-59, Cotchery 6-57, Washington 3-30, Baker 2-29, Wright 1-11, McCareins 1- 10, Jones 1-6. Chargers 14, Bears 3 Chicago 0 3 0 0 - 3 San Diego 0 0 7 7 - 14 Second Quarter Chi-FG Gould, 27, 14:17. Drive: 8 plays, 27 yards, 3:54. Third Quarter SD-Gates, 17 pass from Tomlinson (Kaeding kick), :52. Fourth Quarter SD-Tomlinson, 7 run (Kaeding kick), 9:16. A-67,837. First downs Total Net Yards Rushes-yards Passing Punt Returns Kickoff Returns Interceptions Ret. Comp-Att-Int 32-1 Chi SD 11 19 202 263 26-80 36-77 122 186 1-0 1-(-1) 3-70 2-37 1-27 1-2 12-23-1 23- Sacked-Yards Lost 3-23 3-21 Punts 6-40.76-40.7 Fumbles-Lost 4-3 2-1 Penalties-Yards 4-38 3-20 Time of Possession 22:57 37:03 INDIVIDUAL STATISTICS RUSHING-Chicago, Benson 19-42, Peterson 7-38. San Diego, Turner 10-41, Tomlinson 17-25, Neal 4-12, Rivers 5-(minus 1). PASSING-Chicago, Grossman 12-23-1- 145. San Diego, Rivers 22-31-1-190, Tomlinson 1-1-0-17. RECEIVING-Chicago, Berrian 5-83, Clark 3-38, McKie 2-5, Benson 1-11, Muhammad 1- 8. San Diego, Gates 9-107, Tomlinson 7-51, Jackson 3-28, Davis 2-15, Manumaleuna 1-4, Neal 1-2. MISSED FIELD GOAL--San Diego, Kaeding 33 (BK). Packers 16, Eagles 13 Philadelphia 0 10 3 0- 13 Green Bay 10 0 3 3 - 16 First Quarter GB-White recovered GLewis' fumble in end zone (Crosby kick), 13:10. GB-FG Crosby 53, 9:35. Second Quarter Phi-FG Akers 33,13:30. Phi-Avant 9 pass from McNabb (Akers kick), 6:00. Third Quarter Phi-FG Akers 47, 8:15. GB-FG Crosby 37, :45. Fourth Quarter GB-FG Crosby 42, :02. A-70,598. Phi GB First downs 13 10 Total Net Yards 283 215 Rushes-yards 29-103 17-46 Passing 180 169 Punt Returns 6-12 2-13 Kickoff Returns 4-81 4-100 Interceptions Ret. 1-3 1-2 Comp-Att-Int 15-33-1 23-42-1 Sacked-Yards Lost 1-4 4-37 Punts 7-40.4 7-40.9 Fumbles-Lost 2-2 1-1 Penalties-Yards 8-76 6-35 Time of Possession 31:48 28:12 INDIVIDUAL STATISTICS RUSHING-Philadelphia, Westbrook 20- 85, McNabb 4-9, Buckhalter 4-5, Tapeh 1-4. Green Bay, Jackson 15-40, Wynn 1-8, Favre 1-(minus 2). PASSING-Philadelphia, McNabb 15-33- 1-184. Green Bay, Favre 23-42-1-206. RECEIVING--Philadelphia, Westbrook 6- 46, Avant 3-54, Curtis 2-53, Smith 2-14, R.Brown 1-14, Buckhalter 1-3. Green Bay, Driver 6-66, Jackson 4-35, Jones 4-29, D.Lee 4-27, Franks 2-17, R.Martin 2-14, Wynn 1-18. ll+TATic>NA-L Fc3cmBAjLL IUEAc�uE CaRus CouNTY (FL) CuRoNici.E CITRUS COUNTY (FL) CHRONICLE SCOREBOARD OvNI)AY, SP'r1-M,3.BL 10, 2007 3B NFL STANDINGS AMERICAN CONFERENCE East L T Pct PF 0 01.000 38 1 0 .000 14 1 0 .000 13 1 0 .000 14 South L T Pct PF 0 01.000 20 0 01.000 41 0 01.000 13 1 0 .000 10 North HomeAway 0-0-01-0-0 0-1-00-0-0 0-0-00-1-0 0-1-00-0-0 HomeAway 1-0-00-0-0 1-0-00-0-0 0-0-01-0-0 0-1-00-0-0 New England Buffalo Miami N.Y. Jets Houston Indianapolis Tennessee Jacksonville Pittsburgh Baltimore Cincinnati Cleveland Denver San Diego Kansas City Oakland Dallas Washington N.Y. Giants Philadelphia Carolina Atlanta New Orleans Tampa Bay Detroit Green Bay Minnesota Chicago Seattle Arizona San Francisco St. Louis East L T Pct PF PA 0 01.000 45 35 0 01.000 16 13 1 0 .000 35 45 1 0 .000 13 16 South L T Pct PF PA 0 01.000 27 13 1 0 .000 3 24 1 0 .000 10 41 1 0 .000 6 20 North L T Pct PF PA 0 01.000 36 21 0 01.000 16 13 0 01.000 24 3 1 0 .000 3 14 West L T Pct PF PA 0 01.000 20 6 0 0 .000 0 0 0 0 .000 0 0 1 0 .000 13 27 HomeAway 1-0-00-0-0 1-0-00-0-0 0-0-00-1-0 0-0-00-1-0 HomeAway 0-0-01-0-0 0-0-00-1-0 0-0-00-1-0 0-0-00-1-0 HomeAway 0-0-01-0-0 1-0-00-0-0 1-0-00-0-0 0-0-00-1-0 HomeAway 1-0-00-0-0 0-0-0 0-0-0 0-0-00-0-0 0-1-00-0-0 IRL Continued from Page 1B for NASCAR in 2008, joining rival team owner Chip Ganassi's Nextel Cup team. But he remained mum about the change Sunday, preferring to enjoy his new role as cham- AFC NFC Div 1-0-00-0-0 1-0-0 0-1-00-0-0 0-0-0 0-0-00-1-0 0-0-0 0-1-00-0-0 0-1-0 AFC NFC Div 1-0-00-0-0 0-0-0 0-0-0 1-0-0 0-0-0 1-0-00-0-0 1-0-0 0-1-00-0-0 0-1-0 AFC NFC Div 1-0-00-0-0 1-0-0 0-0-0 0-0-0 0-0-0 0-0-0 0-0-0 0-0-0 0-1-00-0-00-1-0 AFC NFC Div 1-0-0 0-0 0 0-0-0 .0-0-0 1.0.0 0-0-0 0-1-00-0-00-0-0 0-0-00-1-0 0-0-0 NFC AFC Div 1-0-00-0-0 1-0-0 0-0-0 1-0-0 0-0-0 0-1-00-0-00-1-0 0-1-00-0-0 0-0-0 NFC AFC Div 1-0-00-0-0 0-0-0 0-1-00-0-0 0-0-0 0-0-00-1-0 0-0-0 0-1-00-0-00-0-0 NFC AFC Div 0-0-0 1-0-0 0-0-0 1-0-00-0-0 0-0-0 1-0-00-0-0 0-0-0 0-0-00-1-0 0-0-0 NFC AFC Div 1-0-00-0-00-0-0 0-0-00-0-00-0-0 0-0-0 0-0-00-0-0 0-1-00-0-0 0-0-0 pion. "I don't know right now," he said of the move to NASCAR. "I just want to enjoy this, party with my team tonight, and then we'll decide." Asked to characterize his season in five words or less, Franchitti grinned and replied: "I can do it in three words. No, two. Up and down. NFL Results and upcoming schedule Thursday's Games Indianapolis 41, New Orleans 10 Sunday's Games Minnesota 24, Atlanta 3 Washington 16, Miami 13, OT Denver 15, Buffalo 14 Houston 20, Kansas City 3 Carolina 27, St. Louis 13 New England 38, N.Y. Jets 14 Green Bay 16, Philadelphia 13 Pittsburgh 34, Cleveland 7 Tennessee 13, Jacksonville 10 Detroit 36, Oakland 21 San Diego 14, Chicago 3 Seattle 20, Tampa Bay 6 Dallas 45, N.Y. Giants 35 Today's Games Baltimore at Cincinnati, 7 p.m. Arizona at San Francisco, 10:15 p.m. Sunday, Sept. 16 Buffalo at Pittsburgh, 1 p.m. Indianapolis at Tennessee, 1 p.m. Green Bay at N.Y. Giants, 1 p.m. Houston at Carolina, 1 p.m. San Francisco at St. Louis, 1 p.m. Cincinnati at Cleveland, 1 p.m. New Orleans at Tampa Bay, 1 p.m. Atlanta at Jacksonville, 1 p.m. Dallas at Miami, 4:05 p.m. Minnesota at Detroit, 4:05 p.m. Seattle at Arizona; 4:05 p.m. Kansas City at Chicago, 4:15 p.m. N.Y. Jets at Baltimore, 4:15 p.m. Oakland at Denver, 4:15 p.m. San Diego at New England, 8:15 p.m. Monday, Sept. 17 Washington at Philadelphia, 8:30 p.m. SHARE YOUR THOUGHTS * Follow the instructions on today's Opinion page to send a letter to the editor. "It's been a great season and I'd like to say I enjoyed every minute of it, but there were a. couple of moments when I was upside down that it wasn't so much fun," he added, referring to terrifying airborne crashes that he walked away from on, consecutive weeks last month in Michigan and Kentucky. "But it's been a blast" Johnson hits stride in win Associated Press RICHMOND, Va. - math- ematically eligible to race, his way into contention, suffered hi' third blown motor in the past seven races to finish 30th. "We broke another motor t seriestchampion will start the 10-race title hunt on top of the standings. L T Pct PF PA HomeAway 0 01.000 34 7 0-0-0 1-0-0 0 0 .000 0 0 0-0-0 0-0-0 0 0 .000 0 0 0-0-00-0-0 1 0 .000 7 34 0-1-00-0-0 West" , , ', L T Pct PF PA' HomeAway 0 01.000 15 14 0.-00 1-0-0 0 01.000 14 ' 3 1-0-00-0.0 1 0 .000 3 20 0-0-00-1-0 1 0 .000 21 36 0-1-00-0-0 NATIONAL CONFERENCE Texans 20, Chiefs 3 Kansas City 0 0 3 0 - 3 Houston 0 10 7 3 - 20 Second Quarter Hou-FG K.Brown 26, 7:33. Hou-A.Johnson 77 pass from Schaub (K.Brown kick), 6:01. Third Quarter Hou-M.Williams 38 fumble return (K.Brown kick), 14:01. KC-FG Medlock 27, :26. Fourth Quarter Hou-FG K.Brown 28, 5:00. NFL BOXES Titans 13, Jaguars 10 Tennessee 3 3 7 0- 13 Jacksonville 7 3 0 0 - 10 First Quarter Ten-FG Bironas 20, 4:06. Jac-Broussard 47 pass from Garrard (Scobee kick), 3:34. Second Quarter Jac-FG Scobee 22, 4:19. Ten-FG Bironas 31, :46. Third Quarter Ten-Young 2 run (Bironas kick), :59. A-65,437. Ten Jac First downs 22 12 Total Net Yards 350 272 Rushes-yards 49-282 18-72 Passing 68 200 Punt Returns 3-27 1-3, Kickoff Returns 3-49 2-71 Interceptions Ret. 0-0 1-23 Comp-Att-Int 11-18-1 17-30-0 Sacked-Yards Lost 2-10 2-4 Punts 3-30.0 5-42.2 Fumbles-Lost 2-0 1-1 Penalties-Yards 4-29 4-45 Time of Possession 36:55 23:05 INDIVIDUAL STATISTICS RUSHING-Tennessee, C.Brown 19- 175, White 18-66, Young 11-22, B.Jones 1- 19. Jacksonville, Jones-Drew 7-32, Garrard 5-24, Taylor 6-16. PASSING-Tennessee, Young 11-18-1- 78. Jacksonville, Garrard 17-30-0-204. RECEIVING-Tennessee, Gage 2-26, Scaife 2-18, White 2-7, Davis 1-8, Hall 1-6, B.Jones 1-6, Moulds 1-4, C.Brown 1-3. Jacksonville, Northcutt 4-57, Lewis 4-35, Jones-Drew 3-28, Broussard 2-55, Wilford 2-20, Estandia 1-6, Wrighster 1-3. MISSED FIELD GOALS-None. Lions 36, Raiders 21 Detroit 0 10 7 19 - 36 Oakland 0 0 14 7 - 21 Second Quarter Det-R.Williams 13 pass from Kitna (Hanson kick), 8:27. Det-FG Hanson 46, 1:10. Third Quarter Det-C.Johnson 16 pass from Kitna (Hanson kick), 9:15. Oak-Curry 4 pass from McCown (Janikowski kick), 3:49. Oak-Jordan 12 run (Janikowski kick), :49. Fourth Quarter Det-FG Hanson 46, 12:13. Oak-Griffith 7 pass from McCown (Janikowski kick), 7:43. Det-McDonald 32 pass from Kitna (pass failed), 4:15. Det-FG Hanson 23, 1:56. Det-T.Bell 14 run (Hanson kick), 1:16. A-61,547. Det Oak First downs 21 24 Total Net Yards 392 375 Rushes-yards 21-108 23-92 Passing 264 283 Punt Retumrns 1-18 2-0 Kickoff Retums 1-33 7-155 Interceptions Ret. 2-40 2-26 Comp-Att-Int 27-36-2 30-40-2 Sacked-Yards Lost 2-5 3-30 Punts 3-44.0 3-49.7 Fumbles-Lost 0-0 5-1 Penalties-Yards 6-35 8-50 Time of Possession 26:54 33:03 INDIVIDUAL STATISTICS RUSHING-Detroit, T.Bell 15-87, Kitna 3- 17, Duckett 3-4. Oakland, Jordan 15-70, Fargas 5-19, McCown 3-3. PASSING-Detroit, Kitna 27-36-2-289. Oakland, McCown 30-40-2-313., . ,,, i RECEIVING-Detroit, McDonald 6-90, Furrey 5-52, C.Johnson 4-70, R.Williams 4- 20, Bell 4-6, McHugh 2-45, Calhoun 1-5, Campbell '1-1. Oakland, Curry- 10-1:33, Jordan 9-89, Miller 3-23, Griffith 3-21, Porter 2-26, Madsen 2-10, M.Williams 1-11. KC 14 219 17-72 147 3-19 5-125 1-0 22-33-2 3-21 4-45.5 3-2 5-40 27:10 Hou 13 315 31-109 206 4-14 2-51 2-(-4) 16-22-1 2-19 3-55.0 1-1 6-45 32:50 INDIVIDUAL STATISTICS RUSHING-Kansas City, L.Johnson 10- 43, Bennett 5-24, Kennison 1-5, Huard 1- 0. Houston, A.Green 16-73, Dayne 13-33, J.Jones 1-4, Schaub 1-(minus 1). PASSING-Kansas City, Huard 22-33-2- 168. Houston, Schaub 16-22-1-225. RECEIVING-Kansas City, L.Johnson 7- 44, Gonzalez 5-28, Parker 4-48, Bowe 3- 42, Bennett 2-10, Wilson 1-(minus 4). Houston, A.Johnson 7-142, A.Green 4-23, J.Jones 2-33, Daniels 1-14, Walter 1-10, Leach 1-3. MISSED FIELD GOAL-Kansas City, Medlock 30 (WL). Cowboys 45, Giants 35 NY Giants 6 10 3 16 - 35 Dallas 3 14 14 14 - 45 First Quarter NY-Burress 60 pass from Manning (kick failed), 13:31. Dal-FG Folk 31, 6:32. Second Quarter Dal-Barber 18 run (Folk kick), 9:40. Dal-Witten 12 pass from Romo (Folk kick), 3:59. NY-Burress 4 pass from Manning (Tynes kick), :21. NY-FG Tynes 44, :03. Third Quarter Dal-Owens 22 pass from Romo (Folk kick), 12:00. NY-FG Tynes 48, 5:47. Dal-Romo 9 run (Folk kick), 1:12. Fourth Quarter NY-FG Tynes 24, 13:23. Dal-Owens 47 pass from Romo, 11:43. NY-Ward 9 pass from Manning (pass failed), 7:20. NY-Burress 10 pass from Manning (Tynes kick), 4:09. Dal-Hurd 51 pass from Romo (Folk kick), 3:03. A-63,031. NYG Dal First downs 22 21 Total Net Yards 438 478 Rushes-yards 22-124 30-142 Passing 314 336 Punt Returns 1-13 2-15 Kickoff Returns 7-193 7-182 Interceptions Ret. 1-10 1-18 Comp-Att-Int 29-44-1 15-24-1 Sacked-Yards Lost 1-5 1-9 Punts 2-44.5 2-54.0 Fumbles-Lost 1-0 1-1 Penalties-Yards 4-45 7-55 Time of Possession 32:03 27:57 INDIVIDUAL STATISTICS RUSHING-New York, Ward 13-89, Jacobs 6-26, Droughns 1-5, Lorenzen 1-2, Manning 1-2.. Dallas, J.Jones 16-66, Barber 11-65, Romo 3-11. PASSING-New York, Manning 28-41-1- 312, Lorenzen 1-3-0-7. Dallas, Romo 15- 24-1-345. A-70,080. First downs Total Net Yards Rushes-yards Passing Punt Returns Kickoff Returns Interceptions Ret. Comp-Att-Int Sacked-Yards Lost Punts Fumbles-Lost Penalties-Yards Time of Possession On the AIRWAVES TODAY'S SPORTS BASEBALL 3 p.m. (WGN) St. Louis Cardinals at Chicago Cubs. 7 p.m. (66 PAX) Tampa Bay Devil Rays at Boston Red Sox. 7 p.m. (FSNFL) Washington Nationals at Florida Marlins. FOOTBALL 7 p.m. (ESPN) Baltimore Ravens at Cincinnati Bengals. 10:15 p.m. (ESPN) Arizona Cardinals at San Francisco 49ers. RUGBY 5 p.m. (VERSUS) IRB World Cup 2007 - England vs. United States. (Taped) SOCCER 7:55 a.m. (ESPN2) Women's FIFA World Cup -Argentina vs. Germany. 4:55 a.m. (ESPN2) Women's FIFA World Cup - North Korea vs. United States. Varsity Prep CALENDAR TODAY'S PREP SPORTS GIRLS GOLF 4:25 p.m. Citrus, West Port at Vanguard OPEN Continued from Page 1B Robert De Niro sharing a box with his parents in the stands. Federer - dressed for an evening on the town, he was all in black, from headwrap and ,wristband to socks and shoes, from shirt to shorts with tuxe- do- ed, then sprayed two fore- hands van- ished: Federer hit a cross- court forehand winner that caught a line, and Djokovic missed two backhands. Then came a fourth set point, but Djokovic sent a fore- hand long. Then a fifth, but Federer smacked a forehand return that landed right on the base- line, drawing Djokovic's stab backhand long. After Djokovic missed yet another backhand to give Federer his first break point of the match, the Serb's nerves really got the better of him: He double-faulted. GOLF SCOREBOARD BMW Championship Sunday At Cog Hill Golf and Country Club. Dubsdread Course : Lemont, III. Purse: $7 million Yardage: 7,326 Par: 71, Final Round Tiger Woods (9000), $1,260,000 67-67-65-63 - 262 -2, Aaron Baddeley (5400), $756,000 68-65-65-66 - 264 -2 Steve Stricker (3400), $480,000 68-66-64-68 - 266 -1 Adam Scott (2400), $340,000 69-69-67-65 - 270 -1 Tim Clark (1900), $270,000 68-69-67-67 - 271 -1 Justin Rose (1900), $270,000 65-69-69-68 - 271 -1 Stewart Cink (1613), $229,000 66-73-68-65 - 272 -1 ,Camilo Villegas (1613), $229,000 65-69-71-67 - 272 -1 Sergio Garcia (1450), $206,000 68-70-69-67 - 274 -1 Ian Poulter (1200), $171,000 68-72-69-66 - 275 Rory Sabbatini (1200), $171,000 69-72-68-66 - 275 Carl Pettersson (1200), $171,000 71-68-69-67. - 275 . Jonathan Byrd (1200), $171,000 64-69-71-71 - 275- Lucas Glover (875), $123,625 70-71-67-68 - 276 Brandt Snedeker (875), $123,625 70-71-65-70 - 276 Jim Furyk (875), $123,625 70-69-67-70 - 2764 Nathan Green (875), $123,625 67-71-67-71 - 276 David Toms (609), $85,260 72-70-68-67 - 277 Bubba Watson (609), $85,260 71-69-69-68 - 277 Ernie Els (609), $85,260 73-67-68-69 - 277 Bo Van Pelt (609), $85,260 69-71-68-69 - 277 Charles Howell III (609), $85,260 68-73-67-69 - 277 Ryan Moore (609), $85,260 69-70-68-70 - 277 Pat Perez (609), $85,260 66-69-70-72 - 277 Mark Wilson (390), $54,600 76-69-68-65 - 278 Kevin Sutherland (390), $54,600 70-73-69-66 - 278 Charley Hoffman (390), $54,600 68-70-72-68 - 278 Ryuji Imada (390), $54,600 67-70-71-70 - 278 Stuart Appleby (390), $54,600 68-68-71-71 - 278 Luke Donald (291), $40,688 76-70-68-65 - 279 Angel Cabrera (291), $40,688 72-69-71-67 - 279 Brett Wetterich (291), $40,688 68-72-71-68 - 279 John Mallinger (291), $40,688 74-68-69-68 - 279 Vaughn Taylor (291), $40,688 73-68-69-69 - 279 Scott Verplank (291), $40,688 69-70-70-70 - 279 Hunter Mahan (291), $40,688 69-68-71-71 - 279 Rocco Mediate (291), $40,688 70-70-68-71 - 279 Zach Johnson (200), $28,000 72-71-70-67 - 280 Robert Allenby (200), $28,000 75-68-69-68 - 280 Woody Austin (200), $28,000 67-73-71-69 - 280 Rod Pampling (200), $28,000 73-72-66-69 - 280 PGA Tour FedExCup Leaders Through Sept. 9 Rank Name Points YTD 1. Tiger Woods 112,733 2. Steve Stricker 109,600 3. Phil Mickelson 108,613 4. Rory Sabbatini 103,588 5. K.J. Choi 103,100 6. Aaron Baddeley 102,800 7. Adam Scott 100,227 8. Jim Furyk 99,838 9. Vijay Singh 99,214 10. Sergio Garcia 98,277 11. Geoff Ogilvy 98,063 12. Zach Johnson 97,823 13. Charles Howell III 97,631 14. Ernie Els 97,575 15. Brandt Snedeker 97,507 16. Justin Rose 97,250 17. Woody Austin 97,223 18. Mark Calcavecchia 97,019 19. Scott Verplank 96,632 20. Hunter Mahan 96,516 21. Brett Wetterich 95,774 22. Boo Weekley 95,734 23. John Rollins 95,710 24. Stewart Cink 95,513 25. Jonathan Byrd 95,471 26. Robert Allenby 95,450 27. Tim Clark 95,425 28. Camilo Villegas 95,003 29. Heath Slocum 94,876 30. Padraig Harrington 94,841 Total Money $9,607,052 $4,523,077 $5,685,588 $4,345,640 $4,457,659 $3,317,919 $3,296,285 $3,986,746 $4,497,376 $3,385,185 $2,803,203 $3,302,838 $2,717,291 $2,588,815 $2,723,943 $2,538,575 $2,711,602 $2,305,832 $2,609,089 $2,592,995 $2,021,982 $2,271,317 $2,285,662 $2,223,846 $1,728,906 $2,010,208 $1,826,495 $1,662,561 $1,679,154 $2,490,983 Hurricanes boys golf takes second to Saddlebrook The Citrus boys golf team came in second'Saturday after- noon against Saddlebrook, Associated Press IRVING, Texas - Wade Phillips threw a soft uppercut and smiled widely. He did it early, when his first gamble as coach of the Dallas Cowboys worked out - then again in the closing minutes, follow- ing a touchdown that also made him let out a big sigh of relief. Marion Barber got things rolling with an 18-yard touchdown run on fourth-and-1, Terrell Owens added two high- light-reel touchdown catches and Tony Romo made up for an inter- ception with a 51-yard touchdown pass to Sam Hurd for a 45-35 victory over the injury-deplet- ed New York Giants on Sunday night Romo threw for a career-high 345 yards and four touchdowns, plus ran for another, helping the Cowboys match the most points they ever scored in four years under Bill Parcells. However, Phillips' supposedly improved defense gave up 438 yards and lots of big plays, turning a poten- tial blowout into a nail- biter. Eli Manning showed Tiki Barber and all his critics that he can be a Sports BRIEF= Nature Coast and Tampa Prep. Saddlebrook finished with 319, Citrus with 323, Nature Coast with 360 and Tampa Prep with 386. Bobby Bang had the low round for Citrus with 79. Zach Stanley shot 80 and Nick Brothers and Harlan Kelly both shot 82. The Hurricanes, who are now 9-1, plays 3:30 p.m. Thursday against Crystal River. Associated Press - Dallas Cowboys wide receiver Terrell Owens (81) , - scores as New York Giants safety Gibril Wilson (28) pursues in the fourth quarter Sunday in Irving, Texas. The touchdown came on a 47-yard touchdown pass as the Cowboys won, 45-35. leader, overcoming knee injuries that knocked out sacks leader Osi Umenyiora and new starting run- ning. Redskins 16, Dolphins 13 Miami 0 7 3 3 0 - 13 Washington 0 3 7 3 3 - 16 Second Quarter Was-FG Suisham 31, 12:14. Mia-Peelle 1 pass from Green (Feely kick), :00. Third Quarter Was-Portis 19 run (Suisham kick), 11:47. Mia-FG Feely 20, 3:37. Fourth Quarter Was-FG Suisham 44, 5:30. " Mia-FG Feely 36, 1:55. Overtime Was-FG Suisham 39, 9:24. A-90,163. Mia Was First downs 17 19 Total Net Yards 273 490 Rushes-yards 20-66 41-191 Passing 207 209 Punt Returns 4-20 3-23 Kickoff Returns 3-70 2-50 Interceptions Ret. 2-53 0-0 Comp-Att-Int 24-38-0 12-21-2 Sacked-Yards Lost 2-12 2-13 Punts 7-42.7 5-48.0 Fumbles-Lost 1-1 2-0 Penalties-Yards 8-61 7-65 Time of Possession 30:33 35:03 INDIVIDUAL STATISTICS RUSHING-Miami, Brown 11-32, Chatman 7-15, Booker 1-12, Ginn Jr. 1-7. Washington, Portis 17-98, Betts 17-59, J.Campbell 4-29, Sellers 2-8, Randle El 1- (minus 3). PASSING-Miami, Green 24-38-0-219. Washington, J.Campbell 12-21-2-222. RECEIVING-Miami, Chambers 6-92, Chatman 6-48, Brown 6-40, Booker 3-29, Peelle 2-12, Martin 1-7. Washington, Randle El 5-162, Moss 3-28, Sellers 2-6, Betts 1-16, Cooley 1-10. MISSED FIELD GOALS-None. BUCS Continued from Page 1B led 20-6. On the series before Garcia left, Patrick Kerney,, Brianr any- one get hurt seriously," Peterson said. "But this Seattle defense is different. We're coming to hit We're coming t6 hurt. We want to get that repu- tation around the rest of the league, because that will help our offense." The Buccaneers, who scored 10 points or less in eight games while sinking to 4-12 last sea- son,. Cowboys hold off Giants, 45-35 CITRUS COUN'IY (FL) CHRONICLE 4 B MONDAY, SEPrEMBIR 10, 200 7 1~,4AfC~R LEAGIJE BASEBALL East Division GB L10 - 7-3 5% z-7-3 14 5-5 25 z-3-7 26% z-7-3 East Division Pct GB L10 .570 - 8-2 .528 6 z-5-5 .510 8% z-5-5 .448 17% 6-4 .427 20% 3-7 Home 44-25 47-27 42-27 31-40 35-40 Home 38-30 41-30 38-36 36-35 30-41 Away 43-32 34-35 30-43 30-41 25-43 Away 43-31 34-37 35-34 28-44 31-41 Intr 12-6 10-8 10-8 6-12 7-11 W Cleveland 83 Detroit 77 Minnesota 70 Kansas City 62 Chicago 61 Milwaukee Chicago St. Louis Cincinnati Pittsburgh Houston Central Division Pct GB L10 Str .580 - z-7-3 W-2 .538 6 z-6-4 L-1 .490 13 3-7 W-1 .437 20% z-3-7 L-5 .427 22 4-6 L-1 Central Division Pct GB L10 Str .514 - 7-3 W-2 .507 1 4-6 L-1 .493 3 z-5-5 L-3 .448 9% z-3-7 L-2 .441 10% 4-6 W-1 .434 11% z-3-7 L-5 Home 44-27 38-33 37-35 31-40 31-38 Home 45-26 38-36 39-31 35-37 33-39 36-33 Away 39-33 39-33 33-38 31-40 30-44 Away 28-43 34-34 30-40 29-42 30-41 26-48 Los Angeles Seattle Oakland Texas Arizona San Diego Los Angeles Colorado San Francisco West Division Pct GB L10 .587 - z-5-5 .532 8 2-8 .479 15% z-4-6 .479 15% z-8-2 West Division ,t GB L10 3 - z-7-3 2 3 4-6 4 5% 5-5 1 6 z-7-3 5 15% 4-6 Wild Card Glance American League W L Pct GB New York 81 62 .566 - Detroit 77 66 .538 4 Seattle 75 66 .532 5 National League W L Pct GB San Diego 77 65 .542 - Philadelphia 75 67 528 2 Los Angeles 75 68 .524 2'/ Colorado 74 68 .521 3 AMERICAN LEAGUE Sunday's Games Seattle 14, Detroit 7 Boston 3, Baltimore 2 Tampa Bay 3, Toronto 2 Minnesota 5, Chicago White Sox 2 N.Y. Yankees 6, Kansas City 3 Texas 12, Oakland 9 Cleveland 6, L.A. Angels 2 Today's Games Tampa Bay (Kazmir 11-8) at Boston (Schilling 8-6), 7:05 p.m. Toronto (Halladay 14-7) at Detroit (Rogers 3-2), 7:05 p.m. Minnesota (Bonser 6-12) at Kansas City (Buckner 0-0), 8:10 p.m. Cleveland (Carmona 15-8) at Chicago White Sox (G.Floyd 1-2), 8:11 p.m. Oakland (Blanton 12-9) at Seattle (Ramirez 8-5), 10:05 p.m. Tuesday's Games Texas at Detroit, 1:05 p.m., 1st game Texas at Detroit, 7:05 p.m., 2nd game Tampa Bay at Boston, 7:05 p.m. L.A. Angels at Baltimore, 7:05 p.m. N.Y. Yankees at Toronto, 7:07 p.m. Minnesota at Kansas City, 8:10 p.m. Cleveland at Chicago White Sox, 8:11 p.m. Oakland at Seattle, 10:05 p.m. NATIONAL LEAGUE Sunday's Games Washington 7, Atlanta 4 N.Y. Mets 4, Houston 1 Milwaukee 10, Cincinnati 5 Pittsburgh 10, Chicago Cubs 5 Philadelphia 8, Florida 5 Colorado 4, San Diego 2 San Francisco 4, L.A. Dodgers 2 Arizona 6, St. Louis 5 Today's Games St. Louis (Pineiro 5-3) at Chicago Cubs (Lilly 14-7), 3:20 p.m. Washington (Hill 3-3) at Florida (Olsen 9- 12), 7:05 p.m. Milwaukee (Villanueva 7-3) at Pittsburgh (Armas 3-5), 7:05 p.m. Colorado (Jimenez 3-3) at Philadelphia (Lohse 8-12), 7:05 p.m. Atlanta (T.Hudson 15-7) at N.Y. Mets (O.Perez 13-9), 7:10 p.m. Arizona (L.Hernandez 10-9) at San Francisco (Lincecum 7-4), 10:15 p.m. Tuesday's Games Washington at Florida, 7:05 p.m. Milwaukee at Pittsburgh, 7:05 p.m. Colorado at Philadelphia, 7:05 p.m. Atlanta at N.Y. Mets, 7:10 p.m. St. Louis at Cincinnati, 7:10 p.m. Chicago Cubs at Houston, 8:05 p.m. San Diego at L.A. Dodgers, 10:10 p.m. Arizona at San Francisco, 10:15 p.m. WOODS Continued from Page 1B decid- ed not to play this week Mickelson, the Deutsche Bank Championship win- nerJ. Choi - have a mathemati- cal. Ass The Yankees' Alex Rodriguez watches the ball after hitting home run during the first inning against the Kansas City I Sunday. The blast was Rodriguez's MLB-leading 51st of the Yankees 6, Royals 3 KANSAS CITY, Mo.-/�. Phillies 8, Marlins 5 PHILADELPHIA- Pat Burrell homered and drove in three runs, and Jamie Moyer overcame one awful inning to remain unbeaten against Florida and lead the Philadelphia Phillies to an 8-5 win over the Marlins on Sunday. Carlos Ruiz also homered for the Phillies, who tagged Dontrelle Willis and rebounded from a crush- ing loss on Wednesday at Atlanta to take two of three from the Marlins. The Phillies open a four- game set with Colorado on Monday in a series that could shuf- fle the National League wild-card standings. Hanley Ramirez, Jeremy Hermida and Mike Jacobs homered during a five-run sixth for the Marlins. Twice last week the Phillies blew 5-0 leads in stunning losses to Florida and the Braves that knocked them back in the NL East and severely hindered their wild- card run. They almost blew another early lead again in this one. FLORIDA PHILA ab rhbi HaRmz ss 4 11 2 Rollins ss Amzga 2b 4 01 0 Iguchi 2b Hrmida rf 4 12 1 Vctrno rf MiCbr 3b 3 11 0 Burrell If Jacobs lb 3 11 2 BMyers p Olivo c 4 00 0 Utley lb CRoss cf 4 00 0 Rwand cf Linden If 3 01 0 Werth rf Willis p 1 00 0 Ruiz c Barone p 0 00 0 Nunez 3b Abrcrb ph 1 11 0 Moyer p Grdner p 0 00 0 Alfnsca p De aza ph 1 00 0 KDavis p Lndstr p 0 00 0 Dobbs ph JuMIr p 0 00 0 Rmero p Wlnhm ph 1 00 0 Howard lb ab r h bi 5 1 20 4220 0000 4223 0000 5010 4 2 2 0 4132 0 0 0 0 34 2 2000 0000 05 000 1 000 03 000 0000 0 0 0 0 Totals 335 8 5 Totals 38 814 8 Florida 000 005 000- 5 Philadelphia 520 100 00x- 8 E-Amezaga (5). . DP-Florida 1, Philadelphia 2. LOB-Florida 4, Philadelphia 9. 2B-Abercrombie (3), Burrell (23), Rowand (40). HR-HaRamirez (26), Hermida (15), Jacobs (14), Burrell (27), Ruiz (6). IP Florida Willis L,8-15 3 Barone 2 Gardner 1 Lindstrom 1 JuMiller 1 Philadelphia Moyer W,13-11 51-3 Alfonseca 2-3 KDavis 1 Romero 1 BMyers S,15 1 Umpires-Home, La H RERBBSO 6 5 5 1 00 0 0 0 0 0 1 1 0 0 1 1 0 0 0 rry Vanover; Chad Fairchild; Second, Tony Randazzo; Third, Greg Gibson. T-2:50. A-32,574 (43,647). Devil Rays 3, Blue Jays 2 ST. PETERSBURG - Carl Crawford and Carlos Pena hit con- secutive homers in the sixth inning, and James Shields allowed four hits through seven to lead the Tampa Bay Devil Rays past the Toronto Blue Jays 3-2 on Sunday. Tampa Bay has won four straight series for the first time since winning six straight in June 2004. The Devil Rays have won nine of their last 12 ' games and 12 of 16 since Aug. 24, hitting 32 homers and scoring 128 runs over that stretch. Crawford hit a solo shot to lead off the sixth, the drive hitting the "C" ring of the Tropicana Field catwalk. The homer, his sixth against the Blue Jays this season, tied the game at 2. Pena followed with his 38th home run, giving him 106 RBIs and tying him with former Devil Ray Fred McGriff for third on the franchise sin- gle-season list. He has hit 19 home runs at Tropicana Field this season, a franchise record. Shields (12-8) gave up two runs and struck out five. The 25-year-old allowed no walks and hasn't walked sociated Press more than one batter in 22 of his 30 a two-run starts this season. ie ear. TORONTO TAMPA BAY NEW YORK KANSAS CITY ab rhbi ab r hbi Damon If 5 01 0 Gthrght If 4 0 2 0 MeCbrcf 4 00 0 DJesuscf 3 1 0 0 BAbreu rf 4 10 0 Gload lb 4 1 1 0 ARod 3b 5 22 2 Butler dh 3 0 0 0 Matsui dh 3 11 0 Teahen rf 3 1 0 0 Posada c 3 12 2 Gordon 3b 4 0 1 3 Giambi lb 3 00 0 JSmith 2b 4 0 1 0 Mntkwlb 0000 Buckc 4 0 1 0 Cano2b 4 12 1 TPena ss 2 0 0 0 Btemit ss 4 01 1 Costa ph 0 0 0 0 Gnzalez ss 0 00 0 EGrmn 2b 0 0 0 0 Totals 356 9 6 Totals 31 3 6 3 New York 210 020 010- 6 Kansas City 000 300 000- 3 E-Gathright (3), Teahen (5). DP-New York 1. LOB-New York 7, Kansas City 5. 2B-Posada (37), Betemit (2), Gordon (31). HR-ARodriguez (52). SB-BAbreu (23). CS-Gathright (6). S-Mientkiewicz. IP H RERBBSO New York Wang W,18-6 Farnsworth MRivera S,25 Kansas City 5 3 3 4 4 0 0 0 0 2 1 0 0 0 1 Greinke 32-3 6 3 3 2 1 Duckworth L,2-5 2-3 1 2 2 1 0 Bale 32-3 2 1 1 1 7 Soria 1 0 0 0 0 3. Umpires-Home, Fieldin Culbreth; First, Tim McClelland; Second, Marty Foster; Third, Paul Schrieber. T-2:50. A-24,910 (40,785). Nationals 7, Braves 4 ATLANTA- Ryan Church hit a three-run homer to give Washington the lead, D'Angelo Jimenez drove in three runs with three hits and the Nationals beat the Atlanta Braves 7-4 on Sunday. The Braves led 3-1 through five innings before Church hit the go- ahead homer off Lance Cormier in the sixth. Ryan Zimmerman also. went deep for Washington. Chipper Jones and Mark Teixeira hit home runs for Atlanta. The Braves ended a 4-5 homes- tand failing to take advantage of a chance to gain ground in the NL East or wild-card race. The Braves trail the New York Mets by eight games in the division, and began the day 41 games behind San Diego in the wild card. Jason Bergmann (4-5) gave up two hits in the first, including Jones' two-run homer, but yielded only two hits and one more run after that. WASHINGTON ATLANTA ab rhbi Jimnz ss 5 03 3 Harris If Rauch p 0 00 0 Rnteria ss CCrdro p 0 00 0 CJones 3b Blliard 2b 4 01 0 Txeira lb Zmrmn 3b 5 11 1 McCnn c DYong lb 2 12 0 Frncur rf Mxwell pr 0 00 0 AJones cf Ayala p 0 00 0 Jhnson 2b Munoz p 0 00 0 Crmer p Logan cf 1 00 0 Moylan p Kearns rf 5 11 0 Orr ph Church cf 4 11 3 Mahay p FLopez ss 1 000 Ascanio p WPena If 5 01 0 Ring p Flores c 3 21 0 Diaz ph Brgmn p 1 00 0 Lngrhn ph 1 11 0 Fick lb 2 01 0 ab r h bi 5 1 1 0 3000 3 21 2 4 1 22 4 0 1 0 4 01 0 4 01 0 3 0 1 0 2000 0 0 0 0 0 0 0.0 0 000 0000 0000 1 000 Totals 39713 7 Totals 33 4 8 4 Washington 001 003 111- 7 Atlanta 201 000 010- 4 E-Teixeira (3). DP-Washington 1. LOB-Washington 11, Atlanta 6. 2B- Jimenez (3), DYoung (37), Kearns (31), Harris (19), Teixeira (5), McCann (36). HR-Zimmerman (23), Church (12), CJones (25), Teixeira (11). SB- Langerhans (3). S-Belliard, Bergmann, Orr. IP H RERBBSO Washington Bergmann W,4-5 6 4 3 3 2 6 Ayala 2-3 2 0 0 1 1 Munoz 1-3 0 0 0 0 0 Rauch 1 2 1 1 0 0 CCorderoS,32 1 0 0 0 0 2 Atlanta Cormier L,2-5 6 7 4 4 1 5 Moylan 1 2 1 1 1 0 Mahay 2-3 2 1 1 1 0 Ascanio 1 2 1 1 1 1 Ring 1-3 0 0 0 0 1 Umpires-Home, Jim Reynolds; First, Gary dederstrom; Second, Lance Barksdale; Third, Tim Welke. T-2:59. A-31,582 (49,583). ab rhbi VWells cf 4 00 1 lwmra 3b Jhnson If 3 00 0 Crwfrd If Ovrbay ph 1 00 0 CPena lb Rios rf 4 00 0 Upton dh Thmas dh 401 0 DYong cf Stairs lb 3 00 0 BHarrs 2b Glaus 3b 3 00 0 Gomes rf AHill 2b 3 22 1 Nvarro c Zaun c 3 00 0 JoWlIsn ss JMcDId ss 2 01 0 Lind ph 1 00 0 Olmedo ss 0 00 0 r h bi 0 1 0 1 2 1 1 3 1 0 1 0 1 1 1 Totals 312 4 2 Totals 31 3 8 3 Toronto 001 010 000- 2 Tampa Bay 010 002 00x- 3 E-Glaus (9). DP-Toronto 1. LOB- Toronto 2, Tampa Bay 4. 2B-Thomas (27). HR-AHill (15), Crawford (11), CPena (38), BHarris (10). IP H RERBBSO Toronto Litsch L,5-8 5 7 3 3 0 5 Wolfe 2 0 0 0 0 1 Downs 2-3 1 0 0 0 1 Janssen 1-3 0 0 0 0 0 Tampa Bay Shields W,12-8 7 4 2 2 0 5 Wheeler 1 0 0 0 0 1 ReyesS,23 1 0 0 0 0 1 Litsch pitched to 3 batters in the 6th. WP-Shields. Umpires-Home, Paul Emmel; First, Dan lassogna; Second, Angel Campos; Third, Ron Kulpa. T-2:35. A-20,556 (43,772). Mets 4, Astros 1 NEW YORK - Pedro Martinez's return to Shea Stadium was a huge success. Martinez tossed five shutout innings in his first start at home this season, outpitching Roy Oswalt and leading the New York Mets past the Houston Astros 4-1 Sunday for a three-game sweep.. Moises Alou hit a two-run homer and Carlos Beltran drove in two runs for New York, which has won eight of nine since it was swept in a four- game series at Philadelphia. The NL East-leading Mets entered the day with a six-game lead over the Phillies. Luke Scott homered for Houston, which has lost seven of eight and went 2-7 on its nine-game road trip. The Astros managed only five runs in the series. HOUSTON ab rhbi NEW YORK ab r h bi Pence cf 5 00 0 JBRyes ss 3 0 0 0 Biggio 2b 5 01 0 LCstillo 2b 3 1 1 0 TreMIIr p 0 00 0 Beltran cf 3 1 2 2 Brkmn lb 4 02 0 Alou If 4 1 1 2 CaLee If 5 01 0 Gomez If 0 0 0 0 Loretta ss 4 02 0 ShGren lb 4 0 2 0 Lamb 3b 3 01 0 L Ducac 4 0 1 0 Burke ss 2 00 0 Gotay 3b 4 0 0 0 Scott rf 5 11 1 Chavez rf 4 0 1 0 Asmus c 4 02 0 PMrtnz p 2 1 1 0 Oswalt p 1 00 0 Mota p 0 0 0 0 OPImro ph 0 00 0 Mlldge ph 0 0 0 0 Brntittss 0 00 0 Felicno p 0 0 0 0 Heilmn p 0 0 0 0 Conine ph 1 0 0 0 BWgnr p 0 0 0 0 Totals 38110 1 Totals 32 4 9 4 Houston 000 001 000- 1 New York 101 020 00x- 4 E-Loretta (7). LOB-Houston 15, New York 8. 2B-Berkman (21), Ausmus (16), LCastillo (5), Beltran (31), ShGreen (30), PMartinez (1). HR-Scott (18), Alou (11). S-Oswalt, JBReyes. SF-Beltran. IP H RERBBSO Houston Oswalt L,14-7 7 9 4 4 1 4 TreMiller 1 0 0 0 0 0 New York PMartinez W,2-0 5 6 0 0 1 4 Mota 1 2 1 1 1 2 Feliciano 1 1 0 0 0 0 Heilman 1 0 0 0 1 0 BWagnerS,32 1 1 0 0 0 1 HBP-by Oswalt (Milledge), by PMartinez (Oswalt). WP-PMartinez. Umpires-Home, Dana DeMuth; First, Kerwin Danley; Second, Doug Eddings; Third, Mike Everitt. T-2:42. A-51,847 (57,343). Mariners 14, Tigers 7 DETROIT - Ichiro Suzuki scored in each of the first four innings and the Seattle Mariners busted out of a long slump, beating the Detroit Tigers 14-7 on Sunday for only their second victory in 15 games. Raul Ibanez hit a three-run homer, Adrian Beltre had four RBIs and Jose Guillen drove in three runs for Seattle, which began the day five games behind the New York Yankees in the AL wild-card race. Felix Hemandez (12-7) earned the win despite giving up seven runs - six earned - and 10 hits with three walks over five-plus innings. The Tigers, who entered three games behind the Yankees, had won four straight for the first time since mid-July. Curtis Granderson joined Willie Mays and Frank "Wildfire" Schulte as the only players in major league history with 20 stolen bases, 20 homers, 20 triples and 20 doubles in a season. SEATTLE DETROIT ab rhbi ab r hbi ISuzuki cf 443 1 Grndsn cf 4 2 4 1 Beltre 3b 6 23 4 Maybin cf 1 0 0 0 Ibanez If 5 12 3 Planco 2b 4 1 2 0 Jmrsn rf 0 00 0 Raburn 2b 1 0 0 0 JGillen rf 5 04 3 Shffield dh 3 1 0 0 AJones rf 1 01 0 MOrdz rf 4 1 2 3 Brssrd 1b 5 00 1 Clevlen rf 1 0 0 0 Sexson dh 2 000 CGillen lb 4 0 2 1 JReed dh 4 11 0 TPerez If 2 0 0 1 Jhjima c 4 10 0 Thmes If 2 0 0 0 Blmqist2b 4 22 1 Rabelo c 4 0 0 0 YBtcrtss 5 33 1 RSntgo ss 4 1 0 0 Inge 3b 4 1 2 1 Totals 45141914 Totals 38 712 7 Seattle 244 300 010-14 Detroit 410 101 000- 7 E-Bloomquist (3), CGuillen (24). DP- Seattle 1. LOB-Seattle 10, Detroit 8. 2B- Beltre (38), JGuillen 2 (24), YBetancourt (35), CGuillen (29). 3B-Beltre (2), JReed (1). HR-lbanez (17), Granderson (21). SB-Granderson (20). CS-TPerez (1). SF-Broussard. IP H RERBBSO Seattle FHrndzW,12-7 5 10 7 6 3 4 Green 2-3 1 0 0 1 0 O'Flaherty 21-3 0 0 0 0 3 Putz 1 1 0 0 0 1 Detroit Bndrm L,11-9 11-3 7 6 6 2 1 Grilli 11-3 1 3 3 1 1 Rapada 0 1 1 1 0 0 Vasquez 41-3 6 3 3 1 1 Capellan 2 4 1 1 0 1 FHernandez pitched to 2 batters in the 6th, Rapada pitched to 1 batter in the 3rd. HBP-by Grilli (Johjima). Balk- O'Flaherty. Umpires-Home, Brian Gorman; First, Paul Nauert; Second, Rob Drake; Third, Gerry Davis. T-3:17. A-39,990 (41,070). D'backs 6, Cardinals 5 PHOENIX - Jose Valverde retired pinch-hitter Yadier Molina with the bases loaded for the final out, and the Arizona Diamondbacks held off the St. Louis Cardinals 6-5 on Sunday for. their fifth straight victory. Tony. The Cardinals fell three behind first-place Milwaukee in the NL Central. Yusmeiro Petit (3-4) pitched two innings of one-hit ball for the win. Valverde came on in the ninth for his major league-leading 45th save in 52 chances. ST. LOUIS Schmkr If Ryan ss Edmnd ph Pujols lb Ludwck rf Tguchi cf RFrkIn p KJimnz p Eckstin ph Brnyan 3b GBnntt c YMolna ph Stnet c Miles 2b Thmps p Barden ph KWells p Ankiel cf Cairo 2b Duncan ph ARIZONA ab rhbi 5 01 0 Drew ss 4 11 1 Cllspo 2b 1 11 0 Byrnes If 4 01 1 TClarklb 4 01 0 Rynlds 3b 3 00 0 CBYng cf 0 00 0 CSnydr c 0 00 0 Upton rf 0 00 1 Pena p 3 00 0 CJcksn ph 0 00 0 VIverde p. 1 00 0 DDavis p 2 11 0 Wckmn p 1 00 0 Bnfacio ph 0 00 0 Petit p 1 11 0 Salazar rf 2 01 0 1 00 0 3 11 2 1 00 0 Totals 365 9 5 Totals 33 6 9 6 St. Louis 004 000 001- 5 Arizona 020 000 40x- 6 E-Reynolds (10). DP-Arizona 1. LOB-St. Louis 10, Arizona 5. 2B- Edmonds (14), Pujols (30), Barden (1), TClark (5), CSnyder (16), Salazar (6). 3B- Schumaker (2), Cairo (1). HR-CBYoung (29), Upton (2). SB-Byrnes (44). IP H RERBBSO St. Louis Thompson 2 4 2 2 0 1 KWells 4 2 1 1 0 4 RFranklin L,4-3 1 3 3 3 1 1 Jimenez 1 0 0 0 0 0 Arizona DDavis 4 7 4 4 2 3 Wickman 1 0 0 0 1 1 Petit W,3-4 2 1 0 0 0 2 Pena 1 0 0 0 0 1 Valverde S,45 1 1 1 1 2 1 KWells pitched to 1 batter in the 7th. HBP-by Valverde (Ludwick), by KWells (Byrnes). WP-Thompson, DDavis. Umpires-Home, Jerry Meals; First, Gary Darling; Second, Larry Poncino; Third, Jim Wolf. � T-3:25. A-35,136 (48,785). Red Sox 3, Orioles 2 BALTIMORE - Josh Beckett allowed two runs in seven innings to earn his 18th victory, and the Boston Red Sox completed another suc- cessful season at Camden Yards by beating the Baltimore Orioles 3-2 Sunday. Coco Crisp singled home the tiebreaking run in the eighth inning, Mike Lowell drove in two runs and Dustin Pedroia had three hits for the Red Sox, who went 6-3 in Baltimore this year. Boston has had a winning record at Camden Yards every sea- son since 1998, going 54-23 during that span. Beckett (18-6) yielded seven hits, struck out eight - including Brian Roberts three times - and walked none. The right-hander is 4-1 life- time against the Orioles, including 4- 0 with a 2.05 ERA in four starts at Baltimore. Hideki Okajima worked the eighth and Jonathan Papelbon got three outs for his 35th save in 36 chances. The closer had retired 17 straight batters before Melvin Mora singled with one in the ninth. BOSTON BALTIMORE ab rhbi ab r hbi Ellsbry If 5 01 0 BRbrts 2b 4 0 0 0 Pedroia 2b 5130 Redmncf 4 0 1 0 DOrtiz dh 511 0 Mrkkis rf 4 1 2 1 Lowell 3b 4 01 2 Tejada dh 4 0 0 0 JDrewrf 3 11 0 Huff lb 4 0 1 0 Yukilis lb 3 01 0 Mora 3b 4 1 2 1 Varitek c 3 01 0 RaHrdz c 2 0 1 0 Crisp cf 4 01 1 Fahey ss 0 0 0 0 Cora ss 4 00 0 Moore ph 1 0 0 0 Bynum if 3 0 0 0 LHrndzss 2 0 1 0 Millar ph 1 0 0 0 Molina c 0 0 0 0 Totals 36310 3 Totals 33 2 8 2 Boston 002 000 010- 3 Baltimore 000 101 000- 2 E-Redman (1). DP-Boston 1, Baltimore 1. LOB-Boston 9, Baltimore 6. 2B-Pedroia (35), DOrtiz (44). HR- Markakis (18), Mora (14). SB-JDrew (3), Youkilis (4). CS-LHernandez (1). S- Bynum. Boston Beckett W,18-6 Okajima Papelbon S,35 Baltimore Guthrie JWalker Bradford L,3-7 Birkins IP H RERBBSO 7 2 2 0 8 1 0 0 0 2 10002 5 7 11-3 1 11-3' 2 11-3 0 Guthrie pitched to 1 batter in the 6th. HBP-by Beckett (RaHernandez). Umpires-Home, Laz Diaz; First, Wally Bell; Second, Mike DiMuro; Third, Bill Welke. T-3:20. A-39,234 (48,290). Indians 6, Angels 2 ANAHEIM, Calif. - Ryan Garko hit a three-run homer, Asdrubal Cabrera had two RBIs and the Cleveland Indians beat the Los Angeles Angels 6-2 Sunday night to split a four-game series between AL division leaders. Cleveland's 13th victory in 16 tries increased its AL Central lead to six games over Detroit. The first-place Angels, who played without ailing right fielder Vladimir Guerrero again, have an eight-game cushion over Seattle in the AL West. Aaron Laffey (3-1) pitched five innings for the Indians, allowing two runs and six hits while striking out three in his sixth major league start. One of the runs against the left-han- der was unearned, the result of a throwing error by shortstop Jhonny Peralta. Jensen Lewis, Rafael Perez and Joe Borowski combined for four scoreless innings of three-hit relief.. CLEVELAND LOS ANGELES ab rhbi ab r hbi Szmore cf 5 22 0 Willits cf 5 0 0 0 ACbera 2b 4 122 Izturis 3b 4 1 2 0 Hafnerdh 3 00 0 OCbera ss 4 0 1 0 VMrtnz c 3 11 0 GAndsn If 4 0 1 0 Garko 1b 4 11 3 Kndrck2b 4 0 0 0 JhPIta ss 4 11 0 JRivra rf 4 0 0 0 Lofton If 4 00 0 Quinlan dh 1 1 1 0 Gutirrzrf 4 02 1 Figgins dh 1 0 1 0 Blake 3b 4 00 0 Aybar dh 1 0 0 0 Ktchm lb 4 0 3 0 Napoli c 3 0 0 1 Totals 356 9 6 Totals 35 2 9 1 Cleveland 000 510 000- 6 Los Angeles 110 000 000- 2 E-JhPeralta (16). DP-Cleveland 1. LOB-Cleveland 4, Los Angeles 10. 2B- Sizemore (31), ACabrera (6), JhPeralta (25), Kotchman (34). HR-Garko (17). SB- Sizemore (31). CS-Gutierrez (2). SF- Napoli. IP H RERBBSO Cleveland Laffey W,3-1 5 6 2 1 2 3 Lewis 11-3 2 0 0 1 1 RPerez 12-3 0 0 0 0 2 Borowski 1 1 0 0 0 1 Los Angeles JdWeaver L,11-7 5 9 6 6 1 5 Oliver 2 0 0 0 1 1 Bootcheck 1 0 0 0 0 2 FrRodriguez 1 0 0 0 0 2 Umpires-Home, Tom Hallion; First, Dale Scott; Second, Chris Guccione; Third, Phil Cuzzi. T-2:54. A-40,037 (45,257). Boston New York Toronto Baltimore Tampa Bay New York Philadelphia Atlanta Washington Florida Home 49-25 41-27 36-35 42-32 Home 46-29 40-31 37-32 43-28 35-36 Away 35-34 34-39 33-40 26-42 Away 35-34 37-34 38-36 31-40 30-42 NIA14DR ILEA4GuE IBASE13AJLL -7 4BMONDAY, SEPTEMBER 10, 200' IV Y . MchONDAY SEPTEMBER 10, 2007 Entertainment CITRUS COUNTY CHRONICLE Western steams its way to top Associated Press LOS ANGELES - The cri acclaimed Western "3:10 to Yum gunned the fright fest "Hallowe become the weekend's top box draw. The remake from Lionsgate t $14.1 million from Friday tl Sunday according to studio esti While the film did not produce numbers, it performed well for a picture on a historically slow we( "We ended the summer on a note and we're starting off the typical fashion," said Dergarabedian, president of box tracker Media By Numbers. "It w huge weekend, but it was bette the same weekend in 2006." This weekend's top 12 films t 22.5 percent more than last year Labor Day crop, making the straight weekend the box offi< Spotlight on "=" *,i-, 1 ..:." , .-. " . Keillor returns to Lake Wobegon ST PAUL - Maybe it's that he's hit retirement age, but Garrison Keillor wasn't afraid to admit that his lat- est novel was easy to write. "For me, that was p manage- ._- - able," Keiller S. j said of S I "Pontoon," his 248-page return to Lake Garrison Wobegon. Keillor "I'm telling my publisher I want to write a series of short novels. Now that I'm suddenly a senior citizen, I'm don't want to spend years reading a book" The novel will be pub- lished Tuesday, the same week that Keillor begins a new season of his long-run- ning Minnesota Public Radio show, '"A Prairie Home Companion." The new book is his fifth set in the fictional town of Lake Wobegon. Bill Cosby talks about school LOS ANGELES - Bill Cosby is getting behind efforts to improve education. Cosby announced last week that his animated series, "Little Bill," which is aimed at getting preschool- ers interested in learning, is returning to television on cable's Noggin net- work It pre- viously was part of the Nickelodeon cable net- Bill osby work's "Nick Jr." program- ming bloc for preschoolers. In an era where the edu- cation reform act No Child Left Behind dominates edu- cation, the comedian com- plained recently, "The high school dropout rate in some cities is as high as 55 to 75 percent. While the behinds are moving forward, some of the minds are left behind." Beginning today, Cosby's show will air weekdays on Noggin at 11 a.m. and 2:30 p.m. It will be broadcast at 1:30 p.m. on the weekends. - From wire reports exceeded 2006 results. The performance of "3:10 to Yuma," which paired Russell Crowe and Christian Bale, thrilled Lionsgate exec- utives, who chose this weekend to posi- tion the film for Oscar consideration. "We wanted to be the first Western into the marketplace this fall, we want- ed crit- ically acclaimed film of note in that genre was 1992's "Unforgiven," starring Clint Eastwood. This fall will see two Westerns con- tending suc- cess before they grant you awards suc- cess." TOP MOVIES 1. "3:10 to Yuma," $14.1 million 2. "Halloween," $10 million. 3. "Superbad," $8 million. 4. "Balls of Fury," $5.7 million. 5. "The Bourne Ultimatum," $5.5 mil- lion. 6. "Shoot 'Em Up," $5.5 million. 7. "Rush Hour 3," $5.3 million. 8. "Mr. Bean's Holiday," $3.4 million 9. "The Nanny Diaries," $3.3 million. 10. "Hairspray," $2 million. in four theaters for a per-screen aver- age of $10,300. Estimated ticket sales for Friday through Sunday at U.S. and Canadian theaters, according to Media By Numbers LLC. Final figures will be released Monday. Stars turn out for MTV awards Britney Spears leads offperformances Associated Press LAS VEGAS - Some- . where, Kevin Federline is laughing. An out-ot-shape. out-of-touch Britnevy Spears delivered what %ws a destined to be the most it talked about performance of the MTV Video Music Awards- but for all the a.rong reasons. Kicking off the show Sunda. night with her new single, "Gimme More-," Britney Spears looked bleary and unprepared, much like her recent tabloid exploits on the streets ol Los Angeles. The MTV Video Music i Awards was hoping to rein- vent itself on Sunday. After suffering poor reviews and a decline in ratings over the last few years. MTV moved the show to Las Vegas' Palms Casino, short- ened the show from three hours to two, and changed the show's setup to focus more on per- formances than awards. To that end, Justin Ti mberlake and Timbaland, Kanye West, Fall Out Boy and the .Foo Fighters were each hosting four separate suite par- ties, where much of S the show's perform- ances would be held. Thankfully, after Spears' dismal start and a lukewarm S intro by comedian Sarah Silverman, the show rebounded. Tim- berlake's suite was Packed with revelers, alcohol and eight lin- gerie-clad stripper .- , types on raised plat- Nicole Scherzinger of the Pussycat Dolls arrives . Sunday at the MTV Video Music Awards at the Palms Hotel and . citedtd Press forms.. Meanwhile, Rihanna won Monster Single of the Year for her ubiquitous hit "Umbrella," and Beyonce and Shakira won Most Earthshattering Collaboration for "Beautiful Liar." Beyonce's shimmer- ing gold dress barely contained her top; immediately after she picked up her tro- phy, she asked an assistant backstage to help fix her dress, apparently to prevent a wardrobe malfunction. Other performers were appearing on the show's main stage, in front of an indus- try-only audience seated at tables, like at the Golden Globes. Chris Brown gave one of the evening's most extravagant per- formances - a dance-centric, eye-popping spectacle that channeled Michael Jackson, right down to a brief "Billie Jean" imitation. Later, he was joined by Rihanna, who performed her monster sin- gle. And Nicole Scherzinger, making her solo debut from the Pussycat Dolls, gave a performance for the gawking fans, per- forming her new single with the rapper Lil' Wayne. Metroid Prime 3' brings MATT SLAGLE AP technology writer Action heroine Samus gets to face her evil twin in "Metroid Prime 3: Corruption," the final game in the science-fiction tril- ogy and the first for Nintendo's Wii. The Wii's focus on casual games has meant a bounty of simple titles for the whole fam- ily. But there's been a dearth of action for the hardcore gaming set. "Corruption" finally pro- vides wire- less controls actually work. The game makes full use of the Wii's remote and nunchuk attachment for looking and moving around, shooting and jumping. The controls are perhaps the This undated s shows a comic "Metroid Prime biggest initial will face. I wrestling with the enemies. But like an; just have to giv took me a sevE eventually can how motion-se can enliven shooter. The c an extension o The tactile si control innovations to first-person shooters run- Associated Press ning and gunning, too. screen shot courtesy of Nintendo of America Inc. Sometimes you'll have to solve bat scene in the new first-person video game puzzles, while other levels are 3: Corruption" on the Wii console. more of a carnival shooting gallery. The overall experience obstacle players ing the nunchuk to throw a is one of exploration, puzzle- found myself grapple beam and yank some- solving and action that kept me them instead of thing off a wall is unlike any- wanting to push farther. thing I've experienced before Owners of rival consoles can thing new, you in a video game. Instead of tap- boast all they want about exclu- e it sometime. It ping a button to pull a lever, sive blockbuster titles like eral hours, but I simply twist and move your "Halo 3" for the Xbox 360 or ne to appreciate hand around to pull it, like you "Warhawk" for the PlayStation .nsitive controls would in the real world. 3. With "Corruption," the Wii a first-person' And then there's the satisfy- has an excellent new video controls become ing rumble of a fully charged game all to its own. f your arms. Power Beam blast. Three-and-a-half-stars out of sensation of flick- Fans will appreciate how four. FloEida LOTTERIES Here are the winning numbers selected Sunday in the Florida Lottery: CASH 3 8-5-4 PLAY 4 6-8-5-2 FANTASY 5 3- 26- 27- 30- 36 SATURDAY, SEPTEMBER 8 Cash 3:2 - 5 - 1 Play 4:5 - 7 - 3- 4 Lotto: 6- 10- 18-23-27-34 6-of-6 No winner 5-of-6 106 $3,566 4-of-6 5,420 $56.50 3-of-6 101,718 $4 Fantasy 5: 9 - 22 - 23 - 28 - 32 5-of-5 No winner 4-of-5 368 $864 3-of-5 11,522 $10.50 FRIDAY, SEPTEMBER 7 Cash 3:3-5-6 Play 4: 3 - 7 - 9 - 9 Fantasy 5: 7-13-18-20-25 5-of-52 $128,068.28 4-of-5 415 $99.50 3-of-5 12,024 $9.50 Mega Money: 4 - 18 - 35 - 38 Mega Ball: 15 4-of-4 MB No winners INSIDE THE NUMBERS * To verity the accuracy of winning lottery numbers, players should double check the numbers printed above with numbers officially posted by the Florida Lottery On the Web, go to .corn; by telephone, call 1850) 487. -7':7. Today in HISTORY Today 1846, Elias Howe received a patent for his sewing machine. In 1907, 100 years ago, the first Neiman Marcus department store opened in Dallas. In 1963, 20 black students entered Alabama public schools following a standoff between feder- al authorities and Gov. George C. Wallace. In 1987, Pope John Paul II arrived in Miami, where he was welcomed by President Reagan as he began a 10-day tour of the United States. Today's Birthdays: Golfer Arnold Palmer is 78. Actor Philip Baker Hall is 76. Country singer Tommy Overstreet is 70. Actor Greg Mullavey is 68. Jazz vibra- phon under- standing; if there is no understand- ing, there is no knowledge." - The Talmud. Curtis Peterson Auditorium - Citrus County Sept. 15, Nov. 3, Dec. 1, Feb. 2 - 7:00 pm Marion Technical Auditorium - Ocala 1100 seats - October 20, 07 - 7:00 pm Tickets by phone, Aeb site. at the door, or : Fresh Start Donuts of Inverness - Rt. 41 North Crystal River Music-Rt. 44 near Crystal River Video Game REVIEW POW k6Latt-Y , r- I I I I �ffffliwlTlj lklTkul ENTERTAINMENT( 6B MONDAY, SEPTEMBER 10, 2007 MONDAY EVENING SEPTEMBER 10, 2007 c: Comcast,Citrus B: Bright House D: Comcast,Dunnellon I: Comcast, Inglis C B D I 6:00 6:30 7:00 7:30 8:00 8:30 9:00 9:30 10:00 10:30 11:00 11:30 ESH News (N) NBC News Entertainme Access Conversations With Heroes "Parasite" (In Dateline NBC (In Stereo) News Tonight I C U 8 19 19 19 497 nt ' Hollywood Carlos Watson 'PG'7565 Stereo) '14, V' C 1359 'PG' g 3316 14851229 Show (W - - - BBC World Business The NewsHour With Jim Antiques Roadshow History Detectives (N) 'G' The Blitz: London's Longest Night (In PBS P B 3 3 News 'G' Rpt. L___ ehrer 9 8671 "Honolulu, HI"'G' 7519 C9 4855 Stereo) 'PG' B9 60229 Previews Swui -BBC News Business The NewsHour With Jim Antiques Roadshow History Detectives (N) 'G' The Blitz: London's Longest Night (In Tavis Smiley S BS 5 5 5 7749 Rpt. Lehrer (N) 29720 "Honolulu, HI"'G' 45768 K 21132 Stereo) 'PG' 9 83313 74381 WFA News (N) NBC News Entertainme Extra (N) Thank God You're Here Heroes "Parasite" (In Dateline NBC (In Stereo) News (N) Tonight 8 NBC B 8 8 8 6687 nt 'PG' 'PG' CB 38478 Stereo) '14, V BB 41942 'PG' C 24229 9325478 Show 1 News (N) ABC WId Jeopardy! Wheel of Wife Swap Fat March (N) BB 61774 Supernanny "McAfee News (N) Nightline 20 20 20 20 C 4671 News 'G'G 92584 Fortune (N) "Slater/Williams" 'PG L' Family" 'PG' [] 64861 1264300 98990519 S_ - News (N) Evening Inside Be a How I Met Old Two and a Engagemen CSI: Miami "Kill Switch" News (N) Late Show 10 10 0 10 2213 News Edition'PG' Millionaire IChristine Half Men t '14, V C[ 62403 1262942 | 3r 13 News (N) 9[]37300 TMZ (N) The Insider Prison Break "Fin Del Prison Break "Sona" '14, News (N) CU 10923 News (N) TMZ 'PG' OX 3 133 1 1'PG' 9B 8229 Camino" -'14, LV V' LV' 90 59836 3324958 [cc 2465126 WCJ 11 News (N) ABC Wid Entertainme Inside Wife Swap Fat March (N) SC 83584 Supernanny "McAfee News (N) Nightline 11 11 76671 News nt Edition 'PG' "Slater/Williams" 'PG, L' Family" 'PG' CC 86671 7348720 83708590 SWCLF Richard and Lindsay Steve-Kathy Zola Levitt Gregory Possess the Life Today Manna-Fest The 700 Club 'PG' CC Pentecostal Revival Hour IND 2 2 2 2 Roberts 'G' CC 5668045 :Presents Dickow'G' 'G' 3153213 'G' B 9974671 Z 9627942 2 News (N) ABC WId Wheel of Jeopardy! Wife Swap Fat March (N) CC 43958 Supernanny "McAfee News (N) Nightline SABC B3 11 1 56855 News Fortune (N) (N)'G' -Slater/Williams" 'PG L' Family" 'PG' CC 46045 8223923 18104749 WMOR Family Guy Family Guy Frasier 'PG, Access RoboCop: Prime Directives Part Two -- Meltdown Conversations With Reno 911! Will & Grace IND 12 12 " '14 DL '14, L,S'. D' 72215 Hollywood (Part 2 of 4) '14' C 94652 Carlos Watson 'PG' 86687 '14' 57687 '14, D' I A Judge Mathis (N) 'PG' B9 Every- Seinfeld IFL Battleground (N) (In Stereo) CC 4848229 Every- Scrubs '14' Seinfeld Sex and the SMNT I 6 6 6 6. 4931300 Raymond 'PG' 'Raymond 1203774 'PG, D' City '14, WAX Faith The 700 Club 'PG' 9 Variety 5381 Love a Child Pastor Jim The Faith R. The Gospel Claud Bowers 88774 TBN 21 21 21 Builders 888381 'PG'9478 Raley 1213 Show Scarborouq Truth 'G' SOG4 Two and a The King of The Two and a Hates Chris Hates Chris Girlfriends The Game The King of According to That'70s That'70s EC 4 4 4 4 Half Men Queens Simpsons Half Men 'PG, D' 'PG DL' Queens Jim 'PG, Show 'PG, Show '14, WY) TV 20 News Law Talk County Junk'd: Let's Talk Golf 31966 Eastern Golf Links Classic Golf Cross TV 20 News County FAM 16 16 16 16 41584 Court Makeover Illustrated Points Court G XTMZ (N) King of the The The Prison Break "Fin Del Prison Break "Sona" '14, News (N) (In Stereo) X9 Seinfeld Seinfeld FOX 13 13 'PG' 9 Hill 'PG' Simpsons Simpsons Camino" '14, L,V' 90 L,V' 9 83942 66229 'PG' 37229 'PG, D' 15 15 15 15 Noticias 62 Notcer o Amo a Juan Amar sin Lmites 557381 Destilando Amor 640045 Cristina 643132 Noticias 62 Noticiero SN151 15 (N) 851584 Univisi n Querend6n 644861 -(N) 914132 JUnivisi6n Diagnosis Murder (In MLB Baseball Tampa Bay Devil Rays at Boston Red Sox. From Fenway Park The Wonder The Wonder Time Life Paid S17 Sereo PV' 1198 i Boso Live 361010 . Ye s'P ' Years'G' Music Pro m 544 Cold Case Files Arsonist. CSI: Miami "Hurricane CSI: Miami "Darkroom" The Sopranos "WhitecapsTwo Tony s ony and Carmela contemplate pur- 448 541 54 ,'PG' [ 964861, Anthony"' '14' B 172213 '14, D.S.V' 9 254861 chasing a summer home. (In Stereo) 9B 13041519 i 55 64 55 55 Movie: * * "Ladder 49" (2004, Drama) Joaquin Movie: ** "WyattEarp" (1994, Biography) Kevin Costner, Dennis Quaid, Gene Hackman. Portrait Phoenix, John Travolta. BB 748107 traces him from boy to lawman. 386010 SThe Crocodile Hunter 'G' The Most Fooled by Meerkat Meerkat Animal Cops Detroit Stray Animal Cops Detroit An The Most Fooled by 2 3A ) 52 1 5 2 95 5660403 Extreme 'G' Nature 'G' Manor 'G' Manor 'G' dogs. 'PG' 9973942 injured cat. 'PG' 9056229 Extreme 'G' Nature 'G' SA74 Movie: "The AFI's 100 Years ... 100 Movies: 10th Anniversary Edition (In Stereo) 'PG, L,V' Last Comic Standing '14' Inside the Actors Studio U(BRAVO) 74__ ntouchables" 628584 9 384584 C[ 461590 'PG, L' 9 442010 27 61 27 27 Movie: "The Royal Scrubs '14, Scrubs'14' Daily Show Colbert Mind of South Park Scrubs '14' Scrubs '14' Daily Show Colbert _T_ 27 61 2 27 Tenenbaums"857687 S'72233 32836 Report Mencia'14, 'MA, L' 80584 62132 Report 98 45 98 98 "Baby CMT Music Kenny Chesney: Celebrity Celebrity Celebrity Trick My Trick My Trick My Celebrity Celebrity S 9845 98 98 Boom" -Somewhere in the Sun Bull Riding Bull Riding BullRiding Truck Truck Truck Bull Riding Bull Riding T ' One-Hearts Conversion Daily Mass: Our Lady of The Journey Home (Live) Letter and The Holy Abundant Life 'G' The World Over 5733720 95 65 95 951the Angels 'G' 7927300 'G' 7903720 Spirit 'G' Rosary 7926671 291 52 29 29 Greek "Multiple Choice" Greek "Separation Greek "Depth Perception" Greek An article creates Slacker Slacker The 700 Club 'PG' B] S29 52 29 29 630805 Anxiety" S 609942 'PG, D' S9 781590 scandal. 605126 Cats B] Cats '14, D' 776213 30 6030 Malcolm in Malcolm in Malcolm in Malcolm in Movie: * * "Fat Albert" (2004, Comedy) Kenan Thompson, That'70s That '70s "Joe Smb" [O 30 the Middle the Middle the Middle the Middle Kyla Pratt, ShedrackAnderson II. 7009923 Show '14, Show '14, 'H GV ,23,5723 23 Offbeat If Walls House House Designed to Buy Me (N) Color Hidden House Living With Design Star 'G' 6566039 S23 57 23 America 'G' Could Worth? Hunters 'G' Sell (N) 'G' 'G' 7051861 Splash (N) Potential (N) Hunters 'G' Ed (N) 'G' HT 51 c 25 5c 1 51 Man, Moment, Machine Modern Marvels "Poison" Modern Marvels Diggin for the Truth (N) Cities of the Underworld Lost Worlds Herod's i 51 25 'PG, V' CC 6337316 'PG, V CC 7005132 "Welding"'PG' CC 'PG' B 7001316 'PG' 9 7004403 Temple. 'PG' 9 5748652 24. 38 24 241Reba 'PG, Reba 'PG' Still Still Reba 'PG' Reba 'PG' Movie: "Custody" (2007, Drama) Rob Morrow, Will & Grace Will & Grace 2 8 D' 987107 553377 Standing Standing 264768 349403 James Denton, Kay Papabaker. 'PG' C9 691923 '14' '14' K 28 36 28 28 Zoey 101 Ned's Ned's Drake & SpongeBob Drake & Home Home George George Fresh Fresh '.____ ' Y7' 441720 School School Josh 'Y7' CC Josh 'Y7' [f Improvemen Improvemen Lopez 'PG' Lopez 'PG' Prince Prince S FI 31 59 31 31 Stargate SG-1 Star Trek: Enterprise Star Trek: Enterprise B9 Star Trek: Enterprise Star Trek: Enterprise C9 Movie: "Ghost in the 1 5 1 1 "Redemption"'PG' "Cease Fire" 1427478 1436126 "Canamar" 1512590 1426749 Shell" (1996) 4169774 SK 37 43 37 137CSI: Crime Scene CSI: Crime Scene CSI: Crime Scene Movie: ** "Die Another Day" (2002) Pierce Brosnan, Halle Berry. James [_il Investigation '14 D14, LV Investigation '14, DV Bond and an American spy track a North Korean villain. 586478 S 49 23 49 49 Friends '14' Every- EEvery- very- Friends 'PG' Friends 'PG' Friends 'PG' Friends '14' My Boys (N) My Boys (N) Sex and the Sex and the S3 1 4 341381 Raymomon d Raond Raymond 628942 614749 484233 509958 '14, L' '14' 788923 City '14, City '14, S 53 Movie: * * * "Executive Suite" (1954) William Movie: * * * "Some Came Running" (1958, Drama) Frank * * * * "A Funny Thing Happened ___ ____Holden. JuneAllyson. C iDVS) 46610749 Sinatra, Dean Martin, Shirley MacLaine. LM 5727229 Ion the Way to the Forum"6708855 53 34 53 53 Cash Cab Cash Cab Survivorman '14, L' C Lobster Wars "The Battle Lobster Wars 'PG, L' 9 Lobster Wars 'PG, L' Lobstermen: Jeopardy at 53 4 53 5 'G450478 G'5647958 250045 Begins" 'PG, L' 163565 256229 259316 Sea 'PG1 L' 587381 501 46 50 50 n Property Ladder 'G' CC Getting In ... Kindergarten On the Road With 16 My Unique Family 'G' B Half Ton Man 'G' 9 On the Road With 16 S 4 5 281316 (N) 480010 Children 'G' [9 579958 486294 489381 Children 'G' C9 806294 48 33 48 48 Law & Order "Showtime" Law & Order "City Hall" The Closer "Til Death Do The Closer "Til Death Do Saving Grace (N) 'MA, The Closer "Til Death Do '14' 289958 '14' 488652 Us Part" '14, L' 497300 Us Part" (N) '14, L' LSV CC 487923 Us Part" '14, L' 804836 TRAV 4 9 9 Into Alaska With Jeff Into Alaska With Jeff Zimmern & Bourdain: New York The chefs return to Anthony Bourdain: No Zimmern & Bourdain: 9.5AV) 9 54 9 9 Corwin 'PG' 9 7821403 Corwin 'PG' B 5856590 their roots. 'PQ D,L' 5770126 Reservations 'PG, D,L' New York 'PG, D,L' 32 75 32 32 1 Little House on the Andy Griffith Andy Griffith Bob Bob Bob Bob Bob Bob Bob Bob ( Prairie 'PG' 95582671 Newhart Newhart Newhart Newhart Newhart Newhart Newhart Newhart SA 47 32 47 47 Law & Order: Special Law & Order: Criminal Law & Order: Special WWE Monday Night Raw (In Stereo Live) '14, D,L,V Burn Notice "Unpaid UA 473V2 4 Victims Unit '14'422855 Intent '14' 90 701749 Victims Unit '14' 710497 9f 4997861 Debts" C9 10309132 18 18 18 18Tenth Inning Funniest America's Funniest Home Corner Gas Corner Gas America's Fuhniest Home WGN News at Nine (N) Sex and the Scrubs '14' _ _ 18_ 18 18 Pets Videos 'PG' 466045 'PG' i 'PG' [ Videos 'PG' 462229 9 465316 City '14, 722768 MONDAY EVENING SEPTEMBER 10, 2007 C: Comcast,Citrus B: Bright House D: Comcast,Dunnellon I: Comcast, Inglis cBD 6:00 6:30 7:00 7:30 8:00 8:30 9:00 9:30 10:00 10:30 11:00 11:30 S 46 40 46 46 inthe Coryinthe Hannah Zack & Cody Movie: "Twitches" (2005, Fantasy) Tia That'sSo That's So Life With Zack & Cody Hannah 4House'G' House'G' Montana 'G' I Mowry. 'G' B] 3990836 Raven'G' Raven'G' Derek'G' Montana'G' S 3968. 39 3 M*A*S*H M*A*S*H Murder, She Wrote (In Murder, She Wrote (In Movie: "The Runaway" (2000, Drama) Dean Cain, Murder, She Wrote (In S9 'PG' 5567942 'PG' 5558294 Stereo) 'G' 9977768 Stereo) 'G' 90 9059316 Maya Angelou, Pat Hingle. 'PG' 9052403 Stereo) 'G' 9 9612010 Movie: ** "Scoop" (2006) Scadett Johansson, Real Time With Bill Maher Curb- Making Tell Tell Me You Love Me 'MA' Bob Saget ThatAin't Woody Allen. BB 41269403 'MA' C9 523923 Enthsm Me 90 619774 Right 'MA' 355377 : "Phat Movie: *** "Red Eye" (2005) Rachel Movie: * 'The Return"(2006) Sarah Kingdom: Movie: *** "Rising Sun" (1993, Mystery) Sean Girlz"90 McAdams. 9[ 848519 Michelle Gellar. 90 743010 Max Connery, Harvey Keitel. C9 5841854 (MTf7) 97 66 97 97 The Real The Real The Real The Real Life of Ryan Life of Ryan Newport The Hills The Hills (N) Life of Ryan Newport Newport S orld'PG' World'PG' WorldPG Wrd'PG'P ' World'P 'PGWo'P' -Harb. 'PG'480382 331039 (N) Harb. Harb. N 71 Ultimate Tomado 'G' Sturgis: Hell on Wheels Cowboys of the Sea '14, L' Independence Hub 'G' Daytona Biker Rally 'PG' Cowboys of the Sea '14, L 1-1 5091045 'PG'5159942 5231590 5155126 5158213 6130381 PL2EX 62 : "Twelfth Movie: ***s "Sleepless in Seattle" Movie: *s "Picture Perfect" (1997) Jennifer Aniston, Movie: ** "The Third Wheel"(2002) "Mixed SNight; (1993) 24671855 Jay Mohr. (In Stereo) 9 51171687 Luke Wilson. 9 1555190 Nuts" c] '*F^ ^l 43 42 43 43 Mad Money 3523749 On the Money 1308313 Fast Money 4352233 Warren Buffett: The The Big Idea With Donny Mad Money 6658855 SBillionaire Next Door Deutsch FNN) 40 29 40 40 Lou Dobbs Tonight C9 The Situation Room To Be Announced 898229 Larry King Live 'PG' 90 Anderson Cooper 360 'PG' CC 884279 500687 709381 705565 fCiO T 25 55 25 25 World's Wildest Police Cops'14, V Cops '14, V Ocean Ocean Forensic Forensic Dunne: Power, Privilege & North Haunting _ _ _ Videos 'PG' [9 3614045 2873855 3144836 Force Forpe Files '14, V Files '14' Justice Mission Evidence S7 4 4Special Report (Live) 90 The Fox Report With The O'Reilly Factor (Live) Hannity & Colmes (Live) On the Record With Greta The O'Reilly Factor ) 44 37 4122328 Shepard Smith 90 9 1421294 90 1514958 Van Susteren 8109039 _ MNFlB 42 41 42 42 Tucker 8722382 Hardball CC 1418720 Countdown With Keith MSNBC News Live Predator Raw: The MSNBC Reports 8105213 Olbermann 1434768 1510132 Unseen Tapes 1520519 EPiN 33 217 33 33 Monday Night Countdown NFL Football Baltimore Ravens at Cincinnati Bengals. From Paul Brown Stadium NFL Football Arizona Cardinals at San Francisco 33 27_ 33 33 ZB3 602519 in Cincinnati. (Live) 9094067316 49ers. (Live) C 39239010 ESPN2 34 28 34 34 NASCAR College Football Live 2007 World Sedes of 2007 World Series of Baseball Tonight (Live) CC 4062923 The Contender 6551107 Now C 2452126 Poker 2520671 Poker 9253478 __I__ F 35 Final Score Ma ns on MLB Baseball Washington Nationals at Florida Marlins. From Dolphin Stadium in Inside the Final Score Best Damn Toughman 5 9 5 5F Deck (Live) Miami. (Live) 362872 Marlins Special (N) 927298 G 67 Personal Playing Leaming Top 10 The Golf Central Natalie My World The Turn Learning Personal Golf Central Lessons Lessons Center 3151126 Approach (Live) Gulbis 3520652 6329671 Center Lessons 136 3 1 36 136 Inside the Road-TOUR Tailgate Overtime (Live) Fishing Keys Portraits- Flatsmasters Series (N) Tailgate Overtime 17565 Gators BCS SRays1824_-p18294 ee 14478 Championship Year inrn. If you have a VCR with the VCR Plus+ fea- your cable channel numbers are the same as th. Mother should find new living arrangement ear. ANN Mom complains endlessly MAIl about my daughter-in-law, but takes full advantage of her hospitality. The other day, my daughter-in-law went to check on her and saw through t any- more, and no one else wants her to live with them. What do you suggest? - Burned Out in California Dear Burned Out If Mom is financially L. Dear Annie: Please settle a dispute between my husband and me. Several weeks ago, I surprised him with a 50th birthday party. It was very low key and in our back yard. Several of his friends gave him gifts. I handed him the addresses and thank-you IE'S notes for him to write out He .BOX stated that since he is now 50, he doesn't need to write thank-you notes, and furthermore, he did- n't ask for any of the gifts. He said it was enough that he thanked everyone in per- son for coming. I believe that you are never too old to write a thank-you note, and since he did- n't open the gifts in front of anyone, thank- ing them for coming isn't sufficient 1 man- ners, and they will be right DearAnnie: thera- pist and the first medications may not be the right ones. Keep looking. I suffer from recurring depression. The first time, I worked for two years in thera- py, rearranging the mixed-up furniture of my life. The second time, anti-depres- s. Annie's Mailbox is written by Kathy Mitchell and Marcy Sugar, longtime editors of the Ann Landers column. == Today HOROSCOPE Your Birthday: Chance could play a greater role than usual in the outcome of events. However, if you do all that you possi- bly can to achieve your purposes, you'll con- siderably cut down any poor timing that could upset things for you. Virgo (Aug. 23-Sept. 22) - Be careful that something you do doesn't thoughtlessly inconvenience another, just so you can have what you want. Libra (Sept 23-Oct. 23) - You could be tempted to exaggerate and stretch the truth a bit in order to make yourself look good. Scorpio (Oct 24-Nov. 22) - There are indications in your chart that you could be a bit wasteful where your resources are concerned Sagittarius (Nov. 23-Dec. 21) - Those who have to share the day with you will resent it if you're inconsiderate and too self-serv- ing.Capricom (Dec. 22-Jan. 19) - Make certain you are seeing your problems for what they really are. Don't overreact or view them through rose-colored glasses, or you'll have no way of working things out. Aquarius (Jan. 20-Feb. 19) - Engaging in the least expensive activities will prove to be most gratifying for you. Pisces (Feb. 20-March 20) - Something you're hoping to achieve depends a great deal on timing and luck. Unfortunately, today may not be the day that will offer you either, and factors could work against you instead. Aries (March 21-April 19) - You're too smart to believe everything you hear, so don't start now. Taurus (April 20-May 20) - Subdue your risk-taking urges, especially if they involve an outlay of money in hopes of scoring unrealis- tic gains. Gemini (May 21-June 20) - Although you know better, there is a strong possibility you may make an unwise decision, similar to one you made previously that didn't turn out well. Cancer (June 21-July 22) - Just because a certain philosophy suits someone else to a T doesn't mean it will fit your require- ments. Be your own person and don't try to imitate what is not right for you. Leo (July 23-Aug. 22) - Remain as thoughtful and gracious as you usually are in your social involvements, regardless of how another may be acting. Bad manners and poor taste are never attractive. Answer here: L . 1 -LI (Answers tomorrow) Saturda'sI Jumbles: FETCH NOVEL AGHAST NAUGHT y Answer: What she got when she dried her laundry outdoors - THE "HANG" OF IT ....-. - .-B... Bridge PHILLIP ALDER Newspaper Enterprise Assn. An opponent opens with four of a suit. What does it mean if you double? Traditional wisdom treated a double of four of a minor for take- out, a double of four hearts also for takeout but promised - nay, guar- anteed - four spades, and a dou- ble of four spades for penalty. Any pure penalty is not a good idea, because against normal play- ers you,-will not have a trump stack. A double of four of any suit should just say that you have too many points to pass and nothing better to do. You have anywhere from a classic takeout double - 4- 4-4-1 with a singleton in the open- er's suit - to a balanced hand with at least 15 points. How should partner react? iHe should pass with a balanced hand, or bid a long suit if he has one, con- fident that your dummy will con- tain some useful cards. In this deal, after West opens four clubs, you (North) have no choice but the double, hoping that partner does not bid four hearts on a five- card suit Here, South has a whop- ping hand and bids what he thinks he can make. Well, how should he plan the play in six diamonds after West leads the club king? 1 5 P 8 BE 12 \ 13 ( e 14 G 15 In 16 I 18 S 20 E ACROSS 38 Oohed and - 39 Rancid By - of hard 40 Sharp tool work 41 Lawn pest Pigment 43 Holly item Bubbly drink 46 Run into prob- Winged god lems (3 wds.) Gun the 48 Light beams engine 50 Between Great reptile 51 "I" trouble n- 52 Tenderfoot as found) 53 Southwest fea- vory source ture Summer wear 54 Decimal base Electric swim- 55 Rabbit dish mers 21 Provide help 22 Tattoo site 23 Carpet makers 26 Most arid 29 Jai - 30 Lofty 31 In the know 33 Hear clearly 34 Type of wrestling 35 Moon ring 36 Movie awards DOWN 1 Some, to Pierre 2 Late spring flower 3 - - chance! 4 Tidal wave 5 Apprehension 6 Shout 7 Festive night 8 Nefarious plan 9 Vaccine type 10 Grandees North 09-10-07 6 AK Q 5 V J 10 * K 6 4 4 A 8 5 3 West East 83 J 109 6 4 V K 7 V 8 6 5 4 3 2 * 10 + 5 2 4 KQJ109764 4 - South V A Q 9 * AQJ9873 4 2 Dealer: West Vulnerable: Both South West North East 4 4 Dbl. Pass 6 + Pass Pass Pass Opening lead: 4, K There are 12 top tricks: three spades, one heart, seven diamonds and one club. But if West has eight clubs for his opening bid, East must be void. So, South should play a low club from the board at trick one. And do the same at trick two if West continues with another club. Note that, with this layout, play- ing the club ace too early costs the contract. East ruffs, and South has an unavoidable heart loser. Answer to Previous Puzzle 11 Perform in a theater 17 Grave risk 19 Bad-mouth 22 The younger Guthrie GET MORE in the new "Just Right Crossword Puzzles" series from Quill Driver. Call 800-605-7176. 9-10 23 Drop behind 24 Ersatz butter 25 Horse feed 26 River blockers 27 Jahan was one 28 Linoleum square 30 Stomping ground 32 Bean hull 34 Hotel conveniences 35 Risks 37 Pina- 38 Citrus cooler 40 Inert gas 41 Say with gestures 42 Bluesman - Redding 43 Salary 44 Like a bow string 45 Jekyll's other half 46 Sandwich meat 47 Tennis court divider 49 Replace a button � 2007 bv NEA. Inc. THAT SCRAMBLED WORD GAME by Henri Arnold and Mike Argirion Unscramble these four Jumbles, one letter to each square, to form four ordinary words. I CILLA I MELTIG| I L CLAMBY I L^ L- 11 Now arrange the circled letters to form the surprise answer, as suggested by the above cartoon. Onus Couwy (FL) CHRoNicLE CITRUS Cbuiviy (FL) CHRONICLE C~Mrc S MoNIAY. SrI'IIjMBFR 10. 2007 75 Garfield For Better or For Worse Sally Forth Beetle Bailey The Grizzwells Kit 'N' Carlyle I'M HOPING TO FORM AN UNHOLY ALLIANCE WITH THE MILITARY INDUSTRIAL COMPLEX. ---- T WOUL� fes. 1 ROt-&556IAThL1 ------ Rubes _ LOOK MVVTRSW -7 SOMKE PEOPLE. PW (GOWt * ..,. , ;: Dennis the Menace The Family Circus "This is Car 17 ... am in pursuit of happiness ... I repeat, am in pursuit of happiness ..." Doonesbury Big Nate Dist. by King Featres, Synd. A i I//,- wwwJfamllycircus.comr n AW "Being tackled doesn't hurt as much when you've just intercepted a pass!" Betty Frank & Ernest Citrus Cinemas 6 - Inverness Box Office 637-3377 "3:10 to Yuma" (R) 1 p.m., 3:50 p.m., 7:20 p.m. Digital. "Halloween" (R) 1:10 p.m., 4 p.m., 7:30 p.m. "Balls of Fury" (PG-13) 1:30 p.m., 4:15 p.m., 7:45 p.m. "Superbad" (R) 1:15 p.m., 4:20 p.m., 7:40 p.m. "Rush Hour 3" (PG-13) 1:40 p.m., 4:25 p.m., 7:505 p.m. "The Bourne Ultimatum" (PG- 13) 1:20 p.m., 4:10 p.m., 7:15. Visit for area movie listings and enter- tainment information. Times subject to change; call ahead. Arlo and Janis Peanuts Cathy Dilbert I'LL NEED MORE THAN TALL PANTS AND TRADITIONAL LOOKING HAIR TO GET ELECTED PRESIDENT. Born Loser 7CRIU~, WT5 fK.E N $A.Ut'NkIM TRF- WZE.- ROUSEI CNN'S I U 0 O~NF-MCOtAN- > INNwIe'% . ~'Ol~tN\1NT0~(?A. Today's MOVIES CELEBRITY CIPHER by Luis Campos Celebrity Cipher cryptograms are created from quotations by famous people, past and present. Each letter in the cipher stands for another. Today's clue: X equals G "IVLS FNO' H L KS C MZOPT, KR' M CZPNMR CM KD FNO ZN NA NOR CR RVL DKLZE CSE KR'M NSL YKX XZNJ L. " - YCM LYCZZ' M JCSG L ZCI PREVIOUS SOLUTION - "Life seems to be divided into two periods: in the first we indulge, in the second we preach." - Will Durant (c) 2007 by NEA, Inc. 9-10 I MONI-)oAY, SEPTEMBER 10, 2007 703 Cimus CouNiy (FL) CHRONICLE COMICS The I R To place an ad, call 563-5966 8B MONDAY, SEPTEMBER 10, 2007 Classifieds In Print and Online All The Time * ~ ~ ~ ~ a A, IL V. Wq 0S--, 1,. - Fa: 05)063565 eTllFre:(88)85-240 1 mal:clssfidsfi onclon*n cm w0ste w w hrnilenlneco 24 yr. Old Hispanic Male Seeking Female 120-140 lbs. Age 22-30. For Movies & Companionship (352) 257-5513 MIDDLE AGED MAN would like to meet lady for dining & dancing. Call (352) 382-5661 -C RENTAL FINDER rentalfinder.com $$CASH WE BUY TODAY Cars, Trucks, Vans - rt FREE Removal Metal, Junk Vehicles, No title OK 352-476-4392 Andy Tax Deductible Receipt I TOP DOLLAR I l For Junk Cars $ (352) 201-1052 $ � $$ CASH PAID $$ Having Code Enforcement problems w/ Junk vehicles in your yard? (352) 860-2545 F - I $ CASH $ I PAID FOR | I Unwanted I 352-220-0687 I Cat female, 2 yrs. old Free to good home (443) 452-7163 COMMUNITY SERVICE The Path Shelter is available for people who need to serve their community service. (352) 560-6163 or (352) 746-9084 Leave Message COMPUTER DESK 'Computer desk w/printer "stand. Blck & gray. Like I new. 352-637-0194 FREE AD SPECIAL free kittens wormed, and litter box trained grey, or- anges, whites, short and long hair. 352 563-0493 FREE KITTENS To good homes, 3 males, 3 females, black/ white or grey, tabby mixed, 8-10 wks old. (352) 476-0271, after 5. Your World CH ONICI ww chronicleonline coam FREE KITTENS To good home. 352-341-1352/476-3776 LEAD FOR SINKERS FOR BULLETS, 4 SHOT Free you pick up (352) 344-9073 PIT BULL/MIX? Large male/ To good home w/ Ig yard /time to spend. 352-212-1131. TABBY CAT Female, 4 yrs., spayed, declawed. all shots. Loving & ,playful. Fearful of other animals. (352)634-4350 The Path Shelter will pick up your unwanted vehicle Tax deductible receipt given (352) 746-9084 $ $ CASH PAID $ $ Junk Cars, Trucks, Vans No Title OK, Call J.W. (352) 228-9645 WHITE TERRIER MIX Male, Vic. Colby St, Inverness. 9/4, (352) 257-2639 Yorkie, silver, 25 Ibs, Beverly Hills (352) 249-0860 Cell 476-1113 BLACK LAB MIX APPROX. 1YR YEAR OLD, WHT. UNDERSIDE, loveable. Found Gulf & Cherrywood St. Crystal River. (352) 220-6199 Cat female, gray & white Pine Ridge Area (352) 746-7531 Dog Boxer type puppy, found in Wildwood (443) 452-7163 Your world first Need a job or a qualified employee? This area's #1 employment source! CHRONICl Classifieds awagSSESomS"P14 ZLi7CS6 T Z 9 981 kZ'LSE6 81IL96ZE-1S EseLt'T698 179--6 "8 E "I LZ-TLZ ZZ86TS -SV6 S t Z9 E-Z 8 Sudoku *. 4puz.com 8 362 9 8 1 25 7 31 7 11 -64 9 2 3 5 4 _ T8 - -- -- - -- - 93 2 9 85 4 Fill in the squares so that each row, column, and 3-by-3 box contain the numbers 1 through 9. CAT ADOPTIONS r-U� D "DIVORCES BANKRUPTCY I -* Name Change * Child Support I Wills SWe Come To You BUY or SELL! Receive Quality Customer Care! FLRealEstateSale.Com TERI PADUANO, REALTOR C21 JW Morton (352) 212-1446 Hablo Espanol FREE Home Warranty & Visual Tour ON ALL MY LISTINGS FLORAL DESIGN CLASSES All Holiday, wedding & funeral designs. (352) 400-4912 < Act N101 RENTAL FINDER rentalfinder.com * SOD * SOD * SOD- BANG'S LANDSCAPING Sod, Trees, Shrubs (352)341-3032 MR CITRUS COUNTY REALTY i. . - ALAN NUSSO 3.9% Listings INVESTORS RESIDENTIAL SALES COMMERCIAL SALES (352) 422-6956 ANUSSO.COM OFFICE HELP Individual with good phone & people skills, organized & able to multi-task. Quickbooks exp. pref'd, good computer skills in a casual work environ- ment. Email resume to: careerincltrus@ yahoo.com HAIR STYLIST Teera's Hair Salon, Beverly Hills. (352) 527-6600 tiM .1 ptr ,.-iF..-,w .4I i .. l and read 1,000's of Items sold everyday using the Chronicle classified. Call today and we'll help you get rid of your unwanted stuff. CQilONiiE 61P (352) 563-5966 (352) 726-1441 A free report of your home's value livlng.net Boost Traffic.To Your Website Chronicle Website Directory in print and online. Our search engine will link customers directly to your site. In Print + Online = One Price $51.95 (3 lines of copy for 30 days) I Header and Website Address Call Today: (352) 563-5966 wheels.com Free Sample NEWSPAPERS online.com REAL ESTATE homefront.com RENTALS rentalfinder.com L-E PRE SCHOOL TEACHER & SCHOOL AGE TEACHER F/T or P/T Experience required CDA preferred TODAY'S CHILD or TADPOLES (352) 344-9444 (352) 560-4222 EXECUTIVE PERSONAL ASSISTANT Reception exp. is a plus. Must have reliable transportation. (352) 341-5425 LPN For Dr's office in Homa. Sprngs. Gd. sal. & ben, Fax resume to 1-727-841-9848 or call 1-800-573-0123 r ..... LPN MDS NURSE Position requires a reliable positive team player. Mail or Fax Resume: SAlt: Laurie Coleman 136NE 12thAve. Crystal River, FL 34429 OR FAX RESUME to: (352) 795-5848 CONTACT Laurie Via Mail or FAX ONLY!! DFWP/EOE LPN NEEDED Must have strong computer skills for clinical research position. Research experience desirable. Please call (352)563-1865 or email rwood@encore 35260-088*5 C1 8.3 . .. 7o NURSES 3-11, 7A-7P, & 7P-7A WEEKEND FLEX SHIFTS so HR/Connmie (M, T, Th. & F 9-3) DFWP/EOE Office Needs Person That has Experience Assisting Doctor. Must give injections, draw blood, EKG and have some front desk exp. Send Resume to: Citrus Co. Chronicle Blind Box 1370M 1624 N. Meadowcrest Blvd., Crystal River Florida, 34429 Orthopedic Exp'd SURGICAL SCHEDULER LPN/MA Orthopedic Practice. Fax resume to: Nettie (352) 746-0333 RECEPTIONIST/ BILLING MANAGER Needed for medical office. Exp. preferred. Fax Resume to 352-489-6920 Registered Nurse Allen Ridge Family Care Center We are currently seeking a Registered Nurse for our fast-paced family medical care center located in Lecanto, FL, Responsibilities include, but not limited to, the delivery of patient care through the use of the nursing process of assessment, planning. Implemen- tation and evalua- tion; participating in Quality Assessment and Improvement and integrates appropriate recommendations into the provision of patient care. Ideal candidate must be a Registered Nurse with current licensure by the State of Florida. Department of Health Division of Quality. Assurance. Previous clinic experience preferred and Basic Cardiac Life Support within 30 days from hire. Please apply online at CMHS is an equal opportunity employer S ALL STAR I SERVERS BANQUET CHEFS & LINE COOKS Needed Please apply at: 505 E Hartford St. Hernando or Call (352) 746-6855 $$ GOT CASH $$ Earn great money by setting appts. for busy local company., Call Steve: 352-628-0187 EXP. SALES PERSON Needed, company car & commission + pay Mon- Fri. 9 - 5 Call (352) 795-0949 VILLAGE SELECT APPLICANTS WANTED Village Cadillac Toyota/Scion is looking for motivated, confident self-starters with outstanding work ethic. Unlimited Income Potential. Extensive training seminar by the #1 Sales School. We offer: * Paid Training * Best Pay Plan in Area * Blue Cross/ Blue Shield * 401K With Employer Contribution * Paid Vacation * Dental Plan * Promotion from within No experience necessary. Please apply in person at: Village Cadillac Toyota/Scion 2431 S. Suncoast Blvd. Homosassa We are a Drug Free Workplace EXPERIENCED ASPHALT MAN SEAL COATING & STRIPING HELP CDL Lic. (352) 563-2122 Immediate Work EXP'D. ROOFERS NEEDED Commercial & Resi- dential Crews. Must have valid Driver's lic. & willing to work, (352) 341-3921 INSTRUCTORS WANTED HEAVY EQUIP. OPERATOR SCHOOL Located in Lecanto Patience, punctuality, ability to work w/ other instructors, min, 3 yrs. exp. in Construction required, Training provided. Fax Resume to 352-628-7686 and or email atsmary iayahoo.com $$ GOT CASH $$ Earn great money by setting appts. for busy local company. Call Steve @ 352-628-0187 Appoint. Setter Will Train, Top Pay 352-726-1002 GRIMALDI'S Exp. Irrigation and Landscape Person FI. Driver Lic. Required Apply in Person Mon - Fri., 12-4pm ONLY KENNEL & BATHING HELP Part to full time, Fax Resume to: (352) 795-4640 Maintenance Person Handyman, electri- cal, refrigeration, plumbing, pneumatic systems exp. a plus On call 24/7 Work van/gas included (352) 629-6917 MAINTENANCE Person Needed Apply in Person TRADE WINDS MARINA & RESORTS 10265 W Fishbowl Dr. Homosassa OPPORTUNITIES FOR A NEW CAREER! Stanley Steemer Will train, FT, benefits. Must have FL Driver's lic. and be at least 21yrs of age. Drug Free. Apply at 911 Eden Dr., Inv. SALES REPS FOR SPRINT SINGULAR Kiosk in Wildwood Salary + Bonuses/ Benefits. 1-877-424-4737, ext. 5737 staffing@icrocks.com Earn extra income after taking course Flexible schedules, convenient locations. Courses start in Sept. Call S877-766-1829 Liberty S Tax Service SFee for books. CAREGIVER Paralyzed man. Re- sumes, ref. to PO Box 1615 Hoam. Spgs. 34447 Maintenance Honest, dependable Hard worker needed in Crystal River PT/flexible hrs. 30 min/day. $200/month. Great for retirees. Vehicle req'd Call M-F 813-888-9222 Youir'world first Need a job or a qualified employee? This area's #1 employment source! C CalpNicE Classifieds 15WIRH~LIil Yard/Gen. Maint. Part time, Yard & Home Repair CALL (352) 522-1109 after 7pm Only, Cit. Springs [-jl F " l l" lMl" " -- T.-- , NOW HIRING LOCALLY Large national organization. I Avg. Pay $20/hr. Over $55K annually. Including full benefits & OT, paid training, vacation. I S F/ & P/T 1-866-515-1762 ESTABLISHED SALON FOR SALE. Exc. location. 352-341-5043 or 352-212-0514/637-5078 LAWN BUSINESS & EQUIP. FOR SALE Steady year round income (352) 628-4500 Pool Route, Hernando net $84K + year, will train, & guarantee accounts $67K FP Broker (877) 766-5757 poolroutesales.com COMMERCIAL LOANS Prime, Sub-Prime, Hard Money, REHAB, Private. Also, equip, loans. Mark (352) 422-1284 ALL 5.TIL BUILUINGSP BARBER'5 CHAIR "Emil J. Paidar'. Chicago. Over 75 yrs. old. Access. Good to Exc. Cond. $1,250 obo 352-746-5077 $$$$$$$$$$ $1500.00 Sign on Bonus! LICENSED NURSES 11-7 (M, T, Th., & F 9-3) DFWP/ EOE CERT. DENTAL ASSISTANT Must have experience with Radiology & Expanded Functions. Please contact: Peggy or Vicky @ (352) 746-0330 EARN AS YOU LEARN CNA Test Prep/CPR Continuing Education 341-2311/ Cell 422-3656 Licensed Practical Nurse/Certified Medical Assistant Allen Ridge Family Care Center We are currently seeking an LPN/CMA for our fast-paced family medical care center located in Lecanto, FL. Ideal candidate must have previous physician office experience to be responsible for performing EKGs, PFTs, vital signs and phlebotomy. Will also assist the physician and be responsible for front desk duties. Must be a Licensed Practical Nurse with current licensure by the State of Florida, Department of Health Division of Quality Assurance; or Certified Medical Assistant. Please apply online at CMHS is an equal opportunity employer S 86 6_1 CLASSIFIED CITRUS COUN'IY (FL) CHRONICLE CITRus COUNTY (FL)) CHRONICIISR bn nfiHole� LjAplia "LIVE AUCTIONS" For Upcoming Auctions 1-800-542-3877 A/C & HEAT PUMP SYSTEMS. 13th SEER & UP. New Units at Wholesale Prices - 2Ton $780.00 2-/2 ton $814.00 * 3 Ton $882.00 *Installation kits; *Prof. Installation; *Pool Heat Pumps Also Available Free Delivery! Call 746-4394 ABC Briscoe Appliance Refrigerators, washes, stoves, Service & Paits (352) 344-2928 AC SYSTEMS HEAT PUMPS, MH UNITS ALL SIZES, 13 SEER, FROM $475. 352-400 4945 ELECTRIC STOVE 20 , 4 BURNER, perfect for small mobile, caLtn or camper $100 (352) 613-3503 KENMORE WASHER & DRYER, Series 80, HD, super capacity+ White, works we'l $100/pr. (352) 220-6414 REFRIG. & STOVE MATCHING Ceramic top, almond. Freezer on lop, $300/both (352) 746-0243 REFRIGERATOR 21 Cu. Ft. Fridgidaire; Almond. Runs good $25 SECTIONAL SOFA 4 rnajor pieces $150 (352) 726-7421 Kenmore Dishwasher, like new $75. obo (352) 637-2725 REFRIGERATOR Frigidaire, 18cu. ft. , w/ ice maker excel cond. $235./obo. (352) 637-4645 REFRIGERATOR Side By Side, Kenmore Ice & water in door. GE Smooth Top RANGE w/self-cleaning oven MICROWAVE, GE Above Stove. $750/all0 OB (352) 341-5247 ROPER BY WHIRLPOOL REFRIGERATOR Freezer on top. White, like new, less than yr old. $450 (352) 476-9527 used, Snowbirds. $300. (352) 344-3485 "LIVE AUCTIONS" For Upcoming Auctions 1-800-542-3877 SOUTHERN AUCTION MARKETING & APPRAISAL AUCTION Every Monday Night 7:00 PM Super nice 1994 Ford Explorer, Unique German oak dining table & hutch, Salt/fresh water rods, reels, lures... Pics at #4341 15991 NE Hwy 27 Alt. Williston, FL 352-528-2950 Col. Joel Kulcsar AU1437-AB2240 10% BP on all sales - - rIo7IL II Your '. world fl'r-,i Ci I1 N( I I. E . [ CA * custorner must call each month to reschedule. L i --i - m I Cl-ASSFIY--" udigo -Suolie 8 PC. PATIO SET w/Tea Cart $550 Like New' (352) 613-4891 PVC Love Seat sling is off white w/ 2 mauve cushions, $50. (352) 257-1478 5 PC. BEDROOM SET $375. DESK $50: (352) 628-5924 9 PC. LIVING RM. SET Good Cond. $250; YOUTH BED White Heavy Plastic. Good Cond. $40 (352) 628-4210 Bassett Sofa Sleeper, green black, new cond. $250. obo 8 Pc. Patio Set, neutral $250. obo (352) 382-4757 BEDS ,* BEDS *. BEDS The factory outlet store! For TOP National Brands Fr.50%/70% off Retail Twin $119-:. full $159 Queen $199 / King $249 Please call 795-6006 s70915 A/C Tune up w/ Free permanent filter + Termite/Pest Control Insp. Lic & Boned Only $44.95 for both. (352) 628-5700 caco36870 ADVERTISE YOUR BUSINESS IN THE SERVICE DIRECTORY TODAY! $$$$$$$$$S$$$$$$$$$ Its Less than Pennies per day per household. $$$$$$S$$$S$$$$$$$ IF WE DON'T HAVE YOUR BUSINESS CATEGORY. JUST ASK. WE CAN GET IT FOR YOU!!! CALL TODAY (352) 563-5966 "DEBRIS HAULING" & Misc. Clean-Up, Tree Service & Demos 352.447-3713/232-2898 55' BUCKET TRUCK 20% off, mention of this ad. Lic. & Ins. (352) 344-2696 IF - � =---m al AFFORDABLE, HAULING CLEANUP, I PROMPT SERVICE STrash, Trees, Brush, Appl. Furn, Const, I I Debris & Garages 1, ins.& Lic #0256879 352-341-6827 F TREE REMOVAL . Stump grinding, land I Clearing, bushhog. 352-220-5054 L mm am ow m m 0M A TREE SURGEON Lic. & Ins. Exp'd friendly serv. Lowest rates Free estimates,352-860-1452 All Computer Repairs We come to your home or office. 21 yrs. exp. 7 days (352) 212-1165 Computer Pro, Lw Fit RI. In-House Networking, virus, Spyware & morel & ODp JOBS. 30 yrs J. Hupchick Lic./Ins. (352) 726-9998 POPCORN CEILINGS PAINTED Free Estimates (800) 942-3738 * RUDY'S PAINTING * Int./Ext., Free Estimates Pressure Wash., Lic./Ins. 24/7, (352) 476-9013 ROOIN Boulericeg CCC0254G4 QG002180 & SUPPLY INC. Family Owned & Operated NEW ROOFS - REROOFS - REPAIRS FREE ESTIMATES ! i - - - - - - - - - - - - - - - $10 OFFS '-- -- ----- (352) 628-5079 * (352) 628-7445 BIII S.l L S^ Willie a ruiiiiiny x Pressure Cleaning ,,--. n-tl I c- . &,s n a Is. Anoiacae Bot Miant. & Repair, Mechanica,Electricd, Custom Rig. John (352) 746-4521 DOCKS, SEAWALLS, Boat Lifts, Boat Houses, New, Re decks, Repair & Styrofoam Replace.L Lic.CBC060275. Ins. (352) 302-1236 BATHTUB REGLAZING Old tubs & ugly ceramic tile is restored to-, newco nd.Allcols FREE COEiVIMiTO FREE P.U. & DELIVERY Furniture & Cornices 628-5595 1 Call does it AllI 0 Infants Welcome ft = 352-726-5163 � Vdriveways. 25 yrs exp. Lic./ns. 341-3300 * ROLAND'S * PRESSURE CLEANING Mobiles, houses & roofs Driveways w/surface cleaner, No streaks! 24 yrs. Lic. 352-726-3878 Willie's Painting & Pressure Cleaning Great Rates! Lic. & Ins, 527-9088 or 634-2407 Ultra Seal Coatings Specializing in roof and concrete sealing * Vinyl & Stucco Sealing * Pressure Washing * Designer Driveways * Pool Decks ' Summer Special ', Roof cleaned 1450� 713926 352-628-1027 A# 1 L&L HOUSEHOLD REPAIRS & PAINTING No job too small! 24/7 LIc3008 352-341-1440 AFFORDABLE, HAULING CLEANUP, I PROMPT SERVICE STrash Trees Brush Appl, Furn, Const, I Debris & Garages | 352-697-1126 ALL AMERICAN HANDYMAN Free Est. Affordable & Reliable Lic.34770 (352)302-8001 FAST! AFFORDABLE! RELIABLE! Most repairs. Free Est., Lic # 0256374 (352) 257-9508 HANDYMAN If its Broke, Jerry Can Fix It. Lic#189620 352-201-0116,726-0762 Hauter & Clark Handyman & More Home, Office & Floor Cleaning, Lawn Serv. Pressure Washing, (352) 860-0911 NATURE COAST HOME REPAIR & MAINT. INC. Offering a full range of services. Lic.2776/Ins. (352) 628-4282 Visa/MC STAYLER AC & HEATING, INC. Lic. & Ins, CACO 58704 352-628-6300 FULL ELECTRIC SERVICE Remodeling, Lighting, Spa, Sheds Lic. & Insur. #2767 (352)257-2276 Poe's Sewer & Drain Cleaning, We unstop toilets, sinks, bathtubs, 24/hr serve 352-302-7189 "DEBRIS HAULING" & Misc. Clean-Up, Tree Service & Demos 352.447-3713/232-2898 AFFORDABLE, I HAULING CLEANUP, I | PROMPT SERVICE Trash, Trees, Brush, Appl. Furn, Const, I Debris & Garages | 352-697-1126 N A-I Hauling cleanup, garage clean outs, trash turn. & appl. Misc. Mark (352) 344-2094 All of Citrus Hauling/ Moving items delivered, clean ups.Everything from A to Z 628-6790 C.J.'S TRUCK/TRAILERS Furn., appl, trash, brush, SLow $$$/Professional Prompt 7 day service 726-2264/201-1422 Furn../Cornn. FENCES BY DALLAS Lic./Ins (352) 795-1110 3rd GENERATION SERV All types of fencing, General home repairs, Int/Ext. painting FREE Est., 10% off any job. lic # 99990257151 & Ins. (352) 201-0658 Roof Cleaning Specialist The Only Company that can Keep Mold & Mildew Off Siding - Stucco - Vinyl- Concrete Tile & Asphalt Roofs GUARANTEED! Restore * Protect *Beautify - Residential & Commercial w Suncoast SExterior Restoration Service Inc. S877-601-5050 o 352-489-5265 1w - * S1,. to Serve You. cccT1325492. 795-7003/800-233-5358 RE-ROOFS & REPAIRS Reasonable Rates!! Exp'd, Lic, CCC1327843 Erik (352) 628-2557 All Tractor/Did Service Land Clear, Tree Serv., Bushhog, Driveways & Hauling 302-6955 BIANCHI CONCRETE Driveways-Patios- Sidewalks. FREE EST. Lic#2579 /Ins. 746-1004 Concrete Slabs, Pavers Remove & Haul Debris Demolit. 352-746-9613 Iic# CRC 1326431 CONCRETE WORK. Sidewalks, Driveways Patios, sabs. DOTSON Construction 25 yrs. in Central FL. Our own crews! Specializing in additions, frarning, trin, & decks, Lic, #CRC1326910 (352) 726-1708 ALL AMERICAN HANDYMAN Free Est. Affordable & Reliable Lic.34770 (352)302-8001 We do It ALL! Big or Sm.! Additions, BA & Kitch., Drywall,Crown molding, Demo. CRC1326431 (352) 746-9613CC A Screened, no stones, 10 Yards $150; 20 Yards $250 � 352-302-6436 All Tractor/Dirt Service Land Clear, Tree Serv., Bushhog, Driveways & Hauling 302-6955 r---- LANDCLEARING I Site prep, Tree Serv., | Dump Truck, Demo 352-220-5054 w 352-464-3967 n A POOL LINERS! A" * 15 Yrs. Exp. * Call for free estimate � (352) 591-3641 i POOL REPAIRS? Comm. & Res., & Leak detection, lic. 2819, 352-503-3778, 302-6060 WATER PUMP SERVICE & Repairs on all makes & models. Anytime, 344-2556, Richard "DEBRIS HAULING" & Misc. Clean-Up, Tree Service & Demos 352.44i-3713/232-2898 Availablel!. Lic. & Ins. 352-860-0714 F ----- " " E ALL EXTERIOR I ALUMINUM S Quality Price! S6" Seamless Gutters SUc & Ins 621-0881 L --n -- RJ NEED A NEW DOOR? Pre-Hung Door units New Const. or remod, ENTRY POINT by Perry's Lic. 2598(352)726-6125 Gopher Gully Sod Inc. Farm Direct Rolls Sod Installation Seeding & Mulching 352-812-4345/817-4887 Ideal Carports Custom Build Your Dream * Carport Garage * Boat * Barn * Any Metal Bldg. I hati er e ou need, N;e've got you covered" 352-795-6568 7958 W. Gulf to Lake Hwy., (Hwy. 44) Crystal River IWW idea Ica *r[ ot 11]0lm Vacuum Leaves & Thatch, Tree Trimming (352) 637-3810 or (352) 287-0393 FREE ESTIMATE Licensed & Insured CIRCLED SOD FARMS INC. RESIDENTIAL & COMMERCIAL INSTALLATIONS Travis Leturno * Larry Leturno Lic. & Ins. Fax. 352-628-5552 352-400-2222 Larry 352-400-2221 New & Re-Roofs * Flat & Low Pitch - Roof Repairs* Commercial * Residential Shingle - Metal - Built Up Roof Torchdown - Shakes S n-is. It..all I I -x i o ns (352) 628-2557 Lucksroof.com Roof Inspections Available Drug Free Workplace Stale Certified Lic #CCC1327843 SEPTFMBER 10, 2007 9B 9-10 ' LiughmngS:ock International Incidist by United Media. 2007 "Use your fingers." I I Call (352) 563-3209 or (3,52i 56;1!.32-06,Tq Place Your, Ad! 0, A l0B MONDAY SPTEMI3ER 10, 2007 -- T ^B II PRE OWNED FURNITURE Unbeatable Prices NU 2 U FURNITURE Homosassa 621-7788 CITRUS HOME DECOR @ Wal-Mart Plaza, Consignment, like new furniture (352) 621-3326 Console table, w/2 drawers, 58" x 30" x 16. $75. Glide rocker, w/ maroon cushions, $100. (352) 527-4634 Couch & matching chair & ottoman, $350 Antique Grandfather clock, solid walnut, $700 (352) 637-1321 Couch, blue contemporary, $200 obo Entertainment Center Black, w/ lights $200. abo (352) 302-7985 COUCH, Flexsteel, like new, mauve & cream must see! $485; SWIVEL ROCKER Mauve, Sound low back, like new. $85 352-382-3269 DINING RM. SET 8 upholstered chairs, 7' table w/leaf & glass top. $200. (352) 527-9876 DINING ROOM SET 6 upholstered chairs (includes 7 yards matching fabric) table & hutch, Whitewash. $475; 352-382-7553 401-474-0089 ,ENTERTAINMENT CENTER 78" HX 34"W Oak. Exc. Cond. $85; SLEEPER SOFA Comfy, Like New $195 (352) 422-3190 Dining Table w/ 6 chairs, $125. obo, 836 Great Pine Pine Pt. Inverness Sat. & Sun. Only (352) 220-9011 Leaders Rattan Dinette 42" tbl, 4 Chrs w/ cast- ers, 2 matching bar stls, soft med. blue cush. Orig. $1,400/Sell $650 Like New Cond. (352) 527-2327 Leather Chair and Ottoman, Ashley, paid $1,500. will sacrifice $650. Coffee & end tables wood w/ stone top $500. for both, new, excel. cond. (352) 422-1909 MOVING SALE Furn, Toshiba 36" TV, Comp. desk, stereo sys. Workbench, Router, Porch furn 352-726-7159 New Tiki Bar All Bamboo w/ 2 bar stools, must sell $150. (352) 621-0300 PAUL'S FURNITURE Open for New Season Beginning Tues Sept 11 Shop while It's cooler In the mornings. Tues-Sat. 9a- I p Turn at Paul's sign on Graver Cleveland to Holiday St. Homosassa 628-2306 Preowned Mattress Sets from Twin $30; Full $40 Qn $50; Kg $75. 628-0808 Queen Serta Bedding Set, very clean, w/ frame linens, skirt, matching comforter & curtains, $400. (352) 212-0013 -----m - RENTAL FINDER | rentalfinder.com SLEEPER SOFA S Blue Cloth $150; TILE Mural Kitchen Table (Beach/Shells) w/4 Wh. Chairs $195 (352) 637-0440 Wh. WICKER/RATTAN Loveseat, 2 Chairs & Table. $175; WROUGHT IRON CHAIRS (4) White w/cushions, $100/set (352) 637-0440 2 Hustler commercial mowers and 18Ft utility trailer, 6 m ord. Loads $95 Deliv'd. Citrus Co. Gravel $75 + Materials. 352-563-9979/400-0150 -U "LIVE AUCTIONS" For Upcoming Auctions 1-800-542-3877 BLUE MOON RESAIL 272 NE 3rd St Crystal River. Now accepting High End Fashions & Accessories, home decor items, unique & trendy home furnishings. Buy/Sell/Consign. (352) 795-2218 FAct Now -* * * ** I Scrub Tops for Health Care Workers, Like new large & X large, 5 for $25. 352-621-3697, 5 PC. PATIO SET Table w/4 swivel rockers & rug. $250; PET WINDOW 8 mo. old. Fits MOST windows $100 (352) 382-2076 serve. for Mobile Home. $300/obo (352) 400-1424 Approximately 300 Concrete Blocks 8x8x 16 $250 for All (352) 726-3093 BEER MAKING EQUIP. Everything you need to make & bottle your, own beer. $100. (352) 746-3508 BURIAL PLOTS in Fountains Memorial Park - Fountains of Life: Two spaces $1050.00- 628-1062 BURN BARRELS Heavy duty wl out tops $7.50 EA (352) 344-9752 HIDE-A BED SOFA Floral Print, Exc. Cond. $175; Lg. Husky Toolbox w/Craftsman Tools $350 OBO (352) 613-4891 MANATEE ART & CARVINGS $250 (352) 563-0022 MASSAGE TABLE Professional & Stationary; Good Cond. $150 (352)746-5077 Mattress Set, Simmons, queen, clean $125. Computer Monitor, flat scrn,, NEC, 19" Analog, $45. (352) 465-2853 ft tall, umbrella Tree $19. (352) 422-3190 REAL CLOWN ITEMS Hats, Shoes, Wigs, Jackets, Clothes. $150 all or will sell separately. (352) 382-1191 rKLrUMI"I IMNIII 250 GAL. $275.00 352-795-6693 2 Port A Pottey $22. ea. (352) 382-1628 2 Wheel Chairs $65. & $90. (352) 382-1628 ASTHMA/POLLEN/DUST Breathing problems?. Cloud 9 Sterile HEPA Filter Air Purifiers, exc. cond. 3.Cost $1485.00 Sell (3) w/filters $300 cash (352) 344-9073 Hospital Bed Like New $850. (352) 212-2733 Hoveround Power wheelchair, 2 yrs old, elec., exc. cond., $600 Handicap ramp, fold- ing, for van never used, $250. (352) 344-3032 BUYING US COINS Beating all Written offers. Top $$$ Paid () 5 228-7676IOlO Flute, Bundy/case, $65. excel. cond. for into/see (352) 795-0636 Piano, Wurlipzer $850, Guitar, Honer/Case $250. All in excel. cond. for info/see (352) 795-0636 Wurlitzer Piano $500. (352) 344-4204 Leave Message Health Rider, Elliptical Machine, $80. Power 9.0 advanced sculpt circuit DVD $10. (352) 746-3615 PRO-FORM 520X TREADMILL, sell as is $100/obo Working condition. Will need console board. (352) 249-1118 SEARS FORM J-6 Space saver, $125; (352) 637-0560 ANTIQUE COLT Pocket Revolver 22 Cal. Brass Frame $600 (352) 628-7818 BERETTA 22 Semi-Autoc. Exc. Cond. $375 (352) 637-7150 ELLIPTICAL TRAINER Pro Form 160 Almost New! $300 OBO (352) 201-9538 EVERLAST BOXING GYM HEAVY & SPEED BAGS $125 352- 287-9847 Folding Bicycles, like new $75. ea. or $100 for pair $250. ea. new, great for travel & RV's (352) 208-4428 Golf Cart, 2001 EZ -Go, 4 seats, Exc cond, $3500. (352) 249-1031 L/M POLARIS 800 Low hours '06, $4500 (352) 302-1861 WE BUY GUNS On site Gun Smithing (352) 726-5238 WEIGHT SET Bar, numerous weights & bench. Also separate slant board for crunches. $100/all (352) 621-0848 C4 tiit do raierst 6 x 12 V Nose Enclosed Dual Axle w/brakes. LED lights, more. 2006 Carry On. $3,500 (352) 382-1804 8 X 14 Single Axle HD Utility Trailer w/ramp gate & 3' sides. Bed is 6 X 10. $700 OBO (352) 634-1674 '02 ENCLOSED Trir 5x10, New tires, $1200: 4X8 UTILITY TRLR 15" tires, $200. 795-4770 CAR HAULER Dbl Axle, Steel Deck, ramps. Spare tire and winch, $1495. 352-228-2608. Equipment Trailer $800. Sell or Trade (352) 382-3642 Dachshunds Must Sell Moving (352) 621-4553 Act N(m oayed $25 Dog Neutered & Spaved start at $35 Low cost shot clinic Tues, Weds & Thurs 1st & 3rd Saturdays 10am-4pm (352) 563-2370 MASTIFF, English Male, AKC, 15 mos. Big Boned Beauty! Pick of the litter! MUST SELL! $800 (352) 621-0848 MINIATURE HORSE 7 Mos. old Mare, very sweet & gentle $400. obo (352) 795-7513 PIT PUPS (8) BLACK Gorgeous/Reg. Phatt Head Colby Villains. Simply the best! $150 (352) 621-0268 ROTTWEILER Male, 14 mos. AKC, in tact, beautiful dog. Pick of litter. MUST SELL $500 (352) 621-0848 SCOTTISH TERRIER AKC REG. Gorgeous, Male. 22wks old. Mov- ing, must sell. 1st $450 firm. 352-422-5685 SHIHTZU, BIk. & White 4 2. Farrier, Richard Iversen (352) 628-9186 6 BDRM HUD $54,000! Only $429/mol 5% dwn. 20yrs. at 8%, For listings 800-366-9783 Ext 9845 1BR Furn. Carpt Scrn rm. $550: 1BR unfurn. $400 1 BR RV furn $325. No pets. 628-4441 3/2 $214/mo HUD Home 5% down 20yrs at 8%apr. For listings call 800-366-9783 Ext 5704 CRYSTAL RIVER 1 BR Sm. Trir., Free Electric, Satellite, fncd, No pets/No smoking. $150/Wk. or $550/MO. $250. dep 352-563-1465 C A= M o ie H me+ st st. sec 352-746-6477 HOMOSASSA 2 BR, CHA, no dogs $550 mo. 1st, last, sec. (352) 628-4002 HOMOSASSA 2/1 DW, CHA, Carport, two sheds, pool,screened porch. 625.00 257-9314 or 503-3681 HOMOSASSA Near Hwy 19 352-634-2368 HOMOSASSA Sm. Mobile, suitable for 1 person, adult park, $300, mo. $150. sec. No pets. (352) 628-6188 INVERNESS 2/1 On Water, $450. 1st last $200 sec. 352-697-1359 INVERNESS 55+ Lakefront park Exciting oppt'y, 1, 1st, BUY AT INVOICES All 2007 Horton/Dynasty Models @ Invoice. Modular & Manufactured. New Cape Cod Modular Was $163,900 NOW $148,900 Call us @ Impressive Home Builders (352) 746-5912 INVERNESS 55+ Lakefront park Exciting oppt'y, 1 or 2BR Mobiles. Scr. porches, apple , water incl. Fishing piers. $7,000-$15,000. Leeson's 352-476-4964 NEW CONDITION 4BR, Paved, Rd. Rockcrusher area, sacrifice $81,900. (352) 621-9181 Cell (352) 302-7332 SRENTAL FINDER rentalfinder.com CRYSTAL RIVER 5/2 Bonus room, FP, wood floors & tile, /2" drywall thruout, 9x42 scrn.- country prch. on lac, $115,000 (352) 200-8897 ERMu 2 Bed, SW, Beautiful V2/ Acre Lot $37,000 Open to Offer, Owner/Agent 352-302-8046 2/2/Crpt. SW Exc. Cond. CHA, ceiling fans, scrnd 12 X 20 porch. Dbl. corner lot on paved street. $53K abo 352-503-6061/628-7480 3/2 SW on Two V2 AC Lots. Sc FLORAL CITY 4/2 on 1.16 Ac. Buy NOW, or kick yourself later. John Maisel III Exit Realty(352) 302-5351 HERNANDO, 2/1 /2 2 scrn. porches, 1 wood deck, all new inside, Quick sale $43,900, at 3199 E. Buffalo Ln, West side of Hwy 200, Daytime 352-344-3444 Evening 352-344-3084 LAND & HOME 2 Acre Lot with 2000 sq. ft., 3/2 NEW Home Garage, Concrete driveway & walkways, Carport, Beautiful Must See 10% down No closing cost $848,90/mo WAC Call 352-621-9182 LAND & HOME Move In Now!! 5 HOMES For Sale from $79,000. to$149.900 CALL 352-621-9181 NEW JACOBSEN 2008 MODEL 32 X48, 3/2,2 x 6 Con- struction 18" ceramic tile, 2007, 3/2, 1,056 SF. Lg. Screen Rm. Decorative Drive-Way Painting.Private Setting. Low Lot Rent. $65,900 (352) 422-2187 .. obleHoe. furn. $64,550 TOO MANY NEWSt. JlltI Houses 2/1 Tropical Ln, $89,500 3/1 Tropical Ln, $99,000 Owner Finan.10% Down Or Rent 2/2's @ $600 mo Onr/Agnt 352-382-1000 r RENTAL FINDER S I rentalfindercom L- - - J�W CR/Hom 2/1, IAC $465; 2/2 V/2-AC $535 CHA220-2447/212-2051 CRYSTAL RIVER 3/2 $475/mo 1st. + Sec. No Pets HOMOSASSA 2 Mobiles 2/1 $400. & $450. 1st &sec. No Pets Don Crigger Real Estate (352) 746-4056 LECANTO CBS 3/2/2, $1,125. mo. 1st.+ Sec. Incl. lawn care. No Pets infDLQropedrt manaamentgrouo. r RENTAL FINDER S rentalfinder com -L CRYSTAL RIVER S& 2 BR, W/S/G ncl. $600 (352) 212-7740 CRYSTAL RIVER Newly Renovated 1 bedroom efficiencies w/fully equip. kitchens, No contracts necessary. Next to park/ Kings Bay Starting @ $35 a day for a week or more. (Includes all utilities & Full Service Housekeeping) (352) 586-1813 FLORAL CITY Lakefront 1BR, Wkly/Mo No Pets. (352) 344-1025 INVERNESS Nicely furn. 1 br/1 bath at- tached to pet friendly home. $600. per month, utl's incl, + security, and pet deposit. 352-726-8094 3/2/2 Rent-to-Own New Home Citrus Spgs. Low Down, Easy Terms Danny (407) 227-2821 CRYS. RIVER 2/1 V2 838 5th NE Ave. Nice, CH/A $600/mo + Sec. (727) 341-2955, (727) 455-8998 Crystal Palms Apts. 1 & 2 Bdrm Ist Mo. FREEI Crystal River. 634-0595 CRYSTAL RIVER 1 BR, laundry/premises, $500 mo.+ sec. deposit. 352-465-2985 CRYSTAL RIVER 2/1, $650. mo. Includes water, sewer, garbage (352) 302-9323 (352) 302-2178. Ist/last/sec (800) 709-8555 INVERNESS 1 BR Downtown Location, W/D hkup. Sewer, water, garbage provided. $600/mo. 352-422-5744 Crystal Palms Apts. 1 & 2 Bdrm Ist Mo. FREEI Crystal River. 634-0595 COMM. STOREFRONT Hwy 44 Crystal River, high traffic. All until. included in $450/mo. 352-563-1717/400-1375 41/ Acrs 29 Michigan St. Inglis, 3,000 total sq. ft. 727-647-2596 INVERNESS AREA 1.000 sf. Office/Retail, Ample parking. Busy corners. (352) 726-6640 REPAIR SHOP Floral City - Established location. For sale or lease. 813-388-3313 2/2 CITRUS HILLS Greenbrlar I/,1st fir. furn. Near pool. $114,500 $1,000mo 352-249-3155 BEVERLY HILLS LAKESIDE VILLAGE 2/2/1 FURN. COM.POOL, 55+MIN 6 MOS. (352)697-0741 CITRUS HILLS Meadow View Villa 2/2/1 Fully turn. Pool, (352) 586-0427 HOMOSASSA UNFURN $815- Sugarmill Woods 2/2/1 '2 Atrium Villa, Ig. lanai; 2/2 End Condo River Links Realty 628-1616/800-488-5184 INVERNESS 2/2 Pool view villa for rent or lease to own. Across from pool & clubhouse. 970 sf. Scrnd porch. 605 Whispering Pines Blvd. $775/mo. 1st & last. No smoking. Star (352) 422-2706 PRITCHARD ISLAND 2/2 $150K, $800/mo. Dock, Comm. Pool 352-237-7436/812-3213 CITRUS SPRGS 2/2 875 SF, Water & Lawn Care Inc. $650/mo. 1st & Sec Avail Oct 8th 803-351-0833 CRYSTAL RIVER 3/1 $750/mo. 1st/sec. (352) 464-3522 INVERNESS 2/1, $550. mo., No pets, 1st, last + sec. 352-344-8389, 860-2418 LECANTO 2/2 Large, NEW! No pets $675/mo. 352-228-0525 . INVEN ES11/1 INVERNESS I/1 RIVERSIDE LODGE Furn. All util. & cable TV $695. mo. $300 moves you In. (352) 726-2002 6 BDRM HUD $54,0001 Only $429/mo! 5% dwn. 20yrs. at 8%. For listings 800-366-9783 Ext 9845 REDUCED $100111 3/2/carport Totally refurbished] SPOTLESSI Immediate Occup. Reduced to $695/mo, 527-3953 or (352) 427-7644 CONDOS, HOUSES SEAS, MONTHLY Furn & Unfurn. Heated pool. All newll 352-302-1370 CRYS RIVER 3/2/2 Pool, Lease/OTB. $1300 Avail 10/1 352-563-9913 RENTAL FINDER rentafinder com Rentals COUNTYWIDE1 GREAT AMERICAN REALTY Call:352-422-6129 or see ALL at tr on 5 ac, $1100 352-726-0793 HOMAS. 2/1, MH Util. Incl. Nice clean, quiet park. short/long term. $695 (352) 628-9759 INVERNESS Lakefront 2/2, DW 1600 sq.ft fully furn., 44-E, East Cove $625 352-476-4964 CITRUS COUNTY (FL) CHtONIC.I WORDY GURDI BY TRICKY RICKY KANE 1. Issue an alert to actor Rip (1) 2. Superman's honey's window pieces (1) Every answer is a rhyming pair of words (like FAT CAT and DOUBLE TROUBLE), and they will fit in the letter cn-uc � 1nnmh I,.niLn r t1L�*LI definition tells you how many 3. Drench a chef's hat (1) syllables in each word. To win $10, send your original rhymes with your definitions to this 4. Fire maniac's Greek sandwiches (2) newspaper. All entries become - - I -the property of UFS, Inc. � 2007 United Feature Syndicate, Inc 5. Breakfast pan in a mind teaser (2) 2007 United Feature Syndate, Inc. Thanks and $10 to Art Griffin of 6. Singer Carey who's an outcast (3) Maspeth, NY for #2. Send your entry to __ this newspaper. 7. Cargo ship's deep pockmarks (2) 1 1 1 1 1II L~ l 9-10-07 SHERIVO Ss1HDIaHi 'L IHIVM HVIHVd '9 IHtDHO aUTIlIE "9 SOTAD SOHAd ' afibO1 HIVOS "' SaNVd SaNV'I T NHOL NHVaM SHAMSNV LECANTO 3/2/2 Upscale, turn.. $700/mo + Sec. Anne (727) 463-1804 BEVERLY HILLS 1/1/crpt. Glass Rm. Clean & Conv. Area $550 (352) 746-3700 BEVERLY HILLS 10 N.Desoto 2/1 $650.mo 8 N.Fillmore 1/1 $625.mo CRYSTAL RIVER 9 N.Candle 2/1 $550.mo INVERNESS 237 N.Croft 2/2 $750.mo 352-637-2973 BEVERLY HILLS 18 N. Osceola, 2/11/2/1 & carport. New Inside $725 mo. 1st., Ist, dep. & 33 Murray St. 2/11/2. Ig shed & fence $600. mo. 1st. last. dep. 352-795-3000 BEVERLY HILLS 2/1 + Fl. Rm., 19 Harrison $650 (352) 422-2798 BEVERLY HILLS 2/1 First Mo. FREE. C/A. $700. (239) 776-6800 BEVERLY HILLS 2/1/1, $565., Easy move in Terms (352) 382-3525 BEVERLY HILLS Lg. 2/2/1 Fam. Rm., Scrn. Rm, Appl. Good Area. Move-In Cond. $725 (352) 746-3700 BEVERLY HILS 2 Bed w/FI. Rm. $700 2 Bed Remod. $650, 1 Bed $600. 352-422-7794 BLACK DIAMOND 3/2/2, like new, immac- ulate, all appliances. 24hr gate guarded community. Deluxe cable TV & lawn main- tenance included in rent. $995 mo. Call Paul (352) 746-9585 CIT SPRINGS 2/11/2/1 Cute & Clean! Scrn. patio, sm pet ok, CHA $625mo. 352-302-9053 CIT. SPRGS 4/2/2 $1,000. MOVES YOU IN $1,000. MO. ALL FEES WAVED (352) 597-3693 CITRUS HILLS 3/2/2 w/pool. Pets OK $1,250mo 352-860-1245 (954) 600-9395 CITRUS SPRINGS 2/2 $700/mo. Ist/lst/sec Avall/1 352-522-1905 CITRUS SPRINGS 3/2/1, w/eBig caged, inground Pool $875. mo. (352) 586-4105 CITRUS SPRINGS 9320 N. Santos, Nice 2/1, Den, new Berber, no pets, $595. + util. & sec. (352) 628-0033 CITRUS SPRINGS Many Available $825,- $875. mo. 2 -4 wks FREE Rent if Qualify. (352) 795-9123 Charlotte G Realty & Investment LLC CR/Hom 3/2/1 $760 CHA, fenced, new car- pet, 220-2447/212-2051 CRYSTAL RIVER 2/2/1, fam. rm., water. gar. & pest, Incl. $750. + sec. (352)464-2716 CRYSTAL RIVER 3/2 CHA Immed. Occup. 1st mo. rent $775 (732)942-0666, Iv. msg. I^K CRYSTAL RIVER 3/2/1, Pets, negot. $750. mo. 1st & sec. Evenings 352-795-5126 DUNNELLON/ Rainbw Spgs C.C. Beautiful & Spacious 2/2/2, FP, on wooded 1/2 ac. $895/mo Rent to own or buvl 352-527-3953/ 352-427-7644 FLORAL CITY 2/1 W&D, City wtr. $425/mo No pets, (352) 726-2979 FLORAL CITY All new 2/1, 150X 115 lot. 8731 E. Ridgecrest Ln. $650/mo. Ist/Ist/sec. (386) 212-3096 Forest Ridge Village 2/2/2 $825.00 Please Call: (352) 341-3330 For more info. or visit the web at: citrusvllaages rentals.com HOMOSASSA $495 2/1 Duplex; $595 2/1/1 Refurbished; Meadows 3/2/2 $695up River Links Realty 628-1616/800-488-5184 HOMOSASSA 2/1 CHA, No pets $575. Ist/last/sec 628-4210 HOMOSASSA 2/11/2 $700 2/1 $650 1st & Sec. Both Tiled, W/D HU Screen area. Trash pu inc. Meadows Deed Rest. Comm. Credit/Ref. No Pets. (Sec 8 OK) 352-686-0539 HOMOSASSA 2/2/2 Lrg yard, new air & appli's. $825 mo Ist/ last/dep (352) 628-7526 LECANTO 2/1 $675/mo., Fish Pond, Fenced B. yd. 628-7042 - NO CREDIT CHECKII RENT TO OWN 352-484-0866 visit jademission.com Riverhaven 3/2/2 New carpet, refrig. paint, pet ok, $950 mo. (352) 621-7713 SMW UPSCALE 2/2/2 SALE/ LEASE, scm. lanai $900. mo 352-592-9811 CRYSTAL RIVER 3/2 Home. $1000 Per mo. Call after 2 p.m. 352-795-2558 CRYSTAL RIVER Spacious 2/2 condo. Beautiful waterfront view w/dock, Recently updated,-partially furnished. Pool, tennis cts., cable TV. $900/mo (414) 690-6337 FLORAL CITY 3/2/2 OPEN LAKE FRONT $1,000 mo. No smok/ pets (352)344-2500 HOMOSASSA Waterview w/private Dock 2/2 CHA, wrap around scrn. porch. (813) 312-9076 INGLIS 1/1 Cottage, 14193W. River Rd.,electric included $600. mo. 352-447-5244 Cell 352-613-0103 INVERNESS Nice 1/1. Util. Inc., Boat ramp. $495/mo. (352) 586-9615 INVERNESS Nice 1/1. Util. Inc., Boat ramp. $495/mo, (352) 586-9615 OZELLO 2/1.5 w/ hardwood Firs & ceilings, new central A/C, Lrg wood deck overlooking water. Beautiful Shaded lot w/dock & boat ramp.' (813) 927-4647 (813) 927-0525 PRITCHARD ISLAND 2/2 $150K, $800/mo. Dock, Comm. Pool 352-237-7436/812-3213 3/2/2 Rent-to-Own New Home Citrus Spgs. Low Down, Easy Terms Danny (407) 227-2821 DUNNELLON/ Rainbw Spgs C.C. Beautiful & Spacious 2/2/2, FP, on wooded /2 ac. $895/mo Rent to own or buyvl 352-527-3953/ 352-427-7644 FISHING IN FRONT YARD 3/2 ON 10.8 Acresll Detached 14 X 28 office, pool, fncd., pond. $325K Ownr. Finan. (352)621-3135 HERNANDO (2) Studio Apt. & Room $125/wk & $100/wk, 352-637-6531, 476-2917 CONDOS, HOUSES SEAS, MONTHLY Furn & SEAS, MONTHLY Furn & Unfurn. Heated pool. All newil 352-302-1370 Kings Bay Crystal River 1 mo. at a time Rentals Furn. 1/1 Apt. Sleeps 4. $1000/mo. Includes boat slip. 386-462-3486 WI 'I vacant pOS"itO . It's es tuu tour hundredd ,. pe 0loyment su, ' - . EveraY ..,ds to Place Vour e, . " . t assht'e ..- o to Ii ,. gO'v t a b e 90 to o W. j lsshaied ad With us. and place your DECLASSIFIESIFIEO S - - What is ez? It's the 24-hour, do-it-yourself website for creating ads that will appear in.the Chronicle's classified section M mm CLASSIFIED L- r------ ~---- I 62 1 I w- - -. I . Tr MR CITRUS COUNTY REALTY ALAN NUSSO 3.9% Listings INVESTORS RESIDENTIAL SALES COMMERCIAL SALES (352) 422-6956 ANUSSO.COM OpenH HouseH C= 0 om eca 4S .RelEte iS STILT HOMES Molular Stilt Homes 140 mph. zoning, We build, sell, deliver We do it alll Eliminate builder mark-up. Call the factory. John Lyons 800-622-2832 xt. 210 INVESTORS Palm Harbor Modular Homes from $53 sf. Finished on your lot. 3 Color brochures. Call John Lyons 863-860-3062 BETTY MORTON Lic. Real Estate Agent 20 Years Experience 2.8 % Commission Rea( elect (352) 795-1555 $10,000 Cash Back At closing Brand new homes, Only $995. down. Call (352) 694-2900 -eran rm Homes" BETTY MORTON Lic. Real Estate Agent 20 Years Experience 2.8 % Commission R(352) 795-155ect (352) 795-1555 I 0 * BEAUTIFUL * 3/2/2 Pool Home On Cul-de-sac Move In Condition 439 W. Blueflax Ct. Liv. Rm., Fam. Rm w/FP Din. Rm., Laun. Rm. IsI. Kit., breakfast bar, desk, cabinets galore, ALL NEW APPLIANCES & CARPET, Vinyl encl. Lanai, sprinkler sys. fully landscaped. Great Location! Minutes from golf shopping & library. $189,000. Must See! 352-746-5757 DICKS MOVING (352) 621-1220 moving.com Michele Rose REALTOR "Simply Put- I'll Work Harder" 352-212-5097 thorn@atlantic.net Craven Realty, Inc. 352-726-1515 �00 0 *R EDj9 T2K, 0 0 (WAS $299,900) This 4/2/2 Pool Home is set on a private Wooded Ac. 3721 sq. ft. lg. lanai, NEW C/H/A! Refurbished. Man M9 ifiesM Price�,c!M.11% low County assessment] 352-746-5810,eve' 14 A N A Southern Woods Golf Club $ 0 Monday, $10,000 October 1, 2007 HOLE ' IN ONE 12 p.m. Shotgun start $75 per person Includes cart, beverages, lunch and greens fees Rules: 4-person scramble, individual and couple entries You can now pay in two payments of $37.50 billed through RACC on your quarterly bill. Name Address City State Zip__ . Phone( ). Bill me: Once Two Payments Name Address City State Zip___ Phone( )- Bill me: Once Two Payments ) Name Address City State Zip_ Phone( ) Bill me: Once Two Payments Name Address City State Zip__ Phone( ) Bill me: Once Two Payments Mail or fax entries to: REALTORS Association of Citrus County, Inc. 714 S. Scarboro Ave., Lecanto Fl 34461 Fax (352) 746-3223 For more information call 746-7550 Sponsored by the REALTORS Association of Citrus County, Inc. and the Citrus County Chronicle. 0*41 Hmos BETTY MORTON Lic. Real Estate Agent 20 Years Experience 2.8 % Commission Re132 -lect5 (352) 795-1555 FOR SALE BY OWNER 3/2/2 Brand new on 1/2 Ac. w/10yr. warranty. Energy efft. & landscaped in "Homes Only" area. $179K Easy owner finan. (352)621-0537 --i DICKSMVN -Jaugiw Woods^ Vic McDonald (352) 637-6200 'i-. -4 " bi Realtor My Goal is Satisfied Customers REALTY ONE * (II.IfltiaJhl'I \.EL'nt (352) 637-6200 MR CITRUS COUNTY REALTY .i * ALAN NUSSO 3.9% Listings INVESTORS RESIDENTIAL SALES COMMERCIAL SALES (352) 422-6956 ANUSSO.COM C - - nnelM| DICK 0VN O 0 0 *Home Finder* Call Me PHYLLIS STRICKLAND (352) 613-3503 Keller Williams Realty *Home Finder* Citrus Hills Homes BETTY MORTON LIC. KeUl 5sclae .Agyeni 20 Years Experience 2.8 Percent Commission Rea3 Select 5teal) 7at95Yo5Way (352) 795-1555 LET OUR OFFICE GUIDE YOU! Plantation Realty. Inc. 1352) 795-0784 Cell 422-7925 Lisa VanDeboe Broker (R)/Owner See all of the listings realtvinc.com -"ee oH lpys -1"URa Ett -Ea *Home Finder* Citrus Ridge Realty 3521 N. Lecanto Hwy. Beverly Hills, FL 34465 720955 1-888-789-7100 I- - I ruy~TiuT~Yu '4Crystal Homes Beverly Hills Homes I "**J Lecan Home . . - I i W. 1-1 nadowcrest C4 omes I [ J I nverne L cc Homes C=-4 Home 44 Loans 0 0 0 I -'J Citrus L .;b. Home '*4J I Lecanto Homes Beverly Hills Ic= Homes W"*4 Citrus Co c= Homes C4-'Wj Marion Co " Homes I -1--ic4Levy Count w Homes I 12B MONIANV SII'MPTEMBIi 10, 2007 5.63 Majestic Acreage! By Duval Is. public boat ramp w/pub water & barn stall. Elite New Home Site! $249K -313843, T. Paduano, C21 352- 212-1446 3/2 SW on Two /2 AC Lots. Scrn porch. BY OWNER. $44,500 1592 S Lookout Pt 2 blocks off US19 352-503-4142 FARMS & WATER FRONT - - ^ Crossland Realty Inc. Since 1989 (352) 726-6644 Lecanto, Centrally Located, 2 cleared .52 ac. lots. Desirable neighborhood, paved roads, cily water, huge oak trees, corner lot, $35,000. Interior lot, $32,500 W Laurel St. Owner Agent 352-302-2300 TERRA VISTA HILLSIDE GOLF COURSE LOT #9 Skyview CC, $77,000 Call (352) 638-0905 1 /a ACRE in Crystal Manor, Lot 23, Block 15, Unit 1, Surveyed, Asking $69,900. (352) 795-1531 2 PR Beautiful LOTS!!!! Maverick Ct. & Gorge Lane $59,900 each, -&315012/1315015 Fran Perez, ERA Amer, BH (352)586-8885 4 CITRUS SPRINGS RESIDENTIAL LOTS Adjacent Lots 0.23 Acres each 3028, 3038, & 3046 Marie Dr. & 9516 N. Emellia Ave. 1/4 mi. from Citrus Springs Golf & Country Club. $8K ea.; $32K/all For Details: Edward (561) 337-4266 CHEAP CHEAP! PINE RIDGE 1 Ac. Treed Lot in area of beautiful homes! $59.900 352-746-6161 CITRUS LOTS BELOW MARKET letsaolandllc.com 800-840-4310 PRISTINE Emerald Hills 2 Ac. .CC581, r7--4- r RENTAL FINDER wwwchronicle rentalfinder.com 18 Ft. John Boat 35 H, Force, trir. good cond, $1,600 obo 14ft. 7.5 Johnson, galv. trr. $850. obo (352) 586-4257 All 2007 Century Boat Packages Receive A FREE Trailer Stop In and SAVE! SAVE! '07 2001 CENTURY F150 & Trailer, T-Top & many extras $28,292 '07 18 ft. PONTOON BOAT with 50 HP $12,675 '07 OUTER BANKS 160 Skiff, 50HP Yamaha & Trailer $13,595 '03 CHAPARRAL 215 SS Cuddy Mercruser & Trailer, SFast & Clean $23,990 20' WELLCRAFT Center Console w/T-Top, '86, w/trlr. NQ POWER. $3,500 (352)621-0848 Air Boat 13ft fiberglass. Rivermaster, hull, S/S, cage, 403 Buick runs good. Bilge pumps etc. trlr. needs paint $4,995. (352) 860-0513 AIRBOAT 16' Panther, Alum, w/trlr. New prop & motor. $5,500 (352) 489-3440 AIRBOAT 18' Rivermaster, S.S. Belt drive, trolling mtr, 500 Cadillac w/warranty. $15K (352)628-1883 CAROLINA SKIFF '04, 115 Yamaha 4strk, Bimini top, Minkota Rip tide trolling mtr. Magic tilt trlr. $11,.500 (352) 697-1172 Carolina Skiff '95 CC 17' w/newly rebuilt 55HP Suzuki, gd. trailer $4500. (352) 212-7651 KEYWEST 1520 A "REEL" STEAL 2005 15' w/ trailer ALL THE UPGRADES!!!!! (too many to mention). Has less than 100 hours. Just asking what is owed. call 400-5520 LANDAU 14' Alum. Jon Boat w/25 hp Merc. motor & trlr. $2,500 352-564-8476/422-5081 Nature Coast Marine New, Used & Brokerage We Pay Cash for Clean Used Boats 352 794-0094 Nature Coast Marine New, Used & Brokerage We Pay Cash for Clean Used Boats 352 794-0094 _ Nature Coast Marine | Sales & Service | Present this Ad for 10% Off on all I Parts & Service 1590 US 19, Homosassa 352-794-0094 NEW T-TOPS & CUDDY CABIN TOPS Super Closeout Sale! Won't Last Long!,trolling motor, livewell, depth finder, much more. VERY NICE $8950. 212-5179 PONTOON 18' � With trailer. '00 40HP motor. All in great shape, $3500/ obo. (352) 564-8941 PONTOON 21 ' Party Barge 40 HP Evinrude-lots of Extras Like New $6,000.00 352-634-2360 SEA PRO 21' 1998, Center Console, 150hp Yamaha, $10,000 (352) 795-2537 Iv. mess. SEA RAY 18' '99 Bowrider w/ trailer, 115 Merc, OB, Tilt & Trim, Extras, $8,900 OBO. (352) 628-9056 SEAPRO 199921' V2100cc bay series. 150 Yamaha w/trailer, bimini, radio, trolling mtr. 13,000. (352)748-5005 SPORTCRAFT '86 20 ', CC, 140 OMC, Sea drive, rebuilt '05, boat/mtr/trlr. $2,500 obo (352) 795-4204 STARCRAFT '98, Bowrider, 18'10", V-6 I/O, used in fresh water only. $11,500 obo. (352) 206-5894 SUNDANCE 02, 14', Skiff, 25hp, Exc Cond, Many extras, $3700 0DO. (352) 628-1653 THUNDERCRAFT 16FT, '89 Bowrider, OMC I/O, new carpet & seats. like new, garage kept $2800obo 352-270-3641 TREMBLAY 17' Fiberglass, live-well, center console, 60 hp Evinrude. Runs great! Swivel seats, front cast- ing deck. Exc. Cond. $5,500 (352) 795-1411 Vectra Deck Boat '06, Like $37.95!* *2 weeks in the *2 weeks Online! *Featured in Tues. "Whees" Sectlonl Call Today (352) 726-3983 or (352) 563-5966 For details. "$5 per additional line Some Restrictions May Apply nr AUTO. BOAT & RV Tax Deductible Maritime Ministries 43 year old Non-reporting 50) -C-3 Charity. Proceeds Benefit Local Battered Women's Shelter (352) 795-9621_ Beaver Monterey 38ft. 2005, C-9 Cat eng. 3 slides, fully loaded, 10k mi. $185,000. (352) 795-9873 DAMON 32', 1992 454 Chevy eng, 27K mi, 2 ACs, queen bed.Non Smoking, No pets, Lots of extras & Exc. Cond! J190M0 (352) 527-8247 FOUR WINDS 31' '04, Duct AC, Pwr. lev., Bckup camera, en.. Loaded! 14K mi., $40,000 (352) 422-7794 GULF STREAM '04 Ford BT Cruiser, 28' Tow pkg. 13K mi 1 slide, walk arnd qn. bd, very clean $44,000. (352) 344-5634 LAYTON Skyline '93, 25' 5th Wheel, slide out room, Priced to sell @ $3,500 (352) 422-7222 PROWLER REGAL '05,39', alum. frame const. fully loaded, 2 Ig sldouts, 2 qu. sz. bdrms. $17,500 (352) 634-4439 TRAIL LITE '05 27FT, self contained, 8FT slide out w/20ft awning, must see $10,800 (352) 584-2491 350 CHEVY ENG. & TRANSMISSION $1,450 OBO (352)746-5077 454 CHEVY ENG. & TRANSMISSION $1,050 0O0 (352)746-5077 FLAT TOPPER Red, Ig wheel base, xtra hvy. duty. Ford 250 like new $800 sell or trade (352) 382-3642 Leer Pick up Cap, Fits 2000 GMC Sonoma Ext Cab, very good cond. $300. (352) 726-9267 LEER TOPPER, fullsize truck forest green, $250. (352) 476-2149 e ,poloive Your world first. Even Doa CHO(A Ci Ft1 j.. r �S I TOP DOLLAR S For Junk Cars $ (352)201-1052 $ CASH BUYER-No Junk *FREE REMOVAL OF. ATV's, bikes, cars, jet skis mowers, golf carts. We sell ATV parts 628-2084 $ $ CASH PAID $ $ Junk Cars, Trucks, Vans No Title OK, Call J.W. (352) 228-9645 r 01 Honda Accord LX, Auto A/C Save I I on Gas, Only $6,988. 866-838-4376 r 7- -- mi r , Ford aurus SEL Low Miles, | Leather Sunroof, ONLY $5,995. 866-838-4376 r03 HUNDAI SONOTA Low miles, fully I Loaded Only $7,988. 866-838-4376 � L-- ---mll r 5, Kia Rio, Save Gas and Money At $129. a month 866-838-4376 Auto, sunr L, L aded .$ 7 ,9 95Lo A WHEEL OF A DEAL 5 lines for only $37.95!* *2 weeks in the Chronicle! *2 weeks Onlinel *Featured in Tues. "Wheels" Sectionl Call Today (352) 726-3983 or (352) 563-5966 For details. *$5 per additional line Some Restrictions May Apply ALL SAVE AUTO AFFORDABLE CARS I I 100+ Clean Dependable Cars FROM $450- DOWN 30 MIN E-Z CREDIT 1675 US HWY 19 HOMOSASSA 352-563-2003 L m-- - ll AUTO , BOAT. & RV DONATIONS Tax Deductible Maritime Ministries 43 year old Non-reporting 501-C-3 Charity. Proceeds Benefit Local Battered Women's Shelter (352) 795-9621 Select Your Choice of Sponsorships: < JlManatee !jull Sponsor ($500 and above) * Full page advertisement in the Golf Program * Inclusion in all sponsorship drive advertising * 4 complimentary player entry fees ($50 per pTlayi value) * Special prize/appreciation package for each player Sffj anatee Cow Sponsor ($250) * Half page advertisement in the Golf Program * Inclusion in all sponsorship drive .dv'tiui'l:z * 2 complimentary player entry fees ($50 per player value) * Special prize/appreciation package for each player ACURA MDX 'U4 Sport w/ navigation, 59K mi. Exc. cond. Garage kept. $24,800 352-746-7402, Iv msg. BUICK CENTURY '02 Custom Sedan, 1 owner 65K, meticulous, Ithr. Int. Loaded. Non-smoking. $8,995 (352) 726-3520 BUICK LASABRE '92 Blue, 4dr, runs great $1400 (352) 563-0642, eve. BUICK LESABRE 2004, Sr. owned, 67K ml. good cond., $8,500 Call before 9pm (352) 382-2420 '92, 145K m],, Cold AC, Runs & Drives Great! $1,500 OBO Maria (352) 795-4718 Cadillac ElDorado '92, custom paint, new tires/rims, keyless entry, AC, Ithr, Nice audio sys. $2900/bo 352-746-6370 CHEVY CAVALIER 1998 $1850 Cold A/C, Clean int & ext, New Tires. Call 352-613-5869 CHEVY COBALT '06 31k ml. 4dr. Metallic sand. Air, CD plyr. Exc. cond. PS. $10,200 (352) 746-5802 MERCURY Marquis LS. 2006, Ultimate Edition, 12,900ml, under warr, $16,100. (352) 795-5554 MUSTANG - RED '01 15,000 mi. 1 owner, loaded, $9,900. (352) 212-5628 PLY. ACCLAIM '94, 4 DR, AC, auto, very depend. 35mpg, cruise control 100k + mi.,clean, $1,350. (352) 586-3854 O 0 o00 vw wwAcnwr. org S ^tSpport the Ike/ae that Supports the Manatees" SPONSORSHIP ACKNOWLEDGMENT Make checks payable to: FCNWR and mail to: Manatee Masters Golf Tournament 682 N. Afterglow Circle Crystal River, FL 34429 TOTAL AMOUNT ENCLOSED J YES, I wish to become a sponsor as indicated below: Check one: E Manatee Bull Sponsor ($500 or more) F Manatee Cow Sponsor ($250) M Manatee Calf-Hole Sponsor ($100) F Donation Only (Any Amount) 1 Name:- -. -------Company: - -- Address: City: ..... ....... Zip:................. ..... ............... ....... ......C t : .ip: Telephone: ( ) _-Fax: ( ) Note: If you plan to enter into the golf tournament, please complete the Golfer's Entry Form. If you don't have a Golfer's Entry Form call Bill at 352-563-2480. O Check here if you DO NOT plan to use your complimentary golf entry fees. SATURN SCI '99 3 dr, 4 cyl, auto, 127K mi. Cold AC. Runs/drives perfect. $2550 (352) 453-6870 TOYOTA '01, Corolla, auto, AC, P/S. P/B, 114k hwy. ml. 1 owner, well maint., all records $5,995. (352) 628-9984 impounds For saoe! Cars from $S0! For sings cal 1-800-366-9813 ext 7374 A Classic Car WANTED American or Foreign Will travel, Cash waiting (407) 957-6957 LINCOLN LIMO 1988 vintage 6 pass. all works, cold AC, garage kept. $2,800 (352) 422-1675 MERCEDES 1987, 560 SL, 126K, White, Both tops, New tires, $10,500 352-586-6805/382-1204 TRIUMPH SPITFIRE '80. Very low miles, runs great, perfect project car. $4,000 (352) 503-6263 VOLKSWAGON '70 7 pass bus. Rebuilt mtr runs great, new brakes, needs body wrk, $1975 352-637-1894, after 9am $5001 Police Impounds For sale! Cars from $500! For listings call 1-800-366-9813 ext 7374 I-----i1 S'05 Nissan Crew Cab. I 4 x 4, LOADED, I i ONLY $16,988. 866-838-4376 J r '07, Chevy Crew I Cab, Z71, Like A Rock Call 866-838-4376 --- --mmm- ml A WHEEL OF A DEAL 5 lines for only $37.95!* *2 weeks in the *2 weeks Online! *Featured in Tues. "Wheels" SectionI Call Today (352) 726-3983 or (352) 563-5966 For details. *S5 per additional line Some Restrictions May Apply BI S L CAH&0 HPH Do 't issTisf '01 Nissan Pathfinder LOADED, with Everything Only 9,899. I 866-838-4376 r '02 Buck Rendez- | vous Perfect, SUV For Family Don't Miss 8 $8,495. 866-838-4376 S 02 HONDA CRV Auto, All Power S A steal at Only $10,988. 866-838-4376 ---m -m -e - ml S98 SATURN SL 1 . I Leather Sunroof 32K I i ONLY $4,990. 866-838-4376 CHEVY Blazer S10 '88, 4.3, Low miles, A/C Sr. owned, very sharp. $2,700.00 (352) 465-0721 GMC SUBURBAN '99, leather, all options, full chrome pkg, cust, wheels/tires, hi mi. perf. maint. exc. cond. $7,000 (352) 422-3661 '98, Dakota, w/ topper & sun visor, 45,520 mi., $5,500. (352) 621-7647 DODGE RAM '96 1500 Club Cab, $3,800/obo Rebuilt Engine & Trans.Runs gd. 352-465-2087/697-2357 FORD '04,F 150 XL, Super Cab V8, Auto, A/C, P/S, 34k well maint.. 1 owner, $14,300. (352) 628-9984 FORD EXPLORER SPORT '02, AC, runs great. 57K mi., exc. cond. $10,000/obo (352) 637-2582 mi. $6,500 (352) 503-3571 FORD RANGER 2004, 27K mi., Auto, AC, V-6. Exc. Cond. $10K obo (352) 527-2464 CHEVY STEP VAN '73, Good Cond. $1,995 (352) 621-0982 Dodge Cony. ANUSSQ.COM $5001 Police Impounds For sale! Cars from $500! For listings call 1-800-366-9813 ext 7374 *FREE REMOVAL OF. ATV's, bikes, cars, jet skis mowers, golf carts. We sell ATV parts 628-2084 SUZUKI DRZ 125 2006 DRZ 125, Excel- lent condition, have only been riden very little Asking $1200.00 (C) 352-257-2051 $5001 Police Impounds For solel Cars from $500! For listings call 1-800-366-9813 ext 7374 A WHEEL OF A DEAL 5 lines for only $37.95!* .2 weeks in the Chroniclel *2 weeks Onlinel *Featured in Tues. "Wheel" Section! Police Impounds For sale! Cars from $500! For listings call 1-800-366-9813 ext 7374 CtLASSIFIEDS 447-0910 MCRN CITY OF INVERNESS PUBLIC NOTICE OF THE CITY OF INVERNESS, FLORIDA ADOPTING A FINAL BUDGET COMMENCING OCTOBER 1, 2007. AND ENDING SEPTEMBER 30, 2008; PROVIDING FOR PROPOSED EXPENDITURES; PROVIDING TAXABLE VALUES: PROVIDING FOR OPERATIVE FISCAL YEAR; PRO- VIDING FOR EXPENDITURES DURING FISCAL YEAR AND SUBSEQUENT HOLD OVER FUNDS; PROVIDING FOR AMENDMENTS TO BUDGET: PROVIDING FOR SEVERA- BILITY; AND PROVIDING FOR EFFECTIVE DATE. will be considered for final reading and adoption by the City Council. All Interested parties may appear at the meeting and be heard with respect to the pro- posed Ordinance at 5:01 PM, September 20, 2007. Copy of the proposed ordinance will be on file with and available for Inspection by the public 4n the office of the City Clerk in the City Hall. 212 W. Main Street, In- verness, Florida, between the hours of 8:30 AM and 4:00 PM, Monday through Friday of each week. Be advised that If any person or persons may wish to appeal a decision of the City Council of the City of In- verness, Florida, made at this meeting, a record of the proceedings will be needed by such person or persons and a verbatim record may be needed. This Notice Is Issued under my hand as the President of the City Council of the City of Inverness this 6th day of September, 2007. Attest: /s/ Deborah Davls City Clerk /s/ Jacqule Hepfer President of City Council Published one (1) time in the Citrus County Chronicle, September 10, 2007. 448-0910 MCRN TOWN OF INGLIS PUBLIC NOTICE NOTICE OF PUBLIC HEARING TO REVIEW PROPOSED AMENDMENTS TO THE TEXT OF THE TOWN OF INGLIS LAND DEVELOPMENT CODE BY THE PLANNING COMMISSION OF THE TOWN OF INGLIS, FLORIDA SERVING AS THE LOCAL PLANNING AGENCY OF THE TOWN OF INGUS, FLORIDA, NOTICE IS HEREBY GIVEN that pursuant to Sections 163.3161 through 163.3215, Florida Statutes and Sections 34 -'35, of the Town of Inglis Land Development Code, com- ments, objections and recommendations regarding the following described proposed text amendments to the Town of Inglis Land Development Code, hereinafter referred to as the Town's Land Development Code, will be heard by the Planning Commission of the Town of Inglis, Florida, serving as the Local Planning Agency of the Town of Inglis, Florida, at public hearing on Thurs- day, September 27, 2007 at 7:00 p.m., or as soon there- after as these matters can be heard. The public hear- ing will be conducted in the Town of Inglls, Town Hall lo- cated at 135 Highway 40 West, Inglls, Florida. LDC 07-01, an application by the Town of Inglis, to amend Article I In General and Article IV, Zoning, of the Town's Land Development Code: Amending Sections 34-2 Definitions: and Amending Section 34-240 Use re- quirements for a Neighborhood Commercial District; and Section 34-241 Use Requirements for a Commer- cial District; and Section 34-242 Use Requirements for an Industrial District; and establishing Article XV, Special Exceptions, within the Town's Land Development Code, to create a process for review and approval of special exceptions to the Ist of permitted uses for the above referenced zoning districts., September 10, 2007. 428-0910 MCRN 2007-DR-3526 Martha E. McKeehan Vs. Richard H. Underswod Dissolution of Marriage PUBLIC NOTICE IN THE CIRCUIT COURT OF THE FIFTH JUDICIAL CIRCUIT, IN AND FOR CITRUS COUNTY, FLORIDA CaseNo.:2007-DR-3526 Division: FAMILY MARTHA E. McKEEHAN, Petitioner and RICHARD H. UNDERWOOD, Respondent. NOTICE OF ACTION FOR DISSOLUTION OF MARRIAGE TO: Richard H. Underwood. (Respondent's last known address): Unknown YOU ARE NOTIFIED that an action has been filed against you and that you are required to serve a copy of your written defenses, If any, to If on Martha E. McKeehan. whose address P.O. Box 3897. Homosossa Springs, FL 34447 on or before 9/19/2007. and file the original with the clerk of this Court at The Citrus County Courthouse, 110 N. Apopka Avenue, Inverness, FL 34450. before service on Petitioner or immediately thereafter, If you fail to do so. a default may be en- tered against you for the relief demanded In the peti- tion. Copies of alil court documents In this case, Includ- ing orders, are available at the Clerk of the Circuit Court's office, You may review these documents upon request. You must keep the Clerk of the Circuit Court's of- fice notified of your current address. (You may tile No- tice of Current Address, Florida Supreme Court Ap- proved Family Law Form 12.915.) Future papers In this lawsuit will be mailed to the address on record at the clerk's office. WARNING: Rule 12.285, Florida Family Low Rules of Pro- cedure, requires certain automatic disclosure of docu- ments and Information. Failure to comply can result In sanctions, Including dismissal or striking of pleadings. Dated: August 3, 2007 BETTY STRIFLER CLERK OF THE CIRCUIT COURT (COURT SEAL) By: /s/ L Johnson Deputy Clerk Published four (4) times In the Citrus County Chronicle August 20, 27, and September 3 and 10, 2007, POLARIS 800 Low hours '06, $4500 (352) 302-1861 4 WHEELER (TWO) 2001 Kawasaki 220 4wheelers. Good condition. $1100.00 each. 352-748-5005 2 HARLEY'S '97 Road King 28K ml. burgundy/silver stocked '01 1200 Sportster custom, 18,250 mi. Burgundy & dark burgundy.Lowered w/forward controls (352) 583-4338 A WHEEL OF A DEAL 5 lines for only $37.951* *2 weeks In the *2 weeks Onlinel *Featured In Tues. "Wheels" Sectionl Call Today (352) 726-3983 or (352) 563-5966 For details. "S5 per additional line Some Restrictions May Apply Friends of Chassahowitzka National Wildlife Refuge Complex M n ist Annuals Manatee Masters Coolf Tournament I *^CThurs.,Sept.20,2007 N SManatee Calf - Hole Sponsor ($100) * Printed sign at tee of sponsored hole * r,lZiiti.ii in the Golf Program )UNTY (FL) CHRONICLE *FREE REMOVAL OF. ATV's, bikes, cars. jet skis mowers, golf carts. We sell ATV parts 628-2084 GOLDWING SE 1990, Honda, 72K mL ml. YAMAHA '85, Venture Royal, exc. cond., new tires, 37K mi. Asking $2,200 obo (352) 621-0927 16- A-�� 0 To be played at: PLANTATION 114N MONDAY, SErI'TMBI-1m 10, 2007 13B-325 ON $37,999 FREE 24 HOUR RECORDED "SPECIAL" INFO AND PRICING ON THIS VEHICLE 800-325-1415 EXTENSION #970 2004 2004 EXPEDITION $16,999 FREE 24 HOUR RECORDED "SPECIAL" INFO AND PRICING ON THIS VEHICLE 800-325-1415 EXTENSION #977 2004 ACCORD $11,999 ON THIS VEHICLE 800-325-1415 EXTENSION #990 2002 LESABRE $7,999A NISSAN 2200 SR 200 OCALA OPEN 'TIL 10 pM (352) 622-4111 ALL PRICES WITH '1,000 CASH OR TRADE EQUITY PLUS SALES TAX, LICENSE FI AND s389 DEALER PEB. ALL INVENTORY PRE-OWNED AND SUBJECT TO AVAILABILITY. PICTURES RE FOR ILLUSTRATION PURPOSES ONLY. 70984N CITRUS COUNTY (FL) CHRONICLE I I 14B MONDAY. SEPTEMBER 10, 2007 CITRUS CoUNn' (FL) ~2HRONIcLE 1 'I FLORIDA'S FASTEST GROWING MITSUBISHI DEALER 08 LANCER SAVE! Sup to $5,000 I i FREE 24 HOUR RECORDED MESSAGE ABOUT THIS VEHICLE 800-325-1415 EXT. 2801 1I88 PER MONTH* 07 RAIDER SAVE! l l7 ,00 r- Mr- - ^ 10 3 1B 8 N ' #%rMr r % - 0%rA 0a r rE.:t 4 MUUH HIEcUOUIUU Mvil.S ABOUT THIS VEHICLE 800-325-1415 EXT. 2807 S888 PER MONTH* I|l PER MONTH SAUtI 2008 ECLIPSE FREE 24 HOUR RECORDED MESSAGE ABOUT THIS VEHICLE 800-325-1415 EXT, 2802 I6 R288 U PE N, ( I~, ~ 07 SPYDER .~ -~- FREE 24 HOUR RECORDED MESSAGE ABOUT THIS VEHICLE 800-325-1415 EXT. 2803 s21,888 206206I I 2003I 2006 GALANT '12,195 2006 ENDEAVOR '14,795 07 OUTLANDER SAVE! up to $3,OOO / FREE 24 HOUR RECORDED MESSAGE ABOUT THIS VEHICLE 800-325-1415 EXT. 2806 Sg7 388:.'2EN \^ ., .7. ,3 PE M W iONTH* 2006 LANCER 98,595 2006 ECLIPSE S12,888 2005 ENDEAVOR 13,888 ,20045 ENDEAVOR 10,895 . . . . ]'2004. 2004 OUTLANDER s11,795 2003 LANCER $5,495 I20 2003 ECLIPSE 9,195 OCALA MITSUBISHI 2200 SR 200 (352)622-4111 * (800)342-3008 0% FINANCING FOR UP TO 72 MONTHS IN UEU OF ALL REBATESINCENTIVES. 70968 Irf~:: $1 6 II $ 07 GALANT ,', FREE 24 HOUR RECORDED MESSAGE ABOUT THIS VEHICLE 800-325-1415 EXT. 2805 t14,888 07 ENDEAVOR - FREE 24 HOUR RECORDED MESSAGE ABOUT THIS VEHICLE 800-325-1415 EXT. 2809 19 8 :ERTH388 ^ ___________ 8'O U PRMB10N'TH" _____ 2003 GALANT '6,295 14BMONDAY, sEvrEMBER 10, 2007 Cmus CouNTY (FL) CHRomcu ( PER MONTH* SO iiew, Contact Us | Permissions | Preferences | Technical Aspects | Statistics | Internal | Privacy Policy © 2004 - 2011 University of Florida George A. Smathers Libraries.All rights reserved. Acceptable Use, Copyright, and Disclaimer Statement Last updated May 24, 2011 - Version 3.0.0 - mvs | http://ufdc.ufl.edu/UF00028315/01001 | CC-MAIN-2014-49 | refinedweb | 53,735 | 73.27 |
#include <Wt/WTableColumn.h>
A table column.
A WTableColumn is returned by WTable::columnAt() and managing various properties of a single column in a table (it is however not a widget).
A table column corresponds to the HTML
<col> tag.
Creates a new table column.
Table columns must be added to a table using WTable::insertColumn() before you can access contents in it using elementAt().
Returns the column number of this column in the table.
Returns -1 if the column is not yet part of a table.
Access the column element at the given row.
Like WTable::elementAt(), if the row is beyond the current table dimensions, then the table is expanded automatically.
The column must be inserted within a table first.
Returns the (unique) identifier for this object.
For a WWidget, this corresponds to the id of the DOM element that represents the widget. This is not entirely unique, since a composite widget shares the same id as its implementation.
By default, the id is auto-generated, unless a custom id is set for a widget using WWidget::setId().
Reimplemented from Wt::WObject.
Sets the CSS Id.
Sets a custom Id. Note that the Id must be unique across the whole widget tree, can only be set right after construction and cannot be changed.
Sets the CSS style class for this column.
The style is inherited by all table cells in this column.
Sets the column width.
The default column width is WLength::Auto.
Returns the CSS style class for this column.
Returns the table to which this column belongs.
Returns the column width. | http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WTableColumn.html | CC-MAIN-2017-51 | refinedweb | 265 | 69.58 |
Table of Contents
A small note: It is reported that due to a bug in mod_python, version 3.2.7 or higher should be used with TurboGears.
First download the mod_python gateway and move it to the <Python_Root>/site-packages directory.
If the original site is down you can get a copy from here: modpython_gateway.py
For an application named myapp, create a myapp_modpython.py script inside <Python_Root>/site-packages containing:
import pkg_resources pkg_resources.require("TurboGears") import cherrypy import turbogears turbogears.update_config(modulename="myapp.config") turbogears.update_config(configfile="/home/PUB/www/myserverorg/myapp/myapp.cfg") from myapp.controllers import Root cherrypy.root = Root() cherrypy.server.start(initOnly=True, serverClass=None) def fixuphandler(req): return 0
The application myapp needs to be installed in the python path for apache to be able to find it. It means that you need to do:
python setup.py install
in your application root directory. For testing purposes you could also use “python setup.py develop” but this is really NOT the recommended way for production use.
To know if your application is correctly installed on the machine you can fire-up a python shell and try the following statement:
>>> import myapp
if it does not work, then your application is not in the python path and will not be visible to Apache. You MUST have you application importable this way in order to continue further.
This script makes references to the production myapp.cfg file that as been put in a special directory for this purpose. This is because we want to control were apache can read/write files so we copied the sample-prod.cfg into this new path/name.
Make sure autoreload is set to off in this configuration file:
autoreload.on = False
Apache needs to be aware of the new location we want it to serve.
For this you need to have mod_python installed and loaded correctly into apache and then to amend the config file to add a <Location> directive:
First we need to make apache aware of the new mod_python so we add theses lines in the LoadModule part of the apache.conf file:
LoadModule python_module modules/mod_python.so PythonOption mod_python.mutex_directory "logs/" PythonOption mod_python.mutex_locks 32
At least on OpenBSD if you do not specify the last line (mutex_locks) you will get weird errors and the server will crash upon startup.
Next, you’ll need to modify your apache.conf to take advantage of this launcher script:
<Location /myapp> SetHandler python-program PythonHandler modpython_gateway::handler PythonOption wsgi.application cherrypy._cpwsgi::wsgiApp PythonFixupHandler myapp_modpython PythonDebug on </Location>
The PythonHandler directive refers to the script you downloaded into site-packages (modpython_gateway.py), and the PythonFixupHandler directive corresponds to the file you created in site-packages (myapp_modpython.py).
Restart Apache and visit /myapp in a browser.
Please note that since you use this special location you will have to make your app aware of this using:
baseUrlFilter.on = True
If you are a Windows user you can skip this part because most of the time apache will have full write access to the directory it needs. If your are on any nix flavor you must read this part.
For serious Windows administrators you should ensure that the apache daemon which is exposed to the world does not have read/write access every directory (and shared drives!) on your system.
If you begin to lock down the apache process as you MUST do on a production machine then you should definitely follow these indications.
If you try to start apache right now you will receive an error like this one:.
The problem comes from the fact that mod_python needs to unzip the required eggs before your application can use them, but for this the user under which apache runs needs to have write access to the specified directory.
There are diverse solutions to solve this problem.
We won’t talk about the first solution because it is NOT an option in a production environment.
The second option to install all TurboGears dependency by specifying that you want them unzipped can be realised doing so:
easy_install -UZ kid
to make sure that kid is installed unzipped intead of inside a zipped egg. Then repeat the operation for each egg that you see in the <Python_Root>/site-packages directory that is used by TurboGears.
The third option is a bit different since you will set an environment variable to be picked up by apache:
mkdir -p /tmp/turbogears-eggcache 2>&1 >/dev/null export PYTHON_EGG_CACHE="/tmp/turbogears-eggcache" apachectl start
it is your responsibility to correctly secure this /tmp/turbogears-eggcache directory to avoid any security holes.
I have seen informations about using a PythonOption to set the PYTHON_EGG_CACHE but I have never been able to make it work. If someone succeeds in using a PythonOption directive inside the apache.conf file to set this variable I’ll be delighted to hear about it.
The config file was also edited to add all the relevant logging directives that could not be loaded from the external log.cfg file the resulting config file is:
[global] sqlalchemy.dburi="mysql://tg:tg@localhost:3306/tg" sqlalchemy.echo = 0 server.environment="production" #server.environment="development" autoreload.on = False server.thread_pool = 30 server.webpath="/myapp" tg.strict_parameters = False # Set the following to True if you are deploying your app using mod_proxy, # mod_rewrite or any other mechanism that forwards requests to your app. base_url_filter.on = True #base_url_filter.use_x_forwarded_host = False [logging] [[handlers]] [[[access_out]]] # set the filename as the first argument below args="('/usr/local/apache2/logs/myapp.log',)" class='FileHandler' level='INFO' formatter='message_only' [[[debug_out]]] class='StreamHandler' level='DEBUG' args='(sys.stdout,)' formatter='full_content' [[[error_out]]] class='StreamHandler' level='ERROR' args='(sys.stdout,)' [[loggers]] [[[psfeed]]] level='ERROR' qualname='psfeed' handlers=['error_out'] [[[access]]] level='INFO' qualname='turbogears.access' handlers=['access_out'] propagate=0 [[formatters]] [[[message_only]]] format='*(message)s' [[[full_content]]] format='*(asctime)s *(name)s *(levelname)s *(message)s'
As you can see the log file was set to some directory were Apache can write easily.
All this was tested on OpenBSD 4.0 using a self compiled apache 2.2.3 with mod_python-3.3.0b. It was not tested intensively since I use mod_proxy but at least was confirmed to basically _work_. I cannot comment about the database caching issues that some people seem to have encountered as I have not used this setup long enough.
I have amended this document at the same time I used it to perform a ‘from-scratch’ installation on Windows for rewriting this document. It works for me. For the record mod_python for windows can be downloaded from here: mod_pythonwindows
There have been reports about problems with using SQLObject and mod_python together in the past. I could not verify if the problem reported on that page still persists.
Warning
Please note that I do not use this setup on any machine because of performance issues. I have long since switched to mod_proxy for deployment. If someone has any idea why there is such a performance impact when running on mod_python, please add some information here. | http://www.turbogears.org/1.0/docs/Install/ModPython.html | CC-MAIN-2014-41 | refinedweb | 1,178 | 56.96 |
im making a code that will solve a simple algebra problem in the form of y=mx+b, and im not sure how to assign the value of the math done to x
this is the code, how do i make the result of [(y-b)/m] assign to x?this is the code, how do i make the result of [(y-b)/m] assign to x?Code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int x = 0;
int m = 0;
int b = 0;
int y = 0;
cout << "Y = _\n";
cin >> y;
cout << "M = _\n";
cin >> m;
cout << "B = _\n";
cin >> b;
((y - b)/m) = x; //This is the problem spot
cout << "X =\n"; cout << x;
system("PAUSE");
return EXIT_SUCCESS;
} | http://cboard.cprogramming.com/cplusplus-programming/88447-help-algebra-code-printable-thread.html | CC-MAIN-2014-52 | refinedweb | 129 | 66.44 |
C - Structure - Struct
Structure and Linked List with C Programming in Tamil
Learn C - C tutorial - struct - C examples - C programs
C Structure - struct - Definition and Usage
- In C- Programming the Structure is defined as a collection of different data types which are grouped together and each element in a C structure is called member.
- In C-Programming Structure is similar to array but we can declare different data type in a single structure
C Syntax
struct structureName { //member definitions };
Example
Let's see the example to define structure for employee in c.
struct employee { int id; char name[50]; float salary; };
- Here,
- struct is the keyword,
- employee is the tag name of structure,
- id, name and salary are the members or fields of the structure.
Declaring Structure Variable
- We can declare variable for the structure, so that we can access the member of structure easily.
- There are two ways to declare structure variable:
- By struct keyword within main() function
- By declaring variable at the time of defining structure.
Accessing Members of a Structure
- There are two ways to access structure members:
- By . (member or dot operator)
- By -> (structure pointer operator)
Example 1:
Sample - C Code
#include <stdio.h> #include <string.h> #include <conio.h> void main() struct student { int id; char name[20]; float percentage; }; void main() { struct student record = {0}; //Initializing to null record.id=1; strcpy(record.name, "xxxx"); record.percentage = 86.5; printf(" Id is: %d \n", record.id); printf(" Name is: %s \n", record.name); printf(" Percentage is: %f \n", record.percentage); getch(); }
C Code - Explanation
- In this statement we create the structure with the structure name as “student” .
- Here in this statement we initialize the structure with its element value as zero.
- In this statement we assign the id value as “id=1” .
- In this statement we assign the name value as “xxxx” .
- In this statement we assign the percentage value as “86.5” .
- Here in this statement we print the value of the record id using structure name with its elements. In this program we define three printf statement which will print the record id, name & percentage value.
Sample Output - Programming Examples
- Here in this output the structure variable id, name and percentage values (1, XXXX and 86.500000) are printed using the printf statement as shown here in the console window.
Example 2:
Sample Code
#include<stdio.h> #include<string.h> #include<conio.h> struct employee { int id; char name[50]; } e1; void main() { e1.id=101; strcpy(e1.name, "Venkat"); printf( "employee 1 id : %d\n", e1.id); printf( "employee 1 name : %s\n", e1.name); getch(); }
Output:
employee 1 id : 101 employee 1 name : Venkat -
Nested structure
- A structure can be nested inside another structure. In other words, the members of a structure can be of any other type including structure.
- There are two ways to define nested structure in c language:
- By separate structure
- By Embedded structure
Separate Structures
- We can create 2 structures, but dependent structure should be used inside the main structure as a member.
Example
struct Date { int dd; int mm; int yyyy; }; struct Employee { int id; char name[20]; struct Date doj; }emp1;
Embedded Structures
- We can define structure within the structure also. It requires less code than previous way. But it can't be used in many structures.
struct Employee { int id; char name[20]; struct Date { int dd; int mm; int yyyy; } doj; } emp1;
- We can access the member of nested structure by
Outer_Structure.Nested_Structure.member:
- e1.doj.dd
- e1.doj.mm
- e1.doj.yyyy
Example
Sample Code
#include <stdio.h> struct Employee { char name[20]; int id; struct date { int dd; int mm; int yyyy; } doj; } emp1= {“Kaashiv",1000,{22,6,1990}}; void main() { printf("\nEmployee Name : %s",emp1.name); printf("\nEmployee ID : %d",emp1.id); printf("\nEmployee DOJ : %d/%d/%d",emp1.doj.dd,emp1.doj.mm,emp1.doj.yyyy); getch(); }
Output
Employee Name : Kaashiv Employee ID : 1000 Employee DOB : 22/6/1990
Array of Structures
- There can be array of structures in C programming to store many information of different data types.
- The array of structures is also known as collection of structures.
Sample Code
#include<stdio.h> #include <string.h> struct student { int rollno; char name[10]; }; void main() { int i; struct student st[3]; printf("Enter Records of 3 students"); for(i=0;i<3;i++) { printf("\nEnterRollno:"); scanf("%d",&st[i].rollno); printf("\nEnter Name:"); scanf("%s",&st[i].name); } printf("\nStudent Information List:"); for(i=0;i<3;i++) { printf("\nRollno:%d,Name:%s",st[i].rollno,st[i].name); } getch(); }
Output
Enter Records of 3 students Enter Rollno:1 Enter Name:venkat Enter Rollno:2 Entern Name:arun Enter Rollno:3 Enter Name:ranjith Student Information List: Rollno:1, Name:venkat Rollno:2, Name:arun Rollno:3, Name:ranjith | https://www.wikitechy.com/tutorials/c-programming/struct | CC-MAIN-2019-43 | refinedweb | 804 | 56.35 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.