locked
Including a textfile RRS feed

  • Question

  • Say I read data from a textfile. Now if I was to send that program to a friend (as well as the textfile), how do I do it in the filepath so that they don't have to manually change the filepath location of the textfiel on their computer? 
    Tuesday, November 25, 2008 12:36 AM

Answers

  • The content from PlayDeez is:

    filePath = Text.GetSubText(File.GetSettingsFilePath(),0,Text.GetLength(File.GetSettingsFilePath())-26)

    However, I have to warn that this is kinda undocumented (ha ha - at the moment everything is undocumented).  While this works for now, there is no guarantee that it might for future releases. 
    • Marked as answer by Dink87522 Wednesday, November 26, 2008 2:40 PM
    Tuesday, November 25, 2008 5:21 PM
  • File.GetSettingsFilePath() looks for your SmallBasicLibrary.dll and returns a string like:
        C:\Documents and Settings\Owner\My Documents\SmallBasic\SmallBasicLibrary.settings
    SmallBasicLibrary.settings is 26 characters long
    If you take your total string and remove the text "SmallBasicLibrary.settings" you are left with the current filepath.  
        C:\Documents and Settings\Owner\My Documents\SmallBasic\
    You can then use     filePath + "the name of your file"     to locate and use your file 

    To send your program to a friend, simply include the .exe, your data file and SmallBasicLibrary.dll
    • Marked as answer by Dink87522 Wednesday, November 26, 2008 2:39 PM
    Wednesday, November 26, 2008 5:40 AM
  • filePath = Text.GetSubText(File.GetSettingsFilePath(),0,Text.GetLength(File.GetSettingsFilePath())-26) 

    • Proposed as answer by PlayDeez Games Tuesday, November 25, 2008 4:49 PM
    • Marked as answer by Dink87522 Thursday, November 27, 2008 11:55 PM
    Tuesday, November 25, 2008 4:49 PM

All replies

  •  Here is a thread were I posed a question as to accessing DOS type commands and being able to read path/folder and file names: http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/cd9d667a-b3d3-4aae-b305-0d64549d589b

    The bottom line answer was there are none, but will be made available in the next update.
    Hopefully this will include an answer to your problem.

    Which I am also wondering.
    I want to create a 3D wire-frame maze game (tip of the hat to Wizardry) and want the maze data to be saved in a data file instead of hard coding the data into the game program.
    This would also allow for a map editor for people to create their own mazes in 2D overhead view and saving to the text file for the game program to read.
    Tuesday, November 25, 2008 4:17 PM
  • filePath = Text.GetSubText(File.GetSettingsFilePath(),0,Text.GetLength(File.GetSettingsFilePath())-26) 

    • Proposed as answer by PlayDeez Games Tuesday, November 25, 2008 4:49 PM
    • Marked as answer by Dink87522 Thursday, November 27, 2008 11:55 PM
    Tuesday, November 25, 2008 4:49 PM
  • PlayDeez;

    I only see a horizontal scroll bar.
    Tuesday, November 25, 2008 5:08 PM
  • The content from PlayDeez is:

    filePath = Text.GetSubText(File.GetSettingsFilePath(),0,Text.GetLength(File.GetSettingsFilePath())-26)

    However, I have to warn that this is kinda undocumented (ha ha - at the moment everything is undocumented).  While this works for now, there is no guarantee that it might for future releases. 
    • Marked as answer by Dink87522 Wednesday, November 26, 2008 2:40 PM
    Tuesday, November 25, 2008 5:21 PM
  • my other solution involved making a extension module that makes Directory.GetCurrentDirectory() visible, but that makes giving your friend an application even more lengthy of a process than before.
    Tuesday, November 25, 2008 5:52 PM
  • Thanks for the help, although I don't get what that lien of code is doing or how to use it. 
    Wednesday, November 26, 2008 2:22 AM
  • File.GetSettingsFilePath() looks for your SmallBasicLibrary.dll and returns a string like:
        C:\Documents and Settings\Owner\My Documents\SmallBasic\SmallBasicLibrary.settings
    SmallBasicLibrary.settings is 26 characters long
    If you take your total string and remove the text "SmallBasicLibrary.settings" you are left with the current filepath.  
        C:\Documents and Settings\Owner\My Documents\SmallBasic\
    You can then use     filePath + "the name of your file"     to locate and use your file 

    To send your program to a friend, simply include the .exe, your data file and SmallBasicLibrary.dll
    • Marked as answer by Dink87522 Wednesday, November 26, 2008 2:39 PM
    Wednesday, November 26, 2008 5:40 AM
  • Thanks for the explanation Rushworks. 
    Wednesday, November 26, 2008 2:37 PM
  • Hopefully they'll add the ability to figure out where the .txt file is.
    The assumption would be in same path as the executable, so maybe something that can read the path where the .exe file is running from?
    Wednesday, November 26, 2008 2:38 PM
  • We will, Path_drc.  That's one of the main reasons we have these forums - to get valuable input from users and incorporate that in upcoming releases.  Thanks for all the feedback and please keep them coming.
    Wednesday, November 26, 2008 2:45 PM
  •  Vijaye;

     I think you guys are doing a bang-up job with this project.  As I work through the programming different things it reminds me of when I was in high-school programming.
    For me it's like a puzzle that, when all the pieces are in place, does more than just leave you with a pretty picture.

    I am not expecting Small Basic to be...  Well, like you have already stated - not a high level .NET programming language.
    But I am very pleased that you are at least putting in what I consider to be bare minimums.

    Thanks for all your work.
    Wednesday, November 26, 2008 6:22 PM