Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to write into data blok into Siemens PLC

Posted on 2009-07-08
6
Medium Priority
?
649 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
[X]
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
  • 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 2000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Simple Linear Regression

618 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