B4A Library RPN Calculator

A simple "shortcut" wrap for this Github project whenever you want to have quick access to a RPN (Reverse Polish Notation) calculator from within your app. It does not have a lot of mathematical functions (eg scientific) - just the basics although it supports the RPN stack. Best you understand RPN notation in order to use it.

Posting B4A sample project, Java Code, B4A library files.

Download and extract RnpRes.zip and copy the extracted RpnRes folder with its contents to be on the same folder level as that of the /Files and /Objects folders of the B4A project.

Download and extract resource.zip and copy the extracted resource folder with its contents to be on the same folder level as that of the /Files and /Objects folders of the B4A project.

I have done something similar here but hard coded in B4A and with lots more of functionality
https://www.b4x.com/android/forum/threads/calculator-rpn-calculator.44475/

1.png


2.png


Take note of the B4A manifest file:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
AddApplicationText(<activity
            android:name="com.ath0.rpn.Main"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.RPN" >

        </activity>)

Sample code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aRPN
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\resource
#AdditionalRes: ..\RpnRes


'#AdditionalRes: C:\Users\----------2\Documents\Basic 4 Android\JOHAN APPS\JHS LIBS\resource\b4a_appcompat, de.amberhome.objects.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\Android\extras\google\google-play-services\libproject\google-play-services_lib\res, com.google.android.gms
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design

'#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
'#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama

'#Extends: android.support.v7.app.AppCompatActivity

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 

 
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Dim rpn As RPN
 
 
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
 
    Activity.LoadLayout("main")
    rpn.Initialize("")
 

 
End Sub

Sub Activity_Resume
 

 
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
 
rpn.startRPN

End Sub
 

Attachments

  • resource.zip
    423 bytes · Views: 311
  • b4aRPN.zip
    8.4 KB · Views: 329
  • RPNLibFiles.zip
    19.1 KB · Views: 322
  • TheJavaCode.zip
    14.3 KB · Views: 312
  • RpnRes.zip
    71.7 KB · Views: 303
Last edited:
Top