Hi Edouard
I'd suggest that you present the user with these choices in a listbox or popupmenu.
The values in the control would be read from a table and when doing so you could read the names and the actual buffer value into two arrays
Fetch First From BufferSizes
Do Until EOT(BufferSizes)
i = i + 1
Redim arrBufferSizeNames(i)
Redim arrBufferSizeValues(i)
arrBufferSizeNames(i) = BufferSizes.Name
arrBufferSizeValues(i) = BufferSizes.Value
Fetch Next From BufferSizes
Loop
You can now present the user with the option to pick one of these values
Dialog
Title "Buffer Size"
Control ListBox
Width 100
Title From Variable arrBufferSizeNames
Value 1
Into nBufferSizeItem
OKButton
CancelButton
Next, after the user selected a buffer size and clicks OK, you can get the buffer width from the array holding these and use that width in your statement
Create Object As Buffer From Selection
Width arrBufferSizeValues(nBufferSizeItem) Units "m"
Type Spherical Resolution 30
Into Table NewBuffers
Please note that the code above hasn't been tested so there may be a glitch or two :-)
If you want to update an existing table with buffers around the existing objects, there is also the Buffer() function.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------
Original Message:
Sent: 06-23-2023 00:42
From: Edouard Loisance
Subject: Buffering based on distances in table
Hello all,
I am trying to create a MapBasic program whereby the user is prompted to type in a criterion (e.g. "Enter size as either small, medium or large") and based on what has been entered, a buffer is drawn off a selected polygon. The buffer radius would be looked up from a table that has, for each size (small / medium / large), the radius in metres.
So I would like to understand whether there is a function that allows for the buffer radius to be picked up from another table based on what the user has entered. In the code extract below, is it possible to replace the number after "width" with a function or variable?
"Create Object As Buffer From Selection Width 10 Units "m" Type Spherical Resolution 30 Into Table"
Many thanks,
Edouard
------------------------------
Edouard Loisance
Anderson Environmental & Planning
CARRINGTON NSW
------------------------------