View Full Version : Applying an Edit Mask to a character field
Guest.Visitor
01-01-1995, 02:00 AM
I have a display field (Input/Output)defined as 60 characters, and I would like to protect specific areas whithin this field from user input. Any ideas? TIA
David Abramowitz
05-18-2000, 10:24 AM
Split the field up, and use a data structure within your program to tie it back together. Dave
B.Myrick
05-18-2000, 10:38 AM
Alan, Create two data structures. One that is the length of the field broken out into two data structures. fielda contains the data from the record as it was read into the program. fieldb will contain the input from the screen. d ds d fielda 60a d fielda1 10a overlay(fielda:1) d fielda2 40a overlay(fielda:11) d fielda3 10a overlay(fielda:51) d ds d fieldb 60a d fieldb1 10a overlay(fieldb:1) d fieldb2 40a overlay(fieldb:11) d fieldb3 10a overlay(fieldb:51) *----------------------------------------------------------------------------* When the record is read in, fill both fielda and field be with the data. c read file c if %found(file) c eval fielda=field_from_file c eval fieldb=field_from_file c endif *----------------------------------------------------------------------------* When you output to the disk, overlay fieldb with subset of fields from fielda. c eval fieldb = field_from_screen c chain file c if not %found(file_name) c eval field_from_file = field_from_screen c write file_record_format c else c eval fieldb = field_from_screen c eval fieldb2 = fielda2 c eval field_from_file = fieldb c update file_record_format c endif By putting fielda2 into fieldb2, you "reset" the values being written out to the values that were originally read in. You can achieve the same effect if you define one data structure over the screen field and initialize it when the record is read in and then put the subfields back into the field_from_file field. You can also use: d save_field_1 40 d save_field_2 10 c read file_name c eval save_field_1 = %subst(field_from_file:11:40) c eval save_field_2 = %subst(field_from_file_51:10) and to update c eval %subst(field_from_file:11:40) = save_field_1 c eval %subst(field_from_file:51:10) = save_field_2 c update file_record_format Either one works well. I like the data structure, because I'm just kinda old fashioned and like things in the front of the program so my old eyes can see them. Hope this helps, Bret Myrick
Guest.Visitor
05-18-2000, 04:14 PM
David, breaking up the field into pieces it's not a choice. Bret, thanks for your resonse, perhaps I didn't explain myself correctly. So here it goes. The user will see one input field 60 characters long. He/she can type something like this 'NNNNNNYYYNYNNNYYYYNNNNNN...' What I'm looking to do is to "protect" from input, specific locations whithin the 60 character field. Kinda applying an edit mask to a numeric field, in which the editing characters are by-passed. Any other ideas? TIA
Guest.Visitor
05-18-2000, 04:22 PM
Your intent is not clear to me, but I suspect you want something like the PARSE instruction in REXX. Maybe some examples of what you are trying to do, maybe.???? bobh
David Abramowitz
05-18-2000, 04:49 PM
I don't see why breaking up the screen field is not an option. The good parts can be displayed with the appropriate number of bytes in between the fields. The whole thing can be tied together with a data structure within the program. Unless..... There is data in the "protected" area that must be displayed. In which case this is not an "edit mask" situation. Dave
B.Myrick
05-18-2000, 04:55 PM
Alan, I see what you want now, I think. Input: iiiiiipppppppiiipipppiiippppiiipppiiipp Where i=input capable and p=protect. Because DSPFs are character based for attributes,you cannot do such with AS/400 and RPG/III. The reason is that there is a beginning and ending character (invisible, but trust me) that marks the beginning and ending of an attribute for a field. If you were able to create several fields next to each other, with the protection on the fields you want, this could be done, but you will need to have (x * number of fields)*2 positions to do so. May require two or more lines of display to do so. Later, Bret Myrick
G.Gaunt
05-19-2000, 07:14 AM
If the specific locations you want to protect within the 60-byte field are constant, write two DDS screens: the first screen contains input fields in nonprotected areas, the second screen specifies CLRL(*NO) and overlays input fields and adjacent protected areas with the entire 60-byte output-only field. The cursor will behave like you want. If the specific locations you want to protect are not constant, call QsnSetFld API for each nonprotected area, and overlay them with the entire 60-byte output-only field.
Guest.Visitor
05-19-2000, 09:34 AM
Gene, that's exactly what I was looking for. Although I had to split the input fields, from the user point of view, it remains as a single field. I owe you one! Thanks
T.Holt
05-19-2000, 01:28 PM
<font color=blue>Gene, that's exactly what I was looking for. Although I had to split the input fields, from the user point of view, it remains as a single field. I owe you one!</font> Alan, please <a > href="mailto:tholt@midrangecomputing.com">email</a> some sample code to me. It sounds like something Midrange Computing might be able to use in TechTalk.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.