Using Caché Basic
Frequently Asked Questions About Caché Basic
Does Caché Basic work only on Windows platforms?
No, Caché Basic is completely platform-independent and works on any platform on which Caché runs. Caché Basic is built into the Caché kernel in the same way as Caché ObjectScript and is not dependent on any external script engine, such as the Microsoft Scripting Host
Is Caché Basic slower than Caché ObjectScript?
No, Caché Basic source is compiled into the same object code as Caché ObjectScript, so the performance of Caché Basic is the same (with minor variations) as that of Caché ObjectScript.
On what breed of Basic is Caché Basic based?
The syntax of Caché Basic is based on Microsoft VBScript. However, since Caché Basic is a server-side scripting language, tightly integrated with the database, there are a number of differences between these two implementations. For instance, there are no MsgBox
functions in Caché Basic, but there are a number of enhancements; for example, the ability to work directly with Caché-specific data types, such as globals, lists, and so on.
Does the introduction of Caché Basic mean that InterSystems is planning to drop support of Caché ObjectScript?
No, the main goal of Caché Basic is to ease the Caché learning curve for developers already familiar with Basic implementations such as Microsoft Visual Basic, not to replace Caché ObjectScript. Both Caché ObjectScript and Caché Basic will be supported and coexist indefinitely.
Are there any other goals beyond easing the learning curve?
Yes, with the introduction of Caché Basic, companies using Caché will gain a number of benefits, including:
Ease in hiring and educating new developers.
Ease in selling applications developed with Caché. End users do not need to study a new language to use and enhance your applications.
Re-hosting business logic of VB and ASP applications in Caché. You can migrate the business logic of existing applications from the VB client side or middle tier into Caché, achieving greater performance and scalability. The combination of CSP and Caché Basic is a good candidate for migrating Active Server Pages (ASP) applications.
No, but nothing prevents you from implementing your own. Contact an InterSystems representative for an example of a Caché Basic shell.
How do I work with globals in Caché Basic?
You can directly reference globals using the following syntax:
Caché Basic Syntax Elements
There are a number of enhancements in Caché Basic for List
support. For example:
l = ListBuild("blue","red")
p = "blue^red"
noOfItems = Len(p,"^")
Is there any analog to $Order
in Caché Basic?
i = Traverse(^MyData(""))
While (i <> "")
i = Traverse(^MyData(i))
How do I work with objects in Caché Basic?
Caché Basic and Objects Quick Reference
|Caché Basic syntax
||call class method
||current object property/method
||create new object
||open object instance
How do I work with SQL in Caché Basic?
Use a dynamic query object:
result = New %ResultSet()
result.Prepare("SELECT Name,Age FROM Basic.Human WHERE Age<?")
Println result.Data("Name") & ", " & result.Data("Age")
How do I work with files in Caché Basic?
file = New %File("c:\test.txt")
file.WriteLine("This is a test")
How do I trap errors in Caché Basic?
On Error Goto errorhandler
PrintLn "Error ", Err.Number, " ", Err.Description, " ", Err.Source
Why don’t I get an <UNDEFINED> error in Caché Basic?
In Basic, each variable is the empty string by default, so instead of an <UNDEFINED> error you get "" when referring to an undefined variable or function.
Can I call Caché ObjectScript programs from Caché Basic and vice versa?
Yes, you can call both methods and functions/procedures, regardless of the language they are written in.
Why can’t I see local variables outside of the scope of my procedure?
This is correct behavior; the Basic language defines this functionality. The scope of all variables is limited to the procedure or function where it was defined. Exceptions are variable names that start with the %
symbol, such as %myvar
How can I convert date and time values to and from $H format?
myDate = "07/15/2002"
println DateConvert(myDate, vbToInternal) ' returns $H format
myHDate = 59000
println DateConvert(myHDate, vbToExternal)
Can I use indirection in Caché Basic?
I suspect there is a bug in Caché Basic. What should I do?
I would like a particular feature in Caché Basic. Can InterSystems implement this?