Tutorial by Examples: f

Use try-finally to avoid leaking resources (such as memory) in case an exception occurs during execution. The procedure below saves a string in a file and prevents the TStringList from leaking. procedure SaveStringToFile(const aFilename: TFilename; const aString: string); var SL: TStringList; ...
Const baseString As String = "Foo Bar" Dim containsBar As Boolean 'Check if baseString contains "bar" (case insensitive) containsBar = InStr(1, baseString, "bar", vbTextCompare) > 0 'containsBar = True 'Check if baseString contains bar (case insensitive) co...
Const baseString As String = "Foo Bar" Dim containsBar As Boolean Dim posB As Long posB = InStr(1, baseString, "B", vbBinaryCompare) 'posB = 5
Const baseString As String = "Foo Bar" Dim containsBar As Boolean 'Find the position of the last "B" Dim posX As Long 'Note the different number and order of the paramters for InStrRev posX = InStrRev(baseString, "X", -1, vbBinaryCompare) 'posX = 0
Const baseString As String = "Foo Bar" Dim leftText As String leftText = Left$(baseString, 3) 'leftText = "Foo"
Const baseString As String = "Foo Bar" 'Get the string starting at character 2 and ending at character 6 Dim midText As String midText = Mid$(baseString, 2, 5) 'midText = "oo Ba"
'Trim the leading and trailing spaces in a string Const paddedText As String = " Foo Bar " Dim trimmedText As String trimmedText = Trim$(paddedText) 'trimmedText = "Foo Bar"
Used by awk to separate fields output by the print statement. For example: echo "a b c d e f" | awk 'BEGIN {OFS="-"} {print $2, $3}' produces: b-c e-f The default value is , a string consisting of a single space.
Command line arguments passed to awk are stored in the internal array ARGV of ARGC elements. The first element of the array is the program name. For example: awk 'BEGIN { for (i = 0; i < ARGC; ++i) { printf "ARGV[%d]=\"%s\"\n", i, ARGV[i] } }' arg1 arg2 arg3 ...
Starting out: HTML <table id='my-table' width='960' height='500'></table> JS var data = [ { type: "Name", content: "John Doe" }, { type: "Birthdate", content: "01/01/1970" }, { type: "Salary", content: "$40,000,0...
The most flexible base R function for reshaping data is reshape. See ?reshape for its syntax. # create unbalanced longitudinal (panel) data set set.seed(1234) df <- data.frame(identifier=rep(1:5, each=3), location=rep(c("up", "down", "left", &quo...
Setup First, install the necessary packages with: npm install express cors mongoose Code Then, add dependencies to server.js, create the database schema and the name of the collection, create an Express.js server, and connect to MongoDB: var express = require('express'); var cors = require('...
Adding a Fragment Statically File: activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <fragment android:id=&qu...
There is currently a proposal (not yet part of the ECMAScript standard) to add a finally callback to promises that will be executed regardless of whether the promise is fulfilled or rejected. Semantically, this is similar to the finally clause of the try block. You would usually use this functional...
Use & to capture functions from other modules. You can use the captured functions directly as function parameters or within anonymous functions. Enum.map(list, fn(x) -> String.capitalize(x) end) Can be made more concise using &: Enum.map(list, &String.capitalize(&1)) Captu...
We often encounter a situation where a property we're trying to extract doesn't exist in the object/array, resulting in a TypeError (while destructuring nested objects) or being set to undefined. While destructuring we can set a default value, which it will fallback to, in case of it not being found...
\documentclass{article}% or book, report, ... \begin{document} See \cite{citeA} or \cite{citeB} or \cite{citeA, citeB}. \begin{thebibliography}{x} % \bibitem{<biblabel>} <citation> \bibitem{citeA} {\scshape Author, A}, {\itshape A title}, Journal of So-and-So, 2000....
round() tie breaking In Python 2, using round() on a number equally close to two integers will return the one furthest from 0. For example: Python 2.x2.7 round(1.5) # Out: 2.0 round(0.5) # Out: 1.0 round(-0.5) # Out: -1.0 round(-1.5) # Out: -2.0 In Python 3 however, round() will retur...
An Interface's function known as a "contract" of functionality. It means that it declares properties and methods but it doesn't implement them. So unlike classes Interfaces: Can't be instantiated Can't have any functionality Can only contain methods * (Properties and Events are metho...
To register your device for push notifications, add the following code to your AppDelegate file in didFinishLaunchingWithOptions method: Swift func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for c...

Page 150 of 457