Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Ask Me About Webinar: Data Center Assets - Modeling, Cooling, and CFD Simulation
Join our 30-minute expert session on July 10, 2025 (9:00 AM & 5:00 PM CET), to explore Digital Twins, cooling simulations, and IT infrastructure modeling. Learn how to boost resiliency and plan power capacity effectively. Register now to secure your spot!

Display a variable from cicode on graphics page

AVEVA Plant SCADA Forum

A support forum for AVEVA Plant SCADA (formerly Citect SCADA). Share new and exciting product information, connect, learn, and collaborate with the ecosystem of Plant SCADA Users. AVEVA Plant SCADA a reliable, flexible and high-performance Supervisory Control and Data Acquisition software solution for industrial process customers. This forum is to connect, share, learn and collaborate new and exciting product information. Feel free to join and share to your Ecosystem of Plant SCADA Users.

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • Industrial Automation
  • AVEVA Plant SCADA Forum
  • Display a variable from cicode on graphics page
Options
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
olivier_vallee
Lt. Commander olivier_vallee
28
Oncom
Commander Oncom
6
BevanWeiss
Spock BevanWeiss
2
RoozeeR
Lt. Commander RoozeeR Lt. Commander
2
View All

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to AVEVA Plant SCADA Forum
Solved
plcplcplc
plcplcplc
Cadet

Posted: ‎2024-02-24 02:08 PM

0 Likes
1
907
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-02-24 02:08 PM

Display a variable from cicode on graphics page

I am trying to display a variable within a cicode function onto a graphics page. This function queries a SQL database. I can get the value onto a diagnostic popup msg reading correctly but cannot seem to display the value on the graphics page, am I missing something obvious here?

Currently I am using a button with UP Command "ReadData()" Input to manually call the function however once I can display the data ok I will create an event.

The SQL column data type is a DECIMAL (5, 2) which I have defined as a REAL in my cidode function. I also tried as a STRING in cicode and was able to receive the same data value which was correct and matched the sql database row e.g "20.45" amps.



Cicode below:
REAL
FUNCTION
ReadData()
INT hSQL2;
REAL rDataQuery;
INT Status1;

hSQL2 = SQLConnect("DSN=SQL_DB; Uid=abc; pwd=def;");
IF hSQL2 <> -1 THEN
Message("Connection Success", "Connected to SQL_DB database", 64);
Status1 = SQLExec(hSQL2, "SELECT amps FROM sql_db_table1 ORDER BY id DESC LIMIT 1");
IF Status1 = 0 THEN
Message("SQL Execution Success", "Query executed successfully", 64);
WHILE SQLNext(hSQL2) = 0 DO
rDataQuery = SQLGetField(hSQL2, "amps");
Message("Data Retrieved", "Amps value: " + RealToStr(rDataQuery, 5, 2), 64);
RETURN rDataQuery;
Amps = rDataQuery;
END
SQLEnd(hSQL2);
ELSE
Message("connect Error",SQLErrMsg(),48);
END
SQLDisconnect(hSQL2);
ELSE
Message("connect Error",SQLErrMsg(),48);
END
END

In my graphics page I have tried the following expressions in the text properties display the wanted value:

When function was defined as a STRING:

1.APPEARANCE > DISPLAY VALUE > STRING > ReadData() - Displays a -1

2.APPEARANCE > DISPLAY VALUE > STRING > RealToStr(ReadData(), 5, 2) - Displays a -1

3.APPEARANCE > DISPLAY VALUE > STRING > ReadData(rDataQuery) Compile Error E2022 - Invalid number of arguments for function

When defined as a REAL:

1.APPEARANCE > DISPLAY VALUE > NUMERIC > ReadData() - Displays a -1

2.APPEARANCE > DISPLAY VALUE > NUMERIC > ReadData(rDataQuery) Compile Error E2022 - Invalid number of arguments for function

Also created a local variable tag in System Model called "Amps" using either REAL or STRING datatypes depending on the type i used in my cicode function and placed in the graphics builder expression value but it would display as blank.

Any help would be appreciated.

Labels
  • Labels:
  • Graphics Builder
  • Scripting - Cicode
  • Tags:
  • english
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
olivier_vallee
Lt. Commander olivier_vallee
Lt. Commander

Posted: ‎2024-04-22 07:05 PM

0 Likes
0
816
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-04-22 07:05 PM

I believe the problem is that Cicode on a page is a blocking function (has to be non-blocking to work on a page). You need to decide where this Cicode will run (as in an event on Client process) or on the Report Server (which can act as a redundant capable event engine) or elsewhere.

Another option could also be to use Calculated Variables (see online help for more info on this) which was introduced in Citect SCADA 2016. This would allow you to only execute the function "ReadData()" when the tag is displayed (it is executed within the IO Server process not on the actual page). Hope this information helps. I would be interested to hear back with which approach you take.

See Answer In Context

Reply

Link copied. Please paste this link to share this article on your social media post.

Reply 1
olivier_vallee
Lt. Commander olivier_vallee
Lt. Commander

Posted: ‎2024-04-22 07:05 PM

0 Likes
0
817
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-04-22 07:05 PM

I believe the problem is that Cicode on a page is a blocking function (has to be non-blocking to work on a page). You need to decide where this Cicode will run (as in an event on Client process) or on the Report Server (which can act as a redundant capable event engine) or elsewhere.

Another option could also be to use Calculated Variables (see online help for more info on this) which was introduced in Citect SCADA 2016. This would allow you to only execute the function "ReadData()" when the tag is displayed (it is executed within the IO Server process not on the actual page). Hope this information helps. I would be interested to hear back with which approach you take.

Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of