
-----------------------------------
davidkey
Sat Jul 14, 2012 11:10 pm

include/import problem
-----------------------------------
What is it you are trying to achieve?
I'm trying to create a 'guest OS' and having problems trying to generate a list of apps for the list


What is the problem you are having?
the code overwrites over the last app written


Describe what you have tried to solve this problem
Looked into references




var AppStream : int := Dir.Open ("C:/")
var AppTemp : string
var AppMax : int := 0
loop
    for a : 1 .. 2
        AppTemp := Dir.Get (AppStream)
    end for
    AppTemp := Dir.Get (AppStream)
    exit when AppTemp = ""
    AppMax := AppMax + 1
end loop

Dir.Close (AppStream)
AppStream := Dir.Open ("C:/")

var Applist : array 1 .. AppMax of string
var TEST : array 1 .. AppMax of string
for id : 1 .. 19
    for a : 1 .. 2
        AppTemp := Dir.Get (AppStream)
    end for
    Applist (id) := Dir.Get (AppStream)
    TEST (id) := "if id = " + intstr (id) + " then\n    include \"F:/new turing saves may 20/OS/OS/ui/" + Applist (id) + "/core.ti\"\nend if\n"
    exit when Applist (id) = ""
    put TEST (id)
end for

var GenStream : int

for id : 1 .. AppMax
    open : GenStream, "C:/Applist.ti", seek, write
    seek : GenStream, *
    write : GenStream, TEST (id)
    close : GenStream
end for




Please specify what version of Turing you are using
Turing 4.1

PS: C:/ is not the actual file location, and it most likely doesn't matter

-----------------------------------
evildaddy911
Mon Jul 16, 2012 9:25 am

RE:include/import problem
-----------------------------------
glancing through, i think that the problem is that you do not use "mod." if you so not use 
open : GenStream, "C:/Applist.ti", seek, write, mod

Turing will delete the contents of C:/Applist.ti before writing anything to it.

-----------------------------------
davidkey
Mon Jul 16, 2012 3:00 pm

Re: include/import problem
-----------------------------------
Thx for that suggestion, but my output is creating:
if id = 1 then
    include "Applet/./core.ti"
end if
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????if id = 2 then
    include "Applet/../core.ti"
end if
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????if id = 3 then
    include "Applet/TEST APP/core.ti"
end if
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????if id = 4 then
    include "Applet/TEST APP 2/core.ti"
end if
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

update:
i'm using '%' to comment out the symbols but its still annoying to have this created

[syntax="turing"]

var AppStream : int := Dir.Open ("Applet")
var AppTemp : string
var AppMax : int := 0
loop
    AppTemp := Dir.Get (AppStream)
    exit when AppTemp = ""
    AppMax := AppMax + 1
    put AppMax, ": ", AppTemp
end loop

Dir.Close (AppStream)
AppStream := Dir.Open ("Applet")

var Applist : array 1 .. AppMax of string
var TEST : array 1 .. AppMax of string
for id : 1 .. AppMax
    Applist (id) := Dir.Get (AppStream)
    TEST (id) := "if id = " + intstr (id) + " then\n    include \"Applet/" + Applist (id) + "/core.ti\"\nend if\n"
    exit when Applist (id) = ""
    put TEST (id)
end for

var GenStream : int

open : GenStream, "System/Applist.ti", write
write : GenStream, TEST (1)
close : GenStream

for id : 2 .. AppMax
    open : GenStream, "System/Applist.ti", seek, write, mod
    seek : GenStream, *
    write : GenStream, TEST (id)
    close : GenStream
end for
