![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| Fanuc Discuss Fanuc controllers here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
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 |
|
#3
| ||||
| ||||
| #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 |
|
#4
| |||
| |||
I would assume this WHILE[#100LE199]DO1 |
|
#6
| ||||
| ||||
| #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. |
|
#8
| |||
| |||
| 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 |
|
#9
| |||
| |||
| 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" |
|
#10
| |||
| |||
| 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 |
| Sponsored Links |
|
#11
| |||
| |||
| 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. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
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 |