Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Elektron72

Running the OpenOS Editor from a program

Question

I am making a program where one of the functions is to open the editor. However, I noticed that part of the program's code seems to interfere with the editor. When the editor is opened by my program, it freezes immediately after displaying the file and will not accept any input. What part of the code is responsible for the issue?

Here is a standalone version of the broken code (https://pastebin.com/CppRwXqh) :

local filesystem = require("filesystem")
local shell = require("shell")
local process = require("process")
local cellLocation
local i
local j
local tempchar
 
function createProgramList()
  cellLocation = shell.resolve(process.info().path)
  cellLocation = filesystem.canonical(cellLocation .. "/..")
  print(cellLocation .. "/programs.cfg")
  io.input(cellLocation .. "/programs.cfg")
  programs = {}
  i = 1
  while 1 do
    print("Loading program #" .. tostring(i) .. "...")
    programs[i] = {}
    print("Loading name...")
    while 1 do
      tempchar = io.read(1)
      if tempchar == ";" then
        break
      elseif programs[i][1] ~= nil then
        programs[i][1] = programs[i][1] .. tempchar
      else
        programs[i][1] = tempchar
      end
    end
    print("Loading option name...")
    while 1 do
      tempchar = io.read(1)
      if tempchar == ";" then
        break
      elseif programs[i][2] ~= nil then
        programs[i][2] = programs[i][2] .. tempchar
      else
        programs[i][2] = tempchar
      end
    end
    programs[i][3] = {}
    j = 1
    print("Loading file associations...")
    while 1 do
      tempchar = io.read(1)
      if tempchar == "," then
        j = j + 1
      elseif tempchar == ";" then
        break
      elseif programs[i][3][j] ~= nil then
        programs[i][3][j] = programs[i][3][j] .. tempchar
      else
        programs[i][3][j] = tempchar
      end
    end
    print("Loading run syntax...")
    while 1 do
      tempchar = io.read(1)
      if tempchar == nil or tempchar == "\n" then
        break
      elseif programs[i][4] ~= nil then
        programs[i][4] = programs[i][4] .. tempchar
      else
        programs[i][4] = tempchar
      end
    end
    if tempchar == nil then
      break
    end
    i = i + 1
  end
end
 
createProgramList()
shell.execute("edit /init.lua")

Also, a file named programs.cfg is necessary in the same directory containing the following text:

;;;

 

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.