Source language: Translate to:

Save a txt file outside NB

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Save a txt file outside NB

Postby sbritton » Fri Apr 19, 2013 4:00 pm

Hi Folks,

I am trying to figure out how to save a *.txt document outside of NB. (Of course, the .txt file was created within NB.)

I want to use the similar method that the InternetLink action uses, except, in this case, rather than launching the default web browser, I want the standard Windows "save as" window to pop-up so the user will have an option of where to save the file.

So far, the only way that I can save files is within NB using FileWrite.

Thank you,

Steve
sbritton
 
Posts: 3
Joined: Thu Apr 18, 2013 2:24 pm

Re: Save a txt file outside NB

Postby Gaev » Fri Apr 19, 2013 5:02 pm

Steve:

From the Help file ...
FileSaveBox

Purpose:
Allow the reader to specify a file name using a standard Windows File Save dialog box.

Category:
Messages/Interaction

Syntax:
FileSaveBox "title" "file mask" "initial directory" "variable"

See FileOpenBox for a description of these parameters.

Example:
FileSaveBox "Save" "Any File|*.*" "c:\" "[File]"
If "[File]" ">" ""
FileWrite "[File]" "1" "[CustomerInfo]"
EndIf

... and if by "the .txt file was created within NB" you mean that it was [Embedded] at compile time ... then take a look at ...
FileToVar

Purpose:
Read the contents of a file into a variable. This is similar to using FileRead with the “All” option, but unlike FileRead, FileToVar can be used with Embedded files.

Category:
Files

Syntax:
FileToVar "file name" "variable"

file name
The name of an existing external or embedded file.

variable
The name of the variable to store the contents of the file.

Example:
FileToVar "[Embedded]dealers.txt" "[TextEntry1]"
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Save a txt file outside NB

Postby sbritton » Sat Apr 20, 2013 4:11 pm

Hi Gaev,

Thank you for pointing out the code. This is the first time that I have used NeoBook to save files and still learning how it works.

I am still having problems.

I am building an simple app that takes form input and formats an HTML page, "test.html" and I want to give the user to save the completed page outside of NeoBook.

With the code below, the Windows "Save" box to pop up, but it does not show any file in the "File Name:" but it does show "Save File As: *.html"

I want the test.html file that was created in NB to show up in the File Name box. Right now, the File Name box is blank. I cannot figure out how to get the file (and file name) to show up.

Could you check out the code and suggest what I am doing wrong?

FileSaveBox "Save" "*.html" "c:\" "test.html"
If "[File]" ">" ""
FileWrite "[File]" "1" "[CustomerInfo]"
EndIf


Thanks again for your help.

- Steve
sbritton
 
Posts: 3
Joined: Thu Apr 18, 2013 2:24 pm

Re: Save a txt file outside NB

Postby Gaev » Sat Apr 20, 2013 6:14 pm

Steve:

Try this ...
Code: Select all
FileSaveBox "Save" "*.html" "c:\test.html" "[File]"
If "[File]" ">" ""
     FileWrite "[File]" "1" "[CustomerInfo]"
EndIf


P.S. For what you are trying to do ... the second parameter of the FileWrite command should perhaps be "All" instead of "1" ... and [CustomerInfo][/b] should be replaced with the variable that contains the html contents ... please read the Help file to understand how this command works.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Save a txt file outside NB

Postby sbritton » Sat Apr 20, 2013 8:19 pm

Thanks for the help Gaev.

Still working on a solution, but you have pointed me in the right direction.

- - - Steve
sbritton
 
Posts: 3
Joined: Thu Apr 18, 2013 2:24 pm

Re: Save a txt file outside NB

Postby dpayer » Sun Apr 21, 2013 7:34 am

sbritton wrote:Thanks for the help Gaev.

Still working on a solution, but you have pointed me in the right direction.

- - - Steve


Steve, welcome to Neobook! I hope you will find it as fun and interesting as many of us here have.

I'd like to suggest that you take an hour or two and go through EVERY action in the helpfile. You will discover many useful things to use in your coding. I still find new aspects to the Neobook Script language that I was unaware of. Also, take a look at some of the things on the resource center site (see button upper right of this page). There are lots of samples there of code, many are in .pub format so you can see how others have done things.

This forum is also a good resource. Example, do a search for filewriteand you will find over 1100 comments on the use of that action command.

Good luck in your efforts. We hope to hear of your accomplishments here in the forum!

David P.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest

cron