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

Username:   Password: 
 RegisterRegister   
 include "file.t"
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tallguy




PostPosted: Thu Mar 12, 2009 8:22 am   Post subject: include "file.t"

i'm just curious if instead of including in an entire file, can i just call upon a procedure that is within that file?
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Thu Mar 12, 2009 8:42 am   Post subject: RE:include "file.t"

There is no way to include individual methods from another file. However, if the file you're including contains only procedures (no code that would execute were you to run file.t) then I don't see what the problem is with just including the whole file.

What problem are you trying to solve?
Tallguy




PostPosted: Fri Mar 13, 2009 9:18 am   Post subject: Re: include "file.t"

okay so this is my assigments

Quote:
Practice Questions for Sequential Files
Little Black Book

1. Create a data file llbook which will contain the name, address, phone number, fax number and email address of your friends. Each of the above fields will be a string variable. Make your program user-friendly and use a sentinel to indicate when the user has finished entering data. Insert at least 10 records. Save this program as create.t.

2. Display all the records in your file lbbook in chart form under appropriate headings. Take care to display one screen of data at a time. Use a getch to get from one screen to another. Even if your file is not so long, you only have 10 friends, boo-hoo, your program should still include this feature to prevent names and other data from scrolling off the page. Headings should appear on each screen. Save this program as display.t.

3. Write a program to modify the file lbbook so that you can add or delete one friend at a time. Give the user a menu which includes: adding a friend to the file, deleting a friend from the file, viewing the current file and exiting the program.
Menu

1. Add a Record
2. Delete a Record
3. View the File
4. Exit
Error trap the menu choice. In the case of option 2, if the record to be deleted does not exist in the file, give the user a message to this effect. Save as add_del.t.

4. You decide to have two files, llbook and llbook2. The difference is that the later, llbook2 should also contain the birthday of your friends. Create this new file llbook2. Save as create2.t.

5. Create a program which uses a function to return how many friends are in your file llbook. Save as popular.t.


so i'm done 1,2,3 and working on #4, i've attached wat i have, so instead of copying the entire code again, i just want to includ some procs, see what you think



vanderMout_FileAccess.zip
 Description:

Download
 Filename:  vanderMout_FileAccess.zip
 Filesize:  6.11 KB
 Downloaded:  44 Time(s)

DemonWasp




PostPosted: Fri Mar 13, 2009 10:03 am   Post subject: RE:include "file.t"

What you seem to be getting at is that you want a common "library" of functions that you can just include from any of several different "main" files, which would make each "main" file much simpler. This works as follows:

1. Write a library file. This file contains the definitions for your data storage (probably a few global variables), as well as all the procedures and functions that operate on that data. It does NOT include any code outside a procedure/function that isn't a variable declaration.

Turing:

% The following are all good things to have in a library file:
var myDataStructure : array 1..30 of string

proc doSomethingToDataStructure()
    % Actually do the something here
end doSomethingToDataStructure


Turing:

% The following are NOT good to have in the library file:
put "My Program"
doSomethingToDataStructure()


2. To double-check, if you run the library file, it shouldn't even bring up a run window.

3. In each of the various files you're supposed to create (create.t, display.t, add_del.t, create2.t, popular.t, which we'll call the "main" files), you would put this as the first line of real code:
Turing:

include "littleBlackBookLibrary.t"


4. In each of the "main" files, you have code that calls those library functions. That's all they really need to do.
Tallguy




PostPosted: Fri Mar 13, 2009 11:06 am   Post subject: RE:include "file.t"

o, okay, i understand, thanks a lot man, it sorrta helps
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  [ 5 Posts ]
Jump to:   


Style:  
Search: