Source language: Translate to:

Random Number between 2 numbers

General questions about NeoBook

Moderator: Neosoft Support

Random Number between 2 numbers

Postby BRobinsonS » Fri Dec 02, 2016 3:31 pm

How do I use Function Random to generate a Random Number between a Min Number and Max Number?
I know Random generates between 0 and MaxNumber.
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Re: Random Number between 2 numbers

Postby Gaev » Fri Dec 02, 2016 4:06 pm

BRobinsonS:

You can download a pub file from here ... http://www.scriptedlogic.com/zzold/neoFREE3.htm ... it contains (among other ready to use function examples) ...
gk1Random - Returns a random number from within a range specified by minimum and maximum values ; including negative numbers.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Random Number between 2 numbers

Postby BRobinsonS » Fri Dec 02, 2016 4:57 pm

Website is down. Comes up with "server not found" both the link for zzold and main website.
FYI
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Re: Random Number between 2 numbers

Postby Gaev » Fri Dec 02, 2016 6:26 pm

BRobinsonS:

Website is down. Comes up with "server not found" both the link for zzold and main website.

Yes, I got the same message when I posted it ... but when I clicked on the Refresh symbol (Chrome Browser), it took me there (of course, now it goes there first time).

Also, tried link in the Edge Browser ... worked first time.

Try this trick ... if still not successful, send me a PM with your email address ... and I will send the .zip file to you.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Random Number between 2 numbers

Postby Gaev » Fri Dec 02, 2016 7:47 pm

BRobinsonS:

Got your PM ... since you did not specify the desired email address, I sent the file to the email address on your website ... let me know if/when received.

To Others ... can you all try and navigate to http://www.scriptedlogic.com/zzold/neoFREE3.htm (or even my website's home page http://www.scriptedlogic.com/) ... let me know if you get same error message as Brian ... if so, I can then contact my web hosting provider.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Random Number between 2 numbers

Postby HPW » Fri Dec 02, 2016 11:30 pm

Hello,

For the first try with IE11 on Win7 it Fails. Chrome and Firefox worked. Now Ie also work's.

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Random Number between 2 numbers

Postby Gaev » Sat Dec 03, 2016 5:14 am

Hans-Peter:
For the first try with IE11 on Win7 it Fails. Chrome and Firefox worked. Now Ie also work's.

Same kind of experience with me ... my website host renewed my domain name last week ... looks like, after that, the first attempt to access the domain gives the error ... but a re-request (e.g. Refresh/Reload) gets you to my website.

Thanks for the feedback.

Other than Brian, if anyone is having problems, please advise.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Random Number between 2 numbers

Postby virger » Sun Dec 04, 2016 8:13 am

Try this.
Be happy
Code: Select all
NBW Publication Source File
(C)2016 NeoSoft Corp.
Title=Random Range
Author=GdoSan/Dic04-2016
Language=US
NeoBookVer=5,80
ScreenColors=16777216
ScreenWidth=320
ScreenHeight=200
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=0
WindowProps=31
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
ShapeTransColor=536870912
SplashProps=3
CompileType=0
MediaType=0
FilesIncluded=1
FontsIncluded=2
CopyExternalFiles=No
SetupMedia=3
SetupInstDir=C:\MyProgram
SetupTitle=Setup
SetupColors=16711680|0|65535
VersionMajor=1
VersionMinor=0
VersionRelease=0
VersionBuild=0
ReqExLevel=1
CustomFontName=Arial
CustomFontSize=9
CustomFontStyle=0
CustomCharset=1
CacheSize=30
ExtractOp=132
L_OK=OK
L_CANCEL=Cancel
L_YES=Yes
L_NO=No
L_CLOSE=Close
L_ERRORTITLE=Error
L_FINDTITLE=Find
L_FINDPROMPT=Find &What
L_FINDFIRST=&Find First
L_FINDNEXT=Find &Next
L_FINDERROR=Search text not found.
L_PWORDTITLE=Password required
L_PWORDMSG=Before continuing, you must first|enter the correct password.
L_PWORDPROMPT=&Password:
L_PWORDERROR=That's not the right password!
L_MEDIAERROR=In order to play this type of file you must install|the appropriate multimedia hardware and/or|software.
L_INTERNETERROR=Unable to locate Internet Browser software.
L_ABORTFUNCTION=Do you want to cancel this function?
L_EXTRACTERROR=This file could not be extracted and cannot be played.
L_INSTDIRPROMPT=Please enter the drive and directory where you would like this program to be installed. To accept the default drive and directory, simply press Enter.
L_INSTFOLDERPROMPT=Do you wish to create a program folder?
L_INSTRUNPROMPT=Do you want to run
L_INSTDISKPROMPT=Please insert disk #
L_INSTDISKERROR=That's not the correct disk, try again.
L_INSTGENERROR=The installation has terminated.
L_INSTEXITPROMPT=Do you really want to cancel the installation?
L_INSTWINTITLE=Setup
L_INSTPROGTITLE=Extracting Files...
L_SENDEMAIL=Sending Mail...
L_MAILSERVER=Please enter the name of your outgoing email server:
L_COPY=Copy to Clipboard
L_SELECTALL=Select All
L_DONWLOADFILE=Downloading: %s
L_PLEASEWAIT=Please wait...
TrayMenuBegin
MenuName=TrayOpen
MenuText=Open
MenuState=3
MenuKey=0
MenuAction=SetVar "[WindowState]" "Normal"
MenuName=TrayExit
MenuText=Exit
MenuState=3
MenuKey=0
MenuAction=Exit "" ""
MenuEnd
MasterPage
NewPage=New Page
PageStyle=0
PageColor=16777215
PageGradient1=16711680
PageGradient2=255
PageGradientDir=1
WallpaperStyle=0
ObjectType=3
Name=BtExec
X=0
Y=0
W=95
H=54
Anchor=3
Text=[Rnd1]¶[Rnd2]
Align=1
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[Ini]" "25"¶setvar "[Fin]" "250"¶¶..Way #1¶:Again¶Random "[Fin]" "[Rnd1]"¶if "[Rnd1]" "<" "[Ini]"¶    gotoline "Again"¶endif¶¶..Way #2¶math "[Ini]-1" "" "[Rnd2]"¶while "[Rnd2]" "<" "[Ini]"¶    Random "[Fin]" "[Rnd2]"¶endwhile
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ObjectType=3
Name=BtFunction
X=225
Y=0
W=95
H=54
Anchor=4
Text=[Rd1]¶[Rd2]
Align=1
ImageStyle=0
XPTheme=Yes
ObjAction=Call "RandomRange" "25" "250" "[Rd1]" "[Rd2]"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
ObjectType=9
Name=EnFunc
X=0
Y=54
W=320
H=146
Anchor=2
Text=THIS IS THE FUNCTION¶            RandoRange¶¶{NeoBook Function}¶Version=5,80¶Language=NeoBook¶Param=[%_Ini]|Number|Init Value¶Param=[%_Fin]|Number|Finish Value¶Param=[%Rd1]|Variable|Return Random Number¶Param=[%Rd2]|Variable|Return Random Number¶{End}¶..Way #1¶:Again¶Random "[%_Fin]" "[%Rd1]"¶if "[%Rd1]" "<" "[%_Ini]"¶    gotoline "Again"¶endif¶¶..Way #2¶math "[%_Ini]-1" "" "[%Rd2]"¶while "[%Rd2]" "<" "[%_Ini]"¶    Random "[%_Fin]" "[%Rd2]"¶endwhile¶
VarName=[Func]
Align=1
EditMultiLine=Yes
WordWrap=No
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=4
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 523
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: Random Number between 2 numbers

Postby mishem » Mon Dec 05, 2016 11:01 am

Between 1 and 2

Code: Select all
Random "1" "[result]"
SetVar "[result]" "[result]+1"


Between 10 and 100

Code: Select all
Random "90" "[result]"
SetVar "[result]" "[result]+10"


etc.
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm


Return to General NeoBook Discussions

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest

cron