Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

GP-Pro EX Quick Start Guides

D-Script & Global D-Script

1 PFTR07_CLS01REVB
D-Script

¾ Overview:
– This chapter explains how to use D-Script and Global D-Script
to enhance custom operation in GP-Pro EX.
¾ Objective:
– At the end of this chapter you can:
• Add, Edit and Remove (Global) D-Scripts
• Identify the differences between D-Script and Global D-Script
• Create Custom Functions
• Use basic operators
• Find advanced Script functions

PFTR07_CLS01REVB
Introduction

¾ The script language in GP-Pro EX is called


D-Script.
¾ It can be further divided in:
– D-Script
• A D-Script only work when the base or window screen it was
created on is active.
– Global D-Script
• D-Script that works anywhere in the project
– Extended Script
• D-Script use specifically to communicate to external devices
using ASCII character transmission
• Extended Script is covered in dedicated chapter

PFTR07_CLS01REVB
Editing Scripts

¾ Global D-Scripts can be created at any time by


selecting the Global D-Script icon or by using the
Common Settings > Global D-Script menu. Up to
32 Global D-Script can be used.
¾ D-Scripts can be created when a base or
Window screen is opened in the
editor by selecting its icon or via
the Parts > D-Script menu.
¾ D-Scripts are displayed at the
bottom of a screen
in the editor
PFTR07_CLS01REVB
Script Editor Components

Toolbar Trigger Condition Tabbed Script Display

Script Data Type

Address Entry

Formula Area

Workspaces Status Area

PFTR07_CLS01REVB
Example

¾ D-Scripts uses assignment based statements.


¾ The result of an action is stored in the leftmost
address in the statement.
¾ This example shows a simple up counter with a
1 second trigger
incrementing LS20
by 1 until it reaches
100 after which it
will reset to 0

PFTR07_CLS01REVB
Trigger Condition

¾ The following script triggers can be used:


– Continuous
• Always active, as fast as possible after higher priority
processes are completed each processing cycle
– Timer
• Runs every 1 to 65535 Seconds
– Bit On / Off / Toggle
• Runs when Bit turns On, Off or any state change
– Expression True / False
• Runs when an expression becomes true or becomes false.
(edge trigger, not a
“while” trigger)

PFTR07_CLS01REVB
Formula Window

¾ Functions are entered in the Formula Window


¾ The message area can display warning and
script error messages that refer to a specific row
number in the formula area.
¾ Use the “Input Address” link to enter a
Device/PLC, Internal or Variable address
¾ Use // to enter a comment
anywhere in the script.

PFTR07_CLS01REVB
Custom Functions

¾ User Defined Functions can be created in any


script and reused in any other script.
¾ The Call function is used to trigger
a function.
¾ Functions help
script editing.
¾ Use for recurring
or 32bit functions
in mostly 16 Bit
Scripts.

PFTR07_CLS01REVB
Tool Box

¾ Use the Tool Box workspace to enter the correct


syntax for commonly used expressions.
¾ Click any item in the list to place it at the cursor
location in the active formula
window.

PFTR07_CLS01REVB
If /else / endif Statements

¾ Use the Tool Box to enter the full If / Endif or


If/Else/Endif syntax in the formula window.
¾ TIP: Typing “If” in the formula window will
automatically create the correct syntax.
¾ Up to 8 If (else) statements can be nested.
//Nested If Statement Example
if([w:[ML1000_DF1]N007:000] <= 100)
{
[b:[ML1000_DF1]B003:000/00] = 1
if([b:[ML1000_DF1]B003:010/05] == 0)
{
[w:[#INTERNAL]LS0100] = 12345
}
endif
}
else
{
[b:[ML1000_DF1]B003:005/00] = 0
}
endif

PFTR07_CLS01REVB
Loop statements

¾ Use the Tool Box to enter the correct Loop


syntax.
¾ TIP: typing Loop will also create the statement
¾ A Temp address has to be selected for each
loop, assign a number to the Temp address
before the loop statement.
¾ Note that the loop
//Loop Example
[t:0000] = 100
loop([t:0000])
{
counts down, not if([w:[ML1000_DF1]N007:000] <> 1000)
{

up (100, 99, etc) }


else
[w:[ML1000_DF1]N007:000] = [w:[ML1000_DF1]N007:000] + 1

{
break
}
endif
}
endloop

PFTR07_CLS01REVB
Function Workspace

¾ The function workspace is divided in the


Function List and User Defined Functions
section.
¾ The Function List gives access to advanced D-
Script operations
¾ The User Defined Functions area
is used to call, display and edit custom
functions that can be reused in any
script.

PFTR07_CLS01REVB
Functions – Draw Instructions

¾ The Circle, Dot, Line and Rectangle functions


draw the selected object on the active screen.
Most setting can be replaced by an address.
¾ The Call Screen function loads the specified
screen number on top of the currently active
screen. (If it is the same screen this
acts like a refresh)
¾ Call Screen is a drawing function:
active parts (like switches) will be
displayed on the active screen as a
drawing, not as an active part.
PFTR07_CLS01REVB
Functions – Memory Operations

¾ Offset Address:
– Writes the result of an expression to an offset of the
selected destination address.
¾ Compare Memory:
– Compares ranges of registers.
– Useful for comparing loaded vs edited
recipes
¾ Compare Memory (Variable):
– Same as compare memory but all
parameters can be assigned during
runtime.

PFTR07_CLS01REVB
Functions – Memory Operations

¾ Ring Shift Memory:


– Cycle through values in an address range, moving
each value into the next address in the range. The
value in the highest address will be stored in the
lowest address in the range
¾ Search Memory:
– Sets a range of addresses as search
item and searches for a match in a
second range of addresses for this item
¾ Initialize Memory:
– Set a range of addresses to a specified
value in a single command.

PFTR07_CLS01REVB
Functions – Memory Operations

¾ Initialize Memory (Variable):


– Like Initialize Memory but all parameters can be
assigned during runtime.
¾ Shift Memory:
– Like Ring Shift Memory but the values
are not moved from the highest to the
lowest address. The data will “fall off”

PFTR07_CLS01REVB
Functions – SIO Port Options

¾ SIO Port Operation functions can be used to


send and receive ASCII characters when the
Script I/O Settings in System Settings are set to
D-Script/Global D-Script.
¾ This function is covered in the Extended
script module

PFTR07_CLS01REVB
Functions – Bit Operations

¾ The “Bit Settings” and “Clear Bit” functions are


rarely used, to set or reset a Bit address the
following expressions are quicker to create: [bit
address] = 1 //Bit Set
[bit address] = 0 //Bit Reset
¾ The “Bit Toggle” function is a time
saving statement that will invert the
specified bit.

PFTR07_CLS01REVB
Functions – CF Card & USB Operations

¾ Using the CF File and USB File functions


custom CSV files can be saved to and read from
a connected CF Card or USB Memory
¾ This extremely powerful function can be used to
create custom report files or a
fully customized logging system if the
sampling data feature does not fully
cover the applications requirements.

PFTR07_CLS01REVB
Functions – Printer Instructions

¾ Use the Send function in the Printer Operation


list to send data to an attached printer.
¾ The PRN_CTRL and PRN_STAT labels can be
used to catch and clear printer errors

PFTR07_CLS01REVB
Functions – Other

¾ The Debug Function allows you to add direct


output to the AGP screen. Output can be Text, a
register value or the value of a temp address.
¾ Debug statements can be left in the
script, simply turn the function off
to prevent output to the screen or
on when debugging scripts.
¾ Note: Start App & Exit functions are for
WinGP only.
(not covered in this module)

PFTR07_CLS01REVB
D-Script List

¾ The D-Script List contains all


scripts configured for the current
Base or Window screen or all
Global D-Scripts.
¾ Use the D-Script List workspace to
open multiple scripts. Each script
will be
displayed as a tab in the editor.

PFTR07_CLS01REVB
Search & Replace Workspace

¾ Use the Search Workspace to find


and or replace text in any open
script in the Script Editor.

PFTR07_CLS01REVB
Questions

Please refer to the Reference Manual that is installed along with GPPRO-EX.
Manuals are also available on-line at:
http://www.hmisource.com/otasuke/download/manual/

For further support please e-mail: Support@profaceamerica.com


Or call: +1 734 429-4971

PFTR07_CLS01REVB

You might also like