stumped

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

stumped

Post by esuohlluf » Mon Apr 10, 2006 1:47 pm

111//extract the number of Users for each group
112 Let>c=0
113 Let>g=-1
114 Repeat>c
115 Let>c=c+2
116 Let>g=g+1
117 DDERequest>Excel,ExcelFile,R39C%c%,return,60
118 EditIniFile>iniFile,Group%g%,UserCount,%return%
119 Let>CountForUserGroup_%g%=%return%
120 Until>c=20
121
122
123 //extract the Users
124 Let>g=-1
125 Let>c=0
126 Label>nextgroup
127 Repeat>g
128 Let>g=g+1
129 Let>c=c+2
130 Let>r=2
131 Let>u=0
132 Let>count=CountForUserGroup_%g%
133
134 MessageModal>%count%
135 If>%count%=0
136 Goto>nextgroup
137 Else
138 Repeat>u
139 Let>u=u+1
140 Let>r=r+1
141 Let>n=n=1
142 DDERequest>Excel,ExcelFile,R%r%C%c%,return,60
143 EditIniFile>iniFile,Group%g%,User%u%,%return%
144 Until>u=CountForUserGroup_%g%
145 EndIf
146 Until>g=9


I have an excel sheet with 9 different groups(0-9) of users spaced one column apart.
With this code I am trying to save the users names to an .ini file.
This code excecutes as intended until I reach line 135 with a count=0.
For a case with a group that has no users I try to skip to the next group.
Although my message box reads zero the code moves past the Else and starts to write
infinte Users to the ini file.
I have tried several different approaches with no success.
[/quote]
Last edited by esuohlluf on Mon Apr 10, 2006 3:43 pm, edited 2 times in total.

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

Post by JRL » Mon Apr 10, 2006 2:22 pm

Have you tried stepping through the code in the editor by using the F8 key and having Debug > Show Watch List turned on. When I do this, I see that a DDERequest> to a blank cell does not return a value of "0", instead it returns a value of %CRLF%. I think if you test for that rather than testing for "0" you'll figure out the rest.

Pretty intricate code for a beginner.

Later,
Dick

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

Post by esuohlluf » Mon Apr 10, 2006 2:29 pm

I have never used the debug, I will read into it.
But I placed the message box in the code to monitor the count and
I show a zero as expected.
At that point I am expecting the code to loop back and get the next column of users, but instead it goes forward and begins to write to the ini.

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

Post by JRL » Mon Apr 10, 2006 3:11 pm

Sorry, I've never used DDERequest myself so I'm learning as I'm testing your code.

It appears that every value assigned to a variable by DDERequest> to excel places a %CRLF% at the end. That would mean that even if you see a "0" in a message box that views the variable you're not seeing tha last part of the variable because %CRLF% will not show up. In other words... 0%CRLF% will appear as 0 in a message box.

But if you're testing the value of the variable with If>value=variable'svalue,
0 will not be equal to 0%CRLF%

Also, when posting code samples please leave out the line numbers.

Hope this made sense,
Dick

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

Post by esuohlluf » Mon Apr 10, 2006 3:39 pm

Yes that makes sense.
I am modifying the code now to retest it.
I figured the code lines would help, to refer to the exact problem line.

I just editted the code I posted.
I decided to change a variable name before posting to make it more readable, then failed to make all the neccessary changes before I posted.
Sorry about that.

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

Post by esuohlluf » Mon Apr 10, 2006 3:47 pm

Dick

I modified the code eliminating the CRLF as you suggested and it
now executes.
//extract the number of Users for each group
Let>c=0
Let>g=-1
Repeat>c
Let>c=c+2
Let>g=g+1
DDERequest>Excel,ExcelFile,R39C%c%,return,60
StringReplace>return,CRLF,,return
EditIniFile>iniFile,Group%g%,UserCount,%return%
Let>CountForUserGroup_%g%=%return%
Until>c=20


//extract the Users
Let>g=-1
Let>c=0
Label>nextgroup
If>g=9
Goto>DoneWithUsers
Endif
Repeat>g
Let>g=g+1
Let>c=c+2
Let>r=2
Let>u=0
Let>count=CountForUserGroup_%g%

MessageModal>%count%
If>%count%=0
Goto>nextgroup
Else
Repeat>u
Let>u=u+1
Let>r=r+1
Let>n=n=1
DDERequest>Excel,ExcelFile,R%r%C%c%,return,60
StringReplace>return,CRLF,,return
EditIniFile>iniFile,Group%g%,User%u%,%return%
Until>u=CountForUserGroup_%g%
EndIf
Goto>nextgroup
Label>DoneWithUsers
Thank you for the help.

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