Different resutls from different dialog input

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Different resutls from different dialog input

Post by kpassaur » Fri Jan 12, 2007 6:14 pm

This is hard to describe, but in a nutshell if I enter the data in a dialog box an process it I am getting a different result than if I place it in an input box or hard code it. I have checked the debugger and it appears to be correct. What the script does is code a string and then unencode it. I have tried for 10 hours to figure this one out and I can't get it. If I remove the dialog box it works with input and it works when I place the variable in the code itself. The dialog was just for testing, but I would like to make 100% sure it will always work.

The script is below, with line marked out for testing. And help would be appriecated

Code: Select all


Dialog>Dialog1
   Caption=Dialog1
   Width=341
   Height=221
   Top=120
   Left=653
   Edit=msEdit1,72,56,185,
   Button=Continue,72,104,75,25,1
   Button=Exit,176,104,75,25,2
   Label=Enter the Key,128,32,true
EndDialog>Dialog1


Label>Dialog1loop
Show>Dialog1,r
If>r=1,testhekey
If>r=2,EOF
Goto>Dialog1loop
Label>testhekey


GoSub>Processkeyname
GoSub>Processkeynumber

SRT>Processkeynumber
/Let>Key=%Dialog1.msEdit1%

Input>Key,Test the Key
Length>%Key%,klen
Sub>%klen%,2
MidStr>%Key%,%klen%,3,Licenses

StringReplace>%Licenses%,SQ,,Licenses
StringReplace>%Licenses%,Q,,Licenses


Let>LNumber=
Let>Lcounter=1
Len>%Licenses%,llen
Add>llen,1
Label>ConvertNumberLine
MidStr>%licenses%,%Lcounter%,1,charread
GoSub>ConvertFrom
ConCat>LNumber,%Name%
Let>Lcounter=%Lcounter%+1
Endif
If>%Lcounter%=%llen%,DoneConvertingLicenseline
Goto>ConvertNumberLine
Label>DoneConvertingLicenseline
MDL>%LNumber%
END>Processkeynumber


SRT>Processkeyname

Input>Key,Test the Key
/Let>Key=%Dialog1.msEdit1%
/Let>Key=1PNGOAMKII1*KDHOG65G6Q71NQ1&
Let>Name1=
Let>counter=1
Len>%Key%,clen
Sub>%clen%,2
Label>StartConvertingLine

If>%counter%=2,SkipSub
If>%counter%=6,SkipSub
If>%counter%=10,SkipSub
If>%counter%=14,SkipSub

MidStr>%Key%,%counter%,1,charread
GoSub>ConvertFrom
ConCat>Name1,%Name%
Label>SkipSub
Let>counter=%counter%+1
If>%counter%=%clen%,DoneConvertingline
Goto>StartConvertingLine
Label>DoneConvertingline

MDL>Registered to %Name1% for %Lnumber% LIcenses
END>Processkeyname


SRT>ConvertFrom
If>%charread%=Q
Let>Name=A
Goto>convertedChar
Endif

If>%charread%=P
Let>Name=B
Goto>convertedChar
Endif

If>%charread%=O
Let>Name=C
Goto>convertedChar
Endif

If>%charread%=N
Let>Name=D
Goto>convertedChar
Endif

If>%charread%=1
Let>Name=E
Goto>convertedChar
Endif

If>%charread%=M
Let>Name=F
Goto>convertedChar
Endif

If>%charread%=2
Let>Name=G
Goto>convertedChar
Endif

If>%charread%=L
Let>Name=H
Goto>convertedChar
Endif

If>%charread%=K
Let>Name=I
Goto>convertedChar
Endif

If>%charread%=3
Let>Name=J
Goto>convertedChar
Endif

If>%charread%=J
Let>Name=K
Goto>convertedChar
Endif

If>%charread%=I
Let>Name=L
Goto>convertedChar
Endif


If>%charread%=4
Let>Name=M
Goto>convertedChar
Endif

If>%charread%=H
Let>Name=N
Goto>convertedChar
Endif

If>%charread%=G
Let>Name=O
Goto>convertedChar
Endif

If>%charread%=5
Let>Name=P
Goto>convertedChar
Endif

If>%charread%=F
Let>Name=Q
Goto>convertedChar
Endif

If>%charread%=6
Let>Name=R
Goto>convertedChar
Endif

If>%charread%=E
Let>Name=S
Goto>convertedChar
Endif

If>%charread%=7
Let>Name=T
Goto>convertedChar
Endif

If>%charread%=D
Let>Name=U
Goto>convertedChar
Endif

If>%charread%=W
Let>Name=V
Goto>convertedChar
Endif

If>%charread%=C
Let>Name=W
Goto>convertedChar
Endif

If>%charread%=9
Let>Name=X
Goto>convertedChar
Endif

If>%charread%=B
Let>Name=Y
Goto>convertedChar
Endif

If>%charread%=A
Let>Name=Z
Goto>convertedChar
Endif

If>%charread%=*
Let>Name= 
Goto>convertedChar
Endif

If>%charread%=+
Let>Name=0
Goto>convertedChar
Endif
If>%charread%=!
Let>Name=9
Goto>convertedChar
Endif
If>%charread%=@
Let>Name=8
Goto>convertedChar
Endif
If>%charread%=#
Let>Name=7
Goto>convertedChar
Endif
If>%charread%=&
Let>Name=6
Goto>convertedChar
Endif
If>%charread%=R
Let>Name=5
Goto>convertedChar
Endif
If>%charread%=T
Let>Name=4
Goto>convertedChar
Endif
If>%charread%=?
Let>Name=3
Goto>convertedChar
Endif
If>%charread%=Z
Let>Name=2
Goto>convertedChar
Endif
If>%charread%=X
Let>Name=1
Label>convertedChar
Endif
END>ConvertFrom
Label>EOF

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

Post by JRL » Fri Jan 12, 2007 8:07 pm

Hi Keith,

I see a couple of problems right off.

1) I need a double slash (//) rather than a single slash (/) to remark a line. If you're using single slash I think your remarked lines are processing.

2) Remove Percents from the variable in add> or sub> functions.
sub>clen,1 works
sub>%clen%,1 will not work

3) You have set R=1 in your show dialog when the "Continue" button is pressed. Therefore, when character "6" is processed variable name becomes "1" rather than "R".

I like to use r + the dialog number for my dialog result variable.

Hope this helps,
Dick

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Using r as results in Dialog

Post by kpassaur » Fri Jan 12, 2007 8:21 pm

Dick

I havn't tried it yet, but I know you go it for me as the issue was with the "R". I looked and looked for somthing that was messing with it and could'n't figure it out. Thank you

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

Post by JRL » Fri Jan 12, 2007 8:48 pm

Keith,
Glad to help.

Couldn't this script be made simpler by using the Macro Scheduler Crypt> function?

Just wondering,
Dick

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Crypt Function Should Work

Post by kpassaur » Fri Jan 12, 2007 10:06 pm

Dick,

I just checked out Crypt Function and it should do what I want. I quess I should have checked it out before. I quess you have figured out what I am doing. An encoded file is read that contains a company name and how many users are allowed. This file will be saved in a location that has read write privelages. When a new user is added his/her computer name will be added to the list. The encrypted file will contain the company name which will be displayed in all windows the utilty has.

So, the file is read for the company name and the number of users. The user list file will just be count the lines that contain text. That way if an employee comes or goes who cares as it is base on computer names.

The employee names are used in a folder structure to limt access to the files. Anyway, that is what I am up to and if I knew this before I would already be done.

Thanks again

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