| Knowledgebase Home | Contact |
| My script works in Surfer 9, but in Surfer 10 I get an error: Operand/operator type mismatch. It stops on a line inside a loop. Why? | |||||||||
For example, this portion of a script works in Surfer 9, but fails in Surfer 10 on the red line: For i = 1 To 3 Dim Plot As Object Set Plot = SurferApp.Documents.Add Path = "c:\temp\SAMPLE"+i Dim Map As Object Set Map = Plot.Shapes.AddContourMap(GridFileName:=Path+".grd") Next i See how “i” is used as part of the string in the Path statement, but really “i” is a number (1 to 3). As mentioned above, the new Scripter doesn’t have a way to convert a number (i) to a string (part of the file path) and so you have a numbers and string in the command line and you get the type mismatch error. To fix this, you need to use the Format statement to convert the number to a string: For i = 1 To 3 Dim Plot As Object Set Plot = SurferApp.Documents.Add Path = "c:\temp\SAMPLE"+Format(i) Dim Map As Object Set Map = Plot.Shapes.AddContourMap(GridFileName:=Path+".grd") Next i |
| Visitor Comments |
| No visitor comments posted. Post a comment |
| Attachments |
| No attachments were found. |