发布新帖

查找

文章
· 五月 26, 2016 阅读大约需 2 分钟

NewBie's Corner Session 5 Operator Precedence

NewBie's Corner Session: 5 Operator Precedence

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

Click on the Caché Cube in your system tray and select Terminal to try out the commands.

Order Precedence means the order in which mathematical operators are executed. In a Mathematical expression, you may have Multiplication, Addition, Subtraction, and Division. Which of these are executed first, second, third, etc.?

The basic Operator Precedence of mathematics is:

       Multiplication and Division has precedence over Addition and Subtraction

In normal mathematics when you encounter an expression like 5+7*10, the multiplication and division is executed first, and then addition and subtraction, so 5+7*10 is 75 (7*10=70+5=75).

However, in Caché the Operator Precedence is strictly left to right,

So:  5+7*10=120  (5+7=12*10=120).

Write 5*7+6                       ; Operator Precedence in Caché same as in Mathematics
41                                                          
Write 4+6*10/5                 ; Caché Operator Precedence 4+6=10, 10*10=100, 100/5=20
20
Write 4+(6*10/5)             ; Mathematical Operator Precedence: 4+(60/5)
16

If you want your expressions interpreted a specific way, you must use parenthesis around the expressions you want evaluated first.  Although this concept seems simple enough, I would dare say there is not a Caché/MUMPs programmer alive that has not been bitten by Operator Precedence, keep an eye on this one.

Until next time.

--Mike Kadow

PaulMikeKadow@gmail.com

If you have a comment, please respond through the InterSystems Developer Community, don't send me private email. Unless of course you wish to address me only.

See NewBie Index for an index of all NewBie Corner posts.

There is no reason for any individual to have a computer in his home.

Software comes from heaven when you have good hardware.

The nicest thing about standards is that there are so many of them to choose from.

                Ken Olsen, founder and CEO of Digital Equipment Corporation, 1977

讨论 (0)0
登录或注册以继续
文章
· 五月 26, 2016 阅读大约需 1 分钟

Caché and virus scanners

Post updated in August 2025 to include links to IRIS.

I have seen customer problems where the use of a virus scanner running over Caché or IRIS databases was causing intermittent application slowdowns and bad user response times.

This is a surprisingly common problem, so this short post is just a reminder to exclude key Caché and IRIS components from your virus scanning.

2 Comments
讨论 (2)3
登录或注册以继续
文章
· 五月 17, 2016 阅读大约需 3 分钟

NewBie's Corner Session 3 More Read and Write commands & Multiple commands

NewBie's Corner Session 3 More Read and Write commands & Multiple commands

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

Click on the Caché Cube in your system tray and select Terminal to try out the commands.

Write command with carriage return and line feed

When the exclamation point "!" is inserted after a Write command, a carriage return and line feed combination is produced. Note in this example, that a comma separates the exclamation point from the variable "X".

Set X=12
Write !,X
                                                ; carriage return and line feed inserted here
12

Multiple variables may be set with one Set command and the Write command does the same

Set X=12,Y=13,Z=14         ;single Set command with variables separated by commas
Write X,Y,Z                          ;single Write command with multiple variables
121314

Now here is where the carriage return and line feed come in

Write !,X,!,Y,!,Z
12
13
14

Other Read and Write operators

Exclamation point (!) – Inserts a carriage return / line feed (already shown)

Hash symbol (#)

        The Hash symbol or pound sign (#) serves two purposes:

                Write # - inserts a formfeed

                             Write #,"Just after a formfeed" 

Read – limits the number of characters' read

                Read entry#5    ; will accept the first 5 characters only

                Integer required

Question mark (?) - Write advancing a number of spaces from the beginning of the line

                               Write ?10,"Now is the time"   ;   will start writing at column 10

                Integer required

Colon (:) - Read command timer

                Read entry:5    ; will only wait 5 seconds before terminating read

Integer required


--Mike Kadow

PaulMikeKadow@gmail.com

If you have a comment, please respond through the InterSystems Developer Community, don't send me private email. Unless of course you wish to address me only.

See NewBie Index for an index of all NewBie Corner posts.

1 Comment
讨论 (1)0
登录或注册以继续
问题
· 五月 16, 2016

Roman Number Converter

Hi, 
My name is Sergio Fernandes and I'm from Brazil.
I would like to know how can i use MVBasic at Cache Terminal or .csp.
My original problem is to converter Integer Numbers to Roman Numbers and consulting cache documentation I found "Conversion Codes" at http://localhost:57772/csp/docbook/DocBook.UI.Page.cls?KEY=GVRF_basicfea...
My version is Intersystems Ensemble 2013.1.6.950.0
Thanks a lot,

Sérgio Fernandes

3 Comments
讨论 (3)0
登录或注册以继续
文章
· 五月 11, 2016 阅读大约需 1 分钟

ZZPRINT a handy way to view routine lines from the command line

Often when debugging COS code you get an error message such as '<UNDEFINED>test^routine *test' so the first thing you want to do is to take a look at this code and see what it is doing. From the command line you can:

ZLOAD routine ZPRINT test

Which means splitting the $zerror information into the routine name and the line and adding the zload/zprint commands. Also you often want to view the lines above the one where the error happened as this gives you some context of how you got to this line, using ZPRINT you could 'ZPRINT +1:test' but that may display hundreds of lines.

Since 2013.1 you can use ZZPRINT as follows:

ZZPRINT "test^routine":10

Which will print the 10 lines before the 'test^routine' line, so here you can cut/paste the line reference directly into the command and you can specify the number of lines before or after using this syntax where both the before or after can be blank:

ZZPRINT "<entry+offset^routine>":<before lines>:<after lines>

Also since 2015.2 you can display the current $zerror line with and the ten lines before with:

ZZPRINT "$ze":10

Also if you are in the command line debugger then you can display the current break point location with:

ZZPRINT "*":5:5

Will display the current location and 5 lines previous and 5 lines after.

6 Comments
讨论 (6)2
登录或注册以继续