KB no longer maintained - MapViewer is a Legacy Product. Legacy Products are still supported, but no longer receive new features or updates. Many of MapViewer's features have been moved to Surfer. Please contact support@goldensoftware.com with any questions. |
This article contains a sample script for extracting data from a data file within the XY specified limits.
To run this script:
- Copy the script below, or click here to download the BAS file: DataExtract.BAS.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\MapViewer 8\Scripter.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
- Change the values in the User-defined variables section to be appropriate for your data.
- Click Script | Run to run the script.
'DataExtract.bas extracts data within the limits specified by ' xmin, xmax, ymin, ymax. Modify the Input statement if not ' 3 columns of comma-delimited data. Sub Main '========================== 'User-defined variables '========================== path$ = "C:\temp\" file1 = path$+"3D Bar Chart.csv" '========================== file2 = Left(file1,Len(file1)-4) & "_Extract.csv" Begin Dialog UserDialog 400,161,"Limits" ' %GRID:10,7,1,1 GroupBox 20,28,360,77,"Limits",.GroupBox1 TextBox 80,42,110,21,.xMin TextBox 80,70,110,21,.yMin TextBox 260,42,110,21,.xMax TextBox 260,70,110,21,.yMax Text 30,42,30,14,"xMin",.Text1 Text 210,42,40,14,"xMax",.Text2 OKButton 60,126,100,21 CancelButton 220,126,90,21 Text 30,77,40,14,"yMin",.Text3 Text 210,77,40,14,"yMax",.Text4 End Dialog Dim dlg As UserDialog 'Initializes the dialog controls dlg.xMin = "2005" dlg.xMax = "2012" dlg.yMin = "53000" dlg.yMax = "56000" Dialog dlg Open file1 For Input As #1 Open file2 For Output As #2 While Not EOF(1) Input #1, a, b, c 'ASCII comma delimited 3-column data only. Debug.Print a If a >= dlg.xMin And a <= dlg.xMax And b >= dlg.yMin And b <= dlg.yMax Then Print #2,a;",";b;",";c numpts = numpts+1 End If Wend
Debug.Print numpts&" points written to " & file2 MsgBox(numpts & " points written to " & vbCrLf & file2) End Sub
Updated December 12, 2018
Comments
0 comments
Please sign in to leave a comment.