Deferred function calls serve a similar purpose to things like finally blocks in languages like Java: they ensure that some function will be executed when the outer function returns, regardless of if an error occurred or which return statement was hit in cases with multiple returns. This is useful f...
K&R
void* is a catch all type for pointers to object types. An example of this in use is with the malloc function, which is declared as
void* malloc(size_t);
The pointer-to-void return type means that it is possible to assign the return value from malloc to a pointer to any other type of ob...
Public Function GetUserFirstName(UserName As String) As String
Dim Firstname As String = ""
'Specify the SQL that you want to use including a Parameter
Dim SQL As String = "select firstname from users where username=@UserName"
'Provide a Data Sourc...
section .data
msg db "Hello world!",10 ; 10 is the ASCII code for a new line (LF)
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 13
syscall
mov rax, 60
mov rdi, 0
syscall
If you want to e...
Variables declared inside a function only exist (unless passed) inside that function.
x <- 1
foo <- function(x) {
y <- 3
z <- x + y
return(z)
}
y
Error: object 'y' not found
Variables passed into a function and then reassigned are overwritten, but only insi...
Named Functions
defmodule Math do
# one way
def add(a, b) do
a + b
end
# another way
def subtract(a, b), do: a - b
end
iex> Math.add(2, 3)
5
:ok
iex> Math.subtract(5, 2)
3
:ok
Private Functions
defmodule Math do
def sum(a, b) do
a...
Sometimes the computation in a Future can create an exception, which will cause the Future to fail. In the "Creating a Future" example, what if the calling code passed 55 and 0 to the divide method? It'd throw an ArithmeticException after trying to divide by zero, of course. How would t...
A class or a structure may declare any function it's friend. If a function is a friend of a class, it may access all it's protected and private members:
// Forward declaration of functions.
void friend_function();
void non_friend_function();
class PrivateHolder {
public:
PrivateHolder(in...
The special symbol T represents the value true in Common Lisp, while the special symbol NIL represents false:
CL-USER> (= 3 3)
T
CL-USER> (= 3 4)
NIL
They are called “Constant Variables” (sic!) in the standard, since they are variables whose value cannot be modified. As a consequence, y...
C99
These functions returns the floating-point remainder of the division of x/y. The returned value has the same sign as x.
Single Precision:
#include <math.h> /* for fmodf() */
#include <stdio.h> /* for printf() */
int main(void)
{
float x = 10.0;
float y = 5.1;
...
Code source View the output here
using System;
using System.Diagnostics;
using System.IO;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
namespace HelloWorld
{
/// <summary>
/// This sample is the obligatory Hello World program.
/// &l...
You can use Bash Parameter Expansion to emulate common filename-processing operations like basename and dirname.
We will use this as our example path:
FILENAME="/tmp/example/myfile.txt"
To emulate dirname and return the directory name of a file path:
echo "${FILENAME%/*}"
...
Before Fortran 95 it was possible to use assigned formats for input or output. Consider
integer i, fmt
read *, i
assign 100 to fmt
if (i<100000) assign 200 to fmt
print fmt, i
100 format ("This is a big number", I10)
200 format ("This is a small number", I6)
e...
To enable Second Level Caching for Hibernate in WildFly, add this property to your persistence.xml file:
<property name="hibernate.cache.use_second_level_cache" value="true"/>
You may also enable Query Caching with this property:
<property name="hibernate.cache...
Const zipCode As long = 10012
Dim zeroPaddedNumber As String
zeroPaddedZipCode = Format(zipCode, "00000000")
'zeroPaddedNumber = "00010012"
Strings can be assigned directly to byte arrays and visa-versa. Remember that Strings are stored in a Multi-Byte Character Set (see Remarks below) so only every other index of the resulting array will be the portion of the character that falls within the ASCII range.
Dim bytes() As Byte
Dim exampl...
public class MyDataExporterToExcell
{
public static void Main()
{
GetAndExportExcelFacade facade = new GetAndExportExcelFacade();
facade.Execute();
}
}
public class GetAndExportExcelFacade
{
// All services below do something by themselves, determine l...
When a user press F1 on a control or click on Help button of form (?) and then clicks on a control the HelpRequested event will be raised.
You can handle this event to provide custom action when user requests help for controls or form.
The HelpRequested supports bubble up mechanism. It fires for y...
If you have a Form with MinimizeBox and MaximizeBox set to true, then you can not show Help button on title-bar of Form and will lose the feature of click on help button to convert it to help cursor to be able to click on controls to show help.
You can make a menu item on MenuStrip act like standar...
VBA is compiled in run-time, which has a huge negative impact on it's performance, everything built-in will be faster, try to use them.
As an example I'm comparing SUM and COUNTIF functions, but you can use if for anything you can solve with WorkSheetFunctions.
A first attempt for those would be t...