Solved

Detecting a line with any number of only spaces or tabs with ZPL

  • 19 June 2020
  • 5 replies
  • 78 views

Userlevel 2
Badge

Is it possible in ZPL to detect if a line red with READSTRING Line$ contains only any number of spaces or tabs?

icon

Best answer by Christoph.Bodendorf 30 June 2020, 18:46

View original

5 replies

Userlevel 1
Badge +1

Hi Christoph,


Are you trying to skip blank lines in a text file? It may be easier to use the READ keyword which will read a line up to a newline character.


As for what you are specifically asking for, there is nothing built in that does this. You may be able to build a loop that goes through each character in the string by using the string function $LEFTSTRING() and some IF statements to see if they match with a space. However, this type of programming would probably be better suited for the ZOS-API.


Let me know if you have any specific questions about this.

Userlevel 2
Badge

Yes, I read a configuration file and need to skip blank lines.

The READ keyword seems to only read numbers and not strings. My file consists of keywords and values, both can be strings.


It seems that you are more and more recommending the ZOS-API. Unfortunately, I already have all the ZPL skripts now.

Userlevel 4
Badge +1

Hi Christoph,


I don't think Kaleb was trying to say that only the API will work for your needs. The $LEFTSTRING keyword in a loop should be able to test character by character if there is anything on a given line. It may look a bit clunky, but it should work.

Userlevel 2
Badge

Yes, ZPL is a clunky language 😉. I found this clunky workaround:


label BEGIN_LOOP01 #-----------------

    READSTRING Line$

    if EOFF() then goto END_LOOP01

    if (Line$ $== '') then GOTO BEGIN_LOOP01

    Keyword$ = $GETSTRING(Line$, 1)  # Substring, space-separiert

    indicator$ = $LEFTSTRING(Keyword$,1)  # 1st character

    if (indicator$ $== '#')|(indicator$ $== ' ') then goto BEGIN_LOOP01   # coment or empty line

    Value$ = $GETSTRING(Line$, 2)

    ...

Hello all,


 


I am trying to save the data with different file name using Macro, but not able to save my data with a different name. Data is saving with same name. Can anyone please help?


I am using the for loop and saving the text window using the for loop


for i,1,2,1

SAVEWINDOW 2, 'E:\faheem....\Textfile name(i)

end


The text file should very with 'i' value.


Best and regards,

Faheem

Reply