Hi all. I have a very simple code snippet and I can’t figure out why I get this error:
Simple text file to read: test.dat contains
Fred 50 Mike 51 Ida 52
f = open("test.dat") i = 1 for ln in eachline(f) if i == 1 desigA, numA = ln[1:8],ln[9:end] else desigB, numB = ln[1:8],ln[9:end] end if i > 1 println(desigA, desigB) end i+= 1 end
I know I could work with regex, split, readdlm etc., but it has a certain reason why I use slicing of the string (fixed column format) and I think it is not connected to the problem I am pointing here.
Running this example code (with Julia 0.6.3) I got the error, that desigA is not defined (after iteration 1). Why?
ERROR: LoadError: UndefVarError: desigA not defined
 macro expansion at /home/mike/astwork/ast/astapp/moid/jul/test.jl:14 [inlined]
 anonymous at ./:?