Difference between revisions of "EverettRandom"

From Free Pascal wiki
Jump to navigationJump to search
m (Added packages category)
m (Fixed syntax highlight errors)
Line 37: Line 37:
 
====Code====
 
====Code====
 
* Declare as a variable:
 
* Declare as a variable:
<syntaxhighlight>MyEverett: TEverett;</syntaxhighlight>
+
<syntaxhighlight lang="pascal">MyEverett: TEverett;</syntaxhighlight>
 
* In form Create:
 
* In form Create:
<syntaxhighlight>MyEverett := TEverett.Create(Self);</syntaxhighlight>
+
<syntaxhighlight lang="pascal">MyEverett := TEverett.Create(Self);</syntaxhighlight>
 
* If you don't want to show a dialog whilst querying the server:
 
* If you don't want to show a dialog whilst querying the server:
<syntaxhighlight>MyEverett.ShowWaitDialog:=FALSE;</syntaxhighlight>
+
<syntaxhighlight lang="pascal">MyEverett.ShowWaitDialog:=FALSE;</syntaxhighlight>
 
* There are 3 functions that will retrieve a single integer:
 
* There are 3 functions that will retrieve a single integer:
<syntaxhighlight>
+
<syntaxhighlight lang="pascal">
 
// Fetch a single random number
 
// Fetch a single random number
 
function MyEverett.GetSingle8Bit: integer;
 
function MyEverett.GetSingle8Bit: integer;
Line 50: Line 50:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
* Array functions will put results into:
 
* Array functions will put results into:
** (GetInteger8BitArray, GetInteger16BitArray) populates <syntaxhighlight>MyEverett.IntegerArray[0..Pred(ArraySize)]</syntaxhighlight>
+
** (GetInteger8BitArray, GetInteger16BitArray) populates <syntaxhighlight lang="pascal">MyEverett.IntegerArray[0..Pred(ArraySize)]</syntaxhighlight>
** (GetHexArray) populates <syntaxhighlight>MyEverett.HexArray[0..Pred(ArraySize)]</syntaxhighlight>
+
** (GetHexArray) populates <syntaxhighlight lang="pascal">MyEverett.HexArray[0..Pred(ArraySize)]</syntaxhighlight>
 
* First set the properties:
 
* First set the properties:
 
** MyEverett.ArraySize (default=1)
 
** MyEverett.ArraySize (default=1)
Line 57: Line 57:
 
** MyEverett.HexSize (default=1)  e.g. 1=00->FF,  2=0000->FFFF,  3=000000->FFFFFF etc.
 
** MyEverett.HexSize (default=1)  e.g. 1=00->FF,  2=0000->FFFF,  3=000000->FFFFFF etc.
 
* Result for array functions is TRUE(Success) or FALSE(failure)
 
* Result for array functions is TRUE(Success) or FALSE(failure)
<syntaxhighlight>
+
<syntaxhighlight lang="pascal">
 
function MyEverett.GetInteger8BitArray:Boolean;
 
function MyEverett.GetInteger8BitArray:Boolean;
 
function MyEverett.GetInteger16BitArray:Boolean;
 
function MyEverett.GetInteger16BitArray:Boolean;

Revision as of 12:05, 30 August 2019

Everett Random Integer Class

Summary

The Everett interpretation of quantum mechanics ("Many Worlds") is that when an interaction is made with an elementary wave function (such as an electron or photon etc) the universe bifurcates. ref: Wikipedia Many Worlds page

This happens naturally of course (just via radioactive decays in atoms of your body there are about 5000 bifucations per second) but this component brings into the mix "Free Will". By requesting a random number from the online source, which is a beam-splitter based in Austrailia you are bifurcating the Universe deliberately - that is, based on your Free Will. You may or may not find that interesting, but nevertheless this component gives you this ability (to "play God" with the Universe)

The random numbers returned are truly random (i.e. not pseudorandom via algorithm)

This package is a wrapper for querying a quantum number generator based in Austrailia.
everettrandom screenshot.png


Download



Installation and Usage

  • Open everettrandom.lpk and compile it.
  • In your application, include everettrandom as a required package
  • In a form unit:
    • In the Uses clause, add ueverettrandom



Code

  • Declare as a variable:
MyEverett: TEverett;
  • In form Create:
MyEverett := TEverett.Create(Self);
  • If you don't want to show a dialog whilst querying the server:
MyEverett.ShowWaitDialog:=FALSE;
  • There are 3 functions that will retrieve a single integer:
// Fetch a single random number
function MyEverett.GetSingle8Bit: integer;
function MyEverett.GetSingle16Bit: integer;
function MyEverett.GetSingleHex: String;
  • Array functions will put results into:
    • (GetInteger8BitArray, GetInteger16BitArray) populates
      MyEverett.IntegerArray[0..Pred(ArraySize)]
      
    • (GetHexArray) populates
      MyEverett.HexArray[0..Pred(ArraySize)]
      
  • First set the properties:
    • MyEverett.ArraySize (default=1)
    • ..and for Hex results
    • MyEverett.HexSize (default=1) e.g. 1=00->FF, 2=0000->FFFF, 3=000000->FFFFFF etc.
  • Result for array functions is TRUE(Success) or FALSE(failure)
function MyEverett.GetInteger8BitArray:Boolean;
function MyEverett.GetInteger16BitArray:Boolean;
function MyEverett.GetHexArray:Boolean;

Internationalisation

  • i8n: everettrandom has a 'locale' folder with all the .po files needed for translation. The base language is English



Demo App

  • In the /demo folder is a small application to demonstrate the use of everettrandom
  • Compile and run the app to see if it runs OK on your system.
    • The server can be busy, so be patient and wait for the result
  • Study the source code to see how to use the methods and properties of the everettrandom class



Minesadorada Last Edited: 30/08/2019