Newbies cwn Posted May 9, 2006 Newbies Posted May 9, 2006 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.
comment Posted May 9, 2006 Posted May 9, 2006 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.
Newbies cwn Posted May 9, 2006 Author Newbies Posted May 9, 2006 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
Newbies cwn Posted May 10, 2006 Author Newbies Posted May 10, 2006 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
stanley Posted May 10, 2006 Posted May 10, 2006 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
Newbies cwn Posted May 10, 2006 Author Newbies Posted May 10, 2006 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
LaRetta Posted May 10, 2006 Posted May 10, 2006 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:
comment Posted May 11, 2006 Posted May 11, 2006 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 ) ; <> ; <> )
Recommended Posts
This topic is 6774 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now