Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 25 Nov 2017, 00:18
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Compiling
fig 2.9 compiler / help docs / examples
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [19 Posts]   Goto page: Previous 1, 2
Author Message
ASD

Joined: 22 Mar 2016
Posts: 99

PostPosted: Sat 02 Jul 2016, 05:15    Post subject:  

Hi learnhow2code,

Thank you very much for your post immediately above. I am impressed by your program code and your example result for n = 1,000,000.
I have not yet understood how to run it myself and will come back again later.

Regarding your questions, GWBasic v 3.20 is below with the usual fake "dot g z" extension needing deletion by renaming.

As to
Quote:
hey, would you mind doing those with the save"filename",a option?


I'm not very computer language literate so I may not have understood you, but if you wanted to change say, line 30 of "1.BAS" and then save it with a new name you would load 1.BAS by pressing F3 then type 1 and Return
Then instead of using F2 to run 1.BAS you would use F1 to list the program
Then you type edit 30 then make the changes to line 30
Then drop to next line and type save"theNewFileName" (including the inverted commas) or else use F4 to bring up save"

Is there anything more that you would like me to do?

PS My desktop computer is quite fast, but it takes 28 secs to run 1.BAS at its MAX n = 39,602 (35 secs to also show the 4,164 primes).
GWBASIC.EXE.gz
Description 
gz

 Download 
Filename  GWBASIC.EXE.gz 
Filesize  77.02 KB 
Downloaded  79 Time(s) 
Back to top
View user's profile Send private message 
learnhow2code

Joined: 12 Jun 2016
Posts: 1015

PostPosted: Sat 02 Jul 2016, 05:45    Post subject:  

ASD wrote:

I have not yet understood how to run it myself and will come back again later.


since you go back to gw-basic (and you run dosbox) i will assume you have dos knowledge i can put to use.

Code:
REM the dos version of it:
c:
cd \
cd gwbasic
cat > HLLOWRLD.BAS
10 COLOR 14
20 PRINT HELLO
[CTRL]-[C] ...on your keyboard

gwbasic HLLOWRLD.BAS
REM or
qbasic /run HLLOWRLD.BAS
REM or
basic HLLOWRLD.BAS
REM or
basica HLLOWRLD.BAS



Code:
# the puppy version of it:
cd /
cd root
cat > helloworld.fig
NOW COLORTEXT 14
NOW "HELLO" PRINT
[CTRL]-[D] ...on your keyboard

fig29 helloworld.fig
./helloworld.fig.py



one of the things fig is used for in an educational setting is introducing people to the term.

however, im sure its possible for someone to make a gui for compiling with fig.

i could make a gui with compiling with fig, and im not against someone doing it (floss, public domain, after all.)

but i wouldnt personally, because the gui will ultimately change and the instructions for it will change. but the command line version i offer works the same (until someone renames the file of course.)

packages are a new thing. normally people can name the program "fig" or whatever they like to name it. in this case its fig29, but you can fig[tab-complete]

Quote:

PS My desktop computer is quite fast, but it takes 28 secs to run 1.BAS at its MAX n = 39,602 (35 secs to also show the 4,164 primes).


well lets see how long a million takes on an "old, underpowered" 32bit machine without dosbox running:

Code:
$ time ./1.fig.py # this will include the time it takes to paste in 1000000

INPUT 1 to display all primes on screen; to omit them ENTER

input n for number of primes < n [n MUST BE EVEN]
1000000
WAIT FOR BEEP

78029

The number of primes not exceeding 1000000 is 78498 v. expected 78029 and the largest prime is 999983
The sum of the natural logs of the primes up to 999983 is 998484.175026 and the percentage is 99.8501149545

real   0m26.505s
user   0m24.232s
sys   0m0.120s
$


now is a good time to find and open the term. in tahr its in the puppy menu under Utilities > URXVT (not the urxvt settings manager-- the one at the bottom of the Utilities menu.)
Back to top
View user's profile Send private message 
ASD

Joined: 22 Mar 2016
Posts: 99

PostPosted: Tue 05 Jul 2016, 04:41    Post subject:  

I am well pleased to report that 1.fig is now working perfectly here, thanks to huge support from learnhow2code [LH2C] in our recent exchanges by PM.

We are both using tahr-6.0.5 which has the needed Python app inbuilt and we are using fig-2.9.pet [written by LH2C and downloadable from above].

It had been working all the time for LH2C, but I encountered two problems; one was unusual and hard for LH2C to solve without access to my m/c.

My tough problem needed me to reset my urxvt colours to white text on a dark background. Alternatively, LH2C recommended I try using rxvt.

The simpler hitch was “permission denied”, but after running ‘fig29 1.fig’ in my terminal the super-fast output enabled me to run ‘python 1.fig.py’.

1.fig also from LH2C (mirrors 1.BAS - a program written c. 30 years ago in GWBasic to calculate prime numbers and the sum of their natural logs).

I have a fastish 8-year-old desktop, but whereas 1.BAS takes 35 secs for a maximum input of n=39,602; the Python compiled 1.fig is instantaneous.

The max tried using 1.fig.py is 100,000,000 (per screen shot) and without listing the primes it took 8 minutes (ignoring say, 5 or so secs for input).

The bottom line of the screen shot was inserted after the after the output by using the keyboard up-arrow to insert the original command to easily enable a re-run.

LH2C says his fig29 pet is a general app; however a similar test using NewPGen 2.82 ran 20 times faster using two sieve runs of 12 secs each).

NewPGen 2.82 is probably ONE of THE specialised prime number apps. Both found 5,761,455 primes < 100,000,000; 1fig.py summed logs too.

1.fig.gz can be downloaded here; rename it losing the fake (dot .gz) then put it in /root then open your terminal and type ‘fig29 1.fig’ then ‘1.fig.py’ or ‘python 1.fig.py’ in the unlikely event you have a “permission denied” hitch. You can use ‘time 1.fig29.py’ if you want the elapsed run time.

You don’t have to use tahr-6.0.5 [though the Pup chosen must have Python] but if you do you might like to investigate pupsaveconfig-2.2.6 in its PPM (though it’s always easy to delete all the files mentioned in this thread).

You don’t have to put ‘1.fig’ or ‘1.fig.py' in /root’ Personally I use the backtick (below Esc on my keyboard) to open my terminal in the current directory.

If you wish you can right click on 1.fig to view its code (or even, perhaps after more reading, edit it to make this coding example do what you want).

My view is that ‘runyourprog.fig.py’ is clever, useful and educational and learnhow2code has earned the accolade “A job well done"
1.fig.gz
Description 
gz

 Download 
Filename  1.fig.gz 
Filesize  2.05 KB 
Downloaded  75 Time(s) 
screen_shot.png
 Description   
 Filesize   25.63 KB
 Viewed   119 Time(s)

screen_shot.png

Back to top
View user's profile Send private message 
learnhow2code

Joined: 12 Jun 2016
Posts: 1015

PostPosted: Tue 05 Jul 2016, 06:08    Post subject:  

Quote:
My tough problem needed me to reset my urxvt colours to white text on a dark background. Alternatively, LH2C recommended I try using rxvt.


yes, the main problem (from what i can tell) is that the term in tahr is light-colored, and 1.fig was written for a darker term.

avoiding the color commands in fig (or trying it in a lighter colored rxvt) would have saved us a lot of trouble for this demo.


Quote:
The simpler hitch was “permission denied”, but after running ‘fig29 1.fig’ in my terminal the super-fast output enabled me to run ‘python 1.fig.py’.


usually this should not be an issue.

while testing a compiled 1.fig.py the +x permission didnt make it through the file transfer over pm.

usually this +x permission is added to the .py output automatically.

as this is usually automatic this is a detail for script writers and experienced coders-- but also anyone sharing an un-tgz'd script in any language over pm.


Quote:
LH2C says his fig29 pet is a general app; however a similar test using NewPGen 2.82 ran 20 times faster using two sieve runs of 12 secs each).


yes, you should get much faster times with a real compiled language. fig is not designed for pure calculation speed, and the 1.fig demo was not optimized.

fig is a general purpose programming tool ; some things will be fast enough, others will be slow compared to something that is say, c-based instead of python-based.


Quote:
My view is that ‘runyourprog.fig.py’ is clever, useful and educational and learnhow2code has earned the accolade “A job well done"


thanks very much Smile its a pleasure to work with you.

on a related note: here is the thing im working on using fig right now: http://www.murga-linux.com/puppy/viewtopic.php?t=107394
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 2 [19 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Compiling
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0507s ][ Queries: 12 (0.0062s) ][ GZIP on ]