Zeus wiping out my tabs!

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
DrLechter

Zeus wiping out my tabs!

Post by DrLechter »

1. I was wondering if there is a way to stop Zeus from eliminating tab chars from my .sql files? Zeus eliminates tabs if the tab is the only thing on a line (other than CRLF). I had intentionally included a tab char on blank lines to stop a problem with the SQL query analyer. Namely, if a .sql file with the tabs removed is executed in the SQL query analyzer, it will ignore lines containing only a CRLF. This causes any created stored procedures to have all blank lines eliminated. Trying to read a piece of code that has had every blank line eliminated is not a fun thing! :shock:

2. Also, I am wondering if I can use a reg-ex to ?fix? some files I was editing in Zeus and damaged in this way? If I could locate lines containing nothing but a CRLF, I could replace them with a <tab>CRLF. That would fix damaged files?
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

1. I was wondering if there is a way to stop Zeus from eliminating tab chars from my .sql files?

Yes indeed there is :) Just used the Options, Editor Options menu and uncheck the trim line white space on save option.
2. Also, I am wondering if I can use a reg-ex to ?fix? some files
I was editing in Zeus and damaged in this way?
Unfortuantely there is no way to fix this using a search and replace, but the macro shown below will restore these missing tabs. Save the macro to the zScript\AddTab.lua file and then use the Macros, Execute Script menu and type in AddTab.lua to run the macro. It will restore the tabs to the currently active file.

Code: Select all

function key_macro()

  -- macro only works for documents
  local document = is_document()

  if document == 0 then
    message("This macro only works for document files!")
    beep()
    return
  end

  -- macro only works for read/write documents
  local locked = is_read_only()

  if locked == 1 then
    message("The current document is marked as read only!")
    beep()
    return
  end

  -- disable screen updates
  screen_update_disable()

  -- save the current cursor
  cursor_save()

  -- total number of lines
  local lines = get_line_count();

  -- move to the fist line
  set_line_pos(0)

  for i = 1, lines, 1 do
    -- get the line text
    local line_text = get_line_text();

    local length = string.len(line_text)

    if length == 0 then
      -- add the missing tab      
      print("\t")
      MoveLineHome()
    end

    MoveLineDown()
  end

  -- restore original cursor
  cursor_restore()

  -- restore screen updates
  screen_update_enable()
end

key_macro() -- run the macro
Jussi
Post Reply