Solved

ZPL: OPEN / READ binary data

  • 10 February 2023
  • 6 replies
  • 215 views

Userlevel 1

Hello community,
I am looking for an example of OPEN / READ / WRITE a binary file in ZPL.
Many Thanks!
Hans-Jürgen 

icon

Best answer by David.Nguyen 10 February 2023, 16:12

View original

6 replies

Userlevel 7
Badge +2

Hi Hans-Jûrgen,

 

I could be wrong but the Help File for OPEN reads:

Opens an existing text file for reading by the READ command.

 

This is only for text files, not binary files.

Also, I suggest writting binary files with MATLAB or Python. I wrote an example for Sources here in Python.

I hope this helps. Take care,

 

David

 

Userlevel 1

Hi David,

thanks!

I was in the wrong help section (Tolerancing ) and found OPEN FILE filename mode (mode = [txt,bin]).

That’s pity.

Is it worth to be a support request?

Best Regards

Hans-Jürgen

Userlevel 7
Badge +2

Hi Hans-Jûrgen,

 

If you want my honest opinion, it isn’t worth it. Reading and writting binary files is a relatively basic task (at least if you know the syntax) in many other more general programming langages including C/C++, C#, MATLAB, Python. Many people, like myself, create our binary files with another langages, which also have a better integrated development environment (IDE). Therefore, I doubt there will be a huge incentive to have it in ZPL in the future. But you can still ask I guess.

Have you had a look at the code I sent you?

Take care,


David

Userlevel 1

Hi David,

thanks for the honest answer.
My problem is to replace missing MODIFYSETTING myself by manipulating the cfg files.
I might as well outsource that if I could launch a program (.exe) from ZPL (?).

Grüße

Hans-Jürgen

Userlevel 7
Badge +2

Hi Hans-Jürgen,

 

Could you use the ZOS-API instead? You’d already be in an environment where writing/reading binary files becomes possible. Running executables as well.

Take care,

 

David

Userlevel 1

Hi David,

thanks. We know that extensions are more powerful.

ZPL is enough for many things. And I like to push the limits.

Ok, for this task / problem we will use ZOS-API.

Viele Grüße

Hans-Jürgen

Reply