hb_R - Petewg/harbour-core GitHub Wiki

🔙 Home

  • hb_Rand32() nRandomInt
    returns a randomly grabbed integer between 0 and 0xFFFFFFFF inclusive. - (0xFFFFFFFF = 4.294.967.295)

  • hb_randInt([<x> [, <y>]]) nRandomInt
    returns an integer random number which, if no parameter argument passed, is 0 or 1, or between 0 and <x> or between <x> and <y>, if relevant params passed.

  • hb_randNum([<x> [, <y>]]) nRandom
    returns a floating point random number which is between 0 and 1, when no parameter argument passed, or between 0 and <x> or between <x> and <y> when one or two arguments used respectively.

    NOTE: As we can see looking into the sources, the above two functions use ARC4 based PRNG (Pseudo Random Number Generator) to generate randomness, while the two below use a Harbour own algorithm (time & stack based). Now, which one of the two methods is more effective (i.e. which one achieves the better randomness) remains to be proved during real-life usage. Either way, the computational methods in generation of "true" random numbers is a quite long-lasting (and debatable) story.

  • hb_Random([<x> [, <y>]]) nRandomReal
    returns a (floating point) number <n> so that: 0 <= n < 1 (if no params passed), or 0 <= n < x (if only <x> passed), or x <= n < y (if <x>, <y> passed). Note: value of <y> (if any), is NOT included in values returned.

  • hb_RandomInt([<x> [, <y>]]) nRandomInt
    returns an integer number <n> so that: 1 <= n <= x (when only x passed), or x <= n <= y (when x and y passed), or 0s and 1s almost evenly distributed (when no params passed). Note: values of x,y (if any), are INCLUDED in values returned.

  • hb_RandomIntMax() 2147483645

  • hb_RandomSeed( <nSeed> ) NIL
    seeds (i.e. initializes) the random number generator used by hb_Rand* family functions. It may be invoked once, before calling a 'randomizer' function. If the parameter nSeed is 0, then first call to hb_Random() or hb_RandomInt() activates initialization which generates new seed using current time in milliseconds and HVM stack address (for MT modes). If repeatable results needed from hb_Random() and hb_RandomInt() then the seed should be initialized for each thread with some fixed value i.e. hb_RandomSeed( 123456789 )

  • hb_RandStr( <nChars> ) cRandChars
    returns a string of <nChars> random characters.


  • hb_RAScan( <aArray>, <uValue> [, <nStart>, <nCount>, <lExact>] ) nPosition
    Scans (right to left) for <uValue> into <aArray> and returns <nPosition> of found or <zero> if nothing found. It's same to hb_AScan(...) but it starts scanning reversely, from right to left (or bottom to top.)

  • hb_RAt( <cSearchFor>, <cIntoString>, [<nStart>], [<nEnd>] ) nPosition
    It finds the last (rightmost) match of <cSearchFor> into <cIntoString> in the range <nStart>-<nEnd>. IOW, the search is performed from the right to left.

  • hb_rddInfo( <nConstandIndex>, [<xNewSetting>], [<xcRDDName>], [<nConnection>] ) xCurrentSetting
    retrieves and optionally sets configuration settings for RDD used.
    For a complete list of settings refer to dbinfo.ch header file. Not all settings are supported by all RDDs.
    Returns the current setting, i.e. the value which is / was current, before the new setting (if any) applied.

  • hb_releaseCPU() NIL
    releases a CPU time slice, that is, causes current thread (or application) to relinquish the remainder of its time slice, becoming un-runnable (stop running) for about 20 milliseconds (32 on OS/2).

  • hb_Run( <cCommand> ) nErrorLevel
    returns the exit-code (or OS errorlevel) that results by executing (running) of <cCommand>.
    see also: hb_ProcessRun()

🔙 Home

⚠️ **GitHub.com Fallback** ⚠️