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.

scripting "time...time"

Featured Replies

  • Newbies

I need to attach a script that will reduce the price by .25 between the hours of 10:00am and 6:00pm. I have tried using an "if" function to no avail.

I am just not clever enuf to fiqure it out. Thank you in advance for any help.

How about:

If [ Get (CurrentTime) ≥ Time ( 10 ; 0 ; 0 ) and Get (CurrentTime) < Time ( 18 ; 0 ; 0 ) ]

Set Field [ YourTable::Price ; YourTable::Price * 0.75 ]

End If []

You could probably use a calculation instead of a script, but we'd need more details for that.

  • Author
  • Newbies

Thank you so much for such a quick reply. I will not have a chance to try it out till later today. Bed time now. Will let you know...Thanx again......cw

  • Author
  • Newbies

I can not seem to make an 'if' function work either as a script or in a calculated feild. The solution you supplied me would work but each time I enter it....it says that......it can not recognize the field 'if'. :?

I am using FM 7 on a mac running tiger.

What am I doing wrong?

If [ Get (CashRegister::Time) ≥ Time ( 10 ; 0 ; 0 ) and Get (CashRegister::Time) < Time ( 18 ; 0 ; 0 ) ]

Set Field [ CAN Price ; CAN Price - 0.25 ]

End If []

It say the specific field cannot be found......'if'

Any help would be greatly appreciated.......cw

CW:

Try defining your discount field (as a calculation field) with a Case[] statement instead of an If[] statement, thusly:

Case(Hour(CashRegister::Time)>9 and Hour(CashRegister::Time)<18;CAN Price*.75;CAN Price)

Note that it is using the Hour() function, which is why it is >9 rather than >10.

-Stanley

  • Author
  • Newbies

Thank you so much for your help. It appears to work fine, but, I actually won't know for sure until after 6:00 pm tonite. I consider myself to have an intermediate knowladge of FM up until FM7. So many functions I have no knowladge of. Still can't get an 'if' function to work. Don't know why. This 'case' function seems to do the job, just fine. again........Thank You.........cw

There was nothing wrong with the calculation Comment gave you. It's just that there is no Get (CashRegister::Time) function and you have no field called Time. You needed to replace 'Time' with your field and leave Get(CurrentTime) alone, as:

If ( Get ( CurrentTime) ≥ [color:blue]CashRegister::Time ( 10 ; 0 ; 0 ) and Get (CurrentTime) < [color:blue]CashRegister::Time ( 18 ; 0 ; 0 )

If() works just as well as Case() here - they both short-circuit and both produce null default result. Dropping the added Hour() functions also saves two evaluations.

LaRetta :wink2:

There was nothing wrong with the calculation Comment gave you.

There WAS one tiny thing wrong with it: it's not a calculation, but a script. Typing "Set Field[]" into a calculation window won't do much good.

I believe in YOUR calculation you meant to write:

If ( CashRegister::Time ≥ Time ( 10 ; 0 ; 0 ) and CashRegister::Time < Time ( 18 ; 0 ; 0 ) ; <> ; <> )

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.