Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 how to import turing files
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rsshelas




PostPosted: Thu Nov 18, 2010 7:43 pm   Post subject: how to import turing files

ok so iam making a turing calculater all in one and i was wondering how to import a turing file so lets say if the user wants to convert binary a turing fill will open in a run menu and so on

anyone know how?
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Fri Nov 19, 2010 3:43 am   Post subject: RE:how to import turing files

I'm not understanding the question completely.

import use is that to use variables/code inside a closed source such as class's or modules etc.

If your wanting to use code from another turing file that would be using "include".

From your question you want to change the type of calculator or the window size/etc? menues? This all can be done without either including files or importing things from code within....

Please update the question so we can assist you further thanks!
ProgrammingFun




PostPosted: Fri Nov 19, 2010 9:10 am   Post subject: Re: how to import turing files

A file can only be imported if it has the file extension: .tu as opposed to .t

In the following example, I am importing a file called Procedures.tu as well as the default GUI file:
Turing:

import Procedures, GUI  %importing proceudres
var g : ^Procedures
new Procedures, g


The var is necessary to import the file but make sure that you do not use that var elsewhere...

In the .tu file, you would need to name the class that you are exporting (same as import name) as well as all of the procedures you wish to export:

Turing:

unit

class Procedures

    export LoadingBar, TitleFont, BodyFont, MainPage1, MainPage2, GrainLesson, VeggieLesson, MilkLesson, MeatLesson
        , About, Quiz1, Quiz2, QuizSelection, MainPageGUI, AboutGUI, GrainGUI, VeggieGUI, MilkGUI, MeatGUI

%All Procedures Go here
%--------------------------

end Procedures


The program from which I gave you these examples is available here: http://compsci.ca/v3/viewtopic.php?t=23967&highlight=food+guide
TokenHerbz




PostPosted: Fri Nov 19, 2010 1:18 pm   Post subject: RE:how to import turing files

code:

include "Location\\FileName.tu"


that lets you use the file and everything inside that file without having to create new useless variables to address which file it is that you want to use...

All the variables and func/proc/class/etc inside that .tu file would be used the same way as it would as if it where in the original code.


code:

import Variable,String,Procedure,etc


This is mostly used in Class's and other structures that act as such.
heres an example of it in use, (I'll do a quick example to show you how it works (its bad programming to have it setup this way tho - Just to show you import in use!))

code:

var name : string := "Turtle" %%name outside class to show you import use

class Animal
    import name %%IMPORTS A VARIABLE TO USE INSIDE A CLASS
    export Init, Detail %%EXPORTS TO USE OUTSIDE OF A CLASS

    var size : real
    var color_ : string
    %%name would go here to but not for example

    proc Init (s_ : real, c_ : string)
        size := s_
        color_ := c_
    end Init

    proc Detail (n_ : string)
        put n_, ": Size: ", size, "color: ", color_
    end Detail
end Animal

var pet : ^Animal
new Animal, pet
pet -> Init (.3, "green") %%initalize the animal
pet -> Detail (name)  %%remember our name turtle! Its not in the class but we USE IT in the class, via "IMPORT"
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: