Monday, November 6, 2017

When I using dictionary, how can I add items using my input order?

eg:
function IlaAutoGenerate ()
let wides = 0
let signals = {}
for line in getline(1, line("$"))
if line !~ '^\s*$'
let line = substitute(line, '^\s*', "", "")
let sig_msb = 0
let wides += sig_msb + 1
let sig_name = substitute(line, '\s*\(;\|,\).*$', "", "")
call extend(signals, {sig_name : sig_msb}, "force")
endif
endfor
for sig_i in keys(signals)
call setline(curr_line, "reg ila_".sig_i.";")
let curr_line += 1
endfor
endfunction
I input the following:
sig_b;
sig_d,
c;
aa;
tmu_a;

I expected output:(or the inverse order as my input)
reg ila_sig_b;
reg ila_sig_d;
reg ila_c;
reg ila_aa;
reg ila_tmu_a;

But actually is:
reg ila_c;
reg ila_sig_b;
reg ila_aa;
reg ila_sig_d;
reg ila_tmu_a;

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment