The Texas Business Software offers server-side tscripts that behave similar to the inbuilt methods. This enables intelligent and capable end users to write their own server methods that can do whatever they want. This is very dangerous when creating tscript methods that update or delete data, and is something we offer with the expectation of installing once off customisations for particular customers. Even though these scripts need not be written by us, it is strongly recommended you leave it to us and restrict yourself to read only queries.
Below is the tscript to obtain the latest currency conversion rates. By using tscript you can change to supplier and format of the remote server to whichever is your preferred supplier.
#include "HTMLClient.ts" #include "TexasDB.ts" public main(Structure parameters: Structure editedList) { TexasDB database; ODBPP::Object objectHandle; Structure currencies, results; BString key1, key = Bx1c;//28 database.OpenDatabase(parameters.DatabasePath); database.BeginTransaction(editedList.reference); database.OpenTable(TexasDB::TABLE_SETTINGS); database.OpenTable(TexasDB::TABLE_CONVERSIONS); database.ReadIndex(TexasDB::TABLE_SETTINGS, CODBPP::GREATER_THAN|CODBPP::NO_LOCK,1,key:objectHandle); while(objectHandle.fixed.SubString(0,4).Integer() == 28){ key = ((objectHandle.fixed.SubString(4,1).Integer() & 0xff) - 'A') << 10 | ((objectHandle.fixed.SubString(5,1).Integer() & 0xff) - 'A') << 5 | ((objectHandle.fixed.SubString(6,1).Integer() & 0xff) - 'A'); currencies[key] = objectHandle.fixed.SubString(4,4).AString(); if(!database.ReadIndex(TexasDB::TABLE_SETTINGS, CODBPP::NEXT|CODBPP::NO_LOCK,1:objectHandle)){ if((error & 0xffff) != CODBPP::NOT_FOUND_INDEX_KEY) return error; break; } } HTMLSession session("www.webservicex.net"); HTMLDocument document; for(key = currencies.FirstIndex(); key < currencies.length; key = currencies.NextIndex(key)){ for(key1 = currencies.NextIndex(key); key1 < currencies.length; key1 = currencies.NextIndex(key1)){ database.NewObject(TexasDB::TABLE_CONVERSIONS:objectHandle); objectHandle.fixed.Copy(key,4,2); objectHandle.fixed.Copy(key1,6,2); objectHandle.fixed.Copy(parameters.TimeStamp,16,8); session.GetDocument( "/CurrencyConvertor.asmx/ConversionRate?FromCurrency=" +currencies[key]+"&ToCurrency="+currencies[key1]:document); if(document.status == 200){ results.SetStructure(document.data,TVariable::XML); objectHandle.fixed.Copy(results.double.Decimal(),8,4); session.GetDocument( "/CurrencyConvertor.asmx/ConversionRate?FromCurrency=" +currencies[key1]+"&ToCurrency="+currencies[key]:document); if(document.status == 200){ results.SetStructure(document.data,TVariable::XML); objectHandle.fixed.Copy(results.double.Decimal(),12,4); database.AddObject(TexasDB::TABLE_CONVERSIONS); } else return error = document.status, error = "Unable to gain currencies conversion:-\n" +document.statusMsg; } else return error = document.status, error = "Unable to gain currencies conversion:-\n"+document.statusMsg; } } database.CommitTransaction(); }