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.

C++ code to script

Featured Replies

How "translateble" is the following C++ code into a script? Is it possible to make a script that functions this way at all?

int Ob(int n)

{

int temp;

if (n == 0) {

return(0); }

else {

temp = rand() % 6 + 1;

if (temp == 6) {

temp = Ob(2); }

return (temp + Ob(n - 1));

}

}

Many thanks in advance!

Why not just explain what it is you are trying to accomplish?

  • Author

Ehum OK.

Well it's about dice rolls. So-called unlimited dice rolls. When you roll a 6, you roll that dice together with a new one again until you don't have anymore 6:s left. The 'Ob' is the sign for 'Obest

Hello Pontus,

I think that the Swedish>>English translation in your original posting is more confounding than the C++>>FileMaker translation. smile.gifsmile.gif

However I suspect that what you are looking for may be along the lines of:

SetField{"gCounter", "0"]

Loop

If ["not gCounter = 0"]

SetField{"gDiceRoll", "Int(Random * 6) + 1"]

End If

Exit Loop If ["not gDiceRoll = 6"]

End Loop

SetField{"RepeatRollCount", "gCounter - 1"]

You gave us a rather cryptic explanation of what you want to do (admittedly it was less cryptic than your original post), but you didn't say anything about *why* you want to do it or what you hope to achieve by it.

If what I've suggested is wide of the mark, then perhaps it will nonetheless give you some ideas to work with. wink.gif

  • Author

Why? Hmm. Oh yes it was a character generator for a

  • Author

Thanks for the link, Lee. And thanks for your script too CobaltSky, with the following changes I've managed to get it workin':

Loop

If ["not gCounter = 0"]

Set Field ["gDiceRoll","Int(Random*6)+1"]

End if

If ["not gDiceRoll = 6"]

Set Field ["gDiceCount","gDiceCount + gDiceRoll"]

Set Field ["gCounter","gCounter - 1"]

End if

Exit loop If ["gCounter=0"]

If ["gDiceRoll = 6"]

Set Field ["gCounter","gCounter + 1"]

End if

End Loop

Before using it one must set gCounter to the number of dices one want to roll, and gDiceCount to zero. Then let the dice roll and take the sum from gDiceCount.

Thanks for the help, everyone!

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.