~ Command

Purpose

Voids a numeric expression.

Syntax

~a

Description

~ causes a calculated value or an integer expression returned from a function not to be put on stack or in a register. This means that the value is indeed calculated but because of ~ it's immediately "forgotten".

Example

This example performs a delay by calculating a complex expression which makes it very dependant on both computer and clock rate. It is much better to use Pause 1 here.

OpenW 1

Local i%, x%

For i% = 0 To _X - 1

Plot i%, (SinQ (i%) + 1) * _Y / // Plots the Sine Curve

~Sin(Cos(Tan(Log(2.3))))           // Is calculated but not used

Next

KeyGet x%

CloseW 1

The following example creates a PopUp menu called POP-UP Menu with entries L1, L2 and L3, without monitoring which entry was selected.

Local xo% = 100

Local yo% = 20

Local a$ = "POP-UP Menu | L _1 | L _2| L _3"

~PopUp(a$, xo%, yo%, 1)

Finally, this example produces a Message Box for which you do not need a return value.

~MsgBox("Press 'OK' to continue", MB_OK, "MsgBox")

Remarks

~x and Void x are equivalent to dummy% = x

New. ~ is also used to void a return value from a user defined function. However, in GFA-BASIC 32 the ~ is no longer needed.

Local d# = DoFunc(1// call function and store return value

~DoFunc(2)            // call function and void the return value

Print DoFunc(3)       // call function and print return value

 

Function DoFunc(a#)

Return a# * 1.0

EndFunc

New. This is also true for DLL functions declared with Declare. The ~ is no longer necessary to void the return value. In addition, DLL functions are no longer called using @@ or ^^, but simply by their name as if they were common functions.

However, ~ is still necessary for built-in API functions.

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

OpenW 1

Dim n$ = String$( 30, #0)

GetUserName(n$, 30)                  ' New Syntax

Print "User Name: "; n$

~GetWindowText(Win_1.hWnd, V:n$, 30) ' Old Style: still uses ~

Print "Window Title: "; n$

See Also

Void

{Created by Sjouke Hamstra; Last updated: 20/09/2017 by James Gaite}