On Thursday, March 08, 2012 10:05:56 AM Jan de Kruyf did opine: > Gene, > I dont know, but sometimes Cprogrammers designing a new (linuxcnc) > language seem to be infected by C rules. > > So K&R says that the scope of a variable does not extend outside the > block where it is defined (read: first assigned to, in this case) > > Now a compound statement (a sequence of statements) under an if, else, > for, while, do, etc. construct is such a block. > > Quite logical really, beause who says that the program willl follow the > exact path through the block where you first defined your variable. > > so better safe than sorry and the variable goes up in smoke as soon as > you leave such a block. > > AND if there was a variable with the same name before you entered this > block, that var will come back alive. > while inside the block it was in hybernation, because you called a new > variable with the same name into being, by assigning to it. > > j.
Which, from the clues I am being tripped up over, would seem to be the case. And yes, I have carved some C code in a past life, so I know exactly how that works IN C. But when the docs say that a named variable, in this style "#<name>" is local, I assume it only lives as long as that subroutine invocation because it is created on the stack. That to me is a given. But when the docs say that "#<_name>" is a global variable, and I have found that I can stop linuxcnc, edit a file, then restart linuxcnc and the contents of that globally defined variable are still there when linuxcnc is restarted, same with #numbered vars, I figure they are truly global. I experimented at length with exactly that sequence of events between runs of gcode when I was writing the inserts to make pcb2gcode work, then came to the conclusion I was using something that could be broken silently at any time by a linuxcnc update, and switched my working premise to one of adjusting the G55-56 co-ordinate systems instead. It is a PIMA to me, when: #<_loop_var> = 0.000 #<_var_inc> = 0.010 #<_end_var> = 1.000 o300 while [#<_loop_var> lt #<_end_var>] #<_loop_var> = [#<_loop_var> + #<_var_inc>] (debug, loop_var = #<_loop_var>) ( You see it being incremented ) o300 endwhile (debug, loop_var> = #<_loop_var>) and its either the original 0.000 in the 2nd debug statement, or in the case previously at hand, totally NE, printing #.#########! And that variable was being assigned a value completely outside of any oword stuff. A globally named var that is derived from a math operation immediately after the source values that math depends on has been assigned at the top of the file and which then disappears, becoming undefined after having been successfully used 360,000 times in that file, is to me, a bug. Convince me otherwise. ;-) I have that part of that part carved, the finish looks good except for a small artifact in the Y table reversals that probably would have disappeared if the F speed hadn't been 100% of the machines capabilities. Or perhaps the nut is wearing. :( They aren't much on that mill. Now I need to drill holes, 3 each clearance and 3 each tap size for the 10-32 jack screws, turn it over & face the back flat, drill & tap 3 holes in the gear after using my centerfinder code on the gears existing hub hole, and cutting the matching taper into its center hole, assemble it to the gear & chuck that in the lathe & make it round & smaller than the gear. First things first though. I spent most of yesterdays great warm weather installing a trailer towing harness in the Toyota (getting through the firewall was fun, about 4 hours screw around before I finally just drove a 6" piece of 1/4" brass tubing completely through the packing gland the main vehicle harness goes through the firewall in, just to get a piece of 12 gage wire to a fuse attached to the battery. Today I find my other Reese hitch insert, fire up the lawnmower to get my trash trailer turned around & hung on the Toy, take that to the landfill, and stop on the way back to get the long block I'll be putting in my 99 GMC. Mine has warped heads and all the antifreeze I put in eventually winds up in the pan. I am busier now than before I 'retired'! Before I finished with this email, the neighbors were at the door with their engine crane, & ready to go to work. Later, lots later I suspect. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: <http://coyoteden.dyndns-free.com:85/gene> You will probably marry after a very brief courtship. ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users