I don't have your applications, so I can't test or look up the names of your fields and such, but it would go something like this.
#include "sbasic_include.sbas" // This line should go in GLOBAL CODE
var vNum as Int
var vVendor as String
var vRS as Int
vNum = @ToNumber(@GlobalValue("LastVendor")) // Get the last used vendor id
If vNum < 199 vNum = 199 // Enforce a start value of 200
vNum = vNum + 1 // Increment vendor id
GlobalValue("LastVendor", @Str(vNum)) // Put new value into LastVendor for next time
vVendor = @Left(PayTo, 2) + @Str(vNum) // Assemble the new Vendor Number
// Open an external resultset. You may need to change the name/path of the application/database/fields to match
// what you have. I'm also assuming that there are no records with a blank vendor number because I want an
// empty resultset.
vRS = @XResultSetSearch("Contacts.db", "Contacts", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!VendorNumber==")
if(vRS > -1)
{
XResultSetCreateNewRecord(vRS) // Make a new record
XResultSetValue(vRS, "VendorNumber", vVendor) // Fill in all the fields
XResultSetValue(vRS, "PayTo", PayTo)
XResultSetValue(vRS, "Address", Address)
XResultSetValue(vRS, "City", City)
XResultSetValue(vRS, "Prov", Prov)
XResultSetValue(vRS, "pc", pc)
XResultSetClose(vRS) // Close the ResultSet
}