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]
stumped
Moderators: Dorian (MJT support), JRL
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
Pretty intricate code for a beginner.
Later,
Dick
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
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
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.
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.
Dick
I modified the code eliminating the CRLF as you suggested and it
now executes.
I modified the code eliminating the CRLF as you suggested and it
now executes.
Thank you for the help.//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