- GCode and Part Programs
- G&M Codes
- Named Parameter Indirection (like arrays of variables in other languages)
Named Parameter Indirection (like arrays of variables in other languages)
- yeltrow
- Offline
- Senior Member
- 
				  
		Less
		More
		
			
	
		- Posts: 65
- Thank you received: 3
			
	
						15 Apr 2018 19:10				#109085
		by yeltrow
	
	
		
			
	
			
			 		
													
	
				Named Parameter Indirection (like arrays of variables in other languages) was created by yeltrow			
			
				I would like to use arrays so that I can have a custom action run on arbitrary places on a gridded fixture.  Imagine milling custom sized pockets for coins in a grid.  I run batches of custom jobs so having a standard DEBUGGED program with a parameter area would be very handy.  I would like to supply something like
(first coin)
#<n> = 0
#<coin_x[#<n>]> = 1
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 1
( second coin)
#<n> = #<n> + 1
#<coin_x[#<n>]> = 3
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 1.25
( third coin)
#<n> = #<n> + 1
#<coin_x[#<n>]> = 5
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 0.8
Ideally retrieval of the data would be something like G0 X<coin_x[#<n>]> --- but I haven't been able to make that work.
This flat out doesn't work. The calculation of the array index gets taken literally as the parameter name of a named parameter.
What CAN work is using something like
(data size of 3 parameters)
#<d_size> = 3
( user parameter location start of array)
#<d_base> = 500
#<n> = 0
(first coin data)
#[d_base + #<d_size> * #<n> + 0 ] = 1
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] = 1
(next coin data)
#<n> = #<n> + 1
#[d_base + #<d_size> * #<n> + 0 ] = 3
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] = 1.25
(next coin data)
#<n> = #<n> + 1
#[d_base + #<d_size> * #<n> + 0 ] = 5
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] =0.8
retrieval would look something like G0 X#[d_base + #<d_size> * #<n> + 0 ]
(zero is the offset from the start of data block for that coin for the "X" variable. Maybe #<x_var>???)
But that is SO GROSS. Any more elegant solutions? Maybe some O code to get/set parameters?
Thank you for your thoughts!
					(first coin)
#<n> = 0
#<coin_x[#<n>]> = 1
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 1
( second coin)
#<n> = #<n> + 1
#<coin_x[#<n>]> = 3
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 1.25
( third coin)
#<n> = #<n> + 1
#<coin_x[#<n>]> = 5
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 0.8
Ideally retrieval of the data would be something like G0 X<coin_x[#<n>]> --- but I haven't been able to make that work.
This flat out doesn't work. The calculation of the array index gets taken literally as the parameter name of a named parameter.
What CAN work is using something like
(data size of 3 parameters)
#<d_size> = 3
( user parameter location start of array)
#<d_base> = 500
#<n> = 0
(first coin data)
#[d_base + #<d_size> * #<n> + 0 ] = 1
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] = 1
(next coin data)
#<n> = #<n> + 1
#[d_base + #<d_size> * #<n> + 0 ] = 3
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] = 1.25
(next coin data)
#<n> = #<n> + 1
#[d_base + #<d_size> * #<n> + 0 ] = 5
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] =0.8
retrieval would look something like G0 X#[d_base + #<d_size> * #<n> + 0 ]
(zero is the offset from the start of data block for that coin for the "X" variable. Maybe #<x_var>???)
But that is SO GROSS. Any more elegant solutions? Maybe some O code to get/set parameters?
Thank you for your thoughts!
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- 
				  
- Away
- Platinum Member
- 
				  
		Less
		More
		
			
	
		- Posts: 4686
- Thank you received: 1433
			
	
						15 Apr 2018 21:21				#109094
		by Todd Zuercher
	
	
		
			
	
			
			 		
													
	
				Replied by Todd Zuercher on topic Named Parameter Indirection (like arrays of variables in other languages)			
			
				You can set up a repeat array with an o-sub and two repeat calls here is an example.
forum.linuxcnc.org/49-basic-configuratio...9-array-offset#47103
					forum.linuxcnc.org/49-basic-configuratio...9-array-offset#47103
Please Log in or Create an account to join the conversation.
- andypugh
- 
				  
- Offline
- Moderator
- 
				  
		Less
		More
		
			
	
		- Posts: 19677
- Thank you received: 4554
			
	
						24 Apr 2018 16:01				#109552
		by andypugh
	
	
		
			
	
			
			 		
													
	
				Replied by andypugh on topic Named Parameter Indirection (like arrays of variables in other languages)			
			
				You can do indirection with _numbered_ parameters. It is even documented.			
					Please Log in or Create an account to join the conversation.
- GCode and Part Programs
- G&M Codes
- Named Parameter Indirection (like arrays of variables in other languages)
		Time to create page: 0.067 seconds	
