Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SET('DATE') Switching
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00770484
Message ID:
00770523
Vues:
12
>>Hi everyone,
>>
>>Here is a curious problem; one of those which is driving me nuts. I have a little app which is designed to work with a user defined 'BRITISH' or 'AMERICAN' set date format. The user makes his choice and an 'A' or 'B' is stored in a table. An application method on loadup reads that table and then sets the date.
>>
>>However, when I open forms in the app - the date format switches back and forth (forex: when the init of a grid fires, it is setting the date format to American!!!) I have checked every method in my code and the only place I allow for a SET DATE change is in that one single application method. That method is only called on startup, and when each form is loaded (default form class init). In testing, I remove all calls at the form level to the set date - and set the date to British by default; and the same thing still happens (the date switches back to American).
>>
>>As a side note: I am not using system date in that some clients who use this app are sending international - some to the States, some to other countries (which we limit to British date format).
>>
>>Has anyone ever had difficulty with SET DATE changing? Does anyone have a suggestion? TIA
>>
>>Ric
>
>If your using private data sessions, SET DATE is scoped to the current data session.
>Verify you set it on each Form.Load that uses a private datasession.
>Tracy

Tracy,

Thanks for your reply!!! And Very Well Done!!!! This is something new to me regarding the scoping. After looking at this issue, I see you are correct in that when a form object has focus - it is setting the date back to American. When the application object has the focus, it is setting the date to British (because that is the date format I want to use).

Here is the application date setter:
*--oApp.setupdateformat
IF ALLTRIM(THIS.stringsetupdateformat)="A"
 SET DATE AMERICAN
ELSE
 SET DATE BRITISH
ENDIF
I have set my date to British. First - I opened a form with a call to my application method in the form load event:
*-- myform.load
*-- at this point SET('DATE') is AMERICAN
*-- now, when I run the next line, control returns to the application, and set date becomes BRITISH
=oApp.setupdateformat()
*-- I am returned back here, and the date goes back to AMERICAN!!!
Funny how an application cannot return a setting to a private data session. So, I changed the load event (based on your advice) to not call the application object to set date, but still use the application string to get the setting:
*-- myform.load
*-- at this point SET('DATE') is AMERICAN
IF ALLTRIM(oApp.stringsetupdateformat)="A"
 SET DATE AMERICAN
ELSE
 SET DATE BRITISH
ENDIF
at this point SET('DATE') is BRITISH and so it stays....
TaDAA!!!! Thank you very much.


Ric
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform