Recently Updated Posts

krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Last Edit: Aug 16, 2013 6:19:18 GMT -5 by krzysztof
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 15, 2013 5:14:43 GMT -5

StefanPendl Avatar
krzysztof Avatar
Increasing the size is limited because of error message "Your program has exceeded the allowable execution time".


You can overcome this by increasing the session timeout limit in the preferences.


Does not work in downloadable free version of RunBASIC.
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 14, 2013 4:41:21 GMT -5

Thank You very much for Your help. In fact, I'm blind ;) and I need to buy stronger glasses or stop to sit on the programs at night. In the helps of JustBASIC there is even sample program that calculates the time of counting of such loop!
Because of the reasonable period of time to calculate the loop, I had to reduce the number of iterations by a factor of 10. Estimated results are listed below, but be aware that FreeBASIC and PureBASIC are compilers and therefore perform the cycle much faster!

For i = 1 To 10000000 (reduced value)

Time:

Run BASIC 6.3 - 8 sec
Just BASIC 49 - 53.5 sec
Liberty BASIC about 49 sec
Pure BASIC pure 0.09 - 0.17 sec
Free BASIC 0.16 - 0.23 sec

Note that speed of RunBASIC is much higher than Just/Liberty BASIC.
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

Post by StefanPendl on Aug 13, 2013 23:41:51 GMT -5

krzysztof Avatar
I would like to do the same for RunBASIC, but I think there is no suitable command? I checked helps, but it was not there.


See time$("seconds") in the functions section of the help file.

In addition the help file on the Run BASIC web site is the one for the Run BASIC web site, which uses an older version of Run BASIC.
[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 13, 2013 16:46:15 GMT -5

In other dialects of BASIC there are commands counting the number of seconds since specific time in the past. Below there are two examples of programs computing time of 200000000 iterations of a floating point operation. For PureBasic this time is about 1.8 sec, and for FreeBASIC about 3.3 sec on ​​my computer. I would like to do the same for RunBASIC, but I think there is no suitable command? I checked helps, but it was not there.
;PureBasic

OpenConsole()
x.d
y.d
ElapsedTime.d
i.i

StartTime = ElapsedMilliseconds()

x = 1
y = 1.00000001

For i = 1 To 200000000
x = x * y
Next i

ElapsedTime = ElapsedMilliseconds() - StartTime
Print(Str(ElapsedTime))

Repeat

Until Inkey() <> ""
CloseConsole()
'FreeBASIC

Dim As Double x, y, StartTime
Dim As Integer i

StartTime = Timer

x = 1
y = 1.00000001

For i = 1 To 200000000
x = x * y
Next i

Print Timer - StartTime

Sleep
Last Edit: Aug 13, 2013 16:52:07 GMT -5 by krzysztof
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 13, 2013 10:05:19 GMT -5

  • I compared the speed of my programs for simple mathematical calculations, running under RunBASIC and JustBASIC. Although RunBASIC has limitations, for example in an amount of generated numbers (eg prime numbers), then the speed of its operation is much greater than JustBASIC, and comparable to the speed of the analogous calculations carried out in FreeBASIC.
  • Another thing is probably simpler syntax of graphics programs written for RunBASIC than a JustBASIC.
  • Third, the differences in the operation of GOTO to break the loop. This break works fine in the similar programs running in RunBASIC and FreeBASIC, but does not work in JustBASIC. Weird, isn't it?
See the following code with mentioned GOTO in line if p / q = int (p / q) then goto [nextp] in the program for calculation of prime numbers.
input "Enter the limit "; n
print "Prime numbers: "

for p = 2 to n
'or sqr(p) for faster calculations
for q = 2 to p - 1
'or (p mod q = 0)
if p / q = int(p / q) then goto [nextp]
next q

print p; " ";
[nextp]
next p

end
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 13, 2013 6:03:23 GMT -5

I've always loved fractals. It is very interesting and exciting thing. On the site paulbourke.net/fractals there are many examples of different fractals with simple programs written in classic BASIC dialect. They can be easily converted into a RunBASIC. There is no sense to give too many examples, as they use rather simple, similar codes. Two examples are:
'Peter de Jong Attractor
'http://paulbourke.net/fractals/peterdejong/
graphic #deJong, 500, 500

x = 0
y = 0

for i = 1 to 100000
x1 = sin(1.4 * y) - cos(-2.3 * x)
y = sin(2.4 * x) - cos(-2.1 * y)
x = x1
#deJong set(120 * x + 250, 120 * y + 250)
next i

render #deJong
end
and
'Gingerbread man
'http://paulbourke.net/fractals/gingerbread/
graphic #Ginger, 500, 500

x = -0.1
y = 0

for i = 1 to 100000
x1 = 1 - y + abs(x)
y1 = x
x = x1
y = y1
#Ginger set(40 * x + 150, 40 * y + 150)
next i

render #Ginger
end
krzysztof
New Member
*

krzysztof Avatar

Posts: 45

krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 13, 2013 5:50:25 GMT -5

Thank both of You for the tips. The first concerns a completely different way of generating the fractal, but it is interesting too. Second, that the ifs system, just like in my program. I have read the code and I see that I can improve my one:
'Sierpinski triangle IFS method

graphic #Sierpinski, 500, 500

read j
p1 = 0

for i = 1 to j
read a, b, c, d, e, f, p0
a(i) = a
b(i) = b
c(i) = c
d(i) = d
e(i) = e
f(i) = f
p1 = p1 + p0
p(i) = p1
next i

for w = 1 to 500000
p2 = rnd(1)

if p2 <= p(1) then k = 1
if p2 > p(1) and p2 <= p(2) then k = 2
if p2 > p(2) and p2 <= p(3) then k = 3

'One can use instead:
'if p1 <= p(3) then k = 3
'if p1 <= p(2) then k = 2
'if p1 <= p(1) then k = 1

x1 = a(k) * x + b(k) * y + e(k)
y = c(k) * x + d(k) * y + f(k)
x = x1
#Sierpinski set(250 * x, 250 * y)
next w

render #Sierpinski

end

data 3
data 0.5, 0, 0, 0.5, 0.0, 0.0, 0.33
data 0.5, 0, 0, 0.5, 1.0, 0.0, 0.33
data 0.5, 0, 0, 0.5, 0.5, 0.5, 0.34
Last Edit: Aug 22, 2013 10:17:39 GMT -5 by krzysztof
tenochtitlanuk
New Member
*

tenochtitlanuk Avatar

Posts: 25

meerkat
Senior Member
****

meerkat Avatar

Posts: 250

krzysztof
New Member
*

krzysztof Avatar

Posts: 45

Post by krzysztof on Aug 12, 2013 3:14:54 GMT -5

Example of program that can draw the Sierpinski triangle using iterated function systems (en.wikipedia.org/wiki/Iterated_function_system). I'm not entirely happy with the used subroutines and arrays, maybe they can be improved?
'Sierpinski triangle, IFS
graphic #Sierpinski, 500, 500

x = 0
y = 0

for i = 1 to 100000
j = rnd(1)
if j <= 0.33 then call array1
if j > 0.33 and j <= 0.66 then call array2
if j > 0.66 then call array3

x1 = array(1) * x + array(2) * y + array(5)
y = array(3) * x + array(4) * y + array(6)
x = x1

#Sierpinski set(250 * x, 250 * y)
next i

render #Sierpinski

end

sub array1
array(1) = 0.5
array(2) = 0
array(3) = 0
array(4) = 0.5
array(5) = 0
array(6) = 0
end sub

sub array2
array(1) = 0.5
array(2) = 0
array(3) = 0
array(4) = 0.5
array(5) = 1
array(6) = 0
end sub

sub array3
array(1) = 0.5
array(2) = 0
array(3) = 0
array(4) = 0.5
array(5) = 0.5
array(6) = 0.5
end sub
neal
Full Member
***

neal Avatar

Posts: 104

Post by neal on Aug 11, 2013 21:16:16 GMT -5

On linux you can get headless support using Xvfb (it should be available for any linux version).

Start Xvfb first, set the DISPLAY environment variable and then start run basic as usual - no X display needed


Xvfb :1
DISPLAY=:1
export DISPLAY
rbp rb.im


I've been running my run basic websites this way for years.

This is my startup script for runbasic (Debian linux):


#! /bin/sh
#

### BEGIN INIT INFO
# Provides: runbasic
# Required-Start: $local_fs $named $network $time
# Required-Stop: $local_fs $named $network
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop the Run BASIC Personal server
### END INIT INFO


PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
XVFB=/usr/bin/Xvfb
RBDIR=/home/runbasic/rb101
RBEXE=$RBDIR/rbp
RBUID=runbasic
NAME=runbasic
DESC="Run BASIC Personal Server"
export DISPLAY=:1

test -x $XVFB || exit 0
test -x $RBEXE || exit 0

case "1ドル" in
start)
echo "Starting $NAME - $DESC"
start-stop-daemon --background --start --exec $XVFB -- $DISPLAY
ulimit -H -n 10000
start-stop-daemon --background --chuid $RBUID --chdir $RBDIR --start --exec $RBEXE -- rb.im
;;
stop)
echo "Stopping $NAME - $DESC"
start-stop-daemon --stop --user runbasic --exec $RBEXE
start-stop-daemon --stop --user root --exec $XVFB
;;
restart)
0ドル stop
sleep 5
0ドル start
;;
*)
echo "Usage: $N {start|stop|restart}" >&2
exit 1
;;
esac

exit 0