Solved

How to write into data blok into Siemens PLC

Posted on 2009-07-08
6
628 Views
Last Modified: 2013-11-10
With next code i'm trying to write in the Data Blok 11 into first byte. But i have no sauces. Can you help me to resolve the error.

Best regards
function DB_write ( dbno:Integer;dwno:Integer;var amount:Integer;var buffer):Integer;stdcall;
 
 
function DB_write;external 'w95_s7m.dll' name 'db_write';
 
 
procedure Tform1.writePLC();
var
ammount1: Integer;
buffmy: Word;
begin
ammount1 := 1;
buffMY:= 1 ;
DB_read(11, 0, ammount1, buffmy);
end;

Open in new window

0
Comment
Question by:pr2501
  • 2
  • 2
6 Comments
 
LVL 28

Expert Comment

by:Bill Bach
ID: 24830469
Not my field, but I have an obvious suggestion:  Change DB_read to db_write.
0
 

Author Comment

by:pr2501
ID: 24837794
thank you

It's ok now.

Just..
Can you help me for the nexyt problem:
When i close app. And start agin i have next mesage:

First chance exception at $7C812AFB. Exception class EOleException with message 'Cannot expand named range'. Process Project1.exe (3248)

After clicking on continue, i get mesage error (attached picture) and after clicking on ok  it starts and it works normaly.
I need to avoid this interuption.

canexpand.JPG
0
 

Author Comment

by:pr2501
ID: 24840537
Some explanations more:

I need to close my app, because i'm  writeing new values into buffer by changing variables into Delphi IDE. After restarting my app again and with clicking on speed button i'm writing (calling procedure for write)  . And then that error appears:
Cannot expand named range
0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 500 total points
ID: 24840797
Are you closing the application normally, or are you terminating it through the IDE?  Many data environments instance DLL's, create connections, and perform other tasks at startup that must also be properly shutdown when terminating.  In many cases, if you terminate an app from the IDE, these clean-up functions never get called, memory never gets released, etc., and problems can occur.  Check to see if you have to call some cleanup functions for this library, and just ensure that they are called before terminating the app in the IDE.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question