Author Topic: Loading an Embedded File, Still not certain how exactly.  (Read 3545 times)

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Ok, so this entire time, I've done a good job at loading a file from a certain directory. But now I need to load a text file from the embedded memory in SGDK2. So my main question is, do I specify a filepath or do I simply create a new object named "Putty.txt" and call it in my code with the filestream on "Putty.txt"? I've never loaded a file without using directories before. With dll's it was simply create the DLL as an object Whatever.dll and add "using Whatever;" to the beginning of your file.

I need to load binary files because I'm running into a stack overflow error, similar to the one with the Framesets in the old version of SGDK2.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Loading an Embedded File, Still not certain how exactly.
« Reply #1 on: 2012-06-28, 05:19:44 PM »
The attached bare-bones SGDK2 file demonstrates how to embed and load text. See Embed.cs. The data was embedded using the "Edit as text..." command in the Embedded Data menu of the code editor for Embed.cs.

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Loading an Embedded File, Still not certain how exactly.
« Reply #2 on: 2012-06-28, 06:16:09 PM »
This is very, very nice. Thank you greatly. I'll be able to load sequence .txt files instead of manually copying each line into each element of an array of strings.

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Loading an Embedded File, Still not certain how exactly.
« Reply #3 on: 2012-06-28, 07:26:36 PM »
I almost forgot to ask- are lines still respected? In notepad I have line after line, but can I still read my embedded data line by line? Or are lines destroyed in the embedding process?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Loading an Embedded File, Still not certain how exactly.
« Reply #4 on: 2012-06-29, 04:54:40 AM »
Lines are retained. In fact, the exact binary representation of the data can be embedded if you want by using the "Load From File..." command instead of the "Edit As Text..." command. I think "Edit As Text..." converts the text to binary using UTF-8 encoding before embedding. And of course UTF-8 supports newlines and much more.

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Loading an Embedded File, Still not certain how exactly.
« Reply #5 on: 2012-06-29, 05:44:43 PM »
Perfect, now I can just load the files perfectly and parse from Embedded memory, instead of having them out in the open for manipulation.