Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to write into data blok into Siemens PLC

Posted on 2009-07-08
6
632 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

856 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