Malvern Instruments Zetasizer, Zetasizer 3000, Zetasizer 4000, Zetasizer 2000, Zetasizer 1000 Basic Reference Manual

...
Looking for more information?
Visituson the
Price
web
at http://www.artisan-scientific.com for more information:
Drivers·
Technical
Specifications.
Manuals and Documentation
Artisan
Scientific
TensofThousandsofIn-Stock
HundredsofManufacturers
is
You~
Source
Items
Supported
for:
Quality
Service Center Repairs
Experienced Engineers and Techniciansonstaffinour State-of-the-art Full-Service In-House Service Center Facility
We
bUy
used
equipment!
Sell
your
excess.
Talk to a liveperson: 88EM38-S0URCE fB88-887-68721 I Contact
underutilized. and idle used equipment. Contact oneofour
We
New
Fast
Leasing
and
Certified-Used/Pre:-awned ECJuiflment
Shipping and
/ Monthly
DelIve1y
Rentals
• Equipment Demos
Consignment
InstraView Remote Inspection
Remotely inspect equipment before purchasing with Innovative InstraView-website at http://www.instraview.com
also
offer
credit
usbyemail: sales@artisan-scientific.com I Visit ourwebsite: http://www.artisan-scientific.com
for
Buy-Backs
and
Customer
Trade-Ins
Service
Representatives todayl
our
ZETASIZER BASIC
ZETASIZER 1000/2000/3000
4000/5000/4700
Manual Number MAN 0179
Issue 1.0
February 1997
© Malvern Instruments Ltd, 1997.
Spring Lane South, Malvern, Worcs.WR14 1XZ
Telephone: +44 (0) 1684 892456 Fax: +44 (0) 1684 892789
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Malvern Instruments Ltd. 1997
Malvern Instruments makes every effort to ensure that this document is correct. However, due to Malvern Instruments policy of continual product development we are unable to guarantee the accuracy of this, or any other document after thedate of publication. We thereforedisclaimallliabilityfor any changes,errorsor omissions after the dateofpublication.
Noreproductionortransmissionofanypart of this publication is allowed without the express written permission of Malvern Instruments Ltd.
Head office: Malvern Instruments Ltd. Spring Lane South, Malvern. Worcestershire. WR14 1XZ U.K.
Tel + [44] (0) 1684-892456 Fax + [44] (0) 1684-892789
Printed in England
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Contents MAN 0179
CHAPTER 1
1.1 Welcome 1-1
1.2 Systems covered by this manual 1-1
1.3 Asumed information 1-1
1.4 Windows Terms 1-1
1.5 Menu Commands 1-3
1.6 Where to find information 1-3
1.7 Reporting Problems 1-3
1.8 Other reading 1-4
CHAPTER 2
2.1 Introduction 2-1
2.2 Building blocks of programs 2-2
2.3 Commands and functions 2-3
2.4 Constants and variables 2-3
2.5 Arrays 2-4
2.6 Expressions and operators 2-5
2.7 Control Structures 2-6
2.7.1 Tests and Branches 2-7
2.7.2 Subroutines 2-8
2.7.3 Loops 2-9
2.7.4 Nesting 2-10
2.8 Special programs in Zetasizer Basic 2-10
2.9 Functions - a review 2-11
2.10 Writing and running programs 2-11
2.10.1 Running a program 2-12
2.10.2 Assigning Programs to Keys and Menu 2-12
2.11 Program Errors 2-12
2.11.1 Basic Errors 2-13
CHAPTER 3
3.1 Introduction 3-1
3.2 Writing page description programs 3-1
CHAPTER 4
4.1 List of All commands and functions 4-1
4.1 Abort Command 4-5
4.2 ABS() Function 4-5
4.3 Achannel Function 4-5
4.4 ACOS Function 4-5
4.5 AnalysisType Function 4-6
4.6 Analysis Command 4-6
4.7 Angle Command 4-7
4.8 ASC Function 4-7
4.9 Asin Function 4-7
4.10 Asm Command 4-7
4.11 BackGround Function 4-9
4.12 BackGroundRatio Function 4-9
4.13 Bchannel Function 4-10
4.14 Beep Command 4-10
4.15 Box Function 4-10
4.16 CalcFarPoint Function 4-10
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 1
MAN0179
4.17 Calculate Command 4-11
4.18 CalcZimm Command 4-11
4.19 Capscan Command 4-11
4.20 ChangeTable Command 4-11
4.21 ChDir Command 4-11
4.22 Chr$(character) Function 4-11
4.23 Clear Command 4-12
4.24 Comm Command 4-12
4.25 Common Command 4-12
4.26 Copy Command 4-13
4.27 Corr Command 4-13
4.28 Cos( ) Function 4-15
4.29 CountsPerSec Function 4-16
4.30 CountsPerST Function 4-16
4.31 CurrentTime Function 4-16
4.32 Data Function 4-16
4.33 DataType Function 4-18
4.34 DateFormat Command 4-18
4.35 Dde Command 4-18
4.36 Delay Function 4-19
4.37 Delete Command 4-19
4.38 Dilation Function 4-20
4.39 Dim Command 4-20
4.40 Duration Function 4-20
4.41 Edit Function 4-21
4.42 ElapsedTime Function 4-22
4.43 ElectroMobility 4-22
4.44 Else Command 4-22
4.45 Enable Command 4-22
4.46 Else Command 4-23
4.47 End Command 4-23
4.48 EndAngle 4-23
4.49 Error Function 4-24
4.50 Execute Command 4-24
4.51 Exit Command 4-24
4.52 EXP Function 4-24
4.53 File Command 4-25
4.54 FillColour 4-25
4.55 FirstPoint Function 4-25
4.56 Fit Function 4-26
4.57 Fitdata Function 4-26
4.58 FitNum 4-26
4.59 FitOrder Function 4-26
4.60 FitTime Function 4-26
4.61 FitResiduals Function 4-27
4.62 Font Command 4-27
4.63 For Command 4-27
4.64 Format$ 4-28
4.65 Frequency Function 4-28
4.66 FrequencyChannels Function 4-28
4.67 Get Function 4-29
4.68 Gosub command 4-30
4.69 Goto 4-30
4.70 Graph 4-31
4.71 Keep command 4-32
Page 2 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Contents MAN 0179
4.72 If Command 4-32
4.73 Inp Function 4-33
4.74 Input Command 4-33
4.75 InRange Function 4-33
4.76 InStr function. 4-34
4.77 Int Function 4-34
4.78 Intensity Function 4-34
4.79 Iscan Mode command 4-34
4.80 InstrumentType Function 4-35
4.81 LastPoint Function 4-35
4.82 LCase$ Function 4-35
4.83 Left$ Function 4-36
4.84 Len Function 4-36
4.85 Line Command 4-36
4.86 LineColour Command 4-36
4.87 LineTo Command 4-37
4.88 Ln Function 4-37
4.89 Load Command 4-37
4.90 Log Function 4-38
4.91 LTrim$ Function 4-38
4.92 MAddSelect Command 4-38
4.93 Mcalculate Command 4-38
4.94 MeasFarPoint Function 4-39
4.95 Measure Command 4-39
4.96 Merit Function 4-40
4.97 Message Function 4-40
4.98 Mid$ Function 4-41
4.99 Mie Function 4-41
4.100 Mload Command 4-42
4.101 Mobility Function 4-42
4.102 MobilityChannels Function 4-43
4.103 MolecularWeight 4-43
4.104 Move (x,y) 4-43
4.105 Mprint Command 4-43
4.106 Msave 4-44
4.107 MSelect 4-44
4.108 Number function 4-44
4.109 NumChannels function 4-45
4.110 NumFreq Function 4-45
4.111 NumScans Function 4-45
4.112 NumSizes 4-45
4.113 Open Command 4-45
4.114 OsmoticMob Function 4-46
4.115 Out Command 4-46
4.116 Page Command 4-47
4.117 Pause 4-47
4.118 Peak Command 4-47
4.119 Picture Command 4-48
4.120 Polydispersity Function 4-49
4.121 Print Command 4-49
4.122 Print Page Command 4-50
4.123 Print Report Command 4-51
4.124 Print ...Using command 4-51
4.125 Range 4-52
4.126 RawFreq Function 4-52
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 3
MAN0179
4.127 RecordNumber Function 4-53
4.128 Reference Function 4-53
4.129 Residuals 4-53
4.130 Return 4-53
4.131 Rg 4-53
4.132 Right$ Function 4-54
4.133 RTrim$ Function 4-54
4.134 Run 4-54
4.135 RunMode 4-54
4.136 SampleTime 4-55
4.137 Save Command 4-55
4.138 ScaledCount 4-55
4.139 ScanAngle 4-55
4.140 ScanDuration 4-56
4.141 ScanQ Function 4-56
4.142 ScanType 4-56
4.143 Select Command 4-57
4.144 Set Command 4-57
4.145 Setup Command 4-58
4.146 Setup table Command 4-58
4.147 Setup Report 4-59
4.148 Setup Userlogtable 4-60
4.149 Simulate Command 4-60
4.150 Size Mode Command 4-60
4.151 Sizes Function 4-61
4.152 Spacing 4-61
4.153 StartAngle 4-61
4.154 Step 4-61
4.155 StoreChannel 4-61
4.156 Str$ Function 4-62
4.157 StrCmp Command 4-62
4.158 TextAlign 4-62
4.159 TextColour 4-63
4.160 Then 4-63
4.161 TimeArray 4-63
4.162 TotalSamples 4-63
4.163 To 4-64
4.164 Transfer Command 4-64
4.165 UCase$ 4-64
4.166 Use Command 4-64
4.167 Val Function 4-64
4.168 View 4-65
4.169 ViewNew Command 4-66
4.170 Virial2 Function 4-66
4.171 Virial3 Function 4-66
4.172 Volume 4-66
4.173 Write 4-66
4.174 WriteAt Command 4-67
4.175 Xchar Function 4-68
4.176 Xpage Function 4-68
4.177 Xpos Function 4-68
4.178 Ychar Function 4-68
4.179 Ypage Function 4-68
4.180 Ypos Function 4-69
4.181 ZAnal1 4-69
Page 4 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Contents MAN 0179
4.182 ZAnal2 4-69
4.183 ZAveMean Function 4-69
4.184 ZeroFieldWidth Function 4-70
4.185 ZetaChannels Function 4-70
4.186 ZetaPotential Function 4-70
4.187 ZetaSpectrum 4-70
4.188 ZetaVar 4-70
4.189 ZimmError Function 4-71
4.190 ZimmFitOrder Function 4-71
4.191 ZimmNumConcs 4-71
4.192 ZimmNumAngles 4-71
4.193 ZimmNumPoints 4-71
4.194 ZimmAngle Function 4-72
4.195 ZimmQ Function 4-72
4.196 ZimmResidual 4-72
4.197 ZimmIntensity Function 4-72
4.198 ZimmFit 4-73
4.199 ZimmConc 4-73
4.200 RadiusofGyration 4-73
4.201 ZimmFitorder 4-73
4.202 ZimmError 4-73
4.203 Zerowidth 4-73
4.204 Zeta Command/Function 4-74
4.205 ZetaPotential 4-76
4.206 ZetaValue Function 4-76
4.207 ZetaVar Function 4-76
4.208 Zlower Function 4-76
4.209 Zupper Function 4-76
CHAPTER 5
5.1 Exchange of Data with other programs 5-1
5.1.1 Transferring data by DDE with the PCS program as Client 5-1
5.1.2 Transferring data by File 5-3
5.1.3 Transferring data by Macro program via the clipboard 5-5
5.1.4 Remote control by DDE 5-5
5.2 Automatic startup 5-6
5.3 Remote Control 5-6
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 5
MAN0179
Page 6 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
CHAPTER 1
Introductiontothismanual
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Introduction MAN 0179
1.1 Welcome
Welcome to the Malvern Basic Reference manual. This manual has been designed to give a detailed description of the operation and use of Malvern Basic. It gives details on the structure of a Malvern Basic program and details all commands available.
Warning: You must remember that the Zetasizer or the samples to be
measured are potentially dangerous if misused. You must read the
Health and safety booklet before operating the system.
1.2 Systems covered by this manual
Zetasizer is a generic name given to a family of systems. Each system within the family uses the same software and only vary in operation in small areas. For this reason this manual has been written to cover more than one instrument.
This manual covers the operation of:
Instrument Ref. Number
Zetasizer 1000 DTS 5100 Zetasizer 2000 DTS 5200 Zetasizer 3000 DTS 5300 Zetasizer 4000 DTS 5400 Zetasizer 5000 DTS 5500 4700 PCS 100SM
1.3 Asumed information
Within this manual the Zetasizer system will be referred to as the “Zetasizer” or the “system” unless the information given is for a particular instrument.
Within this manual “BASIC” will refer to the specific Malvern Zetasizer version of the language. Any program examples wil be shown in the Courier font.
1.4 Windows Terms
It is important that you understand some Windows terms before reading further. (Note that US spelling is used for some terms for compatibility)
Program - The Zetasizer software - it can also mean the Zetasizer Basic program used within the main Zetasizer software.
Cursor or Pointer - The graphic - usually a pointer that is moved on the screen by operation of the mouse.
Icon - The graphic on the desktop that represents a program. Click - The mouse button is depressed and released. If this is not qualified with a button
description then assume it is the left button. ‘Clicking a button’ means click the left mouse button with the cursor over the button.
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 1.1
MAN0179
Double-click - Press and release the mouse button twice in quick succession. If this is not qualifiedwith abuttondescription thenassume itis theleft button.Usethe Mouseicon inProgram Managers Control Panel to change the double-click speed.
Dialogue Box - A window containing controls. The OK button accepts changes in the dialogue box. The Cancel button closes the dialogue without accepting the changes.
Control - This can mean a graphic on a dialogue like a button, listbox, textbox etc. Press or Select - This means click the mouse over a control or use the accelerator key (the
underlined letter) or use the Tab key to move the focus to a control then use the Enter key. Menu items can be selected using the cursor keys in the same way.
Button - This acts like a real-life button. Click to carry out an action. A typical button is shown below.
Option Button or Radio Button - A series of buttons in a group, selecting one button cancels the others in the group. A radio button is shown below.
ILL 1992ILL 1993ILL 1994ILL 1995ILL 3864ILL 3863
Check Box - A button that can be toggled on and off. A check box is show below.
Text Box or Edit Box - A box you can type text or values into. A text box is shown below.
List Box- A box containingalist of options. SomeList Boxes allow multiple entriesto be selected.
Combination List Box or Combo Box- A combination of a list box with a text box. A buttonbeside the text box displays or hides the list part of the control. In some cases you can type new values into the text box part, in others the text box just shows the current selection from the list.
Page 1.2 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Introduction MAN 0179
Drag - An action with the mouse which involves moving the mouse while holding down the left mouse button. This is used for moving icons or making multiple selections in a list box.
1.5 Menu Commands
Menu commands from the Malvern software are referred to in the form main menu-menu item. As an example, the command File-Save Sample refers to selecting the Save Sample item in the File menu. The same rules apply for sub-menus of sub-menus, so that Edit-Copy-Data refers to the Data item in the Copy sub-menu, which itself is a sub-menu of the Edit menu. Menu commands are always shown in bold text.
1.6 Where to find information
The information within this manual is divided into five chapters. The information within these chapters is summarized below.
Chapter 1 (This chapter) Chapter 1 gives general information on the content and protocols used within this manual.
Chapter 2 Chapter 2 details the structure of a Malvern Basic program, giving details on how to write and run a program.
Chapter 3 Chapter 3 explains how to write page description programs for views and reports. These views and reports can then be allocated to the View menu.
Chapter 4 Chapter 4 is the main section of the manual. This section gives comprehensive details on all the commands and functions available within Malvern Basic.
Chapter 5 Finally chapter 5 gives details of advanced features.
It should be remembered that on-line help can be gained at any point when using the Malvern software.
1.7 Reporting Problems
Beforereportinga problem pleasecheckthe relevant sectionsof the userandsoftware reference manual, or any accessory manuals, which may have an answer. If the problem persists try to give as much detail as possible.
If thereisaprobleminthesoftware try to give information that will allow the engineers at Malvern to reproduce the conditions. If the problem is in the measurement or the analysis the Malvern engineers will require a copy of the Fullsize.pcp report.
To print a Data report:
l
Change the View menu to Data.
l
Select a report print in the File - Print dialogue.
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 1.3
CHAPTER 2
Introduction to Zetasizer basic
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Introduction to Zetasizer basic MAN 0179
2.1 Introduction
The program language used in the Zetasizer software is similar to many other variants of Basic.
Some features of other versions are not needed for our application and many extra functions have been added for specific use in particle sizing. Throughout these notes the term Basic will
mean the specific Malvern Zetasizer version of the language. Basic is a line interpreted language. This means that as a program is executed each line is
checked for syntax and then executed. Unless controlled to do otherwise, the execution will continue with the next line. This means that, when you test a program, an error some way down
the program will not be reported until you reach that line. Zetasizer Basic program examples in the manual are shown in the Courier font. The fundamental building block of a program is the statement. This is a single instruction to
performsome action.A linein theprogrammaycontainmorethanone statement.Anystatements on a line must be separated by colons (:).
For example :
X = 3 : Y = 2 : Z =-5
and
X=3 Y=2 Z =-5
are equivalent. The lines of a program may be labeled. This is not necessary except when you need to refer to
a specific line from within the program itself.
The apostrophe character ( ‘ ) is used to mark comments. Any line beginning with this character is ignored when the program is executed. Comments may be added at the end of lines using the same character.
For example:
‘Area of a rectangle
‘Prompt for length’ 10 Input “Input length”, Rectlength ‘Prompt for width’ Input “Input width” Rectwidth
‘ Calculate area RectArea = RectLength * RectWidth Print dialogue, Using, “####.##”, RectArea GoTo 10
Notice the following:
l
The use of comments.
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 2.1
MAN0179
l
The use of line numbers with tests to change the order of execution.
Basic is not case sensitive. That is, you can use upper and lower case characters in any
combination. Spaces are not significant. Thus,
RectWidth = Val ( X$ )
and
RectWidth = Val ( X$ )
are equivalent. The exception to this is that names of variables, commands, etc. may not contain spaces. You
can use
InputBox$... Inputbox$... inputbox$... etc.
but
Input Box$...
will fail. There are various standard ways to make names of variables morereadable.Theexample uses
capital letters. You can also use the underscore character. For example MeanSize or
mean_size.
2.2 Building blocks of programs
The building blocks of Basic program statements are:
Commands
The commands cause actions such as “measure”, “print”, etc. They also provide means of controlling the program by repeating loops, branching as the result of tests, etc.
Functions
The functions provide values for testing or printing.
Variables and numerical constants
The variables allow you to store and calculate with values from functions.
Operators
The operators are the means of adding, multiplying, etc. the variables and constants.
Expressions
Expressionsarethe resultofevaluating combinations ofvariables, functionsandoperators. They may often be used as options for commands.
Page 2.2 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Introduction to Zetasizer basic MAN 0179
2.3 Commands and functions
Commands may perform a variety of actions depending on the choice made by additional parameters. They may also modify those actions with further parameters. Functions may be similarly modified.
The full list of all functions and commands (over 200 items and all their variant parameters) will not be described in detail here. The precise format of each command and function is given in chapter 4.
Within each entry in the reference section there is the name ofthecommandorfunction followed by ‘command’ or ‘function’ as appropriate. Remember commands perform actions and functions
give you a value to use.
2.4 Constants and variables
Numbers in Basic are all real numbers (sometimes referred to as floating point numbers). There
are no integer variables. That is to say that all numbers are treated as if they contain decimal points. The number 2.0 has the same value as the integer (whole number) 2 for all uses in the language. If it is important to have a whole number in a particular case the language includes a function Int() which removes the part after the decimal point. For example, Int(2.54) returns the
value 2. Numerical values are stored to single precision giving 6 significant figures and a range of 10
to 1038. There are also text values referred to as strings. Constants are explicit values. For example the number 3.14159 is an explicit numerical constant
and the string “MALVERN” is an explicit text constant. Variables contain or represent numbers or text. Again, there are no integer variables. The name
of a variable can contain up to 20 characters. The name may consist of alphabetic (A...Z, a...z)
and numeric (0 ... 9) characters, the underscore (_) or period ( . ) characters, but must start with an alphabetic character.
Some examples of valid variable names are:
My_Variable P.XPosition Fi257
Some examples of invalid variable names are:
Variable Comment
5Fix Starts with a number. P&G Contains the & operator. A_Very_Long_Variable_Name Too long - would be truncated.
-38
The names of variables are not case sensitive, MyVar , MYVAR and myvar would all refer to the same variable.
Page 2.3
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
MAN0179
There is space for 50 user variables in any program. An error is reported if this number is
exceeded. If one program calls another the variables in the calling program are not accessible
from the called program (but see below for arrays). It is good practice to choose variable names which describe the values they will contain. This
‘self-documenting’ approach together with comments will make program maintenance and debugging much easier.
Certain names will be disallowed. You cannot use a command or function name as a variable name.
The names of string (text) variables follows the convention of numeric variables but the names must end with a $ (dollar symbol). String arrays are not allowed. The total number of numeric,
array and string variables must not exceed 50 per program. The maximum length of strings must
be less than 256 characters. Unlike some versions of Basic, the Zetasizer Basic does not require you to declare all variables
explicitly before use. A numeric or string variable is recognized the first time a value is assigned
to it. However arrays must be declared before use.
2.5 Arrays
An array is a group of values referred to by a single name. The individual values in the array are referred to by an index number.
For example MyData could be an array of 6 elements which would be referenced as MyData(0), MyData(1), MyData(2), ... , MyData(5).
Notice that the numbering of the array is assumed to start at zero. If it is convenient for clarity to use only the elements from number 1 onwards you can, of course, ignore element 0.
Unlike simple variables, it is necessary to declare arrays before they are used so that memory can be reserved for them. This is done using the Dim command.
Array names follow the same rules as for simple variables. String arrays are not allowed. All arrays are one-dimensional. That is arrays of the type X ( 3, 5 ) are not allowed.
For example:
Dim Ax ( 10 ), Ay ( 10 ), Big_List ( 1000 )
The dimension of an array is limited to 1000 (i.e. 1001 elements). In a Dim command you may use variables and functions to specify the array sizes. For example:
X=10 Dim A ( 2 * X + 1 ) Dim B ( StoreChannel )
are valid. Once an array is dimensioned you may not change its dimension.
Page 2.4 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Introduction to Zetasizer basic MAN 0179
Array elements may be used in any place in which a simple variable is used. For example:
Dim X ( 5 ), Y ( 5 ) For i = 0 To 5
A$ = InputBox$ ( “ ”, “ ”, “1.0" )
X ( i ) = Val ( A$ ) Y ( i ) = Log10 ( X ( i ) ) Next
Note that when referencing array elements the index can be any valid expression.
Dim X ( 5 ), Y ( 5 ) For i = 0 To 5
A$ = InputBox$ ( “ ”, “ ”, “0" )
X ( i ) = Val ( A$ ) Next XMax = -1000 For i = 0 To 5
If X ( i ) > XMax Then XMax = X ( i ) End if Next For i = 0 To 5
Y ( 5 - i ) = X ( i ) * 100 / XMax Next
2.6 Expressions and operators
Expressions consist of:
l
Constants and variables
l
Functions returning numerical or text values
l
Operators
Expressions may be used in every place where a single constant or variable could be used. For example you may write
Save RecordAs “myfile”, 5
or
Save RecordAs “myfile”, i + 3
Operators are used to combine variables, constants and function values. For numeric values the operators are:
Operator ( ) Expressions in parentheses are evaluated first. + - Unary plus and minus. ^ The exponentiation operator.
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 2.5
MAN0179
* / % Multiply, divide and modulo. + - Addition and subtraction. < >= Relational operators. >= Relational operator. <= Relational operator. <> Relational operator. | Bit-wise OR operator. & Bit-wise AND operator.
The expressions are evaluated left to right except with exponentiation which evaluates right to left.
Unary plus and minus attach a sign to a number. For example -FirstNumber is -1 if FirstNumber is 1, 7 if FirstNumber is -7, etc.
Exponentiation raises a number to a power. For example 3^4 is 81. Multiply ( * ) and divide ( / ) are the normal arithmetic operations. The modulo operator calculates
the remainder after division. For example 27% 5 is 2.
Expressions involving the relational operators evaluate to 1.0 if TRUE or 0.0 if FALSE. The AND ( & )and OR ( | ) operators convert the decimal numbers to integers before evaluation.
Therefore the expressions on either side of these operators must resolve to values in the range 0 to 65535. For example:
211 & 112 = 80 (211.53) & 112 = 80 211 | 112 = 243
2.7 Control Structures
The simple progress from line to line of a program is very limited. In order to give the language real power we need commands which allow us to change the order of operation according to tests performed on variables.
In addition, the structure of the program can be simplified, the number of variables needed can be reduced and parts of the program can be made more portable by using subroutines.
In this sense, portable means that useful sequences of instructions can be copied and pasted into new programs.
Finally, we need to be able to repeat sequences of operations for whole sets of variables or for a pre-defined number of times.
2.7.1 Tests and Branches
The basic test is the structure:
If expression Then command
Page 2.6 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Introduction to Zetasizer basic MAN 0179
When the program reaches this line it evaluates the expression and if the answer is false (i.e. the expression evaluates to 0.0) the rest of the line is ignored. Otherwise the command is executed.
For example:
If CountsPerSec < 30000 Then Print Status, “Count Rate too small”; Pause 5
This will check if the count rate is below 30000 and if it is will display the message in the status bar. It will then pause for 5 seconds.
What happens if the expression is false? The message is not displayed, theprogram goes to the
next line and there is still a 5 second pause. We only want the pause if the message has been displayed so we could write instead:
If CountsPerSec < 30000 Then Print Status, “Count Rate too smalll”; : Pause 5
This time the group of commands after Then is executed if true and ignored if false. Note that the commands after the Then must all be on one line. The enter key should be pressed after ...Pause 5 (enter key).
We could go on in this way adding commands separated by colons. The line might then become
very long or difficult to read. In this case we could use the block form of the structure. This form is:
If expression Then
command
....command
....
End if
Again the expression is tested and if it is true the sequence of commandsfollowing theIf ... Then line is executed up to the line End if.
For example:
If CountsPerSec < 30000 Then Print Status,“Count Rate too small”;
Beep Pause 5
Print Status, Add more sample and re-run”; End if
There is one more stage to go. Consider:
If CountsPerSec < 30000 Then Print Status,“Count Rate too small”;
Pause 5 End if Print Report
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 2.7
MAN0179
If the test is false the block is ignored and the Print Report will be executed. But, if it is true we will get the warning and still get thePrint Report. We could get round thisin two ways. The GoTo command could be used:
If CountsPerSec < 30000 Then Print Status,“Count Rate too small”;
Pause 5 GoTo 20 End if Print Report 20 ‘ This is where to continue.
The neater and clearer solution is to write:
If CountsPerSec < 30000 Then Print Status,“Count Rate too small”;
Pause 5 GoTo 20 Else Print Report End if
This general form:
If expression Then
command
command
... Else command command
... End if
executes the first block of commands if the expression is true and the second block if false.
2.7.2 Subroutines
Suppose that you write a test:
If CountsPerSec < 30000 Then Print dialogue, Using, “###.### is too large”, ResultBelow (10 ) Beep Pause 5 End if
and subsequently want to test some other parameters, say ResultAbove ( 60 ), etc. in the same way. You could write lots of bits of code copying the above.
The better way would be to use a subroutine.
Page 2.8 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Introduction to Zetasizer basic MAN 0179
2.7.3 Loops
It is often useful to be able to perform a group of operations a number of times in a loop. To
achieve this Basic has the structure:
For variable = expression1 To expression2 ... ... Next
The counter variable is set to the value of expression1, the program lines following the For statement are executed until the Next statement is encountered. Then, 1 is added to the counter
variable and it is compared with the value of expression2. The loop terminates when the value
of variable is greater than or equal to expression2. If expression1 and expression2 have the same value, the loop executes once For example:
Data_Max = - 1000 For i = 1 To NumChannels If StoreChannel ( i ) > Data_Max Then Data_Max = StoreChannel ( i ) Next
This will check through the data to find the maximum value. Avoid changing the value of counter within the loop. Changing the loop counter is poor
programming practice; it can make the program more difficult to read and debug. The counter variable may be just that. For example:
For i = 1 To 4 Measure Sample
Calculate Print Report
Next
Sometimes we may want to step through a set of values using, for example, every other one. To do this we can use the extended form of this command structure
For variable = expression1 To expression2 Step expression3 ... ... Next
This time instead of increasing the variable by 1 each time the Next is reached it is increased by the value of expression3.
For example:
OpenFile “standard” ‘Read the number of records in the file. LastRecord = Numrecords ‘Process pairs of records to show differences between 1 & 2, 3 & 4, etc.
Page 2.9
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
MAN0179
For i = 1 To LastRecord Step 2
Load Record i
DifferenceRecord i + 1 View Difference Pause 10 Next
2.7.4 Nesting
Control structures may be nested, that is placed one inside another. If .. Then can be placed inside For ... Next loops as seen above, or vice versa. If ... Then can be placed inside another If ... Then as below:
If CountsPerSec < 30000 Then Print Status, “Count rate too smalll”;
Pause 5 GoTo 20 Else If ResultValid Then
Print Report
Else Print dialogue, “Result invalid” End if End if
Similarly, For ... Next loops can be placed inside other For ... Next loops.
For i = 1 To 5
For j = 1 To 8
Move 20 * i, 10 * j
Box 20 * i + 19, 10 * j + 9
Next
Next
There are limits placed on the number of levels to which you can nest structures. For example,
For ... Next loops can be nested to 25 levels. None of the limits should cause you any practical
problems ! You can see from the above examples that it would be easy, in complex structures, to lose track
of the match between For and its corresponding Next or between the parts of If ... Then ... Else ... End if You can help to avoid this by indenting each block of statements as in the examples.
2.8 Special programs in Zetasizer Basic
The Zetasizer Basic language is used, not only to provide control and calculation routines, but also as the standard method of producing result tables and reports. It is also used for special programs to perform remote reporting and DDE linking.
For a detailed description of the use of Malvern Basic in page design see chapter 3. For DDE linkingsee ‘DynamicDataExchange’ inthe SoftwareReferenceManualandforremoteoperation see ‘Remote’ in the Software Reference Manual.
Page 2.10 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Introduction to Zetasizer basic MAN 0179
A program may also be run automatically when the Zetasizer software is first started. This may be used, for example, to automatically start a measurement sequence. See Control-Assign Program in the Software Reference Manual for more information.
2.9 Functions- a review
There are over 220 functions available but they will not all be dealt with individually here. For precise details on every function please consult chapter 4.
Page layout functions allow you to design pages by spacing rows and columns of figures in a way which is best adapted to the specific output device. For more details of page design see chapter 3.
Result information functions allow you to use values which describe the size distribution. Sample documentation functions record the Sample identifier, Sample Notes and run number
for accurate identification of the information on print-outs. Hardware information records the specific settings of hardware used in the measurement. Software settings give the parameters used in analysing the data.
2.10 Writing andrunningprograms
2.10.1 Recording a program
If you intend to write a program that controls the Zetasizer measurements or process sample records you may find it convenient to record the basic outline of the program.
There are two modes of recording - if you elect to Fill in dialogue Boxes then the Zetasizer will act normally but all your commands will be recorded. If you do not select Fill in dialogue Boxes then the normal action of the commands will not be carried out - the program will record only the commands that were actioned.
See the Control-Record Program command in the Software Reference Manual for more information.
2.10.2 Editing a program
A recorded programmaybemodifiedora new program may be written using the program editor. Theprogram editoris aseparatewindow thatis alsoused forentering pageand reportdescription
programs. To edit a normal program the editor window is produced by selecting the Control-Edit Program command.
The editor window has its own menu bar.
Menu item Function File-New Edit a new program File-Load Load a program from disk File-Save Save a program to disk File-Save As Save a program with a new name
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 2.11
MAN0179
File-Exit Close the editor window Edit-Undo Undo the last edit Edit-Cut Cut the selected text to the clipboard Edit-Copy Copy the selected text to the clipboard Edit-Paste Paste at the cursor the text in the clipboard Edit-Delete Delete the selected text
TheRun buttonrunstheprogramandchangesto showStop. ClickStop toterminate theprogram.
2.10.3 Running a program
The first time you run a program you should use the Run button in the Program Editor. If there are any mistakes or errors then the cursor will move to the line with the error.
When the program is debugged it may be saved on disk (preferable in the PROGRAMS subdirectory). The program may then be run from the Control-Run Program command (See the Software Reference Manual for details).
2.10.4 Assigning Programs to Keys and Menu
The Control-Run Program command allows a single program to be run several times without having to pick it from the list of all the programs. If you have several programs you wish to run you may want to assign them to the end of the Control menu. An assigned program can be run either by selecting the entry from the Control menu or by using the function keys F5 to F8 (or those keys in combination with the control and shift keys).
See the Control-Assign Program command in the Software Reference Manual for more information.
2.11 Program Errors
Therearetwo types oferrorsinvolved in usingtheZetasizer programming language. Firstlythere
are errors caused by mistakes in the construction of your program. For example the statements:
IfX>0 GoTo 100 End if
will produce the error “THEN expected” because the first line is incomplete. A list of these errors is given below. To correct such an error, consult the details of the particular
command or function, if necessary, correct the error and re-run the Program. The second type of error occurs when you run the Program. For example, if you attempt to use
the command:
Load Record N
and the expected record cannot be loaded for some reason, the system will return an error code which you can use to make decisions about the next action:
Page 2.12 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Introduction to Zetasizer basic MAN 0179
Load Record N If Error = 0 Then Print Report Else X = Print Dialogue “Record no found” End End if
The values of any error codes which might be returned and their meanings are shown in the description of each individual command and function.
2.11.1 Basic Errors
The message displayed at the top of the program editing box gives you information about the type of error which has occurred. If the message is Syntax error in line n then inspect the line to ensure that the commands, functions, etc. are correctly spelled.
Specific error messages are : Unbalanced parentheses
The number of left and right parentheses do not match. For example
X= Int ( ( N - 1 ) / 2
Correct to
X = Int ( ( N - 1 ) / 2 )
No expression present A value was expected.
Equals sign expected The line is interpreted as beginning with a variable name but does not have a value assigned. This often occurs when an incomplete line is entered or a command is mis-spelled.
For I = 1 to 5 Load Record 5 Print Report Nxt
Correct the last line:
Next
Label table full You may use up to 100 labels. Your program contains more than this number. To correct this
you will need to simplify the structure of the program to use less labels. Using If... Then ... Else
structures to replace GoTo may help. Duplicate label
You have used a label more than once. To correct this change one of the labels.
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Page 2.13
MAN0179
Undefined label There is a Goto or Gosub which uses a label which you have not included in your Program. To
correct this check that you have typed the label correctly. Add the required label if necessary.
THEN expected There is an If statement which is incomplete. For example:
IfX>0 GoTo 100 End if
Correct to
If X > 0 Then GoTo 100 End if
TO expected There is an error in the For statement. For example:
For I = 1, 10
Correct to
For I=1 To 10
Too many nested FOR loops For ... Next loops may be nested to a maximum of 25. Your program structure is too complex.
NEXT without FOR Each blockofstatements beginning For ...must end with acorresponding Next. The error ismost easily caused when nesting several levels of For ... Next loops or when code has been cut and pasted incorrectly.
Too many nested GOSUBS When you call a subroutine you may call anothersubroutinebeforereturningto theoriginal point in the Program. This process can continue up to 25 levels. This error indicates that you have
exceeded the limit. Your Program structure is too complex.
RETURN without GOSUB The most common cause of this error is not including an End statement. For example
For I = 1 to 10 GoSub 100 Next 100 Load Record I Print Report Return
Correct to:
For I = 1 To 10 GoSub 100
Page 2.14 Zetasizer 1000/2000/3000/4000/5000/4700
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Loading...
+ 93 hidden pages