Defining and call a function - Atom

I am defining a function and call the same function. When I use the juliabox, the code works well, but I need to use the Atom, then the code don’t works. I first write the function than after I call it, I am using the same julia file, do I need to use two file. For exemplo, julia1.jl for the function and julia.jl to call the funcion. How do I define the funcion in julia2.jl?

Above is my codem that works well in juliabox. I send too the picture off the erros in the Atom IDE.

Tks a lot,
Tulio

function pontosinteriores(Ao,b,c,max_ite)

  # avaliando viabilidade
  status = 1;


  # Formatação do Problema na forma padrão
   (m,n) = size(Ao);

  rho = 0.05
  α = 0.9
  k=0; # número de iterações

   A = [Ao eye(m)];
   c=[c ;zeros(m,1)];


   (m,n) = size(A);

  TOL = 10.0^(-7)
   x = fill(10,n)
   s = fill(10,n)
   y = fill(10,m)
   e = ones(n,1)
  l= x'*s
  while (l[1] > TOL) & (k < max_ite)

      l= x'*s
      u = rho*x'*s/n
      X = x.*eye(n)
      S = s.*eye(n)
      J= [A zeros(m,m) zeros(m,n);zeros(n,n) A' -eye(n); S zeros(n,m) X]
     

      F = [A*x-b;A'*y-s-c; X*S*e-u.*e]
     
      D=J\(-F)
  
      d_x = D[1:n]
     
      d_y = D[n+1:n+m]
   
      d_s = D[n+m+1:n+m+n]
  
      #calculo do tamanho dos passos

      indx = d_x.<0;
      if(sum(indx)>0)
          aux = α*minimum(-x[indx]./d_x[indx]);
          β_p = minimum([1 aux] );
      else
          β_p = 1;
      end

      indx = d_s.<0;
 
      if(sum(indx)>0)
          aux = α*minimum(-s[indx]./d_s[indx]);
          β_d = minimum([1 aux] );
      else
          β_d = 1
      end
      # atualização

      x = x+β_p*d_x;
      y = y+β_d*d_y;
      s = s+β_d*d_s;
     
      # teste de ilimitado
      for i=1:size(x,1)
          if(abs(x[i])>10.0^(9))
              status = 0;
              return(x,y,s,status)
          end
      end
      # teste inviavel
      for i=1:size(y,1)
          if(abs(y[i])>10.0^(9))
              status = -1;
              return(x,y,s,status)
          end
      end


      k=k+1;


  end
  # teste maximo de iteracao
  if (k == max_ite)
      status = -2
      return(x,y,s,status)
  end

  return(x,y,s,status)

end


# teste solução inviavel
teste ="ilimitado"; 

if(teste =="inviavel2")
    c = -[2 3]';                           # Coeficientes de custo da FOB
    Ao = [1 3; 1 -3; 1 1; -1 -1];  # Matriz de coeficientes do conjunto de restrições
    b = [10 9 5 -10]';
elseif (teste =="inviavel1")
    Ao = [2 1; 1 2; -1 -1];
    b = [4 4 -10]';
    c = [4 3]';
elseif (teste =="otima")
    Ao = [2 1; 1 2; -1 -1]
    b = [4 4 -1]'
    c = [4 3]'
elseif (teste =="ilimitado")
     c = [1 0]';                             
     Ao = [-2 -1; -1 1];           
     b = [40 0]';
end

    
    (x,y,s,status) = pontosinteriores(Ao,b,c,100)
    @show x
    @show y
    @show s
    @show status
    if(status==-1)
        println("O problema é inviável");
    elseif(status==-2)
        println("O problema atingiu o máximo de iteração");
    elseif(status==1)
        println("Ponto ótimo encontrado");
    elseif(status==0)
        println("O problema é ilimitado");
    end

I can’t replicate your error, I copied into Atom from your post and it ran fine. I got the following output:

x = [6.08919e11, 497.999, 1.21784e12, 6.08919e11]
y = [4.55082e-6, 8.66684e-7]
s = [2.67943e-6, 0.243902, 4.55082e-6, 8.66684e-7]
status = 0
O problema é ilimitado

If you’re highlighting sections and using the “Run Block” lightning bolt button but haven’t highlighted the whole function you’ll get that error. You need to highlight the whole block all the way to the end for it to run correctly.

Tks Muninn, it works now. Do u know the difference between Run Block and Run File?