May 9, 200619 yr 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.
May 9, 200619 yr 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.
May 9, 200619 yr 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
May 10, 200619 yr 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
May 10, 200619 yr 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
May 10, 200619 yr 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
May 10, 200619 yr 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:
May 11, 200619 yr 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