2007/08/13

You have probably NumLock or CapsLock ON ...

1. The keyboard shortcuts (accelerator keys) are not working when 'Caps' or 'Num Lock' are switched on. Have I overlooked something obvious?

You haven't overlooked anything, it's a Motif design flaw. Netscape painfully works around this and the Alt/Meta key reversal on Sun workstations by internally re-implementing the Motif menu accelerator mechanism. NEdit will likely follow suit with the release of version 5.2.

Another possibility (writes Peter Daifuku of SGI):

There's another answer which unfortunately isn't widespread as yet. For an X11R6.3 X server supporting the XKB extension, there is a mechanism to ignore the NumLock and CapsLock key as modifiers. The file /usr/lib/X11/xkb/X0-config.keyboard should contain the string IgnoreLockMods=NumLock+Lock . For systems with multiple displays, display 1 would be controlled by the file X1-config.keyboard, etc.

On SGI systems, this mechanism is support on IRIX 6.2 with X server patch 1574 or later, on IRIX 6.3 and IRIX 6.4 and all later releases.

Guys do you use the Run feature in Windows XP? For most, this featureremains unused (or rarely used). Why is that? Well, First off nearlyall of the Run Commands Correspond to a particular Control Panel Itemor a Utility, Tool or Task that can be accessed through Windows. Thereare, however, tools and utilities that I bet you never knew you hadthat can be accessed through the Run feature. The main reason mostpeople don't use the Run feature is because they don't know theCommands. So, to solve that problem, I decided to put together thefollowing listing, which lists 101 Run Commands and what theycorrespond too...

2007/06/22

Suppose you are writing a pattern rule to compile a `.c' file into a `.o' file: how do you write the `cc' command so that it operates on the right source file name? You cannot write the name in the command, because the name is different each time the implicit rule is applied.

What you do is use a special feature of make, the automatic variables. These variables have values computed afresh for each rule that is executed, based on the target and prerequisites of the rule. In this example, you would use `$@' for the object file name and `$It's very important that you recognize the limited scope in which automatic variable values are available: they only have values within the command script. In particular, you cannot use them anywhere within the target list of a rule; they have no value there and will expand to the empty string. Also, they cannot be accessed directly within the prerequisite list of a rule. A common mistake is attempting to use $@ within the prerequisites list; this will not work. However, there is a special feature of GNU make, secondary expansion (see Secondary Expansion), which will allow automatic variable values to be used in prerequisite lists.

Here is a table of automatic variables:

$@

The file name of the target of the rule. If the target is an archive member, then `$@' is the name of the archive file. In a pattern rule that has multiple targets (see Introduction to Pattern Rules), `$@' is the name of whichever target caused the rule's commands to be run.

$%

The target member name, when the target is an archive member. See Archives. For example, if the target is foo.a(bar.o) then `$%' is bar.o and `$@' is foo.a. `$%' is empty when the target is not an archive member.

$<

The name of the first prerequisite. If the target got its commands from an implicit rule, this will be the first prerequisite added by the implicit rule (see Implicit Rules).

$?

The names of all the prerequisites that are newer than the target, with spaces between them. For prerequisites which are archive members, only the member named is used (see Archives).

$^

The names of all the prerequisites, with spaces between them. For prerequisites which are archive members, only the member named is used (see Archives). A target has only one prerequisite on each other file it depends on, no matter how many times each file is listed as a prerequisite. So if you list a prerequisite more than once for a target, the value of $^ contains just one copy of the name. This list does not contain any of the order-only prerequisites; for those see the `$|' variable, below.

$+

This is like `$^', but prerequisites listed more than once are duplicated in the order they were listed in the makefile. This is primarily useful for use in linking commands where it is meaningful to repeat library file names in a particular order.

$|

The names of all the order-only prerequisites, with spaces between them.

$*

The stem with which an implicit rule matches (see How Patterns Match). If the target is dir/a.foo.b and the target pattern is a.%.b then the stem is dir/foo. The stem is useful for constructing names of related files. In a static pattern rule, the stem is part of the file name that matched the `%' in the target pattern.

In an explicit rule, there is no stem; so `$*' cannot be determined in that way. Instead, if the target name ends with a recognized suffix (see Old-Fashioned Suffix Rules), `$*' is set to the target name minus the suffix. For example, if the target name is `foo.c', then `$*' is set to `foo', since `.c' is a suffix. GNU make does this bizarre thing only for compatibility with other implementations of make. You should generally avoid using `$*' except in implicit rules or static pattern rules.

If the target name in an explicit rule does not end with a recognized suffix, `$*' is set to the empty string for that rule.

`$?' is useful even in explicit rules when you wish to operate on only the prerequisites that have changed. For example, suppose that an archive named lib is supposed to contain copies of several object files. This rule copies just the changed object files into the archive:

lib: foo.o bar.o lose.o win.o ar r lib $?

Of the variables listed above, four have values that are single file names, and three have values that are lists of file names. These seven have variants that get just the file's directory name or just the file name within the directory. The variant variables' names are formed by appending `D' or `F', respectively. These variants are semi-obsolete in GNU make since the functions dir and notdir can be used to get a similar effect (see Functions for File Names). Note, however, that the `D' variants all omit the trailing slash which always appears in the output of the dir function. Here is a table of the variants:

`$(@D)'

The directory part of the file name of the target, with the trailing slash removed. If the value of `$@' is dir/foo.o then `$(@D)' is dir. This value is . if `$@' does not contain a slash.

`$(@F)'

The file-within-directory part of the file name of the target. If the value of `$@' is dir/foo.o then `$(@F)' is foo.o. `$(@F)' is equivalent to `$(notdir $@)'.

`$(*D)'

`$(*F)'

The directory part and the file-within-directory part of the stem; dir and foo in this example.

`$(%D)'

`$(%F)'

The directory part and the file-within-directory part of the target archive member name. This makes sense only for archive member targets of the form archive(member) and is useful only when member may contain a directory name. (See Archive Members as Targets.)

`$(<D)'

`$(<F)'

The directory part and the file-within-directory part of the first prerequisite.

`$(^D)'

`$(^F)'

Lists of the directory parts and the file-within-directory parts of all prerequisites.

`$(+D)'

`$(+F)'

Lists of the directory parts and the file-within-directory parts of all prerequisites, including multiple instances of duplicated prerequisites.

`$(?D)'

`$(?F)'

Lists of the directory parts and the file-within-directory parts of all prerequisites that are newer than the target.

Note that we use a special stylistic convention when we talk about these automatic variables; we write “the value of `$

Also see Reinforcing Dialog-Based Security, a paper by two U.S. Air Force Academy professors that demonstrates how to get around the object model guard prompts using VBScript code and the SendKeys method to, in effect, click the buttons on the prompts.

Wait Method (VBA help)

Pauses a running macro until a specified time. Returns True if the specified time has arrived.

Important The Wait method suspends all Microsoft Excel activity and may prevent you from performing other operations on your computer while Wait is in effect. However, background processes such as printing and recalculation continue.

expression.Wait(Time)

expression Required. An expression that returns an Application object.

Time Required Variant. The time at which you want the macro to resume, in Microsoft Excel date format.

How to use SendKeys to imitate the keyboard

faq707-5037Posted: 15 Apr 04

If you perform the process using the keyboard you will note that things do not happen instantly on screen - especially the initial opening of a dialog box where the action takes place. The main problem with SendKeys is that the code usually runs faster than Windows can carry out the required activity - this is especially so if manipulating an external (not the one with the code) application or opening a dialog box or menu. We therefore need to slow the action down by using Wait statements. SendKeys also has its own "Wait" argument True or False which needs to be used correctly. One example of using it set to True is when manipulating external applications that require extra time to carry out actions. This is not always sufficient, so extra code is required.

A big key to success in this area is to break down the process into small steps. It does need a bit of trial and error to get it right. Experience shows that operators are prepared to wait a bit longer if it works. Sometimes the speed of external applications varies so much that the job is impossible using SendKeys, when using API calls with KeyUp and KeyDown work better. This area is never an exact science. See VBA Help 'SendKeys' and 'Shell' for more information.

SendKeys Statement, (VBA help)

Sends one or more keystrokes to the active window as if typed at the keyboard.

Syntax

SendKeys string[, wait]

The SendKeys statement syntax has these named arguments:

Part Description string Required. String expression specifying the keystrokes to send. Wait Optional. Boolean value specifying the wait mode. If False (default), control is returned to the procedure immediately after the keys are sent. If True, keystrokes must be processed before control is returned to the procedure.

Remarks

Each key is represented by one or more characters. To specify a single keyboard character, use the character itself. For example, to represent the letter A, use "A" for string. To represent more than one character, append each additional character to the one preceding it. To represent the letters A, B, and C, use "ABC" for string.

The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses ( ) have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use {+}. Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that may be significant when dynamic data exchange (DDE) occurs. To specify brace characters, use {{} and {}}.

To specify characters that aren't displayed when you press a key, such as ENTER or TAB, and keys that represent actions rather than characters, use the codes shown below:

To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes:

Key Code SHIFT + CTRL ^ ALT %

To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to specify to hold down SHIFT while E and C are pressed, use "+(EC)". To specify to hold down SHIFT while E is pressed, followed by C without SHIFT, use "+EC".

To specify repeating keys, use the form {key number}. You must put a space between key and number. For example, {LEFT 42} means press the LEFT ARROW key 42 times; {h 10} means press H 10 times.

Note You can't use SendKeys to send keystrokes to an application that is not designed to run in Microsoft Windows or Macintosh. Sendkeys also can't send the PRINT SCREEN key {PRTSC} to any application.

SendKeys Statement Example

This example uses the Shell function to run the Calculator application included with Microsoft Windows. It uses the SendKeys statement to send keystrokes to add some numbers, and then quit the Calculator. (To see the example, paste it into a procedure, then run the procedure. Because AppActivate changes the focus to the Calculator application, you can't single step through the code.). On the Macintosh, use a Macintosh application that accepts keyboard input instead of the Windows Calculator.

2007/06/16

International Country Codes

The following information was downloaded on 15 June1995 from "http://www.ics.uci.edu/WebSoft/wwwstat/country-codes.txt">http://www.ics.uci.edu/WebSoft/wwwstat/country-codes.txt. Additional useful information may be found in the "Table of Global andCountry Top Level Internet Domains, which is dated 16 April 1995 (as of 15June 1995), and is stored at "http://www.isoc.org/domains.html">http://www.isoc.org/domains.html

2007/06/06

" " " (this line MUST be valid indented in the block!) this is a multiline comment which spawns many linesThe quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog ...the next end line may be NOT indented!" " "

multiline comments are also used to embed what are called doc strings in a function, i.e.:

class school:

""" this class is useful for defining a type of school (1rst. level indented) with its strength,affiliation,address etcthis class has following methods and properties affilitaion() address()"""def affiliation(board): .... ... ...def address(add): ... ... ...

in above piece of code the triple qouted string not only is a commentbut when i declare an object say

2007/06/01

Archive for the ‘PHP’ CategoryUsing PHP to highlight links in htmlSunday, March 4th, 2007 by Rob Thomson

Seems to me that there are loads of code samples that show you how to ‘auto highlight’ email addresses and web addresses in a string. Useful, but what happens when the link is already surrounded by an A tag?

I put together this little function (a little dirty but effective) to ‘ignore’ links that are already surrounded by an A tag. This prevents any unexpected double linking of your code.

–

function findlinks($string){

$string = $string ;

# regular expresion to find matches$href_regex =”$href_regex .=”\s*”; // 2 zero or more whitespace$href_regex .=”a”; // 3 the a of the tag itself$href_regex .=”\s+”; // 4 one or more whitespace$href_regex .=”[^>]*”; // 5 zero or more of any character that is _not_ the end of the tag$href_regex .=”href”; // 6 the href bit of the tag$href_regex .=”\s*”; // 7 zero or more whitespace$href_regex .=”=”; // 8 the = of the tag$href_regex .=”\s*”; // 9 zero or more whitespace$href_regex .=”[\”‘]?”; // 10 none or one of ” or ‘$href_regex .=”(”; // 11 opening parenthesis, start of the bit we want to capture$href_regex .=”[^\”‘ >]+”; // 12 one or more of any character _except_ our closing characters$href_regex .=”)”; // 13 closing parenthesis, end of the bit we want to capture$href_regex .=”[\”‘ >]”; // 14 closing chartacters of the bit we want to capture

Posted in PHP | No Comments »Using EVAL to parse an html fileSunday, March 4th, 2007 by Rob Thomson

Every now and again I stumble upon a little bit of code that just ‘works’. Anyone who as ever coded in PHP and tried to ‘eval’ and html file is almost certain to have ended up a bit frustrated. It would seem that eval can only process pure PHP, and not a file that has any html tags etc in it.

Never mind! After trawling the net for a while I found this great code snippet that does the trick.–

2007/05/30

The "<< EOF" syntax creates what is usually called a "here is" document.The shell takes all of the lines up to (but not including) the line thatbegins "EOF" (in column 1), writes all those lines to a temporary file,and then feeds that file as standard input to "prog", just as in youroriginal example (except that the shell is doing the work for you). When"prog" has finished executing, the temporary file is deleted. You canreplace "EOF" by any string that does not appear in the input; the "<the important part.

Another version of it uses the syntax "<to allow the terminating EOF to be on a line that has leading white spaceon it; it is an instruction to ignore any leading white space in the data(all of the data, not just the EOF line).

It's usually better to use the facilities provided by the shell ratherthan writing out the equivalent code using some other technique. Less codeusually leads to fewer bugs and easier maintenance, because it ishopefully more readable that way. It's probably a bit more efficient touse the "<< XXX" method, but not by a lot in this instance (unless you'redoing it very many times).

One person already gave an example that uses the "<< EOF" syntax,but if you really need to group commands' output together intoa pipe, and you have to commands (and not just interpolated strings),you can do this:

2007/05/15

Cproto generates function prototypes and variable declarations fromC source code. Cproto can also convert function definitions between theold style and the ANSI C style. This conversion will overwrite theoriginal files, however, so be sure to make a backup copy of your originalfiles in case something goes wrong. Since cproto uses a Yacc generatedparser, it shouldn't be confused by complex function definitions as muchas other prototype generators) because it uses a Yacc generated parser.

Cproto will be useful for C programmers, so install cproto if you are goingto do any C programming.

I am sure there is a better solution than this, but in case no onesteps forward with one:---------------------

Greetings,

I don't know the answer to your question but I do know that some IDE'shave a tree view which includes functions prototypes. If your job wason a medium to large scale you could automate the extraction usingthat code. Simply modify the IDE such that it logs the functionprototypes as it adds them to the tree view. Unless you run into somedifficulty, I do not see why this logging code should take longer thana few minutes to add.

Options Controlling C Dialect=============================`-aux-info FILENAME'Output to the given filename prototyped declarations for allfunctions declared and/or defined in a translation unit, includingthose in header files. This option is silently ignored in anylanguage other than C.

Besides declarations, the file indicates, in comments, the originof each declaration (source file and line), whether thedeclaration was implicit, prototyped or unprototyped (`I', `N' fornew or `O' for old, respectively, in the first character after theline number and the colon), and whether it came from a declarationor a definition (`C' or `F', respectively, in the followingcharacter). In the case of function definitions, a K&R-style listof arguments followed by their declarations is also provided,inside comments, after the declaration.