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 or
InputBox functions
in Caché Basic, but there are a number of enhancements; for example,
the ability to work directly with Caché-specific datatypes, such as
globals, lists etc.
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 and
Piece support.
For example:
l = ListBuild("blue","red")
Println List(l,1)
p = "blue^red"
noOfItems = Len(p,"^")
Println Piece(p,"^",1)
Is there any analogue to
$Order in Caché
Basic?
i = Traverse(^MyData(""))
While (i <> "")
Println ^MyData(i)
i = Traverse(^MyData(i))
Wend
How do I work with objects in Caché Basic?
Caché Basic and Objects Quick Reference
Caché Basic syntax |
Objects reference |
"Basic.Human".ClassMethod() |
call class method |
obj.Report() |
instance method/property |
Me.Name="Anton" |
current object property/method |
obj=New Basic.Human() |
create new object |
obj=OpenId Basic.Human(1) |
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<?")
result.Execute(Arg1)
While (result.Next())
Println result.Data("Name") & ", " & result.Data("Age")
Wend
How do I work with files in Caché Basic?
file = New %File("c:\test.txt")
file.Open("WSN")
file.WriteLine("This is a test")
file.Close()
How do I trap errors in Caché Basic?
Function ErrorTest(Arg1)
On Error Goto errorhandler
return 1/Arg1
errorhandler:
PrintLn "Error ", Err.Number, " ", Err.Description, " ", Err.Source
Err.Clear
return 0
End Function
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.
do Procedure^BasicRoutine()
do ##class(MyClass).BasicClassMethod()
Procedure@ObjectScriptRoutine()
"MyClass".ObjectScriptMethod()
Can I create SQL triggers in Caché Basic?
No, not in Caché 5, but this feature is planned for a future
release.
How do I call
$ZU functions from Caché Basic?
You cannot call them directly. Create a wrapper class with class methods
written in Caché ObjectScript and then call these methods from Caché
Basic.
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 need a particular feature in Caché Basic. Can InterSystems
implement this?
Caché Basic is ready to use, but still open for enhancements.
Send your ideas to
andreas@intersystems.com. If your
idea is reasonable, InterSystems may decide to implement it in a future version.
I have comments and suggestions for this document. What should I do?