Recent

Author Topic: MultiFormat File - Simplest - Flexible  (Read 25171 times)

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: MultiFormat File - Simplest - Flexible
« Reply #15 on: August 23, 2016, 12:30:59 am »
Code: [Select]
Var
 C: Cardinal;
begin
  ...
  fs.Read(C, SIzeOf(C));
  ...
end.
Perhaps i'm daft but, that doesn't look very fool-proof to me. It'll work for ansistrings only.

Error on this line...

Code: Pascal  [Select][+][-]
  1. Memo1.Lines.Text :=StringFromStream(fs);
  2.  

Identifier not found
It should read Memo1.Text := StringFromStream(fs);
« Last Edit: August 23, 2016, 12:36:49 am by molly »

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: MultiFormat File - Simplest - Flexible
« Reply #16 on: August 23, 2016, 12:31:25 am »
  Memo1.Text :=AnsiString(fs);
That makes no sense.

Agreed.

Since you read C bytes into Result, try this:

Memo1.Text := Result;

Tip: Don't name your variable Result, since that's the name to use when returning a function result.

And put fs declaration inside your event handler. Don't see any reason why it's outside.

Result..... ERROR
Identifier not found

Code: Pascal  [Select][+][-]
  1. var
  2.   C: Cardinal;
  3.   fs : TFileStream;
  4.   StringFromStream: String;
  5. begin
  6.     fs := TFileStream.Create('test.txt', fmOpenRead);
  7.     fs.Read(C, SIzeOf(C));
  8.     SetLength(Result, C);
  9.     fs.Read(Result[1], C);
  10.     Memo1.Text :=Result;
  11.     fs.Free;
« Last Edit: August 23, 2016, 12:33:12 am by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: MultiFormat File - Simplest - Flexible
« Reply #17 on: August 23, 2016, 12:34:18 am »
Review the properties available to you with the TMemo control.


pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: MultiFormat File - Simplest - Flexible
« Reply #18 on: August 23, 2016, 12:34:28 am »
Code: [Select]
Var
 C: Cardinal;
begin
  ...
  fs.Read(C, SIzeOf(C));
  ...
end.
Perhaps i'm daft but, that doesn't look very fool-proof to me. It'll work for ansistrings only.

Okay... well my file will have normal text, rft code and binary in it
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

sky_khan

  • Guest
Re: MultiFormat File - Simplest - Flexible
« Reply #19 on: August 23, 2016, 12:36:00 am »
Quote from: technipixel
Identifier not found

You should include in your unit StringFromStream procedure you referenced somewhere above. BTW it will help if you give full error message from now on.

Quote from: molly
Perhaps i'm daft but, that doesn't look very fool-proof to me. It'll work for ansistrings only.

I'm aware of that but IMO, reaching somewhat working code is priority now than foolproof code.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: MultiFormat File - Simplest - Flexible
« Reply #20 on: August 23, 2016, 12:42:48 am »
I'm aware of that but IMO, reaching somewhat working code is priority now than foolproof code.
Fair enough.

I'll stay out, as i do not have anything positive to contribute to this thread otherwise.

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: MultiFormat File - Simplest - Flexible
« Reply #21 on: August 23, 2016, 12:43:56 am »
Using the normal load method directly to the control works fine....
Code: Pascal  [Select][+][-]
  1. Memo1.Lines.LoadFromFile(myFile);

But, someone suggested using the Stream because I need to parse the text of my various formats.

However, I want to see the RAW text in the Memo1 for debgging purposes.

Ultimately, I will be reading the text from within an EXE
And parsing it out to the controls.


« Last Edit: August 23, 2016, 12:46:05 am by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: MultiFormat File - Simplest - Flexible
« Reply #22 on: August 23, 2016, 12:53:16 am »
GOT IT Working...
But, I had to comment out the lines that use the "C" and "Result" (errors)

Why do I need it anyways??
I just want the raw string.


Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button2Click(Sender: TObject);
  2.  
  3. var
  4.   C: Cardinal;
  5.   fs : TFileStream;
  6.  
  7. begin
  8.   fs := TFileStream.Create('test.txt', fmOpenRead);
  9.  
  10.   //fs.Read(C, SIzeOf(C));
  11.   //SetLength(Result, C);
  12.   //fs.Read(Result[1], C);
  13.  
  14.   Memo1.Lines.LoadFromStream(fs);
  15.  
  16.   fs.Free;
  17. end;
« Last Edit: August 23, 2016, 01:17:16 am by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: MultiFormat File - Simplest - Flexible
« Reply #23 on: August 23, 2016, 12:54:31 am »
Ultimately, I will be reading the text from within an EXE

That still strikes me as a fundamentally bad idea, a DOS-era idea.

As for solving your problems, I would suggest that you sit back, breathe through your nose and let life ebb and flow as you _peruse_ the FPC and Laz documentation and examples.


pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: MultiFormat File - Simplest - Flexible
« Reply #24 on: August 23, 2016, 01:16:41 am »
Yeah, I am.

I just have to decide how I want to parse the data stream itself.
Right now I am just making sure my data stream will write and read as it should... CONSISTENTLY
I don't want funny characters showing up in places I don't need them.

Do I want to use SubStr, Buffers, Blocks. How I am going to handle the Binary.
I'm not sure how I want to use Segment ID's. Then I also have to consider Arrays if needs be.

Something I don't know code-wise... is how to setup buffers & blocks so I can just call a block and grab the whole chunk.
I really don't want to parse data char-by-char... SLOOOWWWW.

:)


Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: MultiFormat File - Simplest - Flexible
« Reply #25 on: August 23, 2016, 01:27:41 am »
Ultimately, I will be reading the text from within an EXE

That still strikes me as a fundamentally bad idea, a DOS-era idea.

As for solving your problems, I would suggest that you sit back, breathe through your nose and let life ebb and flow as you _peruse_ the FPC and Laz documentation and examples.

It may be DOS like, But to create a standlone EXE with embedded data is needed. (think of eBooks, Interactive Animations, HyperCard - Remember that?)
I am planning on creating a prototype  IDE that takes a template EXE (makes a copy) and embeds user data into it. The user can then create their own "Products" with the IDE.

1) IDE (exe file)
2) Template exe (this gets copied and renames as the user wishes)
3) The IDE embeds the users data into the 3rd final exe.

The ideal is like LAZ, Visual Studio, Flash (Animate), SWFStudio, HyperCard, Ne0Book, Help/eBook Creators
They all create 3rd party products

If you have a better way to do this, then please let me know...
« Last Edit: August 23, 2016, 01:30:03 am by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: MultiFormat File - Simplest - Flexible
« Reply #26 on: August 23, 2016, 01:35:46 am »
Put the resources in their own file, not in the executable.

Nobody distributes apps as a single .exe anymore. Again, that's a DOS way of doing thing.

Please point me to a single multi-media title that does it that way.

The IDE idea and the "template" .exe make sense, but I don't get your obsession with putting the resources in the .exe there too. Have you even tested this on Linux and Mac?

Distribute the "template" .exe once and then it's easier to distribute one or more resources files that the .exe can use. Remember, most organizations restrict who installs what, and installers need to be codesigned. What you're describing, if I  understand it correctly, is to distribute .exe's as though they are "books" or something. That is an idea from a world that no longer exists.

Why not do it as a Web app even?

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: MultiFormat File - Simplest - Flexible
« Reply #27 on: August 23, 2016, 01:53:00 am »
Well... they still do exist in our world.
Not everything is web-based.
Games, Desktop apps and interactive media still exist.
People still use CD/DVD and USB's for promoting locally, if not on YouTube.

http://www.wisdom-soft.com/products/motionstudio.htm
http://www.digitalworkshop.com/products/opus-creator.shtml
http://www.neosoftware.com/nbw.html

A selling point with some users is that they want their personal data secured and not be exposed.
What if a User of my IDE has pictures they want kept secure... they can with an EXE a lot more then having an external file, unless it is obfuscated or encrypted.

And I am also working on a prototype of using a external file to hold all the data.
That is actually what I am doing now and will use some of the same data handling for the EXE IDE

But, as I learn Pascal, I am trying to find what and what cannot be done.
So, I have many projects going at once.

I actually do web design, graphics and marketing as my main business... So, I understand the web-world and what they are offering. Software is just a side thing I do and there are just some things you can't do online.

LAZ would never work online!

« Last Edit: August 23, 2016, 01:54:59 am by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: MultiFormat File - Simplest - Flexible
« Reply #28 on: August 23, 2016, 01:59:18 am »
People still use CD/DVD and USB's for promoting locally, if not on YouTube.

Many organizations don't permit these either because of security concerns.

And I am also working on a prototype of using a external file to hold all the data.

Good.

LAZ would never work online!

But many things do...

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/WebAppOverview.html


balazsszekely

  • Guest
Re: MultiFormat File - Simplest - Flexible
« Reply #29 on: August 23, 2016, 07:56:35 am »
@technipixel

As other people pointed out, writing to an external exe is not a very good idea. In some cases the OS will block your application(writer.exe) not to mention the antivirus softwares.
If you still want to go with external resources, here is a working example(windows only):
https://drive.google.com/file/d/0B9Me_c5onmWoZFhwRnAtVnp3bUE/view

1. Compile/Build reader.lpi
2. Compile/Build writer.lpi
3. Start writer.exe(make sure reader.exe is not running). Write the image, text to reader.exe
4. Start reader.exe and load the resources

Basically you can write anything to reader exe, but you have to specify a unique resource name, both when you read and write data.

 

TinyPortal © 2005-2018