Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 30-Sep-2024 18:13:54

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,527
Website

problem: something faulty with assigning function to object [solved]

hello

I define the object QRSCoordinate as this:

struct QRSCoordinate=[
	posq:	I,
	posr: I,
	poss: I
	]mkQRSCoordinate;

and the object Hexagon as this:

struct Hexagon=[
	VQRScenter:	QRSCoordinate,
	Isize:	I,
	lxypoints:	tab XYVertex,
	lqrspoints: tab QRSCoordinate,
	funcwithinbounds: fun [[Hexagon XYVertex]] I,
	funmakeqrsvertices: fun [Hexagon] [tab QRSCoordinate],
	funconvert_xy_to_qrs: fun [Hexagon][I I I],	
	funconvert_qrs_to_xy:	fun [Hexagon][I I]


	
	]mkHexagon;;

the code includes this function, which should return a table of QRSCoordinate objects:

  fun create_vertex_qrscoordinates(hex)=
		
			set hex.lqrspoints = mktab 6 nil;
			let hexvqrsvectors -> globalvectorlist in
			let hex.VQRScenter -> hexcenter in
			let hexcenter.posq-> q in
			let hexcenter.posr -> r in
			let hexcenter.poss -> s in
			let hex.Isize -> size in
			let 0 -> counter in
			(
				while (counter<(  sizetab hex.lqrspoints)) do
					(
						let globalvectorlist.counter-> this_vector in
						let this_vector -> [this_vector_q this_vector_r this_vector_s] in
							(
								
							let mkQRSCoordinate [50 0 0]-> thisvertex in 
							
							(
							
							
							set hex.lqrspoints.counter = thisvertex;
		
						
							0;
							);
							set counter = counter+1;
							0;
						
							);
						0;
					);
				
			0;
	
			);
	
	let  hex.lqrspoints-> table in
	table;;

when I use mkHexagon here:

fun inithex()=

		let mkXYVertex  [1 1]  -> xyvert in
		_fooS itoa xyvert.posx;
		let mkXYVertex  [1 1]  -> xyvert in
		let mktab 5 xyvert  -> xytab in
		let mkQRSCoordinate [0 0 0] -> center in 
		let mkHexagon [center 10 xytab nil nil  nil nil nil]-> hex in
		let mkXYVertex  [10 20]  -> xyvert in
		let mktab  1 xyvert  -> xytab in
		let xytab.0-> xvert in

		(
			createqrshexvectors hex;
			//set hex.funmakeqrsvertices = @create_vertex_qrscoordinates
			create_vertex_qrscoordinates hex;
			0;
		);
		0;;

and I uncomment:

//set hex.funmakeqrsvertices = @create_vertex_qrscoordinates

the scol machine won't run the function, even though (I think), create_vertex_qrscoordinates takes a hex as an input and returns a table of mkQRSCoordinate , which is what (I think) corresponds to

funmakeqrsvertices: fun [Hexagon] [tab QRSCoordinate],

in the Hexagon struct definition.

any input is welcome

thanks!

Last edited by hebdemnobad (30-Sep-2024 18:26:18)

Offline

#2 30-Sep-2024 18:26:00

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,527
Website

Re: problem: something faulty with assigning function to object [solved]

ok i found the error

In the struct I had [] braces where in the prototype return type i should not have had them for the function prototyping.

I changed

	funmakeqrsvertices: fun [Hexagon] [tab QRSCoordinate],

to

	funmakeqrsvertices: fun [Hexagon] tab QRSCoordinate,

and the code runs without a problem

Last edited by hebdemnobad (12-Oct-2024 18:04:32)

Offline

Board footer

Powered by FluxBB