text:
Clipper Tutorial: a Guide to Open Source Clipper(s)/Basic Language Tutorial

xBase/Clipper Tutorial
Please note: if anybody will contribute, the Clipper tutorial should contain only 'standard' code that would work on every Clipper compatible compiler. Compiler-specific code should be placed somewhere else, or clearly indicated in a box.

The code here should be of simple console-mode applications using only the simplest forms of input/output and focused only on algorithms, since the methods for creating and managing user interfaces will be described in Chapter 5, Making Up a User Interface.

The helloworld application line by line
Let's try to highlight the parts of helloworld:

(in GeoCities this and all other sources were highlighted by the on-line service CodeColorizer at http://www.chami.com/colorizer/, or, alternatively by the service at http://tohtml.com/Clipper/ - they tend to look a bit better than the Wikibook highlighting).

We will comment on each line of the helloworld program.

function MAIN

The first line defines a function named MAIN. Defining such a function is not compulsory with Harbour, as if it is missed errors would occur during compilation, but I will keep it to make sure the examples work with all compilers. A function cannot be defined when typing in commands at the dot prompt (hbrun/xbscript).

Every xBase language is case insensitive, which means that all the following lines are the same:

function MAIN FUNCTION main FuNcTiOn mAiN

Of course, this feature is beneficial only if you use it to improve the code readability.

We will learn later how to define and use functions and procedures.

* This is an example

The second line is a comment. Commenting your programs will help you when you are to modify them later. If they aren't commenting, modifying them will be a very hard task. It will be much more difficult if you are to modify programs written by others if they didn't comment them: figuring out what a program does using only its code is very difficult and even the cleanest programming language may prove to be write-only if not properly commented.

You can write comments in many different styles: using an asterisk (*), two sweeps (//), a double ampersand (&&) or a couple sweep-asterisk (/*) and asterisk-sweep (*/), as shown below:

* This is a comment... // ...and so is this... && ...and this. /* This is an example of the fourth commenting style, which may span over several lines.*/

The second and the fourth commenting styles are derived from the C programming language, the first and the third are peculiar of the Clipper/xBase standard. None of these comments are accepted by xbscript, but hbrun (Harbour) accepts the last three.

clear

No, the purpose of this command is not to make the source code clear (that would be too easy! It is up to us to write clear source code, and to do so we must comment it well), but instead to clean the screen. :-) You could also use clear screen or cls, although these two commands are not exactly the same of this clear (the difference will be clear later when we can GET the point - then, you could also appreciate the pun in this paragraph - but will more likely not).

What are commands?

Harbour commands are defined via the #command macro directive (http://harbour.edu.pl/clipper/en/ng122d3c.html). The first commands we encountered are defined in the file std.ch by these lines:
 * 1) command CLS                       => Scroll ; SetPos(0,0)
 * 2) command ? []         => QOut

? "Hello, the weather is fine today"

The ? is a command which means print. In the BASIC programming language, it is also an abbreviation for its print command (the syntax of xBase is quite similar to that of the BASIC programming language).

In this case ? print the string "Hello, the weather is fine today". Please note that a string can be enclosed in single quotes (or apostrophes), double quotes or square brackets: all of the following are the same:

? "Hello, the weather is fine today" ? 'Hello, the weather is fine today' ? [Hello, the weather is fine today]

The last line:

return nil

Return is used to mark the end of the function. We will explain later what the return exactly does.

Today Harbour needs not an explicitly defined main function/procedure. The following version of helloworld will compile and is exactly the same as the previous one:

The Harbour Interpreter and Virtual Machine

The program above, stored in a text file named hello.prg, can be run with the command hbrun hello.prg

hbrun is an interpreter for Harbour. This means that if we run it, we get to a screen with a "Dot prompt" on its last line, where we can enter and run instructions. For example, entering ? "Hello world"

will get Hello world printed on the screen, but only after the interpreter hbrun itself is closed. To quit the interpreter and get the greeting printed type QUIT

All in all, hbrun permits to feel how handling databases was done in the old dBase "Dot prompt" mode - that is, like this: http://manmrk.net/tutorials/database/dbase/IntrodBASEIIIPlus.htm

Running the compiler harbour (harbour.exe on Windows) on a printA.prg containing the line ? "A"

will output a printA.c file. The bottom of this file reads:

that is, as an intermediate step the Harbour compiler compiles pcode, or bytecode for a virtual machine.

If the compilation is done with the /gh option hbmk2 /gh printA.prg harbour /gh printA.prg

the result will be a file named printA.hrb, a "Harbour Portable Object" file which can be executed by hbrun printA.hrb

In this way, hbmk2 and hbrun work in couple as a perfectly equivalent tools to the Java compiler javac and java interpreter java.

As a parenthesis, virtual machines are not a new concept. If we look into the retrocomputing field, we'll see that in the late 1970s and early 1980s the University of California San Diego has a portable operating system based on pcode, the UCSD P-System which was written in UCSD Pascal and could be run on 6502, 8080, Z-80, and on PDP-11 http://www.threedee.com/jcm/psystem/index.html (it actually was a competitor of MS-DOS, PC DOS and CP/M - http://www.digitalresearch.biz/CPM.HTM and http://www.seasip.info/Cpm/index.html).

Also, in 1979 Joel Berez and Marc Blank developed the Z-machine as a virtual machine to run Infocom's text adventure games, the name not hiding they were mainly thinking about Zork. The programming language for the Z-machine was called ZIL (Zork Implementation Language). A modern compiler for ZIL to Microsoft .NET is ZILF https://bitbucket.org/jmcgrew/zilf/wiki/Home and a Z-machine.NET is available https://zmachine.codeplex.com/. More information at http://inform-fiction.org/zmachine/index.html.

Apart from the JVM (Java Virtual Machine), the Microsoft .NET CLR (Common Language Runtime), is another modern virtual machine.

hbmk2 was created to support all shells, all compilers on all platforms, also to replace old 'bld.bat' solution, while staying compatible with existing hbmk script features and options.

Pieces of information on how to get an executable without using hbmk2 can be found at http://www.kresin.ru/en/hrbfaq.html.

Remember that the PATH Environment Variable (in Windows) must be updated to include the directory containing the compiler: use the command SET PATH=C:\hb32\bin;%PATH% locally in a Prompt Window or update it globally: "Start" → "Control Panel" → "System" → "Advanced system settings" → "Environment Variables..." → select "Path", then click "Edit..."

Data Types in General (and Their Operators)
The list of types supported by Clipper is as follows:
 * A        Array
 * B        (Code) Block
 * C        Character
 * D        Date
 * L        Logical
 * M        Memo
 * N        Numeric
 * O        Object
 * U        NIL

These letters can be used as a prefix to a variable name, to indicate "at first sight" what kind of item it is. This way  o Box would be the name of an object,  a Names an array,  d Birthday a date and so on. An alternative for logical variables is to add an is prefix as in is Ok or is Existing (somewhat more readable than lOk and lExisting). This naming convention is called the Hungarian notation and applies to functions as well, and to their synopsis:  A COPY( , , [], [], [] ) is the function to copy elements from an array to another, which takes two arrays a Source and a Target, and optionally three numeric parameters n Start, n Count, n TargetPos;  C To D ( c Date) takes a character argument and converts it to a date,  DB Create is a function to create a database.

The type Memo can only be used in a database (it is a link to a subsidiary file to a DBF table, as described in the Wikipedia DBF entry).

This is the list of results returned by the function VALTYPE. The function TYPE returns also:
 * U        NIL, local, or static
 * UE       Error syntactical
 * UI       Error indeterminate

Harbour has a longer list (http://www.fivetechsoft.com/harbour-docs/harbour.html):
 * HB_ISARRAY
 * HB_ISBLOCK
 * HB_ISCHAR
 * HB_ISDATE
 * HB_ISDATETIME
 * HB_ISHASH
 * HB_ISLOGICAL
 * HB_ISMEMO
 * HB_ISNIL
 * HB_ISNULL
 * HB_ISNUMERIC
 * HB_ISOBJECT
 * HB_ISPOINTER
 * HB_ISPRINTER
 * HB_ISREGEX
 * HB_ISSTRING
 * HB_ISSYMBOL
 * HB_ISTIMESTAMP

ISPOINTER (http://www.marinas-gui.org/projects/harbour_manual/ispointer.htm) for example is marked: Not available in CA-Cl*pper. Together with HB_IT_POINTER and HB_ISPOINTER it is used in Harbour's internals (the C-level API: http://www.fivetechsoft.com/harbour-docs/clevelapi.html#ispointer).

Let us see a little program that shows the use of the most common data types.

I wanted to show, in this example, a computation of π instead of that of √2, but xBase misses the ArcTan function. We may solve this problem by importing it from an external library, or by supplying it ourselves. (Both ways should be pursued in this tutorial).

The last two data types are a bit different from the preceding: "Memo" is not very useful when used outside of a database, and the arrays cannot be used in databases.

The function SQR has been eliminated from Harbour and replaced by SQRT. Trying to use it will result in a linker error "undefined reference to 'HB_FUN_SQR'".

From the following example (which runs) we see that Harbour is a weakly typed programming language: a variable, such as a in our example can be a number, and then become a string of text.

There is a problem: if the variable type changed and the programmer did not get aware of it he may issue some instruction that will cause an error at run time. If we had another line of code

in the program above, Harbour will attempt to add the number 1 to the string "abc", and the result will be the error

Error BASE/1081 Argument error: +.

Strings
Strings are essentially a list of characters. They are written between double quotes (eg. "Hello"). Note the difference: 123      => a number "123"    => a string

Let's see how to use the function Stuff to change a character within a string:

Here is a list of the most commonly used functions for handling strings:

Lower  Convert uppercase characters to lowercase Upper  Converts a character expression to uppercase format Chr    Convert an ASCII code to a character value Asc    Convert a character to its ASCII value Len    Return the length of a character string or the number of elements in an array At     Return the position of a substring within a character string

Nevertheless in Clipper and Clipper Tools library can also be found very curious functions such as these:

AsciiSum  Finds the sum of the ASCII values of all the characters of a string Soundex   is a character function that indexes and searches for sound-alike or phonetic matches CHARONE   Search and remove repeating characters CHARONLY  Remove non-standard characters CHAROR    "OR" bytes in a string

Let's see what we can do with these functions.

We show the ASCII codes (http://www.asciitable.com/) corresponding to the keys pressed by the user, concluding the program when ESC is pressed.

inkey.ch is the eader file for Inkey function, which serves to obtain the following key code from the keyboard buffer.

Other Considerations about the Classification of Data Types
A first classification of data types divides them into simple (or scalar) types and structured (or composite, or aggregate or compound) types.

In xBase the simple data types are numbers, logical values, strings and dates, that is, the types which can be field types in a database table. Memos are not, since they are a pointer to an external file.

Scalar data types can be composed to build up structured data types: arrays, associative arrays (hash tables), tables or databases (which are a "data type" which is stored on a disk). Primitive_data_type

Code blocks and objects are special data types.

Operators and Precedence
We see in this example that the exponentiation operator ** is left-associative (as opposed to mathematics where exponentiation is a right-associative operation).

The fact that 3**3**3 and 3**(3**3) give two different results means that parenthesis alter the operator precedence: whatever is enclosed in parenthesis is evaluated first.

Even when the operation is left-associative, the result of 9**9**9 is quite a "large" number (196627050475552913618075908526912116283103450944214766927315415537966391196809 to be precise, as you can easily check - maybe using some arbitrary precision calculator program, such as GNU bc, which is available on every Linux distribution and as a download for Windows at http://gnuwin32.sourceforge.net/packages/calc.htm - or by hand spending only some weekend time) which exceeds the resources Harbour allocates for a number (which is called overflow) and it, therefore, prints 23 times a * to indicate this error. It also gives zero (0.00) if we try to compute its reciprocal (which is called underflow). Overflow and underflow errors happen when the result of a computation is, respectively, too big or too small to be represented with the number of bits a compiler has allocated for the variable in which we're trying to store it in.

The same happens with dates. What it the result of date-1000000 (subtracting 1 million of days from the current date)? Let us see:

Here, the last two outputs ("00/00/00") indicate invalid dates, just as the rows of 23 asterisks seen above indicate invalid numeric results. Acceptable dates are those that can be stored in a dBase table (ie a .dbf file) and in these files a date is a string of 8 characters in the "YYYYDDMM" format (4 characters for the year, 2 for the month and 2 for the day). Consequently, negative years (before Christ) or with more than 5 digits are not accepted.

Harbour displays the year with only two digits unless we change its behavior with a SET command and gives wrong results with these large number of years. The reason is simple: in a database application (inventory management, reservation systems) we won't have to deal with intervals of centuries and Harbour's routines for handling dates don't work correctly if we try to do that. In other fields, such as Archaeoastronomy this is the case and those who do deal with those problems (e.g. checking the precision of the alignment of the Winter solstice sunrise at Karnak in 2000 B.C. or the megalithic alignments) use their special routines for the computation of the dates.

There is another quandary when doing computation with computers. Look:

Now, if we extract the square root twice from a number and then square the result twice we should have the starting number. In fact, computers are not so precise and checking for the equality of two floating-point numbers can give unexpected results.

If you want to learn more you could have a look at What Every Computer Scientist Should Know About Floating-Point Arithmetic at https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html (which is part of a Sun Microsystems book entitled Numerical Computation Guide), and the Decimal Arithmetic FAQ at http://speleotrove.com/decimal/decifaq.html.

Fortunately, the precision of the variables used in xBase languages and the fact that in common business applications square roots, logarithms and other mathematical operations that cause loss of precision are rather rare, are circumstances that mitigate the problem.

SET OPTIONS

We've seen SET DECIMALS TO n and SET CENTURY ON/OFF commands. But in fact there are many options which can be set. The SETMODE(, ) function is particularly useful when using hbrun or xbscript: its purpose is to determine the size of the window.

Boolean Algebra & Flow Control
We can print the result of a comparison, which is a Boolean value (represented as .T. or .F.), but they are useful with special words in order to branch or repeat the execution of one or more instructions.

We have a Boolean expression when its result is true (whose xBase symbol is .T.) or false (.F.). The easiest way to get a Boolean result is to use a comparison (relational) operator: =, ==, !=, <>, #, >, <, >=, and <=. Always remember the difference between the comparison operators = (equal), == (exactly equal) and the assignment operator :=.

Actually, the "real" (mathematical) definition of a Boolean expression is different from what is stated in the last paragraph. A "real" Boolean expression would contain only the two Boolean values .T. and .F. and the Boolean operators (.AND., .OR., .NOT.).

Boolean Algebra is applied to electronic digital circuits since the work of Claude Shannon in 1937. See http://www.allaboutcircuits.com/textbook/digital/chpt-7/introduction-boolean-algebra/ (and the successive pages of that online textbook) to have an idea of what Boolean Algebra means when it's applied to bits within a circuit (including a microprocessor). Here we're using it at a much higher level.

Consider Hamlet, Act 3, Scene 1: «[…]To be, or not to be? That is the question— Whether ’tis nobler in the mind to suffer The slings and arrows of outrageous fortune…». If Prince Hamlet asked Boole (but he could not, as it is set in the 14th or 15th century whereas Boole was born in 1815), his reply would have certainly baffled him. Why?

As Harbour told us, in Boolean algebra, the answer is "true". Have a look at this page: https://vicgrout.net/2014/07/18/to-be-or-not-to-be-a-logical-perspective/.

Conditional execution
A number of graphical ways have been developed for seeing how a program's flow control is transferred: these include flowcharts (https://www.lucidchart.com/pages/what-is-a-flowchart-tutorial), data flow diagrams (https://www.lucidchart.com/pages/data-flow-diagram), Nassi-Shneiderman diagrams and the JSP and JSD diagrams by Michael A. Jackson (which is almost certainly not the first Michael Jackson you'll think of).

The following example gets a number from the keyboard and prints it. If the number is 0 it comments that value (I presented this example as a typical nihilist programming). The flowchart shows why conditional execution is sometimes called bifurcation.

This example prints two different comments, whether the condition of the remainder of the division of the number supplied by 2 is, or is not, 0.

This example shows that more than a command can be executed.

This example adds another keyword, ELSEIF, to show that the choices are not necessarily dichotomic. This is a chained conditional. Only one of the branches will be executed.

The following example checks whether the system time is earlier than 18 (6 p.m.) and prints a greeting appropriate to the time of day.

There are three logical operators: .AND., .OR., and .NOT.

Here is an example with a rather long condition, coordinating more comparisons with .OR. operators. The example is terribly stupid, but it shows how a semicolon allows you to continue an instruction on the following line.

This same thing is however achieved in a more concise way using the substring comparison operator $ (or regular expressions, an advanced topic that we will see later).

Looping
DO WHILE, EXIT, LOOP, ENDDO are keywords used To repeatedly execute a series of statements (loop body) while a condition is true (i.e. its result is .T.).

Loops come in several flavours: the pre-tested loop, the post-tested loop, and the definite iteration, which is done via a count-controlled loop (usually called a for loop). In practice, we may have a middle-tested loop as well, but no specific syntax for it... we need to put an EXIT statement within an already existing loop body to get this one. The next program we will key in is of some interest for the mathematicians (Real Programmers aren't afraid of maths, do you know this famous adage?)

Here is it: As you can see, this looping statement is similar to the IF statement: both of them are ended by a END-corresponding statement, both of them contains a logical espression.

This looping statement will continue until its condition remains true (will evaluate to .T.).

The two instructions it repeats are sum=sum+num and num=num+2. The second is fundamental: if it wasn't there or was wrong (for example if you keyed in num=num/2), the condition would not evaluate to .F. and the program would not stop its execution (this is called infinite looping). When this happens to you, press the keys Ctrl and C at the same time. This should convince the computer to give his attention to you instead of running the loop.

The programs above is a nice example of how an extremely methodical calculator without any creativity would attack the problem of summing up the first n odd numbers. Notes about the creative approach to it can be found at this address: http://betterexplained.com/articles/techniques-for-adding-the-numbers-1-to-100/ (along with the usual anedocte about Gauss' show off about it in elementary school).

The WHILE looping statement is said to have the control expression in its head, opposed to the Pascal REPEAT-UNTIL looping statement (a post-test loop) which has the control of the condition in its tail (these are the Italian computer science slang for pre- and post- tested loops, aren't they funny?). How does the xBase/Clipper say REPEAT-UNTIL? It doesn't. Here is how to emulate it (copied & pasted from the Norton Guide):

LOCAL lMore := .T.

DO WHILE lMore

loopbody

lMore := condition

ENDDO

As you see, we first set a variable to be true, enter the loop, and specify the condition at the end of the loop, to make sure its body is executed at least once.

Here is an example, equivalent to the one at the pascal_repeat_until_loop page in tutorialspoint.com.

But the code above changed the condition. If we didn't want this to happen, we can simply negate the condition we'd use in the Pascal code: repeat loopbody until condition becomes then:

Let us now see this kind of loop: This loop prints "I won't stop." as long as 'true' is... true. It is thus called an infinite loop because the ending condition will never be satisfied. It is the first example of control flaw studied in computer science classes. By definition, you incur in an infinite loop every time you specify a tautology as the condition to be checked. It is not always obvious to detect this and other control flaws and errors - it is indeed a process that involves the use of a specific piece of software called a debugger.

Counter-controlled Loops, and Nested Loops
In this section, we will see how to use FOR loops to print multiplication tables, how to nest loops, how to format output on the console screen and the importance of indenting code to improve readability.

The FOR...NEXT construct (counter-controlled loop) is useful when we know how many times we want the loop body be executed. We shall now use it to print out and revise multiplication tables.

(Please note in this example we have a loop inside the body of another loop: this is called a nested loop). Well, this works, but its output is not very nice... Moreover, it is customary to print the multiplication tables up to 10, since we're using a decimal numeration system... let us try it again!

this way we can print it much prettier... by the way, when nesting loops and branching statements, it becomes important to arrange the indentations in order to make the program easier to read... in The Oasis are available "source code beautifiers" such as dst314.zip. Harbour gives us the hbformat tool, https://vivaclipper.wordpress.com/tag/hbformat/.

PICTURE "999" is the instruction to specify we want the output format - as we specified three digits, the numbers in output will be printed as if they were three digits long, thus aligning them in our multiplication table.

As a second example of nested loops, the following is one of the most irritating programs I've ever written. It asks the user for an opinion and then always responds its contrary. It even quits when the user says he has more to tell him and keeps asking for input when the user says he has nothing else to add. Since it is particularly difficult for a program to answer the opposite of the user's assertions, this program simply prints the input string reversed, using the SubStr function (SubStr(, , []) --> cSubstring - extract a substring from a character string cString, at index nStart with length nCount).

User input is obtained through the ACCEPT command (a COBOL reminiscence), and the control flow uses a DO WHILE loop (from FORTRAN) and a FOR ... TO ... STEP loop (from BASIC).

How do we deal with such an awkward customer? Just try typing "remmargorp revelc yrev a era uoy" and the solution will be clear. In Italy there is an expression to call a person who always contradicts his interlocutors: he is called a "bastian contrario". They do work like this program.

& - the Macro Evaluation Operator
Consider this short piece of code:

The & is an operator that will evaluate (runtime compilation) an expressions and will permit text substitution within strings (see https://harbour.github.io/ng/c53g01c/ng110bc2.html). Let's make a simple calculator using it.

Here is an example of interaction with this program:

Please enter the first number: 12 Please enter the second number: 23.5 Enter operation: - 12-23.5=       -11.5

Arrays
An array is an ordered grouping of data, whose elements are identified by a number called an index. In many programming languages the indices (or "indexes") start at 0, but in xBase they start from 1. Since in mathematics the indices are written next to the variable slightly below the line, sometimes they are called subscripts and, for this reason, arrays are sometimes called subscripted variables.

Consider this first example of arrays. We create two arrays, one with the names of the months of the year and one with their duration in days, and then we print them in an orderly manner. The same result can be obtained in a much more elegant way using associative arrays.

In the next example we show that xBase has high-level support for dynamic arrays (implementing them in a low level language like C requires pointer arithmetic and memory management functions).

Note: This example will reappear many times in these notes. Often when we will introduce a new feature of the language we will write a new program which does the same thing of this program in a different way. It is one of the best pedagogical advice I can give you. Since I don't provide you with exercises, think of different ways of redoing some program using new language features, i.e. just to give you an idea: how difficult is it to redo the program that shows the multiplication tables on the screen using code blocks?

Here is the list of functions in hbmisc: https://harbour.github.io/doc/hbmisc.html.

The program above is not very satisfactory: due to the use of the IsDec function it can treat only positive integer numbers. What if we'd like it to accept numbers like -8 and 2.78? Three solutions come to mind offhand: write ourselves function that checks if the string represents a number (an improved version of IsDec), test input using regular expressions, using xBase functions for error handling. We will use this last technique in the next section of the tutorial.

FOR EACH n in aNumbers       && FOR EACH is a more modern control flow statement Harbour syntax ?? AVERAGE - &n NEXT

In addition to a function to add elements to an array we have one to delete them:

Harbour provides a function, hb_ADel, which accepts a third Boolean element and (if it's .T.) shrinks the array.

Multidimensional arrays are made by nesting arrays within other arrays.

Error Handling (the Clipper Way)
All of the programs showed up to this point will fail and show a runtime error if the user entered an unexpected input (in simple words, they crash). Programs called "robust" don't. Checking the conditions in which errors can occur and take countermeasures to prevent crashes is a job that was normally done with if-then-else.

BEGIN SEQUENCE ... END[SEQUENCE] is a control structure that executes some code and optionally some statements if the code produced an error. In our example if the conversion of the user input into a number generates an error, we will call EXIT to leave the while loop and continue our program.

Clipper 5 (C5) provided four classes:

Error          Provides objects with information about runtime errors Get            Provides objects for editing variables and database fields TBrowse        Provides objects for browsing table-oriented data TBColumn       Provides the column objects TBrowse objects

The Clipper 5.3 Norton Guide lists these classes:

Error class      Provides objects with information about runtime errors CheckBox class   Provides objects for creating checkboxes Get class        Provides objects for editing variables and database fields ListBox class    Provides objects for creating list boxes MenuItem class   Provides objects for creating menu items PopUpMenu class  Provides objects for creating pop-up menus PushButton class Provides objects for creating push buttons RadioButto class Provides objects for creating radio buttons RadioGroup class Provides objects for creating radio button groups Scrollbar class  Provides objects for creating scroll bars TBColumn class   Provides objects for browsing table-oriented data TBrowse class    Provides the column objects TBrowse objects TopBarMenu class Provides objects for creating top menu bars

Functions and Procedures
A function is a piece of code that returns a result every time it is called. Let us consider a function to convert Celsius into Fahrenheit (the same function is provided by libct, but we redo it for educational purposes):

But have a look at the following:

Consider this example of use for the function HB_Random:

A good function would function as a "black box", that is you can use it without worrying about how it internally works. An example usually given at this point is that of driving a car: you can use it without worrying about how the engine works (do you know anybody which looked at the pistons of their new car before buying it?). Someone else designed the engine. But there may be problems: if we change our Celsius into Fahrenheit function as follows

we'll get a side effect. This program output is

212.0       32.0         2

That is, our new function did not only return a value, it also increased by 1 the variable number.

The Clipper Norton Guides read, "A procedure in CA-Clipper is the same as a user-defined function, with the exception that it always returns NIL" (http://www.oohg.org/cl53/ng10a778.html), thus a procedure is really just a type of function that relies on these side effects to get something done.

The utility of functions is that they improve program readability, maintainability. Splitting a program into functions is a good design approach, which lets breaking a complex problem into smaller, simpler problems (top-down).

Harbour has four different kinds of subroutines/subprograms:
 * the FUNCTION and
 * the PROCEDURE (which is a FUNCTION with no return value),
 * the method (which has no associated keyword, works like every object-oriented programming language) and
 * the code block.

Why the Main Function?
The main function is the designated start of a program written in C or C++ (Java uses a static main method). Since a procedure is a function that returns NIL, we can have a procedure main instead of a function main in our program. With Harbour it is not necessary anymore.

Another characteristic of variables: scope identifiers
Variables have a name, a type, a scope and a lifetime (http://www.dbase.com/Knowledgebase/dbulletin/bu05vari.htm) which may be explicitly declared as (list below copied verbatim from Harbour (software)):

 * LOCAL: Visible only within the routine which declared it. Value is lost upon exit of the routine.
 * STATIC: Visible only within the routine which declared it. Value is preserved for subsequent invocations of the routine. If a STATIC variable is declared before any Procedure/Function/Method is defined, it has a MODULE scope, and is visible within any routine defined within that same source file, it will maintain its life for the duration of the application lifetime.
 * PRIVATE: Visible within the routine which declared it, and all routines called by that routine.
 * PUBLIC: Visible by all routines in the same application.

They do not make sense before we work with functions and procedures.

On running this, we get a strange output:

9 x from A=        10 9 x from B=         5 9 x from C=         -1 9 x from D before updating value=         -1 x from D=        12 9 x from E=        12 9

This program sets a variable x and five different procedures, A, B, C, D, E. The first three procedures define a variable x within themselves, assign it a value and print it. The fourth function assigns a new value to some variable named x without declaring it. The fifth function shows the value of some x variable, which happens to be the value of the fourth x variable. The main fact to remember here is that two variables are not the same, even if hey have the same name, provided they have different scopes and this feature is called shadowing.

9 x from A=        10 9 x from B=         5 9 x from C=        -1 -1 x from D before updating value=        -1 x from D=        12 12 x from E=        12 12

As static variables seem to require further informations (they work like C static variables), here is an example:

See pascal_variable_scope in tutorialspoint.com and http://aelinik.free.fr/c/ch14.htm

Variable scope is a foretaste of object oriented programming, in the sense that it anticipates some encapsulation concepts.

Part 1: Using the Clipper Tools (CT) Library
If you checked the list of functions you will have noticed that the xBases have no trigonometric functions. Not that in general they miss them: these languages are targeted database applications such as "accounting systems and airline reservations systems" (see Database application. ) in which trigonometric functions are not really important. But we now ask ourselves how to compute an approximation to the Ludolphine number, π (more information on this "search" at http://www.mathpages.com/home/kmath457.htm), We can do it using the CT library (see http://vouch.info/harbour/index.html?hbct.htm), or importing the C standard library function atan.

Part 2: Mixing C and Harbour Code
We get the idea from Harbour for beginners by Alexander Kresin (http://www.kresin.ru/en/hrbfaq_3.html). It must be noted that the extend.h file (* Compatibility header file for CA-Cl*pper Extend System) contains this warning:

/* DON'T USE THIS FILE FOR NEW HARBOUR C CODE */ /* This file is provided to support some level of */ /* Harbour compatibility for old Clipper C extension code */

In fact this example is here only to consider how the open source cross-compilers (Harbour in this case) extend themselves with C library functions, which gives them a lot of flexibility. Not that computing π would be useful in itself for the average xBase programmer (by the way the CT library contains a function to directly compute π). We shall not concern ourselves with a method to do that, but move to something more conventional.

The FizzBuzz interview question: critical thinking and algorithms, with an introduction to table trace and the concept of flag
FizzBuzz is a little problem that is quite often asked in job interviews. A good discussion is found at the page https://micheleriva.medium.com/about-coding-the-fizzbuzz-interview-question-9bcd08d9dfe5. As always there are many ways of solving even a simple problem like this, that can be worded as follows,

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

The first thing one should do is to think as many ways as possible to solve the problem. Also, you may be asked to show that your solution works without having access to a computer: the way of doing so is also one of the best ways of reading a program written by someone else, and even of checking the program you yourself wrote. You take a piece of paper and a pencil and check how the program instructions change the variables and what input they produce by arranging the content of the variables in a table and behaving like the computer. I heard this being called called Trace table, tracing an algorithm, hand tracing, dry running. For the moment I point you to a tutorial on YouTube which should give you a taste of how the thing works: https://www.youtube.com/watch?v=UbANyxE7pGE (Trace tables tutorial GCSE Computer Science).

Take for example the following trivial solution of FizzBuzz:

This example introduces a flag variable, that is, a variable that is checked to know whether the program executed a particular instruction or set of instructions.

Sorting Algorithms
Sorting data is an important application in computer science. In fact, in the ancient times (which means in the 50s), an important component of a computer was a piece of hardware called a Card Sorter, which was used to sort punched cards, see one at http://www.columbia.edu/cu/computinghistory/sorter.html, but the Census Machine built by Hollerith in the 1880's already had its own sorter box, and the French word for computer, ordinateur, can even be literally translated to sorter.

Let's start with a piece of code

From the version above we can (and should) separate the sorting routine in a procedure, this way:

Usually the first sorting algorithm introduced (even in my high school textbook) is Bubble Sort, which is a bad choice. Here we use Exchange Sort, which is equally bad, but at least we vary a little.

Grasping Recursion
We have recursion when a function calls itself. The definition is really this simple.

Put like that, it doesn't seem like a good idea, because it seems that a recursive function will trap the program in an infinite loop. In reality a recursive function does not just call itself, but includes a criterion to stop doing it and provide some actual result.

A first example is the factorial function, of which we take a definition from a dictionary (https://www.dictionary.com/browse/factorial): « Mathematics. the product of a given positive integer multiplied by all lesser positive integers: The quantity four factorial (4!) = 4 ⋅ 3 ⋅ 2 ⋅ 1 = 24. Symbol: n!, where n is the given integer».

Code blocks
https://github.com/vszakats/harbour-core/blob/master/doc/codebloc.txt

Sites around the Net say that Clipper 5 documentation called them unnamed assignable functions.

Let us get back at our Celsius to Fahrenheit temperature converting function:

and redo it as a codeblock:

In the first line we assigned a code block to a variable named Cels2F. The code block is comprised in braces. The first thing is a variable that is to be passed to the block, between vertical bars (|). More variables should be separated by commas. Then we can write the instructions (more than one should be separated by commas).

Later we use two times the Eval function giving it two arguments: the name we assigned to our codeblock and the parameter to pass it. In addition to Eval, other functions can evaluate code block: AEval and dbEval. Ascan and Asort can be given code blocks to change their behavior.

As code blocks can't contain commands, we can't put a ? command in them, but have to use the corresponding QOut function.

Command Line Arguments
Suppose that we wish to write a clone of the Unix cat command, which means that we will have a program to which we'll pass a command line argument that is a file name and output the content of the file.

That's it! In fact, it is quite limited, and it is more likely a clone of the DOS type command (or even of the CP/M type command!). Procedure This file's procedure MAIN receives one argument, and gets it from the command line. Then passes it to the MEMOREAD function (description: Return the text file’s contents as a character string), and sends the result to the console output.

File Management
Accessing files can be done using low-level functions, which are: FOPEN, FCREATE, FWRITE, FREAD, FREASDSTR, FERASE, FERROR, FSEEK, FCLOSE and FRENAME.

How should we code an example using these functions? Here is an idea:

 * 1) We create a new file is created using FCREATE and text is written into it with FWRITE.
 * 2) The pointer is positioned at the end of the file using FSEEK.
 * 3) The contents of the file are read using FREAD.
 * 4) The file is closed with FCLOSE.
 * 5) The file is renamed using FRENAME.
 * 6) Finally, the renamed file using FERASE is deleted.

Harbour, however, provides functions that permit manipulating text files in a similar way to DBF files (https://vivaclipper.wordpress.com/tag/memoread/).


text:
User:Gerardbuzolic

Well, here's my user page. Thought I'd better have one so my username is not in red at the top. Have a good day, Self, and don't get concerned about PDF deletion messages from Eugene.

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

title: User:Gerardbuzolic


text:
User:Gerardbuzolic/sandbox

This is my sandbox. One more page created.

title: User:Gerardbuzolic/sandbox


text:
User talk:Gerardbuzolic

Created the user talk page

title: User talk:Gerardbuzolic


text:
Wikijunior:How Things Are Made/Wood/Paper

Raw Materials
We need trees and complicated chemicals to make paper. Sometimes we recycle paper and it has a separate article. Please go back to this page, and look for a page called "Recycled Paper".

Process

1. Grown-ups called lumberjacks go to big forests with equipment like a chainsaw, and a truck to carry all their logs. The lumberjacks will work together to bring the logs to the truck. They keep going until they get enough logs.

2. The logs are taken to a spinning barrel, called a drum so they can remove the bark and get the wood.

3. The logs are ground up into a white liquid called pulp by being pressed against two huge revolving drums, over and over again.

4. The pulp is filtered to remove unwanted liquids and objects and particles that would mess up the paper and make it bad, and compromise it’s quality.

5. Trucks fill up with the pulp, they leave, and then they drive to a paper mill. At the paper mill, the pulp goes under a process, called beating.
 * The pulp is beaten over and over again by mechanical beaters. Now, the paper mill can have weird and complicated chemicals put into the paper, like chalk, clay or a chemical like titanium oxide.


text:
User talk:2001:569:BD7D:6E00:5505:B0A8:1DC:690F

Thanks
Thanks for that edit on the wikijunior book on future! A diehard editor (discuss • contribs) 01:50, 30 July 2019 (UTC)


text:
Programming Gambas from Zip/Arrays

Arrays, Lists, Sorting and Shuffling
There are times when you need not just separated memories with individual names like Speed, Distance, Time but a list of memories, a collection of variables, that can be numbered. So you might have Speed[0], Speed[1], Speed[2] and so on, all storing different speeds, or a list of several times that have names like Time[0], Time[1], Time[2] etc. This is called an array.

The elements (items) in the array are numbered, starting from zero, and you use square brackets. Teachers might have an array of student names, Student[0], Student[1] … Student[Student.Max]. Arrays have a count (e.g. Student.Count) and a max (Student.Max). Don’t go past Max or you will be out of bounds. And that means detention after school for sure.

You can have arrays of just about anything. However, you need to create them with the NEW operator when you want them.

An array of strings: An array of integers, using the array’s Add method: Arrays have Sort and Shuffle methods. You can write any of these. gb.descent and its mate are constants in the gb component. To see your array, put a listbox on your form then put your array into its list. The array on the right goes into the listbox’s list on the left. The code will look something like this. More detailed instructions follow.

The buttons are called bShuffle and bSort. Notice that you cannot say ListBox1.List.Shuffle, even though ListBox1’s List property acts like an array. Yes, it is an array. No, it doesn’t come with the Shuffle method.

The shuffle button has an extra line in its Click handler compared with the sort button. s.Sort is a thing, a function. s.Shuffle is a method. It is not a thing but a process, a procedure. It is a sub that does not return any value when it is done. You cannot put it into something. If you tried ListBox1.List = s.shuffle you would get an error message. The Gambas help shows how they are different:

Sorting alphabetically and Sorting Numerically
A listbox with numbers needs to be sorted numerically. Sorting number 1 to 12 alphabetically will give you 1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9 because alphabetically “10” comes before “2”. Copy the list into an integer array and sort that: You can see this in action:

Strings
Strings can be treated as arrays of characters. So, if Nm = "Gerard" then Nm[0] is G, Nm[1] is e, Nm[2] is r and so on.

However, you cannot change letters like Nm[2]="x" to make Gerard become Gexard. You can get the letter, but you can’t put something into it. You would have to use some of the wonderful functions that strings have. You can do many things with strings. You could use any of these:

Nm = Left(Nm,1) & “x” & Mid(Nm,3)

Nm = Left(Nm,1) & “x” & Right(Nm,4)

Nm = Replace(Nm, “e”, “x”)

Arrays of Arrays
You can have memories arranged in a list. They would all have the same name, but be numbered like X[0], X[1], X[2] etc:

You can have memories arranged in a grid (square or rectangle) and refer to them by row and column. This is also how the cells are numbered in a GridView or TableView:

You can have them arranged in a cube or prism, so that there are like layers of rectangles. The third number in brackets tells which layer. [Row, Column, Layer]

You can have arrays of them, too, but even though you can have multi-dimensional arrays, simple list arrays are the ones most often used.

Table of Squares, Square Roots and Calculations

This program fills a grid with calculations for the numbers one to ten. It also shows how to adjust properties of a gridview—its columns, rows and cells. Things to notice are the With … End With lines, setting up the gridview when the form opens, and the _Data event to fill each cell. gv1.Rows.Count = 10 is enough to trigger the Data event for every cell in those ten rows.

The _Data event occurs when the cell has to be painted. The filling of the cells could be done when the Fill button is clicked, but then we would have to use nested For statements to count down the rows and across the columns. Gambas already has to do this, because it has to paint each cell. The _Data event happens for each cell in each row, so why not put the text into the cells then?

If Row Mod 2 = 0 Then gv1.Data.Background = &HBFFFBF sets the background of the cell to peppermint green if the row number has a remainder of zero when divided by 2. Mod means “the remainder when you divide by ...”. For example 3 Mod 2 is 1, so row 3 has a white background. 4 Mod 2 is 0 because four divided by two equals two remainder zero, so row 4 has a green background.

We could alternate two colours, pink and green, with

gv1.Data.Background = If(Row Mod 2 = 0, &HBFFFBF, &HFFCFCF)

To colour the columns, try this in the tv1_Data event:

gv1.Data.Background = Choose(Column + 1, &FFAAFF, &FFFFAA, &AAFFFF, &AAAAFF)

Format(Sqr(x), "##.000") is an interesting expression. The Format function takes a floating point number like 1.41421356237 and formats it according to the pattern supplied. "##.000" means two digits if you need them, a dot, and three decimal places using zeros. What number to format? Sqr(x). This is the square root of the number x. The square root of two appears as 1.414.

Format Function
There are many more symbols for formatting dates and currency.

The Game of Moo
To play the game of Moo, also called Bulls and Cows, one person (the computer!) chooses a mystery number. It has 4 digits, and all digits are different. Wikipedia says, “The modern game with pegs was invented in 1970 by Mordecai Meirowitz, an Israeli postmaster and telecommunications expert. It resembles an earlier pencil and paper game called Bulls and Cows that may date back a century or more.” “Moo was written in 1970 by J. M. Grochow at MIT in the PL/I computer language.”

After each guess the computer tells you how many bulls you scored and how many cows. A bull is a digit in your number that is in its correct place in the mystery number. A cow is a digit that is present in the mystery number but is in its wrong place. Thus you are aiming for BBBB, all four digits in their correct places. CCCC means you have the correct digits but they are not in their right places. BBC means two digits are correctly placed, one of the other digits is in the number but in the wrong place, and another digit is not in the number at all. Some people play by the rule that you win if you guess it in ten or fewer turns. Bulls are listed first and cows second. You are not told which digits are the bulls or which are cows.

You need 2 textboxes, a gridview called gvHistory, and a button called bNewGame with the text property “New Game”.

The New Game button is initially invisible. Now for the post-mortem:

There are two public variables. MyNumber is the computer’s secret number. Count keeps count of how many guesses.

Form_Open On startup, set gridview to 2 columns and choose the secret number.

Public Sub ChooseNumber Put digits 0 to 9 in a 10-item array called Digits and shuffle. The secret number is the first four digits. They will be random and none is repeated.

Public Sub EvaluateGuess When you evaluate a guess, it is one more guess so add 1 to Count. Look for Bulls: Is the first character in your guess the same as the first character in the number? Check second, third and fourth characters too. Each time two characters match, take what s was and add a B to the end of it using s &= "B".

In looking for cows, i goes through 0, 1, 2, 3, looking through your number each time. For each one of those digits in your number, check all the digits in the secret number looking for a match, but disregard where the position numbers are the same (like the third digit in the secret number and the third digit in my guess), for that is a bull and has already been found.

S is a variable that contains BBBB or BBCC or B or whatever.

Add a row to the history gridview and put the guess in the first column and its evaluation into the second column.

Public Sub Congratulate Show a message saying “Congratulations! You got it in 8” or whatever. Change the form’s colour to yellow. Make the New Game button visible.

Public Sub bNewGame_Click To start a new game, remove the yellow colour, hide the New Game button, remove everything from the history gridview, set the count of guesses back to zero, choose another number, blank out the two textboxes, and set the focus to the textbox where you type in a guess so you are ready to start typing.

Public Sub tbGuess_Change When the text in the Guess textbox changes because you have typed another digit, check the length of what is typed and if it is 4 characters long, evaluate the guess.

Adding an “I Give Up” Feature
Let us make it that typing a question mark means “I give up—tell me the answer”. We need as new event, tbGuess_KeyPress. As soon as a question mark is typed, this handler will check the static class, Key, to see if the character typed was “?”. If so, message us the correct answer and start a new game.

Starting a new game is exactly what we have in the _Click handler for the New Game button. This code needs to be taken out of the _Click handler and put in a sub of its own. We can call on this NewGame sub when the button is clicked or when the user gives up by typing “?”. Here is the rearranged and extra code: Stop Event is there to prevent the question mark appearing in the tbGuess textbox. It is not necessary.

The important principle is (and you can memorise this or take this to the bank) if you want to refer to the same lines of code in two or more places, put them in their own sub and call on them by name.

Assignment Operators
There are numeric operators including ^ to mean “raised to the power of”. Boolean operators are AND, OR and NOT. There are others but these are the most used and useful.

title: Programming Gambas from Zip/Arrays


text:
Programming Gambas from Zip/TextFiles

The Game of Animal
The Animal Game, in which the computer tries to guess the animal you are thinking of by asking you questions, was around well before people had their own computers. It dates to at least the early 1970s. The author of website http://www.animalgame.com/ says that he/she first saw it in "101 BASIC Computer Games" (ed. by David H. Ahl - Maynard, Mass., Digital Equipment, 1973.) I remember that book. The game was originally developed by Arthur Luehrmann at Dartmouth College. http://www.smalltime.com/Dictator has an online version where you guess the dictator instead of an animal.

The computer starts by knowing only two animals, BIRD and FISH and only one question that can tell the two apart, “Does it swim?”. Questions can be answered YES or NO. If your animal is neither of these, you are asked for a question that would identify your animal. Gradually a list of animals and questions is built up, and the computer becomes smarter and smarter. It is a simple form of Artificial Intelligence (AI). Some wit once said, “Natural stupidity beats artificial intelligence every time”.

To someone starting computing, it may be too complicated. However, there might be bits here and there—saving and loading text from a text file, or the managing of big programs by breaking them into small, meaningful subs, for example—that would be useful. Let it wash over you and get a general feel of things. Practise debugging when you have made a typing error and the program does not run. I was intrigued by it back in the ‘70’s, and it is too good not to include.

Here is a typical dialogue:

 * Are you thinking of an animal?	Yes (No ends the program.)
 * It is a fish.	No.
 * The animal you were thinking of was a …?	Dog
 * Please type in a question that would distinguish a dog from a fish.	Does it have legs?
 * For a dog the answer would be…	Yes
 * Are you thinking of an animal?	Yes
 * Can it swim?	Yes
 * Does it have legs?	Yes
 * It is a dog.	Yes

Here is a data file. It is text only. At the end of every question is the line to go next for yes or no.

 * 0. Can it swim?/1/2
 * 1. Does it have legs?/3/4
 * 2. Does it have 2 big ears?/5/6
 * 3. dog
 * 4. Does it blow air?/9/10
 * 5. rabbit
 * 6. It is little and does it bite you?/7/8
 * 7. mosquito
 * 8. Is it small?/11/12
 * 9. whale
 * 10. fish
 * 11. fly
 * 12. bird

The code refers to these objects by the following names. Here goes. The coloured text at the top is TextLabel1. The “Are you thinking of an animal?” line has label LabPrompt and buttons bYes and bNo. The “The animal you were thinking of was a ...” has label LabPromptForAnimal and textbox tbNewAnimal. The “Please type in a question...” line has label LabQuestionPrompt. That is followed by the long textbox tbQuestion. Under it is another label LabQuestion. The last line, “For a 1111 the answer would be...” has label LabPrompt2 and buttons bYes2 and bNo2. The bottom line of buttons are named, from the left, bShowData, bReset, bSave, bOpen and bQuit.

Next is another form that allows you to look at the data. It shows by clicking the Data… button.

The form is called FData. It will automatically adjust the positions of objects on it when it is resized by dragging its corner handles. To do this, set its Arrangement property to Vertical. This makes its objects stack from top to bottom. The textarea, taData, has its expand property set to True so that its size will expand to fill the space available.

The three buttons, bSave, bCopy and bClose, are in a red rectangle the is a HBox. HBoxes spread their contents horizontally. This one is called HBox1. There are a couple of panels called Panel1 and Panel2. One is above the hbox and one is between the Copy and Close buttons, to separate them. There is a neat little spring called Spring1 that pushes the Save button to the left and the Copy button, tiny separator panel and Close button to the right.

When the game starts, these are the only visible objects. All others have their visible property set to False. The program sets their visibility to true later. There are four areas. Depending on the stage of the game you are up to, one by one they are made visible and the others are hidden.

Look again at the sample data file:

 * 0. Can it swim?/1/2
 * 1. Does it have legs?/3/4
 * 2. Does it have 2 big ears?/5/6
 * 3. dog
 * 4. Does it blow air?/9/10
 * 5. rabbit
 * 6. It is little and does it bite you?/7/8
 * 7. mosquito
 * 8. Is it small?/11/12
 * 9. whale
 * 10. fish
 * 11. fly
 * 12. bird

If the line counter L arrives at a line with an animal name and that name is rejected, the program replaces that line by the new question you give it and the new animal and the wrong animal are added to the end of the list.

The variables declared as Public and Private right at the start are there so that they can be accessed by several different subs. They don’t just last for the duration of the sub. They belong to the form rather than any particular sub. Z[ ] needs to be accessed by the other form, too, so it is Public. The code for the FData form is: Notes:

title: Programming Gambas from Zip/TextFiles


text:
Programming in 1L a

Programming in the minimal two-dimensional esoteric programming language 1L_a is pretty difficult, as there are only a few instructions. However, using some creative strategy, 1L_a has been proved to be Turing-Complete.

History
1L_a was designed by Scott Feeney. Released in 2005, it is the first member to be implemented in the 1L_a family. It's well known due to its simplicity.

Contents

 * 1) /The language/
 * 2) /Flattened 1L_a/
 * 3) /Simple statements/
 * 4) /Making larger programs/

title: Programming in 1L a


text:
User:U$3rname008/The language

Instructions
1L_a is a two-dimensional programming language, which means the code is not neccesarily executed in a linear order. So when the program starts, a pointer spawns on the first character of the first row, heading down. It will go forward every step and execute the comman it reaches, unless something changed its direction.

There's two instructions: GO and STOP. The GO instruction do different operations depending on the pointer's direction, though.

The intepreter will remember the first character of your program, and every time it reaches that character, the GO instruction is executed. Everything else executes STOP. I personally prefer using the whitespace for the GO-triggering character, because you could trace how the pointer moves by just looking at the program easily.

title: User:U$3rname008/The language


text:
Programming Gambas from Zip/ContextualMenus

Making Contextual Menus at Design Time
There is another way to create a contextual menu for when you right-click the tableview: not in code as we have done, but at design time. You still have to write code to handle the menu item clicks, but you avoid all those New Menuitem statements like mn = New Menu(Me) and su = New Menu(mn) As "MenuCopyTable". Simply use the Menu Editor to create a new menu with all its menu items. This menu will appear on the menubar, so to avoid that happening make it invisible (see the Visible checkbox below).

This is an easier way to make a contextual menu. It works if you know what the menu is going to be before you start the application. If you need to make a menu depending on what is typed in, you have to create the menu in code and use the New operator.

Sorting a GridView or TableView
There is no built-in sorting. I wish there were a method attached to each TableView like TableView_Sort(Column, Direction, NumericOrNot), but there isn’t. There is a good way to sort in the online wiki, here, but alas, it doesn’t sort correctly for columns containing numbers. 10 comes before 2, for example, because “1” is would come before “2” in a dictionary. The string “10” is less than the string “2” even though the number ten is greater than the number two.

(Thanks to fgores, Lee Davidson and Gianluigi of the forum for this method.)

So here is my method—somewhat agricultural, but it works. The idea is to go through the tableview row by row, gathering the cells in that row into a string with a separator between each, and putting the item that will determine the sorting right at the start of each. Sort the array, then unpack each row back into the tableview. In other words, pack each row into a string, sort the strings, and unpack each row. Use any rare and unusual character to separate the fields. Here a tilde (~) is used.


text:
Programming Gambas from Zip/FormArranging

Making Controls Expand When a Form is Resized
Gridviews and TableViews are often made to stretch and shrink when the window they are in is resized. A form, which is a window, knows how to resize and arrange the controls that are in it. Even when the form opens any controls that can be arranged and expanded will be.

Make a small form with one TableView.

Set the arrangement property of the form to Vertical. Set the expand property of the tableview to True. Run the program (f5). Change the size of the window and notice how the size of the tableview changes with it.

Adjust the padding property of the form to 8. Run the program again (F5). The space between the tableview and the edge of the form has increased. The margin inside the form is the padding. Table cells also have padding.

Add a button under the tableview. Run the program again. Move the button to one side of the tableview. Again run the program. Change the arrangement property to Horizontal and try again. Change it back to Vertical.

Delete the button. Add a HBox. Add a button to the HBox. (Alternately, Right-click the button and choose “Embed in a container”, then right-click the container—which is a panel—and Change into... a HBox.)

Controls in a HBox are arranged horizontally.

The spring will push the button to the right as far as it will go. Experiment with and without the spring.

If you make the button wider or narrower it stays whatever width you give it in the HBox.

The button expands vertically to fill the HBox from top to bottom. Change HBox’s height and see. HBoxes expand their controls to fill their height. In panels the button stays the same height but you cannot use springs.

A Spreadsheet to Average Student Marks

tv1 is a tableview. Its expand property is set to True.

At the bottom is a HBox. Inside, from left to right, is a label labC, a boldface label labAverage, a spring, and a Quit button called bQuit whose text property is “Quit”.

As each number is entered the average is recalculated. Blank cells are skipped.

LabC shows the count and labAverage the average. Right at the start two public arrays are created. Names[] is a list of the student names. Scores[] is a list of their results. They match: the first mark goes with the first name, the second mark with the second name, and so on.

The tv1_Data(Row As Integer, Column As Integer) event fires every time a cell needs to be redrawn. It supplies you with Row and Column. It can be thought of as painting the cell.

There is a special consideration with the _DATA event: it does not paint cells that it doesn’t need to. This is great for displaying large numbers of lines. If there are 100,000 lines and you are only showing 15 of them, only the cells on those 15 lines fire the _DATA event, not all hundred thousand. Be careful if you used the _DATA event to put the numbers into the cells! There may be data in only 15 of those 100,000 cells. Here there is no problem, because we are typing the numbers ourselves and every time we finish typing a new number it is put into the cell in the _SAVE event. (tv1[Row, Column].text = Value). When we come to putting values in using the _DATA event from a database, though, we shall only put data into the cells we see. Then we have to remember to do calculations on the internally-held data, not on the displayed contents of cells. To get into good habits, I have used the DATA[ ] array to hold the scores, and this is used in the calculation of averages. If comes down to this: if you are sure all the data is in the cells, use them; if not, use the data where you know for sure it is.

The following lines create a contextual menu for the tableview with four entries: The _Menu event belongs to tv1, the tableview. This event fires when the object is right-clicked (to show a menu). The _Click event belongs to TableviewMenu. What is that? It is the alias by which the menu su is known. Aliases make one think of secretive men in dark trenchcoats, but it is just the name by which it is known.

mn and su only exist for the duration of the popup menu because they are in the _Menu event. As soon as you click any item on the popup menu, that sub finishes and mn and su disappear. Luckily, we have said that su is also known as TableviewMenu. The menu itself, when it was created with New, has that name. So any clicks the menu gets are handled by TableviewMenu_Click.

Menus—whether main menus or submenus or menu items— have several events, methods and properties. See Gambas help for:

You can tell a menu to Close, Hide, Popup, Show or Delete.

You can tell the program to do things when the menu is clicked, after it hides or just before it shows. Usually it is when the menu is clicked that the menu gets to work.

Some properties are boolean (e.g. enabled, checked and visible), others are strings (e.g. text, name), pictures (picture) or variants, which are any type (tag).


text:
Programming Gambas from Zip/Ascii

Game of Concentration
You know the game: cards are arranged face down, you turn over a card, then you try to remember where you have seen its match. It’s somewhere...thinks...yes, it was here! You turn it over to find … no match! It was somewhere else. You turn the cards over and your friend takes a turn. If you do turn over matching cards, you take the cards. Whoever has the more cards at the end wins. In this version, there is only one player and you are racing against the clock to match all the cards.

The form is 508 wide and 408 high, but that is what I needed when I used Cooper Black for the font and +12 for the increased font size. Cooper Black has nice big black letters.

The File menu has three items, Give Up, New Game and Quit.

The form has its arrangement set to Fill so that the solitary gridview gv1 fills the whole window. It shouldn’t be resized, though, so set resizeable to False.

What we will do is have a 6x6 grid. All squares will be pale yellow. In memory is a kind of mirror image of the grid in an array called z. Arrays we have used up to now have been lists. A list is a series of items in a line. Lines are one-dimensional. The one dimension is their length. Grids are 2-dimensional and their two dimensions are length and width. For gridviews there are rows and columns. In our case z has rows and columns just as the gridview gv1 has. Public z As New String[6, 6] will create z as this in-memory grid. The top left cell of the gridview is gv1[0,0]. The top left corner of z is z[0,0]. The bottom right cell of the gridview is gv1[5,5], and the bottom right corner of z is z[5,5]. 36 cells in the gridview, like the 36 memories in z, are arranged in rows and columns.

The gridview shows the “cards” as we turn them over. The array z has the “underneath sides of the cards”. Pictures of your favourite relatives would be nice, but for now they will have big, Cooper Black letters, one on each.

You click a grid cell. The card turns over: we show the letter that we have hidden in z. If we kept doing this every time we clicked a grid cell there would be no game. We would just gradually reveal all the letters. So when you show a letter we raise a flag that says “One letter is showing”. If that flag is up, the next time you click a cell we shall know that a second card has been turned over and it is time to check for a match. No match? Hide the letters and lower the flag—one letter is NOT showing. If we have a match perhaps it is the very last card and you have finished the game. Or perhaps it is not the very last card, and you can leave the cards turned over (their letters showing) and play on, remembering to lower that flag because the next click will again be clicking the first-card-of-the-pair. The flag is a boolean (true/false, hat on/hat off) variable called OneShowing.

How do we know the game is finished? Every time we have a match, add 2 to a running total of how many cards are out of the game. When that total reaches 36, all cards have been matched. The variable that keeps count is called TurnedOver and it is an integer. It is a public (or private, as in “private to the form”—it doesn’t matter) variable, declared right at the start with all the other variables that need to exist for the duration of the form and not disappear when a sub finishes.

There is a timer included. The built-in function Timer represents the number of seconds since the application started. As soon as you make your first click the time is stored in StartTime. How long you took to play is put into the variable secs.

Dim secs As Integer = Timer - StartTime

The game board is set up in the Initialise sub. It zeroes the things that have to be zeroed. It calls on GetRandomLetters to make a list called s[] of the letters that will be distributed to the cells of z with its 6 rows and 6 columns. s needs to have 18 random letters, each repeated so there are matching pairs. It has 36 items altogether. Here are the screenshots and the code. If you prefer to work with clicking pictures, you will need a folder called Pix located in your Pictures folder. You need to put 18 pictures in it (jpg or png). In the code that follows, the picture files are read into an array of images. Images and Pictures in Gambas differ in what part of memory they are stored in. Images, unlike pictures, can be stretched to fit in an area with any given width and height. So the images in the array of eighteen are, when one is needed, put into a single Image called Img, stretched to fit one of the grid cells. The resulting image, now the right size, is converted to a picture using the Picture method that images have.

To show an image the cell’s Picture property is set to the converted image. To hide it the picture property is set to Null. This happens when you click on a cell.

There is a corresponding two-dimensional (rows/columns) array of picture names. To see if there is a match, the names of the pictures in the two clicked-on cells are compared.

It is time to congratulate the winner when 18 cells have been correctly matched (two at a time).

ASCII Codes
Characters (letters, digits, punctuation symbols) are stored in a computer’s memory by numbers. The most widely used system is ASCII, American Standard Code for Information Interchange. It was developed in the United States, and Wikipedia tells me the governing body prefers to call it US-ASCII because it uses the American dollar sign ($) and the Latin alphabet. Whenever you hit a key on the keyboard one of those code numbers goes into the computer. Even the non-printing characters have ASCII codes. The spacebar is 32. Hit the Delete key and 127 would go in. The Backspace key sent the number 8. To confuse you, the ASCII code for the digit ‘1’ is 49. What the computer does with these code numbers is up to the application. And you are writing the applications. In the above program, type what you like and nothing happens at all (except for CTRL-G which I have for “Give Up”, CTRL-N which is “New Game” and CTRL-Q, which is the shortcut for Quit). On the old manual typewriters at the end of a line you had to flick a lever and the roller with the paper going around it would zip back to the start of the line (Return) and pull the paper up a line (Linefeed) ready to start typing the next line. Return is 13. ASCII 13 is also Control-M (written ^M) and in programming languages is sometimes written \r. Linefeed is 10 and is also Control-J (^J). There is a Formfeed control, Control-L, that used to go to a new page (ASCII 12). You wouldn’t remember manual typewriters unless you spend time in museums, but for me it is like yesterday (sigh). Nowadays ASCII is largely replaced by Unicode. ASCII was limited to 128 characters. Unicode can display 137,993 characters, says Wikipedia—enough for all sorts of non-English characters and all the emojis you could ever want.

Even the original ASCII gave problems for people who spoke languages other than English. Wikipedia has the amusing example of ‘a Swedish programmer mailing another programmer asking if they should go for lunch, could get "N{ jag har sm|rg}sar" as the answer, which should be "Nä jag har smörgåsar" meaning "No I've got sandwiches" ’ and he or she would just have to put up with it.

title: Programming Gambas from Zip/Ascii


text:
Programming Gambas from Zip/RadioButtons

Radio Buttons and Groups
Radio buttons are like the buttons on the old cassette players. When you press down on one the others pop up. They are used for selecting one option among many.

If you have some radio buttons in a form, only one can be highlighted. Click one and the others clear. Even in code if you set one button’s highlight the others will unhighlight by themselves. The value property (boolean) indicates if the button is highlighted. When you click a radio button rb1 rb1.value = true happens automatically. When you click another button rb1.value = false happens automatically.

You might need two sets of radio buttons. To keep them separate, create them in a panel or some other container. Put the panel there first, and then make radio buttons in it, or select all the buttons you want to work together, right-click, and choose Embed in a container.

Another trick is to make them all share their events. Click any of the buttons and one and only one _Click event will fire. This avoids writing separate _Click handlers for each button. One handler does them all. But how do you know which button was clicked? Your one handler will probably want to do something based on which button was selected. This is where Last comes in. Last is the very last object that something happened to or that did something.

There are two sets of buttons, with each set in their own panel. rbRoad, rbSea and rbAir are in Panel1. rbApple, rbOrange and rbPear are in Panel2. The panels are the parents of their buttons. The buttons are their children.

The Group property for the road, sea and air buttons is set to rbTransport. It is as if they are acting like they are one single radio button, rbTransport.

The Group property for the apple, orange and pear buttons is set to rbFruit. It is as if they are one radio button, rbFruit.

Double-click one of the transport buttons (any one). You will find yourself writing a handler for the rbTransport group of buttons. Likewise, double-click one of the fruit buttons and you will find yourself writing a handler that rbApple, rbOrange and rbPear all respond to. The LCase function makes the text inside the brackets lower case. Run the program and click on buttons.

In the next section, we add the ability to save settings to this program. Whatever state the buttons are in when we close the application will be the state to which they are restored when the application runs next time.


text:
Programming Gambas from Zip/SaveSettings

This section builds on the Radio Buttons exercise from the previous page.

Add Settings Saving to the Radio Buttons
Gambas provides a neat way to save settings. Settings can be the path to the last data file, so it does not have to be relocated the next time the program starts. They can be anything the user typed or chose that you want to remember for next time. Here we shall save the selected radio buttons.

First, make sure the Settings component is enabled as part of your project. After starting a new QT graphical project, select Project Menu > Properties…, look through for the gb.settings component and tick it:

Use the same form as on the previous page (RadioButtons) with the fruit and transport buttons, but change the code to this: Run the program. Select a transport and fruit. Close the program. Run it again: your choices have been restored.

You could have your settings saved when the form closes. Gambas wiki has this example, showing how you can restore the window to whatever place it was last dragged to and whatever size it was resized to when last the program ran: Me means the current form.

Where are these settings actually stored? In your home folder is a hidden folder for settings called .config. In Linux any file or folder whose name starts with a dot is hidden. Look in .config for the Gambas3 folder. In it you will find a text file with the same name as your program. Open it and you will see the settings file.

Settings are neatly arranged under headings. Now you can see the significance of the string that has the slash in it: the first item is the heading. Settings["Radiobuttons/Fruit"] is the Fruit setting under the Radiobuttons heading.

You need to be careful: the very first time you run your program there may not be a settings file. If your form opens and looks for a particular setting when no settings file exists there will be problems. Test for empty (null) strings.

Saving a colour, a checkbox and the contents of a TableView

On the form is a checkbox cbSurnameFirst, a panel Panel1, a label with the text “Choose colour:”, a colorbutton ColorButton1, a label Label1 whose text is “Fill”, colour blue and underlined, and a tableview tv1.

Run the program. Fill the tableview with random letters. Choose a colour. Highlight the completely useless button “Surname first”. Close the program. Run the program again. Settings are restored.

IF Function
There is a special form of the IF...THEN...ELSE statement that saves writing several lines of code. It is in the form of a function. These two are equivalent: is equivalent to In the one-line statement, the If(IsNull(colour), &hFFFFFF, colour) is one single thing. It is a number representing a color. Which colour? In the brackets are three items: a test that is either true or false, the answer if the test comes up true and the answer if the test comes up false. The pattern is if( TrueOrFalseThing, ValueIfTrue, ValueIfFalse). &hFFFFFF is the hexadecimal number for White (all red, green and blue LED lights fully on).

This is a sample settings file. On the left the checkbox is unchecked. On the right, the checkbox is checked.


text:
Programming in 1L a/The language

How it works
1L_a is a two-dimensional programming language, which means the code is not necessarily executed linearly. So when the program starts, an instruction pointer, or IP for short, spawns on the first character of the first row, heading down. It will go forward every step and execute the command it reaches unless something changed its direction.

There are two instructions: GO and STOP. The GO instruction performs different operations depending on the IP's direction. (We will talk about the instructions later after we've introduced the array.) The interpreter will remember the first character of your program, and every time it reaches that character, the GO instruction is executed. Everything else executes STOP. I prefer using the whitespace for the GO-triggering character because you could trace how the IP moves by just looking at the program easily.

The Array
1L_a is array-based, which means you can manipulate a built-in array. (Here, the array is bool-typed.) The first three elements in the array, namely TL0, TL1, and TL2, are for I/O which we will discuss later.

Data Pointer
There's a data pointer (not to be confused with IP), or DP for short, initially pointing at TL2. All your operations are based on the data pointer. You can move the data pointer, or read and toggle the bit it is pointing.

You may notice the fact that I said read and toggle, instead of reading and write. That's because 1L_a doesn't have a direct way to set one bit. To set a bit to 0, you may write something like:

 * Read the bit.
 * If the bit is 1, toggle it.

TL0
TL0 is the first element in the array. If it is toggled, the program will read input from STDIN or write output to STDOUT, depending on the value of TL1 and TL2. That's the only way to do I/O in this language.

TL1
TL1 is the I/O switch. When you toggle TL0, the interpreter will check TL1, if TL0 is 0, the program will read a bit for input, and store its value in TL2; If TL1 is 1, the program will output a bit.

TL2
TL2 is registered for the bit to be outputted or the newly-inputted bit. It is closer to the normal-bits, so when you want to output a bit, you can move it from the normal bits to TL2 without passing other special registers(in 1L_a, moving your DP is very tricky), and when you inputted a bit, you can read that bit on the way back "home".

Instructions
As mentioned earlier, there are two instructions in 1L_a: GO and STOP. Here's a table showing the operation they do:

Unlike what you might think, the "Do nothing" operation is very useful in such a language, since it transfers the IP without any "side effects", like modifying the array.

A side note: The I/O Buffers
This language is bit-based, so it outputs by bits, not characters. Yet, in many implementations, those bits are stored inside a "buffer", when there are already 8 bits in the buffer, those bits are outputted as ASCII code, and they are cleared. For the input, similar things happen. When you enter a character, the program automatically decomposes it into 8 bits, and then stores it into an "input buffer". When the program wants to read a bit, it reads one bit in the buffer, and that bit was removed.

title: Programming in 1L a/The language


text:
User:Nicksh/sandbox/Skyline

Skyline is a freely-available, open-source Windows client application for building Selected Reaction Monitoring (SRM) / Multiple Reaction Monitoring (MRM), Parallel Reaction Monitoring (PRM), DIA/SWATH and targeted DDA quantitative methods and analyzing the resulting mass spectrometer data. Its flexible configuration supports All Molecules. It aims to employ cutting-edge technologies for creating and iteratively refining targeted methods for large-scale quantitative mass spectrometry studies in life sciences.

/Peptide Settings/

title: User:Nicksh/sandbox/Skyline


text: User:Nicksh/sandbox/Skyline/Peptide Settings


text:
History of wireless telegraphy and broadcasting in Australia/Topical/Biographies/Alfred Thomas Bauer

Transcriptions and Notes
More than 50 key articles relevant to Alfred Thomas Bauer, mainly from the NLA's Trove Digitised Newspapers have been transcribed for ease of reference here: Alfred Thomas Bauer - Transcriptions and Notes


text:
History of wireless telegraphy and broadcasting in Australia/Topical/Biographies/Ernest Thomas Fisk

Transcriptions and Notes
More than 50 key articles relevant to Ernest Thomas Fisk, mainly from the NLA's Trove Digitised Newspapers have been transcribed for ease of reference here: Ernest Thomas Fisk - Transcriptions and Notes


text:
History of wireless telegraphy and broadcasting in Australia/Topical/Biographies/Peter Kennedy

Transcriptions and Notes
More than 50 key articles relevant to Peter Kennedy, mainly from the NLA's Trove Digitised Newspapers have been transcribed for ease of reference here: Peter Kennedy - Transcriptions and Notes


text:
History of wireless telegraphy and broadcasting in Australia/Topical/Biographies/Francis Michael Nolan

Transcriptions and Notes
More than 50 key articles relevant to Francis Michael Nolan, mainly from the NLA's Trove Digitised Newspapers have been transcribed for ease of reference here: Francis Michael Nolan - Transcriptions and Notes


text:
History of wireless telegraphy and broadcasting in Australia/Topical/Biographies/Francis William Nolan

Transcriptions and Notes
More than 50 key articles relevant to Francis William Nolan, mainly from the NLA's Trove Digitised Newspapers have been transcribed for ease of reference here: Francis William Nolan - Transcriptions and Notes


text:
History of wireless telegraphy and broadcasting in Australia/Topical/Biographies/Violet Elizabeth Nolan

Transcriptions and Notes
More than 50 key articles relevant to Violet Elizabeth Nolan, mainly from the NLA's Trove Digitised Newspapers have been transcribed for ease of reference here: Violet Elizabeth Nolan - Transcriptions and Notes


text:
History of wireless telegraphy and broadcasting in Australia/Topical/Biographies/Francis Michael Nolan/Notes

Overview
Overview of Frank's life in Halcyon Days VK4FN - FRANCIS MICHAEL NOLAN (SK). AOCP Brisbane 1931. First job an apprentice motor mechanic (14 years). Became an early member QRTL and obtained a permit to transmit over 2 miles (before AOCP). Studied for diploma in radio engineering in Sydney then moved back to Brisbane and worked for Ben's Radio Service before becoming self-employed. Joined the PMG Dept. as B/C technician 1936 and was appointed 2IC at 4RK Rockhampton 1939. Member Wooloowin RC and WIA. WWII service nil, reserved occupation. Sent to Pt Moresby 1945 he established Station 9PA, then returned to Brisbane 1946. Frank served as WIAQ Federal Councillor 1947-48, assisted on the Amateur Advisory Committee 1948-51 and carried out 6 band simultaneous VK4WIA B/Cs 1946-51. In 1951 he returned to Papua New Guinea in charge of broadcasting, created the WIA VK9 division and was president 1953-59. Back in Rockhampton he helped form the Central Qld. branch WIA and was president (with Hal VK4DO as secretary) 1961-68. When retired he conducted the weekly news on 80 mx for over ten years. Frank's on-air activities saw him as top scorer in RD contests for both VK4 and VK9. VK4FN has been honored by WIAQ with Merit Badge No. 3 and latterly with Life Membership.

1987
Overview of Frank's life in Halcyon Days VK4FN - FRANCIS MICHAEL NOLAN (SK). AOCP Brisbane 1931. First job an apprentice motor mechanic (14 years). Became an early member QRTL and obtained a permit to transmit over 2 miles (before AOCP). Studied for diploma in radio engineering in Sydney then moved back to Brisbane and worked for Ben's Radio Service before becoming self-employed. Joined the PMG Dept. as B/C technician 1936 and was appointed 2IC at 4RK Rockhampton 1939. Member Wooloowin RC and WIA. WWII service nil, reserved occupation. Sent to Pt Moresby 1945 he established Station 9PA, then returned to Brisbane 1946. Frank served as WIAQ Federal Councillor 1947-48, assisted on the Amateur Advisory Committee 1948-51 and carried out 6 band simultaneous VK4WIA B/Cs 1946-51. In 1951 he returned to Papua New Guinea in charge of broadcasting, created the WIA VK9 division and was president 1953-59. Back in Rockhampton he helped form the Central Qld. branch WIA and was president (with Hal VK4DO as secretary) 1961-68. When retired he conducted the weekly news on 80 mx for over ten years. Frank's on-air activities saw him as top scorer in RD contests for both VK4 and VK9. VK4FN has been honored by WIAQ with Merit Badge No. 3 and latterly with Life Membership.


text: History of wireless telegraphy and broadcasting in Australia/Topical/Biographies/Francis William Nolan/Notes


text: History of wireless telegraphy and broadcasting in Australia/Topical/Biographies/Violet Elizabeth Nolan/Notes


text:
User talk:Strange quark/2018

Share your experience and feedback as a Wikimedian in this global survey
Hello! The Wikimedia Foundation is asking for your feedback in a survey. We want to know how well we are supporting your work on and off wiki, and how we can change or improve things in the future. The opinions you share will directly affect the current and future work of the Wikimedia Foundation. You have been randomly selected to take this survey as we would like to hear from your Wikimedia community. The survey is available in various languages and will take between 20 and 40 minutes. Take the survey now!

You can find more information about this survey on the project page and see how your feedback helps the Wikimedia Foundation support editors like you. This survey is hosted by a third-party service and governed by this privacy statement (in English). Please visit our frequently asked questions page to find more information about this survey. If you need additional help, or if you wish to opt-out of future communications about this survey, send an email through the EmailUser feature to WMF Surveys to remove you from the list.

Thank you! WMF Surveys, 18:36, 29 March 2018 (UTC)

Reminder: Share your feedback in this Wikimedia survey
Every response for this survey can help the Wikimedia Foundation improve your experience on the Wikimedia projects. So far, we have heard from just 29% of Wikimedia contributors. The survey is available in various languages and will take between 20 and 40 minutes to be completed. Take the survey now.

If you have already taken the survey, we are sorry you've received this reminder. We have design the survey to make it impossible to identify which users have taken the survey, so we have to send reminders to everyone. If you wish to opt-out of the next reminder or any other survey, send an email through EmailUser feature to WMF Surveys. You can also send any questions you have to this user email. Learn more about this survey on the project page. This survey is hosted by a third-party service and governed by this Wikimedia Foundation privacy statement. Thanks! WMF Surveys, 01:34, 13 April 2018 (UTC)

Your feedback matters: Final reminder to take the global Wikimedia survey
Hello! This is a final reminder that the Wikimedia Foundation survey will close on 23 April, 2018 (07:00 UTC). The survey is available in various languages and will take between 20 and 40 minutes. Take the survey now.

'''If you already took the survey - thank you! We will not bother you again.''' We have designed the survey to make it impossible to identify which users have taken the survey, so we have to send reminders to everyone. To opt-out of future surveys, send an email through EmailUser feature to WMF Surveys. You can also send any questions you have to this user email. Learn more about this survey on the project page. This survey is hosted by a third-party service and governed by this Wikimedia Foundation privacy statement. WMF Surveys, 00:44, 20 April 2018 (UTC)

Username
U have a strange name — Preceding unsigned comment added by 2607:fb90:24be:23b4:7182:b2ae:415d:bb78 (talk • contribs) 21:11, 17 September 2018 (UTC)

title: User talk:Strange quark/2018


text:
User:Goitsemodimo Kanyota

Kanyota

title: User:Goitsemodimo Kanyota


text:
C++ Programming/Programming Languages/C++/Code/Keywords/explicit

The   keyword is used to avoid implicit type conversions.

Here's an example class with a constructor that can be used for implicit conversions:

Here's a simple function that takes a  object:

and here's where the  function is called.

The argument is not a  object, but an. However, there exists a constructor for  that takes an   so this constructor can be used to convert the parameter to the correct type.

The compiler is allowed to do this once for each parameter.

Prefixing the  keyword to the constructor prevents the compiler from using that constructor for implicit conversions. Adding it to the above class will create a compiler error at the function call. It is now necessary to call for conversion explicitly with


text:
C++ Programming/Programming Languages/C++/Code/Keywords/auto

The   keyword is used to have the compiler infer the type of the variable which follows it from the RHS or from its declaration.


text:
User talk:AlexS147

Welcome, AlexS147!

If you have any questions, you can ask in the assistance reading room or possibly contact me personally. JackPotte (discuss • contribs) 15:01, 31 July 2019 (UTC)

System Modeling Language (SysML) 1.5
I've deleted your book because its text is protected: 2019 © DocPlayer.net. Please follow PermissionOTRS if you were the original author. JackPotte (discuss • contribs) 15:01, 31 July 2019 (UTC)

title: User talk:AlexS147