xrpn 2.0 → 2.2

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: b9008be323da1eee11b22525fc7a1ca512a7682a12cbe03f8a7cb0964a5a80d5
4
- data.tar.gz: 2e70c297fd2e010fdb85c7b078ffa79da3bff4b06aab3154de79c083a12430be
3
+ metadata.gz: 5ffb9be2c7f2d0322a75cc674de598d9606afa71b467ac55e65dbef3aae512d7
4
+ data.tar.gz: 7cda743855ab4708bff10c7e12cadadbcd8484605fb2f9526805988f0a06adad
5
5
  SHA512:
6
- metadata.gz: '093cf06d45e2db7c771acde846fe23119aa040bc0a13b4f509bed71371750e0cfbcfee0563cc3e01d72d7f36acb0bbd7dd80521a419ba1749e5cf447ec7a59b3'
7
- data.tar.gz: 8041978530c6fb78fb50a8f63efb662513a588e1b4b047ac620432789b1a364c92426cb7135575e217cac198eb1d0276572ddaec0fefab3d0850a7b3aa9abfe8
6
+ metadata.gz: 5bfe087a054e763f342bbe111a2e2ba9924a37719be5784e494deb6be75d3412d7f2442bdc84156dcc3a9389af69ed7a5cf42e3ba824d875ecb3f0fb04f3a3ec
7
+ data.tar.gz: f9400c2544b32edc95db3c243a6490ce4f1860a6dc9c9379042b51710845c542474053127bfd5c8cefbb2d579eaf58e01f8ed04958240b2c802a3162f0866b3e
data/bin/xrpn CHANGED
@@ -137,7 +137,12 @@ until @p.pc == @p.prg[@p.pg].length do
137
137
  read_xcmd
138
138
  elsif XRPN.method_defined?(l1.downcase) # Or execute the command with either 1 or 2 parts
139
139
  begin
140
- l2 ? ret = @p.send(l1.downcase, l2) : ret = @p.send(l1.downcase)
140
+ if @p.flg["25"] == true
141
+ @p.flg["25"] = false
142
+ unerror { l2 ? ret = @p.send(l1.downcase, l2) : ret = @p.send(l1.downcase) }
143
+ else
144
+ l2 ? ret = @p.send(l1.downcase, l2) : ret = @p.send(l1.downcase)
145
+ end
141
146
  rescue ArgumentError
142
147
  puts "Command needs an argument (#{@line})"
143
148
  exit if $exe
data/xcmd/error ADDED
@@ -0,0 +1,8 @@
1
+ class XRPN
2
+ # Clears Flag 25 (error flag)
3
+ def error
4
+ @p.flg["25"] = false
5
+ end
6
+ end
7
+
8
+ # vim:ft=ruby:
data/xcmd/unerror ADDED
@@ -0,0 +1,8 @@
1
+ class XRPN
2
+ # Sets Flag 25 (error flag)
3
+ def error
4
+ @p.flg["25"] = true
5
+ end
6
+ end
7
+
8
+ # vim:ft=ruby:
data/xlib/_xrpn_version CHANGED
@@ -1,5 +1,5 @@
1
1
  def xrpn_version
2
- puts "XRPN version: 2.0"
2
+ puts "XRPN version: 2.2"
3
3
  puts "RubyGem version: " + Gem.latest_spec_for("xrpn").version.to_s
4
4
  end
5
5
 
data/xlib/debug_mode CHANGED
@@ -9,8 +9,8 @@ def debug_mode
9
9
  @p.prstk
10
10
  @line = @debugprompt.ask(">")
11
11
  unless @line == nil or @line.length == 1
12
- @line = [@line]
13
- @line = hp_41(@line)[0]
12
+ @line = hp_41([@line])[0]
13
+ #@line = rxcmd(@line)
14
14
  end
15
15
  end
16
16
  case @line
@@ -87,6 +87,13 @@ def debug_mode
87
87
  @p.prg[@p.pg].insert(@p.pc + 1, @line.sub(/^\+\+ /, ''))
88
88
  when "--"
89
89
  @p.prg[@p.pg].delete_at(@p.pc)
90
+ when /^:/
91
+ begin
92
+ eval @line[1..-1]
93
+ rescue StandardError => err
94
+ puts err
95
+ end
96
+ break
90
97
  when nil # A simple ENTER
91
98
  @line = "lift"
92
99
  break
data/xlib/numeric CHANGED
@@ -36,12 +36,16 @@ class Numeric
36
36
  s = x.to_i.to_s
37
37
  self < 0 ? m = "-" : m = ""
38
38
  s.sub!(/-/, '')
39
- f = x.frc.to_s[0..(i + 1)].to_f
40
- f = f.to_s.sub(/../, '')
39
+ f = (x.frc * 10 ** i).round.to_i.to_s
40
+ if f.length > i # Fix rounding overflow
41
+ s = (x + 1).to_i.to_s
42
+ f = f[1..-1]
43
+ end
44
+ f = f.to_s
41
45
  i > 0 ? s.sub!(/(\d*\.)(\d{,#{i}}).*/, '\1\2') : s.sub!(/(\d*).*/, '\1')
42
46
  if e.abs >= n # If exponent kicks in
43
47
  s += "." + f.ljust(i, "0")
44
- s += "e"
48
+ s += " e"
45
49
  if ge < 0
46
50
  s += "-"
47
51
  s.sub!(/0\.(\d)/, '\1.')
data/xlib/unerror ADDED
@@ -0,0 +1,6 @@
1
+ def unerror
2
+ begin
3
+ yield
4
+ rescue Exception
5
+ end
6
+ end
data/xrpn.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'xrpn'
3
- s.version = '2.0'
3
+ s.version = '2.2'
4
4
  s.licenses = ['Unlicense']
5
5
  s.summary = "XRPN - The eXtended RPN (Reverse Polish Notation) programming language"
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. New in 2.0: Startup speed 4X. Added command 'cmds'."
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. New in 2.0: Startup speed 4X. Added command 'cmds'. 2.1: Fixed rounding overflow bug. Added : commands to access underlying Ruby. 2.2: Added error exception (flag 25) with commands 'error'=CF 25 and 'unerror'=SF 25"
7
7
 
8
8
  s.authors = ["Geir Isene"]
9
9
  s.email = 'g@isene.com'
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: '2.0'
4
+ version: '2.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-25 00:00:00.000000000 Z
11
+ date: 2024-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
@@ -29,7 +29,9 @@ description: 'A full programming language and environment extending the features
29
29
  a wide range of modern programming tasks as well as running existing HP-41 FOCAL
30
30
  programs directly. XRPN gives modern life to tens of thousands of old HP calculator
31
31
  programs and opens the possibilities to many, many more. New in 2.0: Startup speed
32
- 4X. Added command ''cmds''.'
32
+ 4X. Added command ''cmds''. 2.1: Fixed rounding overflow bug. Added : commands to
33
+ access underlying Ruby. 2.2: Added error exception (flag 25) with commands ''error''=CF
34
+ 25 and ''unerror''=SF 25'
33
35
  email: g@isene.com
34
36
  executables:
35
37
  - xrpn
@@ -128,6 +130,7 @@ files:
128
130
  - xcmd/end
129
131
  - xcmd/eng
130
132
  - xcmd/enter
133
+ - xcmd/error
131
134
  - xcmd/exp
132
135
  - xcmd/expx1
133
136
  - xcmd/fact
@@ -282,6 +285,7 @@ files:
282
285
  - xcmd/tone
283
286
  - xcmd/tonexy
284
287
  - xcmd/tx
288
+ - xcmd/unerror
285
289
  - xcmd/version
286
290
  - xcmd/view
287
291
  - xcmd/writefile
@@ -335,6 +339,7 @@ files:
335
339
  - xlib/setpt
336
340
  - xlib/string
337
341
  - xlib/theme
342
+ - xlib/unerror
338
343
  - xlib/xrpn_class
339
344
  - xrpn.gemspec
340
345
  homepage: https://github.com/isene/XRPN