CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > Fanuc


Fanuc Discuss Fanuc controllers here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 03-22-2007, 09:06 PM
 
Join Date: Nov 2005
Location: Only the USA
Posts: 213
theemudracer is on a distinguished road
How do you clear variables after the prg. is done??

I need to add something at the end of a prg. that clears all variables.

something like
#1=0;
#1=[#1thru#499]

I know this example wont work but Im just trying to get my point across.

thanks
Jon
Reply With Quote

  #2   Ban this user!
Old 03-22-2007, 10:29 PM
 
Join Date: Jan 2007
Location: USA
Posts: 355
Eurisko is on a distinguished road

How about:

N1000 #1=2 ( SET LOOP COUNT )
N1010 #[#1]=0
N1020 #1=#1+1
N1030 IF [#1 NE 500] GOTO 1010 ( LOOP THRU 499)
N1040 #1=0

Not sure about the syntax, but it might work...
Reply With Quote

  #3   Ban this user!
Old 03-23-2007, 07:51 PM
jamesweed's Avatar  
Join Date: Jan 2007
Location: USA
Posts: 82
jamesweed is on a distinguished road

#1=#1
N1
WHILE[#1LE33]DO1
#[#1]=0
#1=#1+1
END1

I use this type of can to clear varibles but I'm not at work, to check, so this may not be exactly right. I believe you will need to set a different can for each group of varibles. #1 - #33 , #100 - #199... Otherwise you will probably get a varible not found type error. The above example will clear the locals.
-Jim
Reply With Quote

  #4   Ban this user!
Old 03-23-2007, 10:06 PM
 
Join Date: Nov 2005
Location: Only the USA
Posts: 213
theemudracer is on a distinguished road

Originally Posted by jamesweed View Post
#1=#1
N1
WHILE[#1LE33]DO1
#[#1]=0
#1=#1+1
END1

I use this type of can to clear varibles but I'm not at work, to check, so this may not be exactly right. I believe you will need to set a different can for each group of varibles. #1 - #33 , #100 - #199... Otherwise you will probably get a varible not found type error. The above example will clear the locals.
-Jim
What do I change to clear the #100-#199?
I would assume this

WHILE[#100LE199]DO1
Reply With Quote

  #5   Ban this user!
Old 03-24-2007, 07:08 AM
 
Join Date: May 2006
Location: USA
Age: 42
Posts: 82
lgreeves is on a distinguished road

#1=#1
N1
#[#1]=0
#1=#1+1
WHILE[#1LE33]DO1
END1

I thinks you want the WHILE statement preceding the end statement so you are not in an everlasting loop.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 03-24-2007, 10:15 AM
jamesweed's Avatar  
Join Date: Jan 2007
Location: USA
Posts: 82
jamesweed is on a distinguished road

Originally Posted by lgreeves View Post
#1=#1
N1
#[#1]=0
#1=#1+1
WHILE[#1LE33]DO1
END1

I thinks you want the WHILE statement preceding the end statement so you are not in an everlasting loop.
I think either way will work...

#1=100
N1
#[#1]=0
#1=#1+1
WHILE[#1LE199]DO1
END1

This I believe will clear #100-#199, if not just tinker with it a bit because this is close if not right way.
Reply With Quote

  #7   Ban this user!
Old 03-24-2007, 01:03 PM
 
Join Date: Nov 2006
Location: UK
Posts: 121
ChattaMan is on a distinguished road
#0 not 0

The above examples will asign a value of 0 (zero) to the variables and not clear them. You need to use #0 not 0 to clear them. There is a difference. #0 is always null.

e.g. #[#1]=#0 not #[#1]=0



ChattaMan
Reply With Quote

  #8   Ban this user!
Old 03-24-2007, 05:17 PM
 
Join Date: Nov 2005
Location: Only the USA
Posts: 213
theemudracer is on a distinguished road

Ok, I went to work this morning and played with this some. This is what I get when I use this...

#1=100
WHILE[#1LE149]DO1
#[#1]=#0
#1=#1+1
END1

THIS WORKS, CLEARS 100-149

#1=500
WHILE[#1LE531]DO1
#[#1]=#0
#1=#1+1
END1

THIS WORKS, CLEARS 500-531

#1=1
WHILE[#1LE33]DO1
#[#1]=#0
#1=#1+1
END1

THIS DOES NOT WORK THOU.
THE QUESTION IS WHY????
Can someone explain to me what the "WHILE" and "DO" and "END" statements mean?

I believe "LE" stands for "LESS THAN" right?
#0 is null and can not be written too,but can be referenced.

I want to understand exactly how and why this works so I can possibly work thru this myself.


thanks guys
Jon
Reply With Quote

  #9   Ban this user!
Old 03-24-2007, 08:12 PM
 
Join Date: Sep 2005
Location: USA
Age: 60
Posts: 755
Dan Fritz is on a distinguished road

In your last macro example, you're using #1 as a counter, and the first thing you do is set it to "1" then, inside your loop, you set it to null, so the loop doesn't execute.

If you start the loop with #1=2, then the loop will clear all the variables between 2 and 33, and when the loop is finished #1 will be set to "34". You can then just add another statement setting #1=#0 after the END1, like so:

#1=2
WHILE[#1LE33]DO1
#[#1]=#0
#1=#1+1
END1
#1=#0


LE meand "Less than or Equal To"
Reply With Quote

  #10   Ban this user!
Old 03-24-2007, 11:29 PM
 
Join Date: Nov 2005
Location: Only the USA
Posts: 213
theemudracer is on a distinguished road

Ok, that makes sense now. There are still a few things I dont understand about it thou.

This line inpaticular #[#1]=#0
Why is there a "#" sign out side of the brackets with no number?? I thought the brackets were for calculations, and I dont see any???

Is the DO1 setting the counter to use#1 for the loop then???I think so??

thanks
Jon
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 03-25-2007, 08:47 AM
 
Join Date: Sep 2005
Location: USA
Age: 60
Posts: 755
Dan Fritz is on a distinguished road

The statement:

#[#1]

is an example of "indirect addressing". The variable #1 can have any value from 1 to 34 in your example program, so when you start the loop with the variable #1 set to "2", the statement above is equal to "#2". When you increment the value of #1 to "3", then the statement above is the same as "#3".

Normally, a variable just refers to the memory address of a value. The memory address stays the same, but the VALUE saved in that memory location can be anything.

The statement in your example is an address of an address of a value. Hence the term "indirect addressing". You can even compound this concept by using an address of an address of an address of a value, like so:

#[#[#1]]

.. but this is is too confusing for me. It makes my brains hurt.
Reply With Quote

  #12   Ban this user!
Old 03-25-2007, 09:38 AM
 
Join Date: Nov 2005
Location: Only the USA
Posts: 213
theemudracer is on a distinguished road

Dan, do you know of any books that cover this kind of macro material??


I have not seen anything like this in my Yellow Fanuc manual.

thanks
Jon
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Local variables jorgehrr G-Code Programing 4 02-19-2007 03:03 PM
System variables jorgehrr G-Code Programing 8 02-18-2007 07:26 PM
Variables/Macro use ???? theemudracer G-Code Programing 2 12-11-2006 09:47 AM
Clear Acrylic Fender Stratocaster Guitar HygloCompany Glass, Plastic and Stone 0 02-17-2006 11:49 AM
Clear rubber question? DrStein99 Composites, Exotic Metals etc 24 02-15-2006 10:09 AM




All times are GMT -5. The time now is 01:38 PM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361