More dialog help.....

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
daniel
Junior Coder
Posts: 32
Joined: Mon Apr 25, 2005 5:04 pm

More dialog help.....

Post by daniel » Wed Jul 27, 2005 11:26 pm

I've created a dialog that's going to be used for data entry. The purpose of this dialog is to get the value entered from each field and send it to another screen.

My question to any of you is; is it possible to set a length limit for each field?

For example, if the first field is a date in the format MMDDYY can the macro be setup so that if the data entry operator keys 062505 it will automatically tab to the next entry field?

Thanks again for all your help and support?

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jul 28, 2005 3:00 am

daniel,

This was taken straight from the help files and modified. Not well thought out, I'm sure this could be made more efficient but the basic concept is here.

Try this:

Dialog>Dialog1
Caption=Non-Modal Dialog
Top=113
Width=264
Left=16
Height=113
Button=Update,16,8,75,25,5
Button=Exit,16,48,75,25,6
Edit=msEdit1,104,8,121,Fred
ComboBox=msComboBox1,104,32,121,1%CRLF%2
Edit=msEdit2,104,56,121,
EndDialog>Dialog1

Show>Dialog1

Label>ActionLoop
GetDialogAction>Dialog1,r
if>r=5,Update
if>r=6,Close
if>r=2,exit
Len>Dialog1.msEdit2,elen
If>elenedittest=0
EndIf
If>elen>6
Midstr>Dialog1.msEdit2,1,6,editlimit
Let>Dialog1.msEdit2=editlimit
Let>edittest=0
ResetDialogAction>Dialog1
EndIf
If>edittest=1,skippresstab
If>elen=6
Let>edittest=1
Press TAB
ResetDialogAction>Dialog1
EndIf
Label>skippresstab
Goto>ActionLoop
Label>exit

SRT>Update
Let>Dialog1.msEdit2=%Dialog1.msEdit1% %Dialog1.msComboBox1%
ResetDialogAction>Dialog1
END>Update

SRT>Close
CloseDialog>Dialog1
Let>r=2
END>Close

Hope this helps,
Dick

daniel
Junior Coder
Posts: 32
Joined: Mon Apr 25, 2005 5:04 pm

Post by daniel » Fri Jul 29, 2005 2:50 pm

Thanks for your response, but that's not what I was looking for. My problem is that, let's say that I have three field in a dialog that will always be required to be entered. The first field has to be in length four digits, the second one has to be five and the third one six. I want it so that if a person keys 1234 in the first field, the macro will tab to the next field to the right, and then if the person enters 12345 then it will tab to the next field to the right, and finally if they type 123456 then it will tab to the next line below. can you help with this?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Jul 29, 2005 10:17 pm

I don't think that The current version can deal with that.

As a general comment re Dialogs, once you open a Dialog then macro script halts until you exit/close the Dialog.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Jul 30, 2005 5:54 am

OK Daniel, here's another shot at the task.... This sample will give you four rows of three fields with the first column accepting four characters then auto tabbing to the second column which will accept 5 characters then auto tabbing to the third column which will accept 6 characters then auto tabbing to the first column second row which is back to accepting 4 characters.... Etc.... If you follow the pattern set up in the sample you could create as many columns and rows as you want.

If you have anything but sequential field length requirements (Such as 4, 5, 6 in this sample) You will have to specify a value for "L" based on specific column and row designations.

A deficiency in this script that I'm not sure how to overcome is that the dialog is not aware of what column or row it is in. The order for going through the fields is fixed. Stray from that order and the whole thing fails. This might be addressed using the "GetCusorPos" function but it would add more complexity than I'm willing to deal with tonight.

Try this. Let me know what you think:


Dialog>Dialog1
Caption=Field Length Test
Top=208
Width=281
Left=396
Height=250
Label=4 Char,24,8
Label=5 Char,104,8
Label=6 Char,192,8
Edit=F11,16,24,49,
Edit=F12,80,24,73,
Edit=F13,168,24,81,
Edit=F21,16,56,49,
Edit=F22,80,56,73,
Edit=F23,168,56,81,
Edit=F31,16,88,49,
Edit=F32,80,88,73,
Edit=F33,168,88,81,
Edit=F41,16,120,49,
Edit=F42,80,120,73,
Edit=F43,168,120,81,
Button=OK,24,176,75,25,3
Button=Exit,176,176,75,25,2
EndDialog>Dialog1

Let>C=1
Let>R=1
Let>L=4
Let>Update_F=0
Show>Dialog1

Label>ActionLoop
GetDialogAction>Dialog1,X
if>X=3,complete
if>X=2,exit
If>Update_F=1,Bump_C,
If>F%R%%C%=F51,skipupdate
GoSub>Update
Label>skipupdate
Goto>ActionLoop

SRT>Bump_C
Let>Update_F=0
Let>C=C+1
If>C=4
Let>C=1
GoSub>Bump_R
EndIf
If>C=1
Let>L=4
EndIf
If>C=2
Let>L=5
EndIf
If>C=3
Let>L=6
EndIf
END>Bump_C

SRT>Bump_R
Let>R=R+1
END>Bump_R

SRT>Update
Let>cell=Dialog1.F%R%%C%
Len>%cell%,elen
If>%elen%edittest=0
EndIf
If>%elen%>%L%
Midstr>%cell%,1,%L%,editlimit
Let>%cell%=%editlimit%
Let>edittest=0
ResetDialogAction>Dialog1
EndIf
If>edittest=1,skippresstab
If>%elen%=%L%
Let>edittest=1
Press TAB
Let>Update_F=1
ResetDialogAction>Dialog1
EndIf
Label>skippresstab
END>Update

Label>complete

///////////Do Stuff

Label>exit


Hope this is helpful,
Dick

daniel
Junior Coder
Posts: 32
Joined: Mon Apr 25, 2005 5:04 pm

Post by daniel » Mon Dec 11, 2006 4:35 pm

The codes that you gave me works fine, but I have another minor problem. For example, if the I've declared a field length to be 4 characters max, but if it's three that would be okay. The problem that I'm having is that if I click the TAB key it trows the whole thing off and the auto-tabbing does not work anymore. Is there a work around so that only alpha-numeric characters counts a valid character in a field? Thanks.

daniel

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Dec 11, 2006 4:56 pm

JRL wrote:A deficiency in this script that I'm not sure how to overcome is that the dialog is not aware of what column or row it is in. The order for going through the fields is fixed. Stray from that order and the whole thing fails.
As I noted, the script is set up for autotabbing based on the correct number of characters being entered in the field. The dialog is not aware of which field the cursor is located.

Try entering a space at the front of the text if there will only be 3 characters in a four character field. If a space is an invalid character then perhaps you could test for the space character in the value of "cell" and eliminate it if it exists.

Bottom line is, this script has to autotab to work correctly.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Dec 11, 2006 7:17 pm

I apologize for not looking at the script detail right now, but I wondered:

When the "auto tab" runs, could it loop through each of the characters and look at the ascii values of each to determine if it is in alphanumeric range?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts