Cleaner Code Vol. 2

By David Gyenes, Director of IT

Last week we saw an example of what kinds of code can be used for creating a new record in a table. But how can I return different values from it?

In this first example I show how to return a single value – the ID number of the newly created record:

							
					let xReturn := do as server
		let xRec := 0;
		(create ‘Test Table’).(
			xRec := number(Id);
			‘Text field’ := “New”
		);
		xRec
	end;
popupRecord(‘Test Table’, xReturn)				
			

Here is how I return multiple values from the new record and then retrieve one of them. I can retrieve any of the values in this way:

							
					let xReturn := do as server
		let xRec := 0;
		let xName := “”;
		let xAge := 0;
		(create ‘Test Table’).(
			xRec := number(Id);
			Name := “Jon”;
			xName := Name
		);
		{
			RecordID: xRec,
			Name: xName
		}
	end;
xReturn.Name				
			
en_USEN