Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

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.

Convert to range of numbers

Featured Replies

Hello, I'm working on a script to convert a list of numbers into a user friendly range of numbers.

For example, here's a list of numbers

21
22
23
24
25
31
32
33
34
35

I would like it to set a field with:

21-25,31-35

I have a script that can easily deal with the first half, but I am struggling to make it work with multiple ranges.

Set Variable [ $counter; Value:1 ]
Set Variable [ $first; Value:GetValue ( range reverse::test unit numbers; $counter)]
Set Variable [ $last; Value:$first ]
Loop
Set Variable [ $last; Value:$last+1 ]
Set Variable [ $counter; Value:$counter + 1 ]
Exit Loop If [ $last ≠ GetValue ( range reverse::test unit numbers; $counter) ]
End Loop
Set Field [ range reverse::range result; $first & "-" & $last-1 ]

Thank you for the help

I wrote a custom function that does this (and a bit more).

Scripting it is slightly easier - try:

Set Variable [ $values; Value:YourTable::ListOfValues ] 
Loop
   Set Variable [ $i; Value:$i + 1 ]
   Exit Loop If [ $i > ValueCount ( $values ) ]
   Set Variable [ $thisValue; Value:GetValue ( $values ; $i ) ] 
   # TEST AGAINST PREVIOUS VALUE
   If [ GetValue ( $values ; $i - 1 ) ≠ $thisValue - 1
      # START A NEW RANGE
      Set Variable [ $startValue; Value:$thisValue ] 
   End If
   # TEST AGAINST NEXT VALUE
   If [ $thisValue + 1 ≠ GetValue ( $values ; $i + 1 ) ]
      # END THIS RANGE
      Set Variable [ $result; Value:List ( $result; If ( $startValue = $thisValue ; $thisValue ; $startValue & "-" & $thisValue ) )]
   End If 
End Loop
Set Field [ YourTable::Result; Substitute ( $result ; ¶ ; ", " ) ] 
Commit Records/Requests

 

  • Author

Perfection again, comment

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

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.