xrpn 1.1.13 → 1.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7a19f8e4bef73ee3b6099d50a418d033d129ecbfb808b7e6ca2e058f1036a74
4
- data.tar.gz: 0eda38a9de877944f51b0c7c2407261b60d386edf1a7f7c1e466b9a601bdc01d
3
+ metadata.gz: 997d8363376f12e825a6fef631f9746670abe5a15b87854092fba9f804967b89
4
+ data.tar.gz: 0a177f5c9f3c572aa658b77f3140a424b3ebc81d19a429ffa581ba930066db6e
5
5
  SHA512:
6
- metadata.gz: 0c70decfd7068d4defa8b912cbafa7d30fb2595425f2df8a5a5ebf3ca02f775e1a4acca00cf7710413ba3f06907e11fa534778748da752db24e526788bbd0a9a
7
- data.tar.gz: 118569c5be20f93115c304b9072dfae4e9c6254ab2fdd7ca78c75d5e8231ec580f035f252528734465b335b609a5d9187507b016ffa571fa1766b3f78425caa1
6
+ metadata.gz: 7aee88191d0b2f629833e649e5eddfeb7162f9d91e97cd3a32c8c218d6fbf48feb99e85946bc83727fbbdb96d677b736ceb3b180ee4709f48b84105ea0694e92
7
+ data.tar.gz: fd57147cffdd7993105ca869e9f85793236b9ac4909d5b6f8bd3ffcb1948a5171bf0c91c80de3c1a2c6826f12d1e096493a100e17248ec1e3dbf97165347ad80
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # XRPN
2
+
3
+ ## Introduction
4
+
5
+ XRPN is a stack-based programming language, similar to [Forth](https://en.wikipedia.org/wiki/Forth_(programming_language)), but simpler in nature.
6
+
7
+ XRPN is on-the-fly extensible. Language functions can be upgraded or implemented while programs are running.
8
+
9
+ It runs programs in text files or manually in debug mode (if no text file is supplied or when a program stops).
10
+
11
+ The language is a superset of [FOCAL](https://www.hpmuseum.org/prog/hp41prog.htm), implementing the full set of [HP-41CX calculator](https://www.hpmuseum.org/hp41.htm) commands. It uses Reverse Polish Notation for calculations.
12
+
13
+ XRPN implements indirect addressing, self-modification and features well beyond the FOCAL language.
14
+
15
+ ## Install
16
+
17
+ You need Ruby installed to get XRPN to work.
18
+
19
+ You also need to install the Ruby Gem tty-prompt: `gem install tty-prompt`
20
+
21
+ To install XRPN, simply clone this repository and run the script `INSTALL.sh`. It is only tested on Linux but should work well on Mac OS and BSD systems. If you are on Windows, please tell me if it works in that environment. The install script will put create a symbolic link in your home directory - named ".xrpn" to make it a hidden directory - pointing to the cloned repo. It will also attempt to add a symlink to "~/bin" to make it easy to run XRPN.
22
+
23
+ A Ruby Gemfile will be created soon that will make all this a lot easier.
24
+
25
+ ## Run
26
+
27
+ To run XRPN, make sure the program file ("bin/xrpn") is copied or linked to a directory in your path. If you have "~/bin" in your path, the install scrip has already taken care of this. Simply run the environment via `xrpn` in a terminal to enter the "debug mode" and manually issue commands or do calculations. To run a program, save it in a text file (like "myprogram.txt") and run `xrpn -f myprogram.txt` or `xrpn --file myprogram.txt` to let xrpn execute it. If you want to load a program without running it immediately, you can use the `-l` or `--load` switch like this `xrpn -l myprogram.txt`. If you want to load several program files, just separate the file names with commas (and no spaces) like this `xrpn -l prgm1.txt,prgm2.txt`. You can also save a full XRPN state with the stack, registers, flags, settings and programs in various pages and load that when starting XRPN with the -s switch. You can check a program for possible errors via the -c switch: `xrpn -c myprogram.txt`.
28
+
29
+ The full synopsis goes like this:
30
+ ```
31
+ Usage: xrpn [options]
32
+ -f, --file XRPN-file Specify the file to process
33
+ -l, --load XRPN-file Specify a file to load, but not run
34
+ -s, --state STATE Load a State file
35
+ -c, --check program Program file to check for errors
36
+ -x, --X X-value Set initial value in the X register
37
+ -y, --Y Y-value Set initial value in the Y register
38
+ -z, --Z Z-value Set initial value in the Z register
39
+ -t, --T T-value Set initial value in the T register
40
+ -a, --Alpha Alpha-string Set initial string in Alpha
41
+ -h Display SHORT help text
42
+ --help Display LONG help text
43
+ -v, --version Display the XRPN version number
44
+ ```
45
+
46
+ ## FOCAL and the HP-41 system
47
+
48
+ Since XRPN covers the function set of the HP-41CX calculator, you now have an environment where thousands of HP-41 calculator programs can run. You have at your fingertips programs covering engineering, finance, chemistry and physics to navigation, astronomy, forecasting, statistics and most areas of science and mathematics. With the enhanced features, you can make self-modifying programs, capture web pages, get full regexp capabilities, manipulate files and plenty more.
49
+
50
+ With more than 250 built-in functions, there is a lot to document. The documentation is unfolding in [the wiki page in this repo](https://github.com/isene/xrpn/wiki/XRPN-Documentation).
51
+
52
+ Note that I have not yet implemented the clock, the alarm and stopwatch functionality of the HP-41CX as I can't yet see much benefit to that. The functions TIME, DATE, DATE+, DDAYS, DOW, HR, HMS, HMS+, HMS- are implemented.
53
+
54
+ ## Example program
55
+
56
+ To give you a taste of XRPN, consider this program:
57
+
58
+ ```
59
+ LBL "HELLO"
60
+ "Input your name. Enclose your name in double-quotes and press Enter."
61
+ PROMPT
62
+ ASTO 00
63
+ "Hello, "
64
+ ARCL 00
65
+ ADV
66
+ AVIEW
67
+ ADV
68
+ 13
69
+ 8
70
+ *
71
+ 100
72
+ X<>Y
73
+ X>Y?
74
+ "13 * 8 is greater than 100"
75
+ AVIEW
76
+ END
77
+ ```
78
+
79
+ ## Documentation
80
+
81
+ ...is all in [the wiki page in this repo](https://github.com/isene/xrpn/wiki/XRPN-Documentation).
82
+
83
+
84
+ ## Note
85
+
86
+ Thanks to the HP Calculator community, the Astrophysical Institute in Oslo and to my lovely Siv for inspirations.
87
+
88
+ Any and all feedback is welcome. Send me an e-mail at `g@isene.com`.
data/bin/xrpn CHANGED
@@ -9,8 +9,27 @@ require 'bigdecimal'
9
9
  require 'open-uri'
10
10
  require 'json'
11
11
  require 'tty-prompt'
12
+ begin
13
+ require 'xrpn'
14
+ $gem = Gem.latest_spec_for("xrpn").gem_dir
15
+ rescue LoadError
16
+ end
17
+
18
+ # ENSURE DIRs
19
+ Dir.mkdir(Dir.home + "/.xrpn") unless File.exist?(Dir.home + "/.xrpn")
20
+ ["data", "extra", "print", "xcmd", "xlib"].each do |d|
21
+ Dir.mkdir(Dir.home + "/.xrpn/" + d) unless File.exist?(Dir.home + "/.xrpn/" + d)
22
+ end
23
+
24
+ # READ LIBRARY AND COMMANDS
25
+ Dir[$gem+"/xlib/*"].each { |file| load file } if $gem # Read xlib directory from the Gem
26
+ Dir[Dir.home+"/.xrpn/xlib/*"].each { |file| load file } # Read xlib directory from home dir
27
+ read_xcmd # Read XRPN commands (both from Gem and home dir)
12
28
 
13
- # Handle the command line options
29
+ # INITIALIZE VARIABLES
30
+ @x, @y, @z, @t, @a = 0, 0, 0, 0, ""
31
+
32
+ # HANDLE COMMAND LINE OPTIONS
14
33
  options = {}
15
34
  optparse = OptionParser.new do |opts|
16
35
  # Set a banner, displayed at the top of the help screen.
@@ -32,23 +51,16 @@ optparse = OptionParser.new do |opts|
32
51
  end
33
52
  optparse.parse!
34
53
 
35
- # ENSURE DIRs
36
- Dir.mkdir(Dir.home + "/.xrpn") unless File.exist?(Dir.home + "/.xrpn")
37
- ["data", "extra", "print", "xcmd", "xlib"].each do |d|
38
- Dir.mkdir(Dir.home + "/.xrpn/" + d) unless File.exist?(Dir.home + "/.xrpn/" + d)
39
- end
40
-
41
- # INITIALIZE
42
- $theme = "dark"
43
- @x, @y, @z, @t, @a = 0, 0, 0, 0, ""
44
- begin
45
- require 'xrpn'
46
- rescue LoadError
47
- end
48
- Dir[Dir.home+"/.xrpn/xlib/*"].each { |file| load file } # Read libraries
49
- read_cmd # Read XRPN commands
54
+ # INITIALIZE CLASS
50
55
  @p = XRPN.new($rfile)
56
+
57
+ # READ USER CONF
58
+ load(Dir.home+'/.xrpn/conf') if File.exist?(Dir.home+'/.xrpn/conf')
59
+
60
+ # SET VARIABLES FROM OPTPARSE
51
61
  @p.x, @p.y, @p.z, @p.t, @p.a = @x, @y, @z, @t, @a
62
+
63
+ # INITIALIZE XRPN PROGRAM
52
64
  @p.prg[@p.pg] = ["LBL \"XRPN\"", "END"] unless $rfile # Put dummy program in page 0 if no file to run
53
65
  @p.prg[@p.pg] = hp_41(@p.prg[@p.pg]) if $rfile # Substitute HP-41 commands with XRPN commands
54
66
  if $lfile # Read file to load but not run if -l switch is used
@@ -59,7 +71,8 @@ if $lfile # Read file to load but
59
71
  end
60
72
  read_state($sfile) if $sfile # Read state file in ~.xrpn/ if -s switch is used
61
73
  $debug = true if $lfile or $sfile # Do not run loaded program or program in state file
62
- load(Dir.home+'/.xrpn/conf') if File.exist?(Dir.home+'/.xrpn/conf') # Read config file
74
+
75
+ # THEME
63
76
  theme($theme)
64
77
  load(Dir.home+'/.xrpn/theme') if File.exist?(Dir.home+'/.xrpn/theme') # Override theme if user theme file exists
65
78
 
data/conf ADDED
@@ -0,0 +1,13 @@
1
+ @p.x = 0.0
2
+ @p.y = 0.0
3
+ @p.z = 0.0
4
+ @p.t = 0.0
5
+ @p.l = 0.0
6
+ @p.a = ""
7
+ @p.i = 4
8
+ @p.s = 9
9
+ @p.srg = 11
10
+ @p.reg = {}
11
+ @p.flg = {"28"=>false, "29"=>true, "31"=>false, "44"=>false, "22"=>false, "23"=>false}
12
+ @p.prg = [["LBL \"XRPN\"", "END"]]
13
+ $theme = "dark"
data/theme_example ADDED
@@ -0,0 +1,10 @@
1
+ $colors = {
2
+ "X" => 255,
3
+ "Y" => 246,
4
+ "Z" => 243,
5
+ "T" => 240,
6
+ "L" => 130,
7
+ "A" => 39
8
+ }
9
+
10
+ # vim:ft=ruby:
data/xlib/_xrpn_version CHANGED
@@ -1,5 +1,5 @@
1
1
  def xrpn_version
2
- puts "XRPN version: 0.95"
2
+ puts "XRPN version: 0.98"
3
3
  end
4
4
 
5
5
  # vim:ft=ruby:
@@ -1,5 +1,13 @@
1
- def read_cmd
1
+ def read_xcmd
2
2
  $cmd = []
3
+ if $gem
4
+ Dir[$gem+"/xcmd/*"].each do |file|
5
+ load file
6
+ l = IO.readlines(file)[1]
7
+ c = l.sub(/\s*def (\S+).*/, '\1').chomp
8
+ $cmd.push(c)
9
+ end
10
+ end
3
11
  Dir[Dir.home+"/.xrpn/xcmd/*"].each do |file|
4
12
  load file
5
13
  l = IO.readlines(file)[1]
data/xlib/theme CHANGED
@@ -1,4 +1,4 @@
1
- def theme(t="dark")
1
+ def theme(t=$theme)
2
2
  if t == "light"
3
3
  $colors = {
4
4
  "X" => 232,
@@ -19,5 +19,5 @@ def theme(t="dark")
19
19
  }
20
20
  end
21
21
  end
22
-
22
+
23
23
  # vim:ft=ruby:
data/xrpn.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'xrpn'
3
- s.version = '1.1.13'
3
+ s.version = '1.1.14'
4
4
  s.licenses = ['Unlicense']
5
5
  s.summary = "XRPN - The eXtended RPN (Reverse Polish Notation) programming language"
6
6
  s.description = "A full programming language and environment extending the features of the venerable HP calculator programmable calculators. With XRPN you can accomplish a wide range of modern programming tasks as well as running existing HP-41 FOCAL programs directly. XRPN gives modern life to tens of thousands of old HP calculator programs and opens the possibilities to many, many more."
@@ -11,6 +11,6 @@ Gem::Specification.new do |s|
11
11
 
12
12
  s.add_runtime_dependency 'tty-prompt', '~> 0.23'
13
13
 
14
- s.files = ["bin/xrpn", "lib/xrpn.rb", "xrpn.gemspec"] + Dir.glob("xcmd/*") + Dir.glob("xlib/*")
14
+ s.files = ["bin/xrpn", "conf", "theme_example", "README.md", "xrpn.gemspec"] + Dir.glob("xcmd/*") + Dir.glob("xlib/*")
15
15
  s.executables << 'xrpn'
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xrpn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.13
4
+ version: 1.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-15 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
@@ -35,8 +35,10 @@ executables:
35
35
  extensions: []
36
36
  extra_rdoc_files: []
37
37
  files:
38
+ - README.md
38
39
  - bin/xrpn
39
- - lib/xrpn.rb
40
+ - conf
41
+ - theme_example
40
42
  - xcmd/abs
41
43
  - xcmd/acos
42
44
  - xcmd/adate
@@ -313,8 +315,8 @@ files:
313
315
  - xlib/locate_prg
314
316
  - xlib/numeric
315
317
  - xlib/numformat
316
- - xlib/read_cmd
317
318
  - xlib/read_state
319
+ - xlib/read_xcmd
318
320
  - xlib/save_state
319
321
  - xlib/save_xm
320
322
  - xlib/setpt
data/lib/xrpn.rb DELETED
@@ -1,2 +0,0 @@
1
- Dir[__dir__ + "/../xlib/*"].each { |file| load file }
2
- Dir[__dir__ + "/../xcmd/*"].each { |file| load file }