Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

RPN Syntax Help

Featured Replies

Hello,

I am trying to do something that I would think would be easy if I had any clue to what I was doing.

I want to take the variable COM ACTIVE FREQ TYPE:1, String and change the out put based on the value of the variable.

"ATIS" - ATIS
"UNI" - UNICOM
"CTAF" - CTAF
"GND" - GROUND
"TWR" - TOWER
"CLR" - CLEARANCE DELIVERY
"APPR" - APPROAACH
"DEP" - DEPARTURE
"FSS" - FSS
"AWS" - AWOS

I know it's a very minor issue but I am really trying to learn how to use RPN and I thought this would be a simple project.  Here is the latest version of my RPN script:

(A:COM ACTIVE FREQ TYPE:1, String) 'ATIS' scmp 0 == if{ 'ATIS' } els{ (A:COM ACTIVE FREQ TYPE:1, String) 'UNI' scmp 0 == if{ 'UNICOM' } els{ (A:COM ACTIVE FREQ TYPE:1, String) 'CTAF' scmp 0 == if{ 'CTAF' } els{ (A:COM ACTIVE FREQ TYPE:1, String) 'GND' scmp 0 == if{ 'GROUND' } els{ (A:COM ACTIVE FREQ TYPE:1, String) 'TWR' scmp 0 == if{ 'TOWER' } els{ (A:COM ACTIVE FREQ TYPE:1, String) 'CLR' scmp 0 == if{ 'CLEARANCE DELIVERY' } els{ (A:COM ACTIVE FREQ TYPE:1, String) 'APPR' scmp 0 == if{ 'APPROACH' } els{ (A:COM ACTIVE FREQ TYPE:1, String) 'DEP' scmp 0 == if{ 'DEPARTURE' } els{ (A:COM ACTIVE FREQ TYPE:1, String) 'FSS' scmp 0 == if{ 'FSS' } els{ (A:COM ACTIVE FREQ TYPE:1, String) 'AWS' scmp 0 == if{ 'AWOS' } els{ 'NONE' } } } } } } } } } } }

In the streamdeck the RPN is all on one line and the variable type is S:.

Depending on how I edit the RPN (read make a bigger mess) the button will either be completely blank of more likely it just stays at the same value on the SD button.  The variable is updating in AAO and in SpadNext so I know it is my sub par attempt at RPN.

Can someone point out where I am going wrong?

Thank you,

Joe 

  • Commercial Member
13 hours ago, IrwinMFletcher said:

Can someone point out where I am going wrong?

I don't know about "wrong" (except you are testing scmp backwards 0 = false)- I would just display the value of the AVar...

If I wanted those strings, my solution would be completely different. I would not use S: . Instead, I'd create an Autoscript (Aircraft or even Global) that only runs every second, and that writes the desired string into an LVar - which I then display on the StreamDeck. Thaat way I can test the script properly in the RPN editor and the load on the WebAPI is greatly reduced (the S: code would be sent at least 10 times each secound - I doubt that you need that kind of accuracy for this use case)

My script would look like this, using registers and trusting the stack processing of RPN

(A:COM·ACTIVE·FREQ·TYPE:1,·String)·ss0·
'NONE'·
sl0·'ATIS'·scmp·1·==·if{·'ATIS'·}·
sl0·'UNI'·scmp·1·==·if{·'UNICOM'·}·
sl0·'CTAF'·scmp·1·==·if{·'CTAF'·}·
sl0·'GND'·scmp·1·==·if{·'GROUND'·}·
sl0·'TWR'·scmp·1·==·if{·'TOWER'·}·
sl0·'CLR'·scmp·1·==·if{·'CLEARANCE·DELIVERY'·}·
sl0·'APPR'·scmp·1·==·if{·'APPROAACH'·}·
sl0·'DEP'·scmp·1·==·if{·'DEPARTURE'·}·
sl0·'FSS'·scmp·1·==·if{·'FSS'·}·
sl0·'AWS'·scmp·1·==·if{·'AWOS'·}·
(>L:MyFreqStr,·String)

In more complex use cases and added clarity, I would even resort to JScript or Javascript (same code, different header)

JScript (easier on performance):

(WSH:jscript|AaoEntry)

function AaoEntry(){
    var check = (A:COM ACTIVE FREQ TYPE:1, String);
    var result;
    switch(check){
        case 'ATIS': result = 'ATIS'; break;
        case 'UNI': result = 'UNICOM'; break;
        case 'CTAF': result = 'CTAF'; break;
        case 'GND': result = 'GROUND'; break;
        case 'TWR': result = 'TOWER'; break;
        case 'CLR': result = 'CLEARANCE DELIVERY'; break;
        case 'APPR': result = 'APPROAACH'; break;
        case 'DEP': result = 'DEPARTURE'; break;
        case 'FSS': result = 'FSS'; break;
        case 'AWS': result = 'AWOS'; break;
        default: result = 'NONE'; break;
    }
    (L:MyFreqStrJs, String) = result;
}

Javascript:

(WSH:javascript|AaoEntry)

function AaoEntry(){
    var check = (A:COM ACTIVE FREQ TYPE:1, String);
    var result;
    switch(check){
        case 'ATIS': result = 'ATIS'; break;
        case 'UNI': result = 'UNICOM'; break;
        case 'CTAF': result = 'CTAF'; break;
        case 'GND': result = 'GROUND'; break;
        case 'TWR': result = 'TOWER'; break;
        case 'CLR': result = 'CLEARANCE DELIVERY'; break;
        case 'APPR': result = 'APPROAACH'; break;
        case 'DEP': result = 'DEPARTURE'; break;
        case 'FSS': result = 'FSS'; break;
        case 'AWS': result = 'AWOS'; break;
        default: result = 'NONE'; break;
    }
    (L:MyFreqStrJs, String) = result;
}

 

Edited by Lorby_SI

LORBY-SI

  • Author

Wow!  Thank you for your amazing and detailed help, I greatly appreciate it!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.