Posted: Sun Jul 05, 2009 3:09 pm
Susan,
I don't know why Curfld isn't working for Radio buttons. That sounds like it might be a bug to me.
However, I don't see why you can't just loop through ALL your controls and validate them all, no matter which field the user modified? Does it take too much time to validate your controls?
What I usually do is:
1) I read the record on the disk
Read #DataFile, using form$(Datafile) : mat f$, mat f
2) I transfer the information from the "Record on Disk" to the "Record on Screen"
let s_data$(1)=f$(cu_name)
let s_data$(2)=f$(cu_description)
let s_data$(3)="Male"
let s_data$(4)="Female"
if f$(cu_gender)="M" then
let s_data$(3)="^"&s_data$(3)
else
let s_data$(4)="^"&s_data$(4)
end if
3) I input from the screen.
rinput #window, using mat s_spec$ : mat s_data$
4) after inputting I validate all controls
5) when the input loop is done, I copy all information back to Record on Disk arrays:
let F$(cu_name)=s_data$(1)
let F$(cu_description)=s_data$(2)
if s_data$(3)(1:1)="^" then
let f$(cu_gender)="M"
else
let f$(cu_gender)="F"
end if
6) Finally, if the user wanted to save the data, I save it:
if ExitMode=SaveAndQuit then
rewrite #DataFile, using form$(DataFile) : mat f$, mat f
Of course, this is a simplified example. I actually have routines that do each of these steps in a more generic manageable way. Also, with ScreenIO, I'm not sure when one of your custom functions wants access to the current state of the Record on Disk (mat f$, mat f), so I validate and save all data in the Rinput Fields statement in one step, Each and Every time the rinput fields statement is done. It doesn't waste time when I do it, the validation and saving generally goes so fast it looks instant.
So with ScreenIO, the steps are:
1) Read the Screen Definition (this tells which record on disk goes in which place on the screen)
2) Read the record from the data file
3) Build the input specs (build mat s_spec$)
4) Do
5) Copy data from Record on Disk to Record on Screen. (build mat s_data$)
6) Preform the Input statement
7) Validate the data and save it from Record on Screen back into Record on Disk
Check how the input ended and process accordingly (did they click on a button, or press escape, or what)
9) Loop until Exitmode
10) Save the Data back to the disk with a Rewrite statement (or a regular "write" if we are adding a record).
ExitMode is set to non-zero either by pressing the ESC key or by clicking on a button that sets ExitMode. (step 8 is when it actually gets set)
It looks like George answered the majority of your questions.
Yes, to tell which thing was clicked on, just check for the presence of "^". To set which thing is selected initially, simply put an "^" in the one that needs to be selected.
This way you can fairly easily save the presence of the "^" or not into your data file using whatever logic you want to use.
In ScreenIO check boxes have a setting that says, "What goes in the datafile if its Checked? What goes in the data file if its Not Checked?". We'll probably make radio buttons work the same way when we add them.
However, Georges answers sparked some (incidental) questions of my own:
1) George, you mention that Search is Case Insensitive if your search item begins with a "^"?? When did that start working? Is it 4.2 only? I never knew about that, thank you for letting me know. I'm sure its faster, and its certianly cleaner code, to use "SRCH" then it is to use a For Next loop, but I have been using For Next loops any time I needed to do a case insensitive search because I didn't know SRCH could handle a case insensitive search.
2) Your examples showed exiting a FOR NEXT loop by using a GOTO statement. Does that properly close out the FOR NEXT loop? I always figured that would leave the FOR NEXT loop sitting on the FOR stack or something. I have been setting the INDEX to the MAX VALUE when I wanted to exit a for next loop (until Gordon would implement an EXIT FOR statement in BR) in order to properly exit out of the FOR loop.
I don't know why Curfld isn't working for Radio buttons. That sounds like it might be a bug to me.
However, I don't see why you can't just loop through ALL your controls and validate them all, no matter which field the user modified? Does it take too much time to validate your controls?
What I usually do is:
1) I read the record on the disk
Read #DataFile, using form$(Datafile) : mat f$, mat f
2) I transfer the information from the "Record on Disk" to the "Record on Screen"
let s_data$(1)=f$(cu_name)
let s_data$(2)=f$(cu_description)
let s_data$(3)="Male"
let s_data$(4)="Female"
if f$(cu_gender)="M" then
let s_data$(3)="^"&s_data$(3)
else
let s_data$(4)="^"&s_data$(4)
end if
3) I input from the screen.
rinput #window, using mat s_spec$ : mat s_data$
4) after inputting I validate all controls
5) when the input loop is done, I copy all information back to Record on Disk arrays:
let F$(cu_name)=s_data$(1)
let F$(cu_description)=s_data$(2)
if s_data$(3)(1:1)="^" then
let f$(cu_gender)="M"
else
let f$(cu_gender)="F"
end if
6) Finally, if the user wanted to save the data, I save it:
if ExitMode=SaveAndQuit then
rewrite #DataFile, using form$(DataFile) : mat f$, mat f
Of course, this is a simplified example. I actually have routines that do each of these steps in a more generic manageable way. Also, with ScreenIO, I'm not sure when one of your custom functions wants access to the current state of the Record on Disk (mat f$, mat f), so I validate and save all data in the Rinput Fields statement in one step, Each and Every time the rinput fields statement is done. It doesn't waste time when I do it, the validation and saving generally goes so fast it looks instant.
So with ScreenIO, the steps are:
1) Read the Screen Definition (this tells which record on disk goes in which place on the screen)
2) Read the record from the data file
3) Build the input specs (build mat s_spec$)
4) Do
5) Copy data from Record on Disk to Record on Screen. (build mat s_data$)
6) Preform the Input statement
7) Validate the data and save it from Record on Screen back into Record on Disk
9) Loop until Exitmode
10) Save the Data back to the disk with a Rewrite statement (or a regular "write" if we are adding a record).
ExitMode is set to non-zero either by pressing the ESC key or by clicking on a button that sets ExitMode. (step 8 is when it actually gets set)
It looks like George answered the majority of your questions.
Yes, to tell which thing was clicked on, just check for the presence of "^". To set which thing is selected initially, simply put an "^" in the one that needs to be selected.
This way you can fairly easily save the presence of the "^" or not into your data file using whatever logic you want to use.
In ScreenIO check boxes have a setting that says, "What goes in the datafile if its Checked? What goes in the data file if its Not Checked?". We'll probably make radio buttons work the same way when we add them.
However, Georges answers sparked some (incidental) questions of my own:
1) George, you mention that Search is Case Insensitive if your search item begins with a "^"?? When did that start working? Is it 4.2 only? I never knew about that, thank you for letting me know. I'm sure its faster, and its certianly cleaner code, to use "SRCH" then it is to use a For Next loop, but I have been using For Next loops any time I needed to do a case insensitive search because I didn't know SRCH could handle a case insensitive search.
2) Your examples showed exiting a FOR NEXT loop by using a GOTO statement. Does that properly close out the FOR NEXT loop? I always figured that would leave the FOR NEXT loop sitting on the FOR stack or something. I have been setting the INDEX to the MAX VALUE when I wanted to exit a for next loop (until Gordon would implement an EXIT FOR statement in BR) in order to properly exit out of the FOR loop.