# Error syntax: Extra token 'oftype' after end of expression

**URL:** https://discourse.julialang.org/t/error-syntax-extra-token-oftype-after-end-of-expression/13126
**Category:** New to Julia
**Created:** [August 9, 2018, 10:44pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-oftype-after-end-of-expression/13126 "2018-08-09T22:44:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![marcelord12](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@marcelord12](https://discourse.julialang.org/u/marcelord12)
#### Post date: [August 9, 2018, 10:44pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-oftype-after-end-of-expression/13126/1 "2018-08-09T22:44:20Z")

</div>

Sorry guys, I’m a newbie in Julia and I’m trying hard to execute some bitbucket .jl script files on ATOM 1.29. I think the code is a kind of outdated and I got many errors during execution. I solved some, but when trying to execute the code extract below, I got a Syntax error. Could somebody tell me what is the new syntax to replace dataobject oftype Array{Int64,1}. I tried to remove and let only Array {Int64,1} but it doesn’t work either and returns me the different error below:  
Systemerror: opening file./NewFSAM\_PT/Dist1Iter1.csv: No such file or directory  
in anonymous abase/  
in macro expansion at PlotData.jl:56  
in readcsv at base/datafmt.jl:618  
in #readcsv #14 at base/datafmt.jl:618  
in readdlm at base/datafmt.jl:73  
in #readdlm#6 at base/datafmt.jl:73  
in readdlm at base/datafmt.jl:81  
in #readdlm#7 at base/datafmt.jl:81  
in #readdlm\_auto#11 at base/datafmt.jl:134  
in open at base/iostream.jl:150  
in open at base/iostream.jl:104  
in systemerror at base/ero.jl:64  
in#systemerror#44 at base/error.jl:64

My Julia version is 0.6.4  
Atom 1.29

The code was originally written in Julia 0.45 and is detached below:

==============

for k=1:NumIter  
for i=1:3  
filename = DirName\*“Dist"_string(i)_“Iter"_string(k)_”.csv”

```
    data = readcsv(filename)

    if i==1
        Distributions1[:,:,k] = data
    elseif i==2
        Distributions2[:,:,k] = data
    elseif i==3
        Distributions3[:,:,k] = data
    end
end

filename = DirName*"RobustnessIter"*string(k)*".csv"
data = readcsv(filename)

robustness[:,k] = dataobject oftype Array{Int64,1}

```

end

---

<div class="post-metadata">

### Author: ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)
#### Post date: [August 9, 2018, 10:53pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-oftype-after-end-of-expression/13126/2 "2018-08-09T22:53:01Z")

</div>

So, this might not be what you want, but I think the last line there should be

```julia
robustness[:,k] = data

```

That is, the `oftype Array{Int64,1}` is probably a comment or something that got appended incorrectly.

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [August 9, 2018, 11:01pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-oftype-after-end-of-expression/13126/3 "2018-08-09T23:01:55Z")

</div>

It will be easier to read your code (and also easier for us to help you) if you quote your code: [PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530)

---

<div class="post-metadata">

### Author: ![marcelord12](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@marcelord12](https://discourse.julialang.org/u/marcelord12)
#### Post date: [August 9, 2018, 11:56pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-oftype-after-end-of-expression/13126/4 "2018-08-09T23:56:48Z")

</div>

Do you mean the whole code?

---

<div class="post-metadata">

### Author: ![marcelord12](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@marcelord12](https://discourse.julialang.org/u/marcelord12)
#### Post date: [August 9, 2018, 11:58pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-oftype-after-end-of-expression/13126/5 "2018-08-09T23:58:45Z")

</div>

"  
#====================================================================  
This file plots the distribution from the cross-entropy  
simulations, the average robustness across all cross-entropy trials,  
and a sample monte carlo runs from the selected distributions  
Use ReqIter to select the required cross-entropy trial from which  
you would like to view distributions and run monte carlo simulations  
====================================================================#

include(“MonteCarlo.jl”)  
include(“PlotMCSim.jl”)

# Specify directory from which to read data files

DirName = “./NewFSAM\_PT/”

trials = 1000 # Number of trials in each cross-entropy simulation  
NumIter = 7 # Number of cross-entropy trials to be read from file  
ReqIter = 7 # Required cross-entropy trial to visualize

# Setup variables required

xlabel1 = Array(Array{Float64,1},5)  
xlabel2 = Array(Array{Float64,1},5)  
xlabel3 = Array(Array{Float64,1},3)

Distributions1 = zeros(Nsegments,Nbehavior1,NumIter)  
Distributions2 = zeros(Nsegments,Nbehavior2,NumIter)  
Distributions3 = zeros(Nsegments,Nbehavior3,NumIter)

x1 = collect(1:Nbehavior1)  
x2 = collect(1:Nbehavior2)  
x3 = collect(1:Nbehavior3)

robustness = zeros(trials,NumIter)  
stdrobustness = zeros(NumIter)

Var = zeros(NumIter)  
std = zeros(NumIter)  
AvgRobustness = zeros(NumIter)

#Create labels for bar plots  
for i=1:5  
xlabel1[i] = Array{Float64,1}(Behavior1[i])  
xlabel2[i] = Array{Float64,1}(Behavior2[i])

```
if(i<=3)
 xlabel3[i] = Array{Float64,1}(Behavior3[i])

```

end end

# Read all distributions and robustness values

for k=1:NumIter  
for i=1:3  
filename = DirName\*“Dist"_string(i)_“Iter"_string(k)_”.csv”

```
    data = readcsv(filename)

    if i==1
        Distributions1[:,:,k] = data
    elseif i==2
        Distributions2[:,:,k] = data
    elseif i==3
        Distributions3[:,:,k] = data
    end
end

filename = DirName*"RobustnessIter"*string(k)*".csv"
data = readcsv(filename)

robustness[:,k] = Data

```

end

# Plot distributions for required iteration (bar plots)

figure(4)  
for i = 1:Nsegments  
subplot(Nsegments,1,i)  
bar(x1,Distributions1[i,:,ReqIter][:],width=1,align=“center”,  
alpha=0.6,linewidth=2.0,edgecolor=“k”)  
xticks(x1,xlabel1)  
axis(“tight”)

end

figure(5)  
for i = 1:Nsegments  
subplot(Nsegments,1,i)  
bar(x3,Distributions3[i,:,ReqIter][:],width=1.0,align=“center”,  
alpha=0.6,linewidth=2.0,edgecolor=“k”)  
xticks(x3,xlabel3)  
end

#=  
figure(3)  
for i = 1:Nsegments  
subplot(Nsegments,1,i)  
bar(x2,Distributions2[i,:,ReqIter][:],align=“center”,  
alpha=0.6,linewidth=2.0,edgecolor=“k”)  
xticks(x2,xlabel2)  
end  
=#

# Compute average robustness and standard deviation for all trials

# and plot a graph with errror bars

figure(6)  
for k=1:NumIter

```
AvgRobustness[k] = sum(robustness[:,k])/trials

for i=1:trials
    Var[k] = Var[k] + (robustness[i,k] - AvgRobustness[k])^2
end

Var[k] = Var[k]/trials
std[k] = sqrt(Var[k])

```

end

x = collect(1:NumIter)  
lerror = std  
uerror = std  
errs = vcat(lerror’,uerror’)

plot(x,AvgRobustness)  
errorbar(x,AvgRobustness,yerr=errs,fmt=“ro”)  
ylabel(“Average Robustness”)  
xlabel(“Iterations”)

# Pitch guidance

Distribution1 = Distributions1[:,:,ReqIter]

# Yaw guidance

Distribution2 = Distributions2[:,:,ReqIter]

# Thrust guidance

Distribution3 = Distributions3[:,:,ReqIter]

#trials = 50  
#RunMCSim()  
#PlotSim()  
"

---

<div class="post-metadata">

### Author: ![marcelord12](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@marcelord12](https://discourse.julialang.org/u/marcelord12)
#### Post date: [August 9, 2018, 11:59pm UTC](https://discourse.julialang.org/t/error-syntax-extra-token-oftype-after-end-of-expression/13126/6 "2018-08-09T23:59:50Z")

</div>

hile loading /Users/marcelord12/Documents/phd2018/mppo/thesis/Falsification/PlotData.jl, in expression starting on line 52

#systemerror#44 at error.jl:64 [inlined]

systemerror(::String, ::Bool) at error.jl:64

open(::String, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at iostream.jl:104

open(::Base.#readstring, ::String) at iostream.jl:150

#readdlm\_auto#11(::Array{Any,1}, ::Function, ::String, ::Char, ::Type{T} where T, ::Char, ::Bool) at datafmt.jl:134

#readdlm#7 at datafmt.jl:81 [inlined]

readdlm(::String, ::Char, ::Char) at datafmt.jl:81

#readdlm#6 at datafmt.jl:73 [inlined]

readdlm(::String, ::Char) at datafmt.jl:73

#readcsv#14 at datafmt.jl:618 [inlined]

readcsv(::String) at datafmt.jl:618

macro expansion at PlotData.jl:56 [inlined]

anonymous at \<missing\>:?

include\_string(::String, ::String) at loading.jl:522

include\_string(::Module, ::String, ::String) at Compat.jl:88

(::Atom.##112#116{String,String})() at eval.jl:109

withpath(::Atom.##112#116{String,String}, ::String) at utils.jl:30

withpath(::Function, ::String) at eval.jl:38

hideprompt(::Atom.##111#115{String,String}) at repl.jl:67

macro expansion at eval.jl:106 [inlined]

(::Atom.##110#114{Dict{String,Any}})() at task.jl:80
