text:
Computer Programming Principles/Maintaining/Debugging

Introduction
Debugging is the art of diagnosing errors in programs and determining how to correct them. "Bugs" come in a variety of forms, including: coding errors, design errors, complex interactions, poor user interface designs, and system failures. Learning how to debug a program effectively, then, requires that you learn how to identify which sort of problem you're looking at, and apply the appropriate techniques to eliminate the problem.

Bugs are found throughout the software life cycle. The programmer may find an issue, a software tester might identify a problem, or an end user might report an unexpected result. Part of debugging effectively involves using the appropriate techniques to get necessary information from the different sources of problem reports.

The most common types of mistakes when programming are:
 * Programming without thinking
 * Writing code in an unstructured manner

Bugs in Detail
What are these different kinds of bugs, then?

With coding errors, the source of the problem lies with programmer induced erroneous or improper code. Some examples of coding errors include:
 * Disregarding adopted conventions.
 * Calling the wrong function ("moveUp", instead of "moveDown")
 * Using the wrong variable names in the wrong places ( "moveTo(y, x)" instead of "moveTo(x, y)")
 * Failing to initialize a variable ( "y = x + 1", where x has not been set) when absolutely required.
 * Skipping a check for an error return.

Software users readily see some design errors, while in other cases design flaws make a program more difficult to improve or fix, and those flaws are not obvious to a user. Obvious design flaws are often demonstrated by programs that run up against the limits of a computer, such as available memory, available disk space, available processor speed, and overwhelming input/output devices. More difficult design errors fall into several categories:
 * Failure to hide complexity
 * Incomplete or ambiguous "contracts"
 * Undocumented side effects

Complex interactivity bugs arise in scenarios where multiple parts of a single program, multiple programs, or multiple computers interact.

Poor user interface designs often lead users to use the program in ways that accomplish something other than what they intend. For example, a "search" page for a web site might have an option for "case-insensitive" searching. When the option is hard for the user to find or see, that user might report a bug that some of their data is "lost", simply because it is not found by the case sensitive search.

Sometimes, computer hardware simply fails, and it usually does so in wildly unexpected ways. Determining that the problem lies not with the software itself, but with the computer(s) on which it is usually complicated by the fact that the person debugging the software may not have access to the hardware that shows the problem.

Preventing Bugs
No discussion of debugging software would be complete without a discussion of how to prevent bugs in the first place. No matter how well you write code, if you write the wrong code, it won't help anyone. If you create the right code, but users cannot work the user interface, you might as well have not written the code. In short, a good debugger should keep an open mind about where the problem might lie.

Although it is outside the scope of this discussion to describe the myriad techniques for avoiding bugs, many of the techniques here are equally useful after the fact, when you have a bug and need to uncover it and fix it. Thus, a brief discussion follows.

Understand the Problem
In order to write effective software, the developer must solve the problem the user needs solved. Users, naturally enough, do not think in strict algorithms, windowing systems, web pages, or command line interfaces. Rather, users may not think of problems in the same way that the developer thinks of problems.

To address this difference, sit down with the intended user, and ask them what they want from the software. Users frequently want more than software can actually deliver, or have contradictory aims, such as software that does more, but doesn't require that they learn anything new. In short, ask the users what their goals are. Absent those goals, users will keep reporting bugs that do not add up to a coherent whole.

Unit Testing
Unit testing means checking what happens in all possible states that the current module can enter. Therefore you should prepare a "test list" where you define all the possible inputs for current module.

For example: We have program that gets positive numbers from the user and process them. First we need to check if the input is a number (it can be a char), then we will check if it's positive. By checking I mean enter input and see what happens.

Hint: When you start to write this test list you'll notice that it's quite hard to predict all the possibilities; if you have the option to ask someone else (that didn't help writing the module) to help it could be fruitful.

Basic debugging steps
Although each debugging experience is unique, certain general principles can be applied in debugging. This section particularly addresses debugging software, although many of these principles can also be applied to debugging hardware.

The basic steps in debugging are:

 * Recognize that a bug exists
 * Isolate the source of the bug
 * Identify the cause of the bug
 * Determine a fix for the bug
 * Apply the fix and test it

Recognize a bug exists
Detection of bugs can be done proactively or passively.

An experienced programmer often knows where errors are more likely to occur, based on the complexity of sections of the program as well as possible data corruption. For example, any data obtained from a user should be treated suspiciously. Great care should be taken to verify that the format and content of the data are correct. Data obtained from transmissions should be checked to make sure the entire message (data) was received. Complex data that must be parsed and/or processed may contain unexpected combinations of values that were not anticipated, and not handled correctly. By inserting checks for likely error symptoms, the program can detect when data has been corrupted or not handled correctly.

If an error is severe enough to cause the program to terminate abnormally, the existence of a bug becomes obvious. If the program detects a less serious problem, the bug can be recognized, provided error and/or log messages are monitored. However, if the error is minor and only causes the wrong results, it becomes much more difficult to detect that a bug exists; this is especially true if it is difficult or impossible to verify the results of the program.

The goal of this step is to identify the symptoms of the bug. Observing the symptoms of the problem, under what conditions the problem is detected, and what work-arounds, if any, have been found, will greatly help the remaining steps to debugging the problem.

Isolate source of bug
This step is often the most difficult (and therefore rewarding) step in debugging. The idea is to identify what portion of the system is causing the error. Unfortunately, the source of the problem isn't always the same as the source of the symptoms. For example, if an input record is corrupted, an error may not occur until the program is processing a different record, or performing some action based on the erroneous information, which could happen long after the record was read.

This step often involves iterative testing. The programmer might first verify that the input is correct, next if it was read correctly, processed correctly, etc. For modular systems, this step can be a little easier by checking the validity of data passed across interfaces between different modules. If the input was correct, but the output was not, then the source of the error is within the module. By iteratively testing inputs and outputs, the debugger can identify within a few lines of code where the error is occurring.

Skilled debuggers are often able to hypothesize where the problem might be (based on analogies to previous similar situations), and test the inputs and outputs of the suspected areas of the program. This form of debugging is an instance of the scientific method. Less skilled debuggers often step sequentially through the program, looking for a place where the behavior of the program is different from that expected. Note that this is still a form of scientific method as the programmer must decide what variables to examine when looking for unusual behavior. Another approach is to use a "binary search" type of isolation process. By testing sections near the middle of the data / processing flow, the programmer can determine if the error happens during earlier or later sections of the program. If no data problems are detected, then the error is probably later in the process.

Identify cause of bug
Having found the location of the bug, the next step is to determine the actual cause of the bug, which might involve other sections of the program. For example, if it has been determined that the program faults because a field is wrong, the next step is to identify why the field is wrong. This is the actual source of the bug, although some would argue that the inability of a program to handle bad data can be considered a bug as well.

A good understanding of the system is vital to successfully identifying the source of the bug. A trained debugger can isolate where a problem originates, but only someone familiar with the system can accurately identify the actual cause behind the error. In some cases it might be external to the system: the input data was incorrect. In other cases it might be due to a logic error, where correct data was handled incorrectly. Other possibilities include unexpected values, where the initial assumptions were that a given field can have only "n" values, when in fact, it can have more, as well as unexpected combinations of values in different fields (field x was only supposed to have that value when field y was something different). Another possibility is incorrect reference data, such as a lookup table containing incorrect values relative to the record that was corrupted.

Having determined the cause of the bug, it is a good idea to examine similar sections of the code to see if the same mistake is repeated elsewhere. If the error was clearly a typo, this is less likely, but if the original programmer misunderstood the initial design and/or requirements, the same or similar mistakes could have been made elsewhere.

Determine fix for bug
Having identified the source of the problem, the next task is to determine how the problem can be fixed. An intimate knowledge of the existing system is essential for all but the simplest of problems. This is because the fix will modify the existing behavior of the system, which may produce unexpected results. Furthermore, fixing an existing bug can often either create additional bugs, or expose other bugs that were already present in the program, but never exposed because of the original bug. These problems are often caused by the program executing a previously untested branch of code, or under previously untested conditions.

In some cases, a fix is simple and obvious. This is especially true for logic errors where the original design was implemented incorrectly. On the other hand, if the problem uncovers a major design flaw that permeates a large portion of the system, then the fix might range from difficult to impossible, requiring a total rewrite of the application.

In some cases, it might be desirable to implement a "quick fix", followed by a more permanent fix. This decision is often made by considering the severity, visibility, frequency, and side effects of the problem, as well as the nature of the fix, and product schedules (e.g., are there more pressing problems?).

Fix and test
After the fix has been applied, it is important to test the system and determine that the fix handles the former problem correctly. Testing should be done for two purposes: (1) does the fix now handle the original problem correctly, and (2) make sure the fix hasn't created any undesirable side effects.

For large systems, it is a good idea to have regression tests, a series of test runs that exercise the system. After significant changes and/or bug fixes, these tests can be repeated at any time to verify that the system still executes as expected. As new features are added, additional tests can be included in the test suite.

Steps to reduce debugging
There are concrete steps that can be taken to reduce the amount of time spent debugging software. These are listed in the sections below.

The correct mindset
Probably the most important thing you can do when you are starting to debug a program is to realize that you don't understand what is going on. Programmers who are convinced that their program should work fine are less likely to find errors simply because they are refusing to admit their confusion. If the program behaved the way you think it does, you wouldn't be debugging; the program would be working fine. Even when the program appears to work, if you examine it with the thought that there is at least one bug remaining and you are going to find it, then you are more likely to find something wrong with the program.

Start at the source
The time when you are most aware of where problems are more likely to arise is usually when first designing and writing the code. By inserting integrity checks at various places within the program, problems can be detected and reported by the program itself. In addition to detecting problems, considerations should be given as to how best to handle each error. Options include:
 * Report error, set invalid fields to a default value, and continue
 * Report error, discard the record associated with the invalid value, and continue
 * Report error, transfer invalid record into separate file/table so the user can examine and possibly correct the problem
 * Report error and terminate the program

Treat user input with suspicion
Any data that originated from users (including external systems) should be treated with suspicion. Carefully validate all such input data, performing syntactical and semantical integrity checks. Such invalid data are a common source of programming errors. Think not just of data entered in error, but malicious data as well, as in buffer overflow exploits.

If data are entered interactively by users, you can provide appropriate error messages and allow the user to correct the invalid field(s). If data are not from an interactive source, then the erroneous records should be handled as described above.

Use of log files
Programs that write information to log files can provide significant information that can be used to analyze what was going on before, during, and after problems are encountered. The number of entries to be searched can be reduced by creating various log files, such as a separate log for each major component of the system, plus one log file strictly for errors. Each entry should be date/time stamped so that entries from different logs can be correlated.

Test suites
A standard set of tests that can be run to perform tests can assist in finding errors before they make it into production. These test cases should be automated as much as possible to reduce the amount of effort required to perform these tests. As new features are added to the system, additional tests should be created to exercise those features.

Change one thing at a time
When making a lot of changes, apply them incrementally. Add one change, and then test that change thoroughly before starting on the next change. This will reduce the number of possible sources of new bugs. If several different changes are applied at the same time, then it is much more difficult to identify the source of the problem. Furthermore, minor errors in different areas can interact to produce errors that never would have happened if those changes had been applied one at a time.

Back out changes that have no effect
If you make a change to fix a problem, but the program still behaves the same, back out those changes before proceeding. The fact that your changes didn't do anything indicates one of several things:
 * The problem is not where you think it is
 * The area you modified either isn't being called, or isn't being called the way you think it is
 * Assuming the section you changed wasn't executed, you might have introduced new bugs that won't appear until you fix the current bug

Try another port of your Application
Programs, that are available under different Architectures (e.g. Operation Systems like MS Windows, MacOSX, Linux or Processors like Intel Pentium, PowerPC or DEC Alpha) sometimes react differently on other Systems (especially for subsequent errors). Sometimes it is far more easy to find the error on a different architecture.

Think of similar situations
When a bug has been found, think of other places where the same mistake might have been made. Check those places and see if the same problem exists there as well.

Finding Coding Errors
Not every kind of program is debugged in the same way and not all techniques can be used on all types of programs.

The main character in debugging is the debugger. This is software which runs simultaneous with the newly written program and allows you to pause the program and read memory addresses, stack and various other normally invisible parts of your program.

Another method of debugging is the log-file. Outputting the contents of certain variables can provide valuable information on how your program performs. Outputting a string containing the name of the function when the function is called can be useful in locating when an error is introduced. For finding where a program crashes it's more practical to use the debugger.

Large programs are hard to debug, small programs are (relatively) easy to debug. So the key is to turn a large program into a lot of small programs for debugging. This is called "Unit testing" and involves compiling a part of your program (a routine, a collection of related routines, a module or even a complete subsystem) with extra code to allow it to run without the rest of the code in place.

Full screen application (especially games) can be hard to debug as you won't be able to see the debuggers output. A solution lays in using a null-modem cable, a second computer and a terminal program (e.g. Hyper-terminal). Pipe the output of the debugger through the null modem cable to the second computer.

e.g. In Dos with gdb using a serial null modem cable:

Configure the port with mode: mode COM2: 9600,n,8,1,none Pipe the output to COM2 by adding >COM2 when you invoke the debugger.


text:
User:Zeeshan khan

Muhammad Zeeshan Khan is a new-blooded increment in the field of Information Technology especially in web developing. He is 16 years old student of spiritual science. He has greater interest in research of holy books such as the Quran, the Bible, the Bhagavad-Gita, the book of Adam, the book of Enoch and the Tai Ti Ching etc. He has also research on Life, Bibliography & History of Prophet & Sufi (Saints)& also research on History of pharaoh, Mesopotamia & other ancient civilization. Studying and searching information books, computer science, information technology, general history, education and journalism are his major Interesting subjects. He is awaiting to home your honorable comments and advices belong to this site. Please send your comment by e-mail yet.

E-MAIL selk2000@hotmail.com

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: User:Zeeshan khan


text:
MATLAB Programming/Psychtoolbox/Differences Between Psychtoolbox Versions

 * MATLAB Programming/Psychtoolbox/Version independent scripts - Scripts to allow you to write programs that run on all versions of psychtoolbox.


text:
MATLAB Programming/Psychtoolbox/Screen

For all commands in a single screen go to Psychtoolbox:Screen Commands.

Here's a list of all commands that you can issue using the screen function.

 * BlitImage255
 * BringMATLABToFront
 * BringWindowToFront
 * ClearScreen
 * Close
 * CloseAll
 * CloseScreen
 * Computer
 * CopyWindow
 * CopyWindows
 * DrawLine
 * DrawOval
 * DrawPoly
 * DrawRect
 * DrawText
 * FillArc
 * FillOval
 * FillPoly
 * FillRect
 * FrameArc
 * FrameOval
 * FrameRate
 * FrameRect
 * Gamma
 * GetClut
 * GetFrontWindow
 * GetImage
 * GetImage255
 * GetMATLABWindow
 * GetWindowByTitle
 * GlobalRect
 * IsOffscreen
 * MATLABToFront
 * MoveWindow
 * OpenOffscreenWindow
 * OpenWindow
 * PixelSize
 * PixelSizes
 * Preference
 * PutColorImage
 * PutImage
 * Rect
 * Screens
 * SelectMATLAB
 * SetClut
 * SetClutQ
 * SetDrawingRegion
 * SetGamma
 * TextFace
 * TextFont
 * TextMode
 * TextSize
 * TextStyle
 * TextWidth
 * UsageWarnings
 * VideoCard
 * WaitBlanking
 * WaitVBL
 * WindowKind
 * Windows
 * WindowScreenNumber
 * WindowTitle
 * WindowToBack
 * WindowToFront

title: MATLAB Programming/Psychtoolbox/Screen


text:
Template:Psychtoolbox Header

Back to MATLAB Programming/Psychtoolbox /Templates

title: Template:Psychtoolbox Header


text:
MATLAB Programming/Psychtoolbox/Screen Commands

BlitImage255
Usage:

SCREEN(windowPtr,'PutImage',imageArray,[rect],[copyMode])

Copy "imageArray" to a window, slowly. "imageArray" may be double or uint8. Its values, which should be non-negative integers, are copied to the window, by CopyBits or CopyBitsQuickly. "imageArray" can be an MxN array (for any window) or MxNx3 array (only if the window pixelSize is 16 or 32 bits). In the latter case the three r g b components are combined, as appropriate for the window pixelSize, to form a single value that is copied to the window. In 16-bit mode r, g, and b each contribute 5 bits. In 32-bit mode r, g, and b each contribute 8 bits.

"rect" is in window coordinates. The whole image is copied to "rect", scaling if necessary. The rect default is the imageArray's rect, centered in the window. The orientation of the array in the window is identical to that of MATLAB's numerical array displays in the Command Window. The first pixel is in the upper left, and the rows are horizontal. Unless you specify a "Quickly" copyMode, PutImage inherits the behavior of CopyBits, scaling the image into the rect.

The copyMode argument is a string variable that is passed to the VideoToolbox CopyWindows routine. copyMode can be 'srcCopy' (default) or 'bltFast'.

The copying is done in two stages. First, slowly, from the image array into a temporary offscreen window, and then, quickly, from there to the window designated by "windowPtr".

BringMATLABToFront
Usage:

SCREEN('MATLABToFront',[n])

Bring forward n-th window in MATLAB Window menu. If not specified, n defaults to 0 (the command window).

BringWindowToFront
Usage:

SCREEN(windowPtr,'WindowToFront')

Bring specified window to front.

ClearScreen
Usage:

SCREEN(windowPtr,'FillRect',[color],[rect])

Fill "rect". "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces white with the standard CLUT for this window's pixelSize. Default "rect" is entire screen, so you can use this function to clear the screen.

Close
Usage:

SCREEN(windowPtr,'Close')

Close any of SCREEN's windows (on- or offscreen). Closing an on-screen window takes about a second. After closing the last on-screen window the cursor is made visible.

CloseAll
Usage:

SCREEN('CloseAll')

Close all of SCREEN's windows (on- and offscreen). Closing each on-screen window takes about a second. After closing the last on-screen window the cursor is made visible.

CloseScreen
Usage:

SCREEN(windowPtr,'Close')

Close any of SCREEN's windows (on- or offscreen). Closing an on-screen window takes about a second. After closing the last on-screen window the cursor is made visible.

Computer
Usage:

desribeStruct=SCREEN('Computer')

Return information about the computer in a Matlab struct.

CopyWindow
Usage:

SCREEN('CopyWindow',srcWindowPtr,dstWindowPtr,[srcRect],[dstRect],[copyMode])

Copy images, very quickly, between two windows (on- or off- screen). copyMode can be only 'srcCopy' on Win. (default, will scale image to fit in dstRect). Use with Rush for reliable timing. See Rush.

CopyWindows
Usage:

SCREEN('CopyWindow',srcWindowPtr,dstWindowPtr,[srcRect],[dstRect],[copyMode])

Copy images, very quickly, between two windows (on- or off- screen). copyMode can be only 'srcCopy' on Win. (default, will scale image to fit in dstRect). Use with Rush for reliable timing. See Rush.

DrawLine
Usage:

SCREEN(windowPtr,'DrawLine',[color],fromH,fromV,toH,toV,[penWidth],[penHeight],[penMode])

Draw a line. "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel. Default is black. Default "penWidth" and "penHeight" is 1. "penMode" specifies the drawing mode: The Win32 GDI interface does not have support for these Copy, Or, xOr operatation. So the pen modes here represent the line styles of the pen: 'patCopy' (solid pen, default), 'patOr' (dashed), 'patXor' (dashdot), 'patBic' (dotted), 'notPatCopy' (invisible), 'notPatOr' (dashed), 'notPatXor' (dashdotdot), 'notPatBic' (inside frame).

DrawOval
Usage:

SCREEN(windowPtr,'FillOval',[color],[rect])

Fills an ellipse with the given color, inscribed within "rect"."color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces white with the standard CLUT for this window's pixelSize. Default rect is whole window.

DrawPoly
Usage:

SCREEN(windowPtr,'FillPoly',[color],pointList)

Fill polygon. "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces white with the standard CLUT for this window's pixelSize. "pointList" is a matrix: each row specifies the (x,y) coordinates of a vertex.

DrawRect
Usage:

SCREEN(windowPtr,'FillRect',[color],[rect])

Fill "rect". "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces white with the standard CLUT for this window's pixelSize. Default "rect" is entire screen, so you can use this function to clear the screen.

DrawText
Usage:

[newX,newY] = SCREEN(windowPtr,'DrawText',text,[x],[y],[color])

Draw text. "text" may include two-byte characters (e.g. Chinese). Default "x" "y" is current pen location. "color" is the CLUT index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces black with the standard CLUT for this window's pixelSize. "newX,newY" return the final pen location.

FillArc
Usage:

SCREEN(windowPtr,'FillArc',[color],[rect],startAngle,arcAngle)

Draw a filled arc inscribed within the rect. "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces black with the standard CLUT for this window's pixelSize. Default "rect" is entire window. Angles are measured clockwise from vertical.

FillOval
Usage:

SCREEN(windowPtr,'FillOval',[color],[rect])

Fills an ellipse with the given color, inscribed within "rect"."color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces white with the standard CLUT for this window's pixelSize. Default rect is whole window.

FillPoly
Usage:

SCREEN(windowPtr,'FillPoly',[color],pointList)

Fill polygon. "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces white with the standard CLUT for this window's pixelSize. "pointList" is a matrix: each row specifies the (x,y) coordinates of a vertex.

FillRect
Usage:

SCREEN(windowPtr,'FillRect',[color],[rect])

Fill "rect". "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces white with the standard CLUT for this window's pixelSize. Default "rect" is entire screen, so you can use this function to clear the screen.

FrameArc
Usage:

SCREEN(windowPtr,'FrameArc',[color],[rect],startAngle,arcAngle,[penWidth],[penHeight],[penMode])

Draw an arc inscribed within the rect. "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces black with the standard CLUT for this window's pixelSize. Default "rect" is entire window. Default pen size is 1,1 .Angles are measured in degrees, clockwise from vertical.

FrameOval
Usage:

SCREEN(windowPtr,'FrameOval',[color],[rect],[penWidth],[penHeight],[penMode])

Draw the outline of an oval. "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces black with the standard CLUT for this window's pixelSize. Default "rect" is entire window. Default pen size is 1,1.

FrameRate
Usage:

hz=SCREEN(windowPtrOrScreenNumber,'FrameRate',[hz])

Frame rate, in Hz, as most recently measured for this screen (typically when you first opened it).

MacOS: FrameRate counts frames over some measured period and calculates the rate. Setting "hz" doesn't affect the screen, only the returned value. Setting "hz" to NaN or [] forces SCREEN to remeasure it now, eg after you use a Control Panel to change the screen resolution. The cached value is flushed when you close the last window on this screen.

Windows: The returned value is the nominal frame rate, not the measured rate. The returned value is always current. FrameRate will accept an argument, for compatibility with the MacOS implementation, but it ignores the value passed.

FrameRect
Usage:

SCREEN(windowPtr,'FrameRect',[color],[rect],[penWidth],[penHeight],[penMode])

Draw the outline of a rectangle. "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default produces black with the standard CLUT for this window's pixelSize. Default "rect" is entire window. Default pen size is 1,1. "penMode" specifies the drawing mode: The Win32 GDI interface does not have support for these Copy, Or, xOr operatation. So these pen modes here reprensent the line styles of the pen: 'patCopy' (solid pen, default), 'patOr' (dashed), 'patXor' (dashdot), 'patBic' (dotted), 'notPatCopy' (invisible), 'notPatOr' (dashed), 'notPatXor' (dashdotdot), 'notPatBic' (inside frame).

Gamma
Usage:

[oldGammaTable,dacSize]=SCREEN(windowPtrOrScreenNumber,'Gamma',[gammaTable],[dacSize])

Get/set the gamma table. The gamma table will usually be 256x1 or 256x3. Most users won't need this function.

GetClut
Usage:

clut=SCREEN(windowPtrOrScreenNumber,'GetClut',[bits])

Get the color lookup table (CLUT) of a video screen. The returned "clut" is a 3-column matrix with one row per RGB entry in the hardware CLUT. The "clut" values will be in the range 0 to 255 for an 8-bit CLUT.

GetFrontWindow
Usage:

[windowPtr,rect]=SCREEN('GetFrontWindow')

Get window pointer for frontmost window.

GetImage
Usage:

imageArray=SCREEN(windowPtr,'GetImage',[rect])

Slowly copy an image from a window, returning a MATLAB uint8 array. If the window's pixelSize>8 then the returned imageArray has three layers, an RGB image. "rect" is in window coordinates, and its default is the whole window. CHANGE: as of April, 1998, imageArray is now uint8 instead of double to save space (a factor of 8). However, MATLAB will issue an error if you try to do math on a uint8 array, so you may need to use DOUBLE to convert it, e.g. imageArray/255 will produce an error, but double(imageArray)/255 is ok. Also see 'PutImage' and 'CopyWindow'.

GetImage255
Usage:

imageArray=SCREEN(windowPtr,'GetImage',[rect])

Slowly copy an image from a window, returning a MATLAB uint8 array. If the window's pixelSize>8 then the returned imageArray has three layers, an RGB image. "rect" is in window coordinates, and its default is the whole window. CHANGE: as of April, 1998, imageArray is now uint8 instead of double to save space (a factor of 8). However, MATLAB will issue an error if you try to do math on a uint8 array, so you may need to use DOUBLE to convert it, e.g. imageArray/255 will produce an error, but double(imageArray)/255 is ok. Also see 'PutImage' and 'CopyWindow'.

GetMATLABWindow
Usage:

[windowPtr,rect]=SCREEN('GetMATLABWindow',[n])

Get window pointer for n-th in MATLAB's Window menu.

GetWindowByTitle
Usage:

[windowPtr,rect]=SCREEN('GetWindowByTitle',title);

Get window pointer for window with specified title.

GlobalRect
SCREENGlobalRect not supported yet.

IsOffscreen
Usage:

isOffscreen=SCREEN(windowPtr,'IsOffscreen')

Find out whether window is offscreen. Responses: 1=yes; 0=no

MATLABToFront
Usage:

SCREEN('MATLABToFront',[n])

Bring forward n-th window in MATLAB Window menu. If not specified, n defaults to 0 (the command window).

MoveWindow
SCREENMoveWindow is not supported yet.

OpenOffscreenWindow
Usage:

[windowPtr,rect]=SCREEN(windowPtrOrScreenNumber,'OpenOffscreenWindow',[color],[rect],[pixelSize]);

Open an offscreen window (offscreen surface in DirectDraw). This is simply an area in memory that is treated as a window. Offscreen windows are very useful for creating images for subsequent display, because copying between windows is very fast. You may specify a screen (a screenNumber>=0) or no screen (screenNumber=-1). If you do designate a screen then the offscreen window is attached to the DirectDraw object associated with that screen. You may specify no screen (screenNumber=-1), but any real screen must already have an open SCREEN window when you call OpenOffscreenWindow. "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default is white. "rect" specifies the size of the offscreen window and what part of the screen the offscreen window is aligned with. If supplied, "rect" must contain at least one pixel. If a screenNumber is supplied then "rect" is in screen coordinates (origin at upper left), and defaults to the size of that screen. If a screenNumber of -1 is supplied then "rect" defaults to the size of the main screen. (In all cases, subsequent references to this new offscreen window will use its coordinates: origin at its upper left.) "pixelSize" sets the depth (in bits) of each pixel. If you specify a screen (screenNumber>=0) and a pixelSize>0 then they must be consistent. If you specify no screen (screenNumber=-1) then the default pixelSize is the same as the main screen, but you can specify any legal depth: 8, 16, 24, 32. A pixelSize of 0 or [] is replaced by the default.

OpenWindow
Usage:

[windowPtr,rect]=SCREEN(windowPtrOrScreenNumber,'OpenWindow',[color],[rect],[pixelSize]);

Open an onscreen window. Specify a screen by a windowPtr or a screenNumber (0 is the main screen, with menu bar). "color" is the clut index (scalar or [r g b] triplet) that you want to poke into each pixel; default is white. If supplied, "rect" must contain at least one pixel. If a windowPtr is supplied then "rect" is in the window's coordinates (origin at upper left), and defaults to the whole window. If a screenNumber is supplied then "rect" is in screen coordinates (origin at upper left), and defaults to the whole screen. (In all cases, subsequent references to this new window will use its coordinates: origin at its upper left.) The Windows version accepts "rect" but disregards it, the window is always the size of the display on which it appears. "pixelSize" sets the depth (in bits) of each pixel; default is to leave depth unchanged. Opening or closing a window takes about a second.

PixelSize
Usage:

[oldPixelSize,oldIsColor,pages]=SCREEN(windowPtrOrScreenNumber,'PixelSize',[pixelSize],[isColor])

Get/set screen depth, gray/color mode, and number of video pages. (We don't yet provide a way of changing the page.)

PixelSizes
Usage:

pixelSizes=SCREEN(windowPtrOrScreenNumber,'PixelSizes')

List all possible pixelSizes for this screen.The Windows Version returns only pixel sizes available at the current display size.

Preference
Usage:

boolean=SCREEN('Preference','Backgrounding') oldBoolean=SCREEN('Preference','IgnoreCase',[boolean]) psychTableVersion=SCREEN('Preference','PsychTableVersion') mexFunctionName=SCREEN('Preference','PsychTableCreator') oldPriority=SCREEN(windowPtrOrScreenNumber,'Preference','MaxPriorityForBlankingInterrupt',priority) oldBoolean=SCREEN(windowPtrOrScreenNumber,'Preference','WaitBlankingUsesInterrupt',[boolean]) bits=SCREEN(windowPtrOrScreenNumber,'Preference','ClutDacSize') boolean=SCREEN(windowPtrOrScreenNumber,'Preference','FixedClut') oldBoolean=SCREEN(windowPtrOrScreenNumber,'Preference','SetClutDriverWaitsForBlanking',[boolean]) oldBoolean=SCREEN(windowPtrOrScreenNumber,'Preference','SetClutQuickly',[boolean]) oldBoolean=SCREEN(windowPtrOrScreenNumber,'Preference','SetClutCallsWaitBlanking',[boolean]) oldFrames=SCREEN(windowPtrOrScreenNumber,'Preference','SetClutSimulatesBlankingInterrupts',[frames])

Get/set various preferences. The first four are general, the rest are related to WaitBlanking or SetClut and are screen-specific. "boolean" values are 1 (nonzero) for Yes and 0 for No. Preferences are volatile: They're set by SCREEN when you first use each screen, and they're flushed by closing the last SCREEN window (e.g. by 'Close', 'CloseAll', or flushing SCREEN.mex by typing "clear screen"). So do any preference setting after calling 'OpenWindow'. WARNING: These settings allow you to access all the internal parameters that determine SCREEN's behavior. As a result the set of parameters is ever-changing, as SCREEN evolves to deal with an ever-changing environment (e.g. video drivers that don't wait for blanking, and Rush's high priority). Feel free to play with these expert controls, but, if you do, realize that you may have to tweak your 'Preference' calls with each new release of the PsychToolbox.

- SetClutDriverWaitsForBlanking reports whether the monitor's video driver waits for blanking. Usually read-only, you can also set/clear this on the PowerMac 7300/7500/7600/8500/8600 built-in driver. - SetClutQuickly specifies your preference for whether to use a custom SetEntriesQuickly.c driver (if available for this device) in place of the standard video driver. The SetEntriesQuickly drivers don't wait for blanking. - SetClutCallsWaitBlanking determines whether WaitBlanking should be called after each call to SetClut. - SetClutSimulatesBlankingInterrupts sets/gets the number of blanking interrupts to simulate after each SetClut, to make up for interrupts missed during the SetClut call. - WaitBlankingUsesInterrupt specifies a preference for whether WaitBlanking should use SetClut (original driver) or the screen's blanking interrupt to wait for blanking. See 'WaitBlanking'. - MaxPriorityForBlankingInterrupt specifies the maximum priority at which the hardware blanking interrupt still works. Normally this is 1, but it's reduced to 0.5 (on non-PCI Macs) if necessary for timing the 3-ms interval during which spurious VBL interrupts are ignored. Your programs can override this setting, but your computer is likely to hang unless you really know what you're doing.

PutColorImage
PutColorImage is obsolete. Use PutImage instead. Please use SCREENPutImage.

PutImage
Usage:

SCREEN(windowPtr,'PutImage',imageArray,[rect],[copyMode])

Copy "imageArray" to a window, slowly. "imageArray" may be double or uint8. Its values, which should be non-negative integers, are copied to the window, by CopyBits or CopyBitsQuickly. "imageArray" can be an MxN array (for any window) or MxNx3 array (only if the window pixelSize is 16 or 32 bits). In the latter case the three r g b components are combined, as appropriate for the window pixelSize, to form a single value that is copied to the window. In 16-bit mode r, g, and b each contribute 5 bits. In 32-bit mode r, g, and b each contribute 8 bits.

"rect" is in window coordinates. The whole image is copied to "rect", scaling if necessary. The rect default is the imageArray's rect, centered in the window. The orientation of the array in the window is identical to that of MATLAB's numerical array displays in the Command Window. The first pixel is in the upper left, and the rows are horizontal. Unless you specify a "Quickly" copyMode, PutImage inherits the behavior of CopyBits, scaling the image into the rect.

The copyMode argument is a string variable that is passed to the VideoToolbox CopyWindows routine. copyMode can be 'srcCopy' (default) or 'bltFast'.

The copying is done in two stages. First, slowly, from the image array into a temporary offscreen window, and then, quickly, from there to the window designated by "windowPtr".

Rect
Usage:

rect=SCREEN(windowPtrOrScreenNumber,'Rect')

Get local rect of window or screen.

Screens
Usage:

screenNumbers=SCREEN('Screens')

Return an array of screenNumbers.

SelectMATLAB
Usage:

SCREEN('MATLABToFront',[n])

Bring forward n-th window in MATLAB Window menu. If not specified, n defaults to 0 (the command window).

SetClut
Usage:

err=SCREEN(windowPtr,'SetClut',clut,[startEntry],[bits])

Set the DirectDraw palette for the screen.

The palette is set immediately, without waiting for the vertical blanking.

The "clut" argument is a MATLAB matrix with 3 columns. The number of entries written is the number of rows in "clut". Each RGB entry in the hardware CLUT is loaded with a row of "clut". Each "clut" value should be in the range 0 to 255 for an 8-bit CLUT. Argument startEntry is optional and determines which CLUT entry to load first (entries are numbered from 0 up), to load just a subset of the CLUT's entries. We suggest that "startEntry" always be zero or greater.

The "bits" argument specifies how many bits you want to write to the CLUT. Typically it will be 8, which is the default value. If you set it to some other value, the range of allowable entries scales accordingly. Thus if you use a 9-bit CLUT, then each entry should be between 0 and 511, etc.

PREFERENCES:

SetClutQ
Usage:

err=SCREEN(windowPtr,'SetClut',clut,[startEntry],[bits])

Set the DirectDraw palette for the screen.

The palette is set immediately, without waiting for the vertical blanking.

The "clut" argument is a MATLAB matrix with 3 columns. The number of entries written is the number of rows in "clut". Each RGB entry in the hardware CLUT is loaded with a row of "clut". Each "clut" value should be in the range 0 to 255 for an 8-bit CLUT. Argument startEntry is optional and determines which CLUT entry to load first (entries are numbered from 0 up), to load just a subset of the CLUT's entries. We suggest that "startEntry" always be zero or greater.

The "bits" argument specifies how many bits you want to write to the CLUT. Typically it will be 8, which is the default value. If you set it to some other value, the range of allowable entries scales accordingly. Thus if you use a 9-bit CLUT, then each entry should be between 0 and 511, etc.

PREFERENCES:

SetDrawingRegion
Usage:

SCREEN(windowPtr,'SetDrawingRegion',shapeSpec,[shapeFlag])

Make subsequent drawing to the window visible only if it is within the specified region. This does not apply to PutImage or CopyWindow operations. Call with rect equal to screenRect to reestablish the entire screen. Drawing outside the region is suppressed, but still takes the normal amount of time to complete.

If shapeFlag == 0 [default], shapeSpec is a rect, region is rectangular. If shapeFlag == 1, shapeSpec is a rect, region is oval. If shapeFlag == 2, shapeSpec is a point list, region is polygonal.

SetGamma
Usage:

[oldGammaTable,dacSize]=SCREEN(windowPtrOrScreenNumber,'Gamma',[gammaTable],[dacSize])

Get/set the gamma table. The gamma table will usually be 256x1 or 256x3. Most users won't need this function.

TextFace
Usage:

oldStyle=SCREEN(windowPtr,'TextStyle',[style])

Get/set the font style for future text draws in this window. Useful values for style follow; they may be OR'd.

0=normal,1=bold,2=italic,4=underline. (Outline, Condense and Extend are not yet supported on the Windows version)

TextFont
Usage:

[oldFontName,oldFontNumber]=SCREEN(windowPtr,'TextFont',[fontNameOrNumber])

Get/set the font for future text draws in this window. You can ask what the current font is, or specify the desired font by number or by name (e.g. 'Helvetica'). Font numbers may not be consistent from PC to PC.If no windowPtr is given, and no fontName argument is supplied, then print out a list of all font names. The default font (set by Windows) is 1 (the System font) for both on-screen off-screen windows.

TextMode
Usage:

oldCopyMode=SCREEN(windowPtr,'TextMode',[copyMode])

Get/set text copy mode of this window.

copyMode can be an integer or a string: 'srcCopy' (default), 'srcOr', 'srcXor', 'srcBic', 'notSrcCopy', 'notSrcOr', 'notSrcXor', 'notSrcBic', 'patCopy', 'patOr', 'patXor', 'patBic', 'notPatCopy', 'notPatOr', 'notPatXor', 'notPatBic'. On the Windows version, this function does nothing, since there is no apparent options on Windows that correspond to the Mac text modes.

TextSize
Usage:

oldFontSize=SCREEN(windowPtr,'TextSize',[fontSize])

Get/set the font size for future text draws in this window.

TextStyle
Usage:

oldStyle=SCREEN(windowPtr,'TextStyle',[style])

Get/set the font style for future text draws in this window. Useful values for style follow; they may be OR'd.

0=normal,1=bold,2=italic,4=underline. (Outline, Condense and Extend are not yet supported on the Windows version)

TextWidth
Usage:

width=SCREEN(windowPtr,'TextWidth',text);	% horizontal offset (negative for right-to-left scripts, e.g. Hebrew).

Get width of text string. Width is the change in horizontal pen position that would be produced by calling DrawText; it's negative for right-to-left scripts (e.g. Hebrew). The text may include 2-byte characters (e.g. Chinese).

UsageWarnings
Usage:

[oldMore,oldSeverity,oldAlready]=SCREEN('UsageWarnings',[more],[severity],[already])

Control how usage warnings are handled.

Severity=0(suppress),1(warn), 2(error)

VideoCard
Usage:

[cardName,driverName,driverVersion,slotName]=SCREEN(windowPtrOrScreenNumber,'VideoCard')

Get information about video hardware.

WaitBlanking
Usage:

framesSinceLastWait=SCREEN(windowPtrOrScreenNumber,'WaitBlanking',[waitFrames])

Wait specified number of blankings (frame endings). Call with waitFrames==1 (or omit it, since that's the default) to wait for the beginning of the next frame. Video cards mark the end of each video frame by briefly reducing the voltage to the Vertical Blanking Level (VBL), which "blanks" the screen to black. We do all video timing relative to the beginning of blanking. You may want to run 'WaitBlanking' at high priority (see Rush and Priority) for reliable timing. To keep this routine as fast as possible, no value is returned unless you supply an argument to receive it. When processor priority is at or below MaxPriorityForBlankingInterrupt the WaitBlankingUsesInterrupt 'Preference' controls, for each screen, whether 'WaitBlanking' calls SetClut (default) or waits for a blanking interrupt. When processor priority is above MaxPriorityForBlankingInterrupt, 'WaitBlanking' always uses SetClut (i.e. cscSetEntries or cscDirectSetEntries call to video driver).

WaitVBL
Usage:

framesSinceLastWait=SCREEN(windowPtrOrScreenNumber,'WaitBlanking',[waitFrames])

Wait specified number of blankings (frame endings). Call with waitFrames==1 (or omit it, since that's the default) to wait for the beginning of the next frame. Video cards mark the end of each video frame by briefly reducing the voltage to the Vertical Blanking Level (VBL), which "blanks" the screen to black. We do all video timing relative to the beginning of blanking. You may want to run 'WaitBlanking' at high priority (see Rush and Priority) for reliable timing. To keep this routine as fast as possible, no value is returned unless you supply an argument to receive it. When processor priority is at or below MaxPriorityForBlankingInterrupt the WaitBlankingUsesInterrupt 'Preference' controls, for each screen, whether 'WaitBlanking' calls SetClut (default) or waits for a blanking interrupt. When processor priority is above MaxPriorityForBlankingInterrupt, 'WaitBlanking' always uses SetClut (i.e. cscSetEntries or cscDirectSetEntries call to video driver).

WindowKind
Usage:

kind=SCREEN(windowPtr,'WindowKind')

What kind of windowPtr is this? Returns 0 if it's invalid, -1 our offscreen, 1 our onscreen, 2 MATLAB's onscreen.

Windows
Usage:

windowPtrs=SCREEN('Windows')

Return an array of windowPtrs.

WindowScreenNumber
Usage:

screenNumber=SCREEN(windowPtrOrScreenNumber,'WindowScreenNumber')

Get the screen number.

WindowTitle
Usage:

title=SCREEN(windowPtr,'WindowTitle')

Get window's title

WindowToBack
Usage:

SCREEN(windowPtr,'WindowToBack')

Send specified window to back

WindowToFront
Usage:

SCREEN(windowPtr,'WindowToFront')

Bring specified window to front.


text:
Ada Programming/Mathematical calculations

Ada is very well suited for all kinds of calculations. You can define your own fixed point and floating point types and — with the aid of generic packages call all the mathematical functions you need. In that respect Ada is on par with Fortran. This module will show you how to use them and while we progress we create a simple RPN calculator.

Addition
Additions can be done using the predefined operator. The operator is predefined for all numeric types and the following, working code, demonstrates its use:

; Numeric_1 Value_Type  12 -999_999_999_999.0e999 .. 999_999_999_999.0e999; T_IO Ada.Text_IO; F_IO   Ada.Text_IO.Float_IO (Value_Type); Value_1 : Value_Type; Value_2 : Value_Type; T_IO.Put ("First Value : "); F_IO.Get (Value_1); T_IO.Put ("Second Value : "); F_IO.Get (Value_2); F_IO.Put (Value_1); T_IO.Put (" + "); F_IO.Put (Value_2); T_IO.Put (" = "); F_IO.Put (Value_1 Value_2); Numeric_1;

Subtraction
Subtractions can be done using the predefined operator. The following extended demo shows the use of + and - operator together:

Numeric_2 Value_Type 12     -999_999_999_999.0e999 .. 999_999_999_999.0e999; T_IO ; F_IO   Ada.Text_IO.Float_IO (Value_Type); Value_1  : Value_Type; Value_2  : Value_Type; Result   : Value_Type; Operation : Character; T_IO.Put ("First Value : "); F_IO.Get (Value_1); T_IO.Put ("Second Value : "); F_IO.Get (Value_2); T_IO.Put ("Operation   : "); T_IO.Get (Operation); Operation '+' =>        Result := Value_1 + Value_2; '-' =>        Result := Value_1 - Value_2; =>        T_IO.Put_Line ("Illegal Operation."); Exit_Numeric_2; ;  F_IO.Put (Value_1); T_IO.Put (" "); T_IO.Put (Operation); T_IO.Put (" "); F_IO.Put (Value_2); T_IO.Put (" = "); F_IO.Put (Result); Exit_Numeric_2 ; Numeric_2;

Purists might be surprised about the use of goto — but some people prefer the use of goto over the use of multiple return statements if inside functions — given that, the opinions on this topic vary strongly. See the isn't goto evil article.

Multiplication
Multiplication can be done using the predefined operator. For a demo see the next chapter about Division.

Division
Divisions can be done using the predefined operators, ,. The operator performs a normal division,  returns a modulus division and  returns the remainder of the modulus division.

The following extended demo shows the use of the, , and  operators together as well as the use of a four number wide stack to store intermediate results:

The operators and  are not part of the demonstration as they are only defined for integer types.

; Numeric_3 Pop_Value; Push_Value; Value_Type  12 -999_999_999_999.0e999 .. 999_999_999_999.0e999; Value_Array  (Natural  1 .. 4)  Value_Type; T_IO Ada.Text_IO; F_IO  Ada.Text_IO.Float_IO (Value_Type); Values   : Value_Array := ( => 0.0); Operation : String (1 .. 40); Last     : Natural; Pop_Value Values (Values' + 1 .. Values') := Values (Values' + 2 .. Values') & 0.0; Pop_Value; Push_Value Values (Values' + 1 .. Values') := Values (Values' .. Values' - 1); Push_Value; Main_Loop: T_IO.Put (">"); T_IO.Get_Line (Operation, Last); Last = 1  Operation (1) = '+' Values (1) := Values (1) + Values (2); Pop_Value; Last = 1  Operation (1) = '-' Values (1) := Values (1) + Values (2); Pop_Value; Last = 1  Operation (1) = '*' Values (1) := Values (1) * Values (2); Pop_Value; Last = 1  Operation (1) = '/' Values (1) := Values (1) / Values (2); Pop_Value; Last = 4  Operation (1 .. 4) = "exit" Main_Loop; Push_Value; F_IO.Get (From => Operation, Item => Values (1), Last => Last); ;      Display_Loop: I  Value_Array' F_IO.Put (Item => Values (I),            Fore => F_IO.Default_Fore,             Aft  => F_IO.Default_Aft,             Exp  => 4); T_IO.New_Line; Display_Loop; Main_Loop; ; Numeric_3;

Exponential calculations
All exponential functions are defined inside the generic package.

Power of
Calculation of the form $$x^y$$ are performed by the operator. Beware: There are two versions of this operator. The predefined operator allows only for Standard.Integer to be used as exponent. If you need to use a floating point type as exponent you need to use the defined in.

Root
The square root $$ \sqrt{x} $$ is calculated with the function. There is no function defined to calculate an arbitrary root $$\sqrt[n]{x}$$. However you can use logarithms to calculate an arbitrary root using the mathematical identity: $$ \sqrt[b]{a} = e^{\log_e (a) / b} $$ which will become  in Ada. Alternatively, use $$\sqrt[b]{a}=a^{\frac1b}$$ which, in Ada, is.

Logarithm
defines a function for both the arbitrary logarithm $$log_n(x)$$ and the natural logarithm $$log_e(x)$$, both of which have the same name  distinguished by the number of parameters.

Demonstration
The following extended demo shows the how to use the exponential functions in Ada. The new demo also uses Unbounded_String instead of Strings which make the comparisons easier.

Please note that from now on we won't copy the full sources any more. Do follow the download links to see the full program.

; ;  ;  Numeric_4 Str Ada.Strings.Unbounded; T_IO Ada.Text_IO; Pop_Value; Push_Value; Get_Line Str.Unbounded_String; Value_Type  12 -999_999_999_999.0e999 .. 999_999_999_999.0e999; Value_Array  (Natural  1 .. 4)  Value_Type; F_IO  Ada.Text_IO.Float_IO (Value_Type); Value_Functions  Ada.Numerics.Generic_Elementary_Functions (      Value_Type); Value_Functions; Str.Unbounded_String; Values   : Value_Array := ( => 0.0); Operation : Str.Unbounded_String; Dummy    : Natural; Get_Line Str.Unbounded_String BufferSize : := 2000; Retval    : Str.Unbounded_String := Str.Null_Unbounded_String; Item      : String (1 .. BufferSize); Last      : Natural; Get_Whole_Line : T_IO.Get_Line (Item => Item, Last => Last); Str.Append (Source => Retval, New_Item => Item (1 .. Last)); Get_Whole_Line Last < Item'; Get_Whole_Line; Retval; Get_Line; ...  Main_Loop : T_IO.Put (">"); Operation := Get_Line; ...         Operation = "e" Push_Value; Values (1) := Ada.Numerics.e;         Operation = "**"   Operation = "^" Values (1) := Values (1) ** Values (2); Pop_Value; Operation = "sqr" Values (1) := Sqrt (Values (1)); Operation = "root" Values (1) := Exp (Log (Values (2)) / Values (1)); Pop_Value; Operation = "ln" Values (1) := Log (Values (1)); Operation = "log" Values (1) := Log (Base => Values (1), X => Values (2)); Pop_Value; Operation = "" Main_Loop; Push_Value; F_IO.Get (From => Str.To_String (Operation),              Item => Values (1),               Last => Dummy); ; ...       Main_Loop; ; Numeric_4;

Trigonometric calculations
The full set of trigonometric functions are defined inside the generic package. All functions are defined for 2π and an arbitrary cycle value (a full cycle of revolution).

Please note the difference of calling the  function.

; ;  ;  Numeric_5 ...   Put_Line (Value :  Value_Type); Value_Functions; Str.Unbounded_String; Values   : Value_Array := ( => 0.0); Cycle    : Value_Type  := Ada.Numerics.Pi; Operation : Str.Unbounded_String; Dummy    : Natural; ...   Put_Line (Value :  Value_Type) Value_Type' (Value) >= Value_Type' (10.0 ** F_IO.Default_Aft) F_IO.Put (Item => Value,           Fore => F_IO.Default_Aft,            Aft  => F_IO.Default_Aft,            Exp  => 4); F_IO.Put (Item => Value,           Fore => F_IO.Default_Aft,            Aft  => F_IO.Default_Aft,            Exp  => 0); ;     T_IO.New_Line; ;   Put_Line; ...  Main_Loop : Display_Loop : I   Value_Array' Put_Line (Values (I)); Display_Loop; T_IO.Put (">"); Operation := Get_Line; ...         Operation = "deg" Cycle := 360.0; Operation = "rad" Cycle := Ada.Numerics.Pi; Operation = "grad" Cycle := 400.0; Operation = "pi"  Operation = "π" Push_Value; Values (1) := Ada.Numerics.Pi; Operation = "sin" Values (1) := Sin (X => Values (1), Cycle => Cycle); Operation = "cos" Values (1) := Cos (X => Values (1), Cycle => Cycle); Operation = "tan" Values (1) := Tan (X => Values (1), Cycle => Cycle); Operation = "cot" Values (1) := Cot (X => Values (1), Cycle => Cycle); Operation = "asin" Values (1) := Arcsin (X => Values (1), Cycle => Cycle); Operation = "acos" Values (1) := Arccos (X => Values (1), Cycle => Cycle); Operation = "atan" Values (1) := Arctan (Y => Values (1), Cycle => Cycle); Operation = "acot" Values (1) := Arccot (X => Values (1), Cycle => Cycle); ...       Main_Loop; ; Numeric_5;

The Demo also contains an improved numeric output which behaves more like a normal calculator.

Hyperbolic calculations
You guessed it: The full set of hyperbolic functions is defined inside the generic package.

; ;  ;  ;  Numeric_6 Str Ada.Strings.Unbounded; T_IO Ada.Text_IO; Exept Ada.Exceptions; ...  Main_Loop : Try : Display_Loop : ...               Operation = "sinh" Values (1) := Sinh (Values (1)); Operation = "cosh" Values (1) := Coth (Values (1)); Operation = "tanh" Values (1) := Tanh (Values (1)); Operation = "coth" Values (1) := Coth (Values (1)); Operation = "asinh" Values (1) := Arcsinh (Values (1)); Operation = "acosh" Values (1) := Arccosh (Values (1)); Operation = "atanh" Values (1) := Arctanh (Values (1)); Operation = "acoth" Values (1) := Arccoth (Values (1)); ...               An_Exception :  => T_IO.Put_Line (Exept.Exception_Information (An_Exception)); Try; Main_Loop; ; Numeric_6;

As added bonus this version supports error handling and therefore won't just crash when an illegal calculation is performed.

Complex arithmethic
For complex arithmetic Ada provides the package. This package is part of the "special need Annexes" which means it is optional. The open source Ada compiler GNAT implements all "special need Annexes" and therefore has complex arithmetic available.

Since Ada supports user defined operators, all operators have their usual meaning as soon as the package  has been instantiated ( ...   ...) and the type has been made visible (  ...)

Ada also provides the packages and  which provide similar functionality to their normal counterparts. But there are some differences:

 * supports only the exponential and trigonometric functions which make sense in complex arithmetic.

 * is a child package of and therefore needs its own . Note: the   function is pretty fault tolerant - if you forget the "," or the "" pair it will still parse the input correctly.

So, with only a very few modifications you can convert your "normals" calculator to a calculator for complex arithmetic:

Ada.Text_IO.Complex_IO; Ada.Numerics.Generic_Complex_Types; Ada.Numerics.Generic_Complex_Elementary_Functions; Ada.Strings.Unbounded; Ada.Exceptions; Numeric_7 ...   Complex_Types   Ada.Numerics.Generic_Complex_Types (      Value_Type); Complex_Functions Ada.Numerics.Generic_Complex_Elementary_Functions (     Complex_Types); C_IO  Ada.Text_IO.Complex_IO (Complex_Types); Value_Array (Natural 1 .. 4)  Complex_Types.Complex; Put_Line (Value : Complex_Types.Complex); Complex_Types.Complex; Str.Unbounded_String; Complex_Functions; Values   : Value_Array := ( => Complex_Types.Complex'(Re => 0.0, Im => 0.0)); ...   Put_Line (Value :  Complex_Types.Complex) ( Value_Type' (Value.Re) >=          Value_Type' (10.0 ** C_IO.Default_Aft)) ( Value_Type' (Value.Im) >=                 Value_Type' (10.0 ** C_IO.Default_Aft)) C_IO.Put (Item => Value,           Fore => C_IO.Default_Aft,            Aft  => C_IO.Default_Aft,            Exp  => 4); C_IO.Put (Item => Value,           Fore => C_IO.Default_Aft,            Aft  => C_IO.Default_Aft,            Exp  => 0); ;     T_IO.New_Line; ;   Put_Line; ...               Operation = "e" Push_Value; Values (1) := Complex_Types.Complex'(Re => Ada.Numerics.e, Im => 0.0); ...               Operation = "pi"   Operation = "π" Push_Value; Values (1) := Complex_Types.Complex'(Re => Ada.Numerics.Pi, Im => 0.0); Operation = "sin" Values (1) := Sin (Values (1)); Operation = "cos" Values (1) := Cot (Values (1)); Operation = "tan" Values (1) := Tan (Values (1)); Operation = "cot" Values (1) := Cot (Values (1)); Operation = "asin" Values (1) := Arcsin (Values (1)); Operation = "acos" Values (1) := Arccos (Values (1)); Operation = "atan" Values (1) := Arctan (Values (1)); Operation = "acot" Values (1) := Arccot (Values (1)); ...  ;  Numeric_7;

Vector and Matrix Arithmetic
Ada supports vector and matrix Arithmetic for both normal real types and complex types. For those, the generic packages Ada.Numerics.Generic_Real_Arrays and Ada.Numerics.Generic_Complex_Arrays are used. Both packages offer the usual set of operations, however there is no I/O package and understandably, no package for elementary functions.

Since there is no I/O package for vector and matrix I/O creating a demo is by far more complex — and hence not ready yet. You can have a look at the current progress which will be a universal calculator merging all feature.

Status: Stalled - for a Vector and Matrix stack we need Indefinite_Vectors — which are currently not part of GNAT/Pro. Well I could use the booch components ...

Wikibook

 * Ada Programming
 * Ada Programming/Delimiters/-
 * Ada Programming/Libraries/Ada.Numerics.Generic Complex Types
 * Ada Programming/Libraries/Ada.Numerics.Generic Elementary Functions

Ada 2005 Reference Manual

|Mathematical calculations


text:
Cookbook:Rigatoni Pasta with Ricotta in Tomato Cream Sauce

| Pasta Recipes

Pasta with ricotta cheese in a tomato cream sauce topped with Parmesan cheese and parsley.

Ingredients

 * 16 oz rigatoni (or other) pasta
 * 2 tbsp olive oil
 * 1 tbsp butter
 * 1 cup finely-chopped onions
 * 3 garlic cloves, minced
 * 1 can (28 oz) plum tomatoes, drained and chopped
 * 1 ½ cups tomato sauce
 * 2 tbsp fresh minced basil
 * ½ tsp fresh minced oregano
 * ½ tsp salt
 * ⅛ tsp black pepper
 * 16 oz ricotta cheese
 * 1 cup heavy cream
 * 1 ½ tsp granulated sugar
 * ¼ cup parsley, chopped
 * ½ cup grated Parmesan cheese

Procedure

 * 1) In a large pot bring 2 quarts of lightly salted water to a boil.
 * 2) Cook rigatoni pasta for 11 minutes (or until al dente), drain and set aside until needed.
 * 3) Over medium heat, melt butter and heat oil in a large skillet.
 * 4) Lightly sauté onions and garlic cloves, don't brown. Cook about 5 minutes.
 * 5) Drain canned tomatoes, dice and add to skillet with onions and garlic.
 * 6) Also add to skillet tomato sauce, basil, oregano, salt and pepper. Simmer 20 minutes.
 * 7) Stir in ricotta cheese. Mix well and simmer for 5 minutes.
 * 8) Stir in heavy cream and sugar. Mix well and simmer 5 minutes.
 * 9) Remove from heat and add to cooked rigatoni pasta. Mix well.
 * 10) Stir in chopped parsley and sprinkle grated Parmesan cheese over top.
 * 11) Serve hot.


text:
Movie Making Manual/Post-production/Digital Intermediate

Take a look at the papers here for more info on DI: http://www.digitalpraxis.net/

/Cinematography /Post-production


text:
Genealogy/UK

Here are listed a group of external links originally deposited by users in the Wikipedia article on Genealogy.

 * RootsChat.com Comprehensive free UK & Irish Family History Forum
 * United Kingdom Census Finder
 * View, Search or upload a family tree
 * A guide to the free genealogy sites covering England and Wales
 * Genealogy resources maintained by volunteers.
 * The extensive suite of online genealogy offerings from the British government
 * A project to transcribe the entire GRO indexes and provide them online free of charge
 * Gazetteer of 50,000 UK villages with maps and pages for genealogy enquiries (chargeable)
 * The entire GRO Indexes of Births, Marriages and Deaths for England and Wales from 1837 to date
 * Irish Genealogy
 * FreeBMD - St Catherine's Index
 * Family Search - International Genealogical Index
 * http://www.tracingyourfamilyhistory.com Build your family tree. Genealogy Forums
 * well-organised and categorised links to UK genealogy resources
 * UK Genealogy Archives

title: Genealogy/UK


text:
User:Ceyockey

I am primarily a Wikipedia contributor, working mostly under the auspices of the Stub Sorting WikiProject and the Fact and Reference Checking WikiProject. However, I've a long term interest in Genealogy and have contributed to on-line genealogical resources. I believe that enhancement of the Genealogy WikiBook will first enhance the Wikipedia article by offloading some information from it and will provide a platform for the development of resources for the enhancement of skills held by amateur genealogists.

(see Wikipedia:User:Ceyockey)

Courtland 18:13, 6 Apr 2005 (UTC)

title: User:Ceyockey


text:
Genealogy/US

In the United States, genealogy is a major and growing hobby, aided in large part by the increasing availability of both free and subscription on-line information resources. This chapter contains information on some of these on-line resources as a beginning to a more thorough treatment of the pecularities of pursuing genealogy research in the United States. The point of view taken here is largely that of an individual looking into his or her own history.

USGenWeb Project

 * USGenWeb Project established in 1996, this project of 2500 volunteers has been serving as a FREE resource for county and state genealogy. Besides the independent websites there is a permanent Archive of 11 G's of information.  The search engine for the USGenWeb Project Archives is located at http://www.rootsweb.com/~usgenweb/newsearch.htm.  And the many special projects supported by the members of the USGenWeb Project can be found at http://usgenweb.org/projects/index.shtml

Cyndi's List

 * Cyndi's List before there was http://www.Google.com there was Cyndi's List. Nine years later her website contains 243,200 genealogy related links. A FREE website.

Family Search

 * Family Search it is associated with the LDS church and is a gateway to 150 years of genealogy research done by church members and other genealogists. A FREE website

Genealogy and Family History Internet Web Directory

 * Genealogy and Family History Internet Web Directory Key worldwide educational Internet genealogical databases and resources, connected to thousands of related sub-sets, with billions of primary or secondary database records. A FREE website.

RootsWeb.com

 * RootsWeb the oldest and largest FREE genealogy website and server. It provides the websites, mailing lists and message boards used by so many genealogists. It is the host to many Genealogical and Historical Societies and the USGenWeb Project. A FREE website

Other Sites

 * Ohio River Valley Families Online Searchable Database
 * Minnesota Historical Society
 * NEHGS - The oldest genealogical society in the United States
 * Genealogy Sleuth - United States Records
 * Online Searchable Death Indexes & Records (United States)
 * The Newberry Library in Chicago, Illinois
 * GenealogyBuff.com

Immigration
The vast majority of Americans are descendents of immigrants within the past 400 years. One of the points of interest for most researchers is "when did my family arrive in the United States?" This invariably has multiple answers as a result of mingling blood lines immigrant groups or distinct waves of immigrants. There are basically two parts to this question: "where was the entry point?" and "when was the entry time?" In many cases a researcher has one of these two pieces of information, often as an anecdote passed down orally through the family.

New York and Ellis Island
One of the most significant entry points in the United States in terms of the sheer volume of persons passing through it was Ellis Island, New York. Millions of immigrants entered the country through this point during its years of operation from 1892 to 1924. In 1982, Lee Iacocca, at the behest of Ronald Reagan, headed the formation of the Statue of Liberty-Ellis Island Foundation (SOLEIF). In 2001, an activity of this foundation led to the establishment of the American Family Immigration History Center, which has made available on-line 25,000,000 immigrant arrival records for public access. The website for the Foundation, which prominently features a search interface for this set of records, is located at http://www.ellisisland.org/.

 * Searchable Database of New York Arrivals 1892-1924

title: Genealogy/US


text:
User talk:Reubenbarton~enwikibooks

Add your comments here.

metric symbols
The liter is abbreviated as L. The milliliter is abbreviated as mL.

There is no metric unit designated by a lowercase l. This would be confused with the number 1 and uppercase letter I.

Pie Crust
Cookbook:Lemon_Meringue_Pie and Cookbook:Banana_Cream_Pie have very similar crusts. Since the crust is useful by itself, and duplication leads to inconsistency, I was thinking I'd move the crust instructions to a new Cookbook:Grandma's Pie Crust page. I hope you don't mind.

Problem is, the recipes are already inconsistent. I don't know if this is intentional or not. The banana one wants "1 egg, whipped" (the white included?), while the lemon one wants "1 egg yolk" (not whipped?). Even if this is intentional, it would be nice to move the more-normal of the two (the banana one?) to a page by itself.

BTW, if you think I'd be responsible and useful as an admin, please support my adminship request. I have well over 1500 wiki edits, which has been enough to earn me a few enemies it seems. (sorry I'm not perfect; I've probably made a few dreadful edits but I have shown responsibility elsewhere, including as a Tux Paint and procps developer)

AlbertCahalan 18:43, 3 May 2005 (UTC)

 * In the crust recipe the egg white is really optional. When making the Lemon Meringue Pie, I use the egg white in the Meringue, where it is more useful. When making the Banana Cream Pie, I just use the whole egg in the crust. This pie crust recipe, using vinegar, results in a consistently good flaky crust. Other pie crust recipes I've tried, turn out in a tough crust. Probably because this recipe tolerates handeling more than others. I will vote for you. Reubenbarton 19:17, 2 Jun 2005 (UTC)

It's interesting that the crust uses 100% shortening. Very old pie crust recipies use lard, which is supposedly the best. Shortening was developed as a lard substitute. Shortening keeps longer and has less saturated fat, but it does have trans- fats which are now thought to be worse than saturated fats. It seems that modern pie crust recipes are moving towards the use of butter, which seems very wrong to me. Butter does not have the same melting properties and it contains almost 20% non-fat content. Butter even has more saturated fat than lard, so it isn't the choice to make for health. Since lard is the most healthful of the choices and seems like a perfect drop-in alternative to shortening, it might deserve a mention. Perhaps you could try it. I just bought a tub of lard to replace my shortening, but I'm not exactly a pie expert, and the hot weather here would probably make for a bad pie crust no matter what recipe I use. Do you use a chilled surface, chilled roller, or strong air conditioning? AlbertCahalan 02:09, 4 Jun 2005 (UTC)

 * I have used lard in pie crusts and biscuits. Lard makes a more flaky crust. It also makes a far superior biscuit. Lard gives the crust a different flavor than shortening. Shortening doesn't really have a flavor, but lard does. Lard can also impart a slight flavor to other things like cookies. I guess my aversion to using lard is because of being told for so many years that lard and animal fat are "bad" for you. It seems that every other year some health study comes out pointing in a different direction. But I do use lard on occasion. The other points you make are also true. Shortening is easier to store and use. I live in Sacramento, California. In the summer, temperatures here reach 100-degrees F. for days on end. My house is air conditioned. I also chill the shortening. For me, cooking is a hobby and my wife enjoys the break when she doesn't have to cook. Reubenbarton 01:47, 5 Jun 2005 (UTC)

 * Heh. Yeah, I know! It felt weird buying a tub of lard last week. Lard sure did get a bad reputation, but it seems to be the best of the well-known solid fats. You can't make a pie crust with olive oil... or can you? Compared to most liquid oils, all the solid fats are bad. People used to fry in lard, which certainly doesn't make sense when Canola oil works so well now. (never fry in olive oil; it will smoke) I'll guess that the major past abuse of lard was for frying french fries, for which there are many good alternatives. AlbertCahalan 02:10, 5 Jun 2005 (UTC)

 * According to, olive oil has a higher smoke point than canola. Go figure. Corn oil is the traditional choice for a frying oil (I belive most donuts these days are fried in corn). Donuts in particular used to be fried in coconut oil (or lard), which has a much higher level of saturated fat (like lard) but does not suffer from many of the problems of [partially-]hydrogenated oils or heated unsaturated fats (which are hydrogenated to some degree by being heated). From : "... if French fries were cooked in saturated fat instead of in hydrogenated vegetable oils, they would probably be safer." Kellen 03:21, 5 Jun 2005 (UTC)

 * That's a very cheap solvent-extracted olive oil then. The smoke point of olive oil varies greatly. The numbers we have show olive oil at 200-406 ºF and Canola at 440 ºF. When people say that olive oil is especially good for you, they're referring to the greenish flavorful kind that smokes at only 200ºF. AlbertCahalan 15:08, 5 Jun 2005 (UTC)

Your account will be renamed
Hello,

The developer team at Wikimedia is making some changes to how accounts work, as part of our on-going efforts to provide new and better tools for our users like cross-wiki notifications. These changes will mean you have the same account name everywhere. This will let us give you new features that will help you edit and discuss better, and allow more flexible user permissions for tools. One of the side-effects of this is that user accounts will now have to be unique across all 900 Wikimedia wikis. See the announcement for more information.

Unfortunately, your account clashes with another account also called Reubenbarton. To make sure that both of you can use all Wikimedia projects in future, we have reserved the name Reubenbarton~enwikibooks that only you will have. If you like it, you don't have to do anything. If you do not like it, you can pick out a different name.

Your account will still work as before, and you will be credited for all your edits made so far, but you will have to use the new account name when you log in.

Sorry for the inconvenience.

Yours, Keegan Peterzell Community Liaison, Wikimedia Foundation 23:37, 17 March 2015 (UTC)

Renamed
 This account has been renamed as part of single-user login finalisation. If you own this account you can |log in using your previous username and password for more information. If you do not like this account's new name, you can choose your own using this form after logging in: . -- Keegan (WMF) (talk) 05:25, 19 April 2015 (UTC)

title: User talk:Reubenbarton~enwikibooks


text:
User:Reubenbarton~enwikibooks

COOKBOOK ="Donuts. Is there anything they can't do?" - H. Simpson=

title: User:Reubenbarton~enwikibooks


text:
MATLAB Programming/Psychtoolbox/Example Code

Examples

 * Imageviewer - show an image on the screen (OSX)
 * OpenManyScreens - open a window on all connected displays (OSX)
 * xsearch - generic visual search code (OS9/WIN)
 * ImgShow - loads a series of images from disk and displays them for the period of time specified, in random order (OS9/WIN)
 * eyelink toolbox - use an sr-research eyelink video eyetracker together with the cross-platform opengl psychtoolbox (OSX/win)

Helpful scripts

 * MATLAB Programming/Psychtoolbox/Version independent scripts - Scripts to allow you to write programs that run on all versions of psychtoolbox.

Code Snippets
function keyPressed = getKeys(keysWanted) % keysWanted is a matrix list of keys you are % waiting for e.g, [124 125 kbName('space')] FlushEvents('keydown'); success = 0; while success == 0 pressed = 0; while pressed == 0 [pressed, secs, kbData] = KbCheck; end; for i = 1:length(keysWanted) if kbData(keysWanted(i)) == 1 success = 1; keyPressed = keysWanted(i); FlushEvents('keydown'); break; end; end; FlushEvents('keydown'); end;
 * Function that takes a list of desired keys and returns the number of the one that was pressed and is nearer to the front of the list that was passed. It ignores other keypresses.

tEnd=GetSecs+2; while ~KbCheck & GetSecs 0 WaitSecs(0.001); end
 * Wait for a key press, continue after two seconds

commandwindow;
 * Bring command window to front. Even though it won't come in front of a window opened by Screen, it is useful to include this, as it allows you to type e.g. Screen('Closeall') to close the window of a crashed program

commandwindow; touch=1; while touch==1 [touch, secs, keycode] = KbCheck; % Sleep one millisecond after each check, so we don't   % overload the system in Rush or Priority > 0 WaitSecs(0.001); end touch = 0; i=0; while ~touch % Sleep one millisecond after each check, so we don't % overload the system in Rush or Priority > 0 WaitSecs(0.001); [touch, secs, keycode] = KbCheck; fprintf('.'); if i==50 fprintf('\n'); i=0; end i=i+1; end clc; % clear command window, removing any typed characters fprintf('\ntouch down\n\n');
 * Issue: KbCheck doesn't appear to wait for key presses, exits loop earlier then expected, continues to return key presses. Solution: make sure you first wait for any keys to be released. For example:


text:
MATLAB Programming/Psychtoolbox/Imageviewer

% this is short bit of matlab + ptb code to show an image on screen % Note: you have to supply your own image 'example.jpg' in the same directory

clear all;

try commandwindow; myimgfile='example.jpg'; nr=max(Screen('Screens')); [w, screenRect]=Screen('OpenWindow',nr, 0,[],32,2); % open screen ima=imread(myimgfile, 'jpg'); Screen('PutImage', w, ima); % put image on screen Screen('Flip',w); % now visible on screen while KbCheck; end % clear keyboard queue while ~KbCheck; end % wait for a key press Screen('CloseAll'); % close screen catch %this "catch" section executes in case of an error in the "try" section %above. Importantly, it closes the onscreen window if its open. Screen('CloseAll'); rethrow(lasterror); end %try..catch..


text:
Talk:GCSE Science/Static Electricity

Hi Everyone! Bill Beaty here. "Static electricity is electricity which is static" is a common misconception which has made its way into K6 textbooks. In fact, "Static" electricity retains all of its characteristics even when it flows, therefore its unmoving-ness is not important in understanding it. A better definition: Static electricity occurs whenever a piece of matter contains more protons than electrons, or when it contains more electrons than protons. Or this one:''When the positive and negative charges in matter are not equal, the matter has a charge imbalance. We call this imbalance by the name Static Electricity. Remember that rubbing some fur against some rubber does not create any charges of electricity, instead it creates an imbalance'' of charges (the charges, the electrons and protons, were already there beforehand.)  See: Static electricity misconception #1 --Wjbeaty 19:36, 6 Apr 2005 (UTC)

title: Talk:GCSE Science/Static Electricity


text:
MATLAB Programming/Psychtoolbox/Example Code/OpenManyScreens

Back to Examples

% matlab + osx ptb demo that will open a window on every attached display clear all; try fprintf('OSX many windows demo\n\n\t'); fprintf('At the end of the demo, press any key to quit\n\n\t');

input('Hit the return key to continue.','s'); fprintf('Thanks.\n');

screens=Screen('Screens'); % vector with valid screen numbers, main is 0

% Open a double buffered fullscreen window on each attached screen % and draw a gray background with a coloured square on it

for screenNumber=screens i=screenNumber+1; fprintf('Opening window on screen #%d\n', screenNumber); [w(i) sRect]=Screen('OpenWindow', screenNumber, 0,[],32,2); white=WhiteIndex(w(i)); black=BlackIndex(w(i)); gray=round((white+black)/2); % not defining some values hangs the program Screen('TextFont',w(i), 'Courier'); Screen('TextSize',w(i), 100); Screen('TextStyle', w(i), 0);

[x,y] = RectCenter(sRect); Screen('FillRect',w(i), gray); Screen('DrawText',w(i), ['Screen #' num2str(i-1)],x-300,y,[255*rand(1,3)]); Screen('Flip', w(i)); end

while KbCheck; end tEnd=GetSecs+5; while ~KbCheck & GetSecs<tEnd; end Screen('CloseAll'); fprintf('\nEnd of demo\n');

catch %this "catch" section executes in case of an error in the "try" section %above. Importantly, it closes the onscreen window if its open. Screen('CloseAll'); rethrow(lasterror); end %try..catch..


text:
MATLAB Programming/Psychtoolbox/Example Code/Imageviewer

Back to Examples

% this is short bit of matlab + ptb code to show an image on screen % Note: you have to supply your own image 'example.jpg' in the same directory

clear all;

try commandwindow; myimgfile='example.jpg'; nr=max(Screen('Screens')); [w, screenRect]=Screen('OpenWindow',nr, 0,[],32,2); % open screen ima=imread(myimgfile, 'jpg'); Screen('PutImage', w, ima); % put image on screen Screen('Flip',w); % now visible on screen while KbCheck; end % clear keyboard queue while ~KbCheck; end % wait for a key press Screen('CloseAll'); % close screen catch %this "catch" section executes in case of an error in the "try" section %above. Importantly, it closes the onscreen window if its open. Screen('CloseAll'); rethrow(lasterror); end %try..catch..


text:
User:Wjbeaty~enwikibooks

William J. Beaty

Research Engineer

74 Bagley Hall

University of Washington

206-543-6195

beaty at chem washington e d u

Also see: Wikipedia user Wjbeaty

Also see my large website Science Hobbyist

In particular, I have some strong words to say about Electricity Education

title: User:Wjbeaty~enwikibooks


text:
Cookbook:Banana Cream Pie I

| Desserts | US Cuisine

Banana cream pie consists of a pastry shell pie filled with fresh sliced bananas in a vanilla pudding type base. A layer of whipped cream is added to the top.

Pie crust

 * Grandma's Pie Crust

Pie filling

 * ½ cup (100 g) white granulated sugar
 * 6 tablespoons all purpose flour
 * ¼ teaspoon salt
 * 2 ½ cups (600 ml) milk
 * 1 egg, whipped
 * 1 tablespoon butter
 * ½ teaspoon vanilla extract
 * 4 ripe bananas, sliced
 * ¼ cup (60 ml) lemon juice

Pie topping

 * ½ cup heavy cream
 * ½ teaspoon vanilla extract
 * 1 ½ teaspoons powdered sugar

Pie crust

 * 1) Prepare Grandma's Pie Crust.

Pie filling

 * 1) In the top of a double boiler, whisk together sugar, flour, salt and milk. Stir out any lumps.
 * 2) Bring water to a boil in lower portion of double boiler.
 * 3) Stir constantly until mixture is thickened, about 5 minutes.
 * 4) Place lid on mixture and continue cooking for 10 more minutes, stirring occasionally.
 * 5) Beat egg in a small bowl. Add about ½ cup of hot pie filling mixture to egg in bowl and stir well. This tempers the egg so it won't scramble when added to the hot pie filling.
 * 6) Pour tempered egg mixture into pan of hot pie filling. Stir constantly and cook for 2 more minutes.
 * 7) Remove from heat, add butter and vanilla. Stir until mixed.
 * 8) Slice 2 bananas. Dip slices in lemon juice, shake off excess and distribute banana slices in the bottom of baked pie shell.
 * 9) Pour half of pie filling over bananas in bottom of pie shell. Make sure banana slices are covered by pie filling.
 * 10) Slice remaining 2 bananas. Dip in lemon juice, shake off excess and arrange on top of filling in pie.
 * 11) Pour remainder of pie filling over second layer of bananas in pie shell. Cover all bananas with filling.
 * 12) Chill for about 1 hour before adding topping.

Pie topping

 * 1) In a large bowl, whip cream with electric mixer until peaks are just forming.
 * 2) Beat vanilla and sugar into cream and continue mixing until peaks form in cream. Don't over beat the mixture or it will form lumps and begin to turn to butter.
 * 3) Spread whipped cream mixture over pie filling on chilled pie. Keep chilled until served.

Warnings

 * The pie filling is quite hot when pouring it into pie shell. Keep this pie refrigerated.

title: Cookbook:Banana Cream Pie I


text:
Template talk:Ada/operator

Wikicode vs. HTML tags
The Template:Ada/attribute template was fully written with wikicode (two quotes), but later it was changed to HTML tags because sometimes there where some visualisation problems: Those two quotes of the template when placed after the quote of the attribute of the code became boldface in wikicode. For that reason it where changed to <i> tags, doing the same with the other two templates: Template:Adakw, Template:Ada/operator. And although in principle there couldn't happen the same problem with those two, I think it's safer to stick to HTML tags. --suruena 20:57, 6 Apr 2005 (UTC)

 * Dann sollten wir auch Template:Ada/operator_2 anpassen ;-) --Krischik 07:27, 7 Apr 2005 (UTC)

 * Sorry? Automatic translation, is it correct?: Then we should adapt also Template:Ada/operator 2 ;-). I didn't know that this template existed. Added to Template:Ada and put HTML tags. Thanks for pointing it out! --suruena 08:23, 7 Apr 2005 (UTC)

 * Ups. did not notice that I wrote german. We will also need a 2nd version for special - because both operator and special need to display characters which wiki won't like. I will do it as soon as there is time - rigth now my wife waits for me.--Krischik 15:42, 7 Apr 2005 (UTC)

title: Template talk:Ada/operator


text:
Talk:Blender 3D: Noob to Pro/Keystroke, Button, and Menu Notation

For keyboards without numeric pad
''For laptop users: You might have to turn on the "Emulate Numpad" option if you don't have a number pad on your laptop. This is found above the "File," "Add," "Timeline," [etc.] pullout bar under "System and OpenGL" (also called the "User Preferences" bar later on).''

I've searched for this for a long time and havent found .... I don't have the "System and OpenGL" bar, only the "User Preferences" bar. Where is this option ???? --Wladston 13:24, 15 January 2006 (UTC)

Found it. Put your mouse cursor just under the bottom edge of the "File" menu bar, and drag down. A new panel will open. Dennis G. Jerz, 12 July 2006.

More Syntax
Should we include syntax examples for things like menu paths? With so many different users people are constantently using different ways such as:

SPACE→Add→Lamp

SPACE > Add > lamp etc...

and SPACE -> Add -> lamp

So how should we display these paths?

Also some people use 'return' when we seem to have always used ENTER.. hmmm --Kisubo 01:59, 7 February 2006 (UTC)

Yes, i think we should. I like the first one with →.

I also think there should be a global syntax for menu items and values and thelike. This would make them stick out of the text much better and thus the tutorial can be easier referred back to. Like when you've already finished the tutorial before but forgot about a certain function or something. Then it would be easier to find those remarks, if you don't have to read through it again. Using italic letters with quotation marks would be a start (like "File" menu). 84.163.130.119 17:41, 29 March 2006 (UTC) Daniel

Mac Users without multi-button mice
So now there's a section for Mac single-button mice, but on my iMac, running Blender 2.41, I'm finding what's been written here to be inaccurate; did it change at some point? For me, LMB is regular click, RMB is Apple+click, MMB is Option+click, and I'm fairly certain I haven't changed any of the defaults... .

Ok, I looked a bit further, and saw text in the Blender Windowing System page that said part of this. I duplicated it here, but am guessing that it probably shouldn't be in both places.

DavidJaquay 20:52, 8 May 2006 (UTC)

Key sequence
It would be fine to add some syntax about key sequence : how to write the CTRL, SHIFT, MKEY sequence ?

I think it should be : CTRL + SHIFT + MKEY ( some people write : CTRL-SHIFT-M ). Others : ALT, MKEY : ALT + MKEY ( some people write : ALT-M ). --N comme Nul 14:57, 1 August 2006 (UTC)

Reformated content
I've reformated content to use footnotes on this page, as well as imported in the Non-standard equipment from other chapters. The purpose: I've also use the wikibook syntax, if someone likes those old orange tables, feel free to add a style-sheet for them. EvanCarroll 17:00, 28 October 2007 (UTC)
 * To eliminate redundancy, and better overall book content by centralizing niche stuff.
 * To better equip those with non-standard equipment early on

Mac Command key
On the newer Mac keyboard they have removed the Apple logo form the command key. Since the command key has had this weird character ( ⌘ ) on it for so long it might be easier to refer to it by the character itself.

 ⌘

Remove "notation" section
I think we should remove the "notation" section. The logic behind this is simple: all the keys are very intuitive and easy to find: we're not teaching Blender to someone who started using their computer yesterday. If it says, then you press the Alt key. Easy as that.

Right now the table is basically formatted as:

It feels like simple copy-paste: I propose we simply clarify the difficult ones, such as the difference between and. A better option altogether is to replace with  and replace  with, but that's a discussion for another day and may require rehauling the whole book.

Since I don't think anyone's working on the book right now, I'm just going to leave this message here as documentation.

Money-lover-12345 (discuss • contribs) 19:49, 2 January 2023 (UTC)