trouble with code

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
esuohlluf
Junior Coder
Posts: 41
Joined: Thu Mar 23, 2006 5:33 am

trouble with code

Post by esuohlluf » Tue Apr 11, 2006 3:24 pm

Let>g=0
Label>FindFirstGroupThatHasUsers
Let>g=g+1
ReadIniFile>iniFile,Group%g%,UserCount,usercount
let>count=%usercount%
If>count>0
Let>RadioGroupString=%g%
Goto>TheOtherGroups
Endif
Goto>FindFirstGroupThatHasUsers

In this segment of code I beginning a string for a radio button group.
There seem to be some sortof problem with Let> g=g+1

When i watch the debug g counts up as expected but for g=1 I return
the usercount for group0 once g=2 the usercount=
nothing returned and i get an error reading the ini file

If i type the group number ex: Let>g=0
Label>FindFirstGroupThatHasUsers
Let>g=g+1
ReadIniFile>iniFile,Group%g%,UserCount,usercount
let>count=%usercount%
If>count>0
Let>RadioGroupString=%g%
Goto>TheOtherGroups
Endif
Goto>FindFirstGroupThatHasUsers

In this segment of code I beginning a string for a radio button group.
There seem to be some sortof problem with Let> g=g+1

In the debug watch list g counts up as expected but for g=1 I return
the usercount for group0. With g=2 the usercount=
nothing returned and I get an error reading the ini file

If I type the group# into the code ex: ReadIniFile>iniFile,Group3,UserCount,usercount

I get a return for usercount that is correct
I tested this for all 8 Groups

Why do I seem to have a problem with Let>g=g+1 when g shows the
number expected in the debug watch list?

I have used this same type of code elsewhere in the macro
the only difference is that in the other cases I used Repeat>

Is there some sort of problem with going back to Label> ?

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

Post by JRL » Tue Apr 11, 2006 3:50 pm

If you are actually using "USERCOUNT" as the name of an entry in the INI file then you should not use it as the name of a variable. You have redefined the term "USERCOUNT" so the entry you are looking for is not "USERCOUNT" but the new value of "USERCOUNT".

Does this make sense?

Dick

esuohlluf
Junior Coder
Posts: 41
Joined: Thu Mar 23, 2006 5:33 am

Post by esuohlluf » Tue Apr 11, 2006 5:07 pm

No it really doesnt make sense because I replaced the variable %g%
with a constant for each group and read back properly from the ini file.

Also I had already tried the same code using ucount instead of usercount,
and the code still failed.

So the code works if I manually type a number in place of %g% but for
some reason will not work with g as a variable.

esuohlluf
Junior Coder
Posts: 41
Joined: Thu Mar 23, 2006 5:33 am

Post by esuohlluf » Tue Apr 11, 2006 5:20 pm

I ran it again using ucount and have this segment working.
I had already tried that change previously , cannot pinpoint why
it didnt work prior.

Sorry for the last post and thanks again

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

Post by JRL » Tue Apr 11, 2006 5:30 pm

I see you reposted while I was typing. Glad its working.


This works for me.

Let>g=-1
// If you have a group 0 you need to start at g=-1

Label>FindFirstGroupThatHasUsers
Let>g=g+1
ReadIniFile>c:\testiniFile.txt,Group%g%,UserCount,usrcount
//renamed usercount variable to usrcount otherwise the second time
//through the loop the variable usercount=
//because the variable is named the same as the INI file entry.

let>count=%usrrcount%
If>count>0
Let>RadioGroupString=%g%
Goto>TheOtherGroups
Endif
Goto>FindFirstGroupThatHasUsers

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