Source language: Translate to:

File read & File write

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

File read & File write

Postby smartmedia » Tue May 20, 2008 11:19 pm

Hi...

I notice that when two commands are next to its other they are not working.
The FileRead is not actually reads the data.
Example:

Code: Select all
Math "[AA]+[Kinisi.oximata.$RecCount]" "" "[LogAA]"
FileWrite "[PubDir]counter.txt" "All" "[LogAA]"
FileRead "[PubDir]counter.txt" "All" "[AA]"


But if i enter a command beetween them like this:

Code: Select all
Math "[AA]+[Kinisi.oximata.$RecCount]" "" "[LogAA]"
FileWrite "[PubDir]counter.txt" "All" "[LogAA]"
dbpPreviewReport "Kinisi" "C:\Program Files\NeoBook 5\Pub\Kinisi\diatagi.dbr" "DisplayMode=FitPage"
FileRead "[PubDir]counter.txt" "All" "[AA]"


is working...

Does any one notice the same thing...?
The objervation made running the pub in degisn mode.

Thanks
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby HPW » Wed May 21, 2008 1:05 am

A empty testpub with one button:

Code: Select all
Math "[AA]+10" "" "[LogAA]"
FileWrite "[PubDir]counter.txt" "All" "[LogAA]"
FileRead "[PubDir]counter.txt" "All" "[AA]"


The debugger shows the correct value on each press.
And the file gets updated each time.
Hans-Peter
User avatar
HPW
 
Posts: 2521
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby smartmedia » Wed May 21, 2008 9:14 am

Hi...

Hans:
The test made on Pentium III at 900Mhz. Maybe the speed has something to do with it...???

What was your speed...???
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Neosoft Support » Wed May 21, 2008 10:16 am

The actions are executed in series, but the operating system handles the actual file i/o. It may be that Windows is caching the data and delaying the file write by a few nanoseconds, but I've not encountered anything like that before.

In practice, I'm not sure why it would be necessary to write and then immediately read the same value from a file like that.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby smartmedia » Wed May 21, 2008 11:07 pm

Hi...
Neosoft Support wrote:In practice, I'm not sure why it would be necessary to write and then immediately read the same value from a file like that.

You remember the traffic order i was referring, after printing the form i want to keep the counter somewhere. So next time i try to print the form it gets the right counter. That's why i use that.
Code: Select all
Math "[AA]+[Kinisi.oximata.$RecCount]" "" "[LogAA]"
FileWrite "[PubDir]counter.txt" "All" "[LogAA]"
FileRead "[PubDir]counter.txt" "All" "[AA]"
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Odd » Thu May 22, 2008 2:45 am

You could try and put a small Delay in between the write and read actions. I sometimes do to be sure the first action is finished executing before the next action begins.
User avatar
Odd
 
Posts: 81
Joined: Sat Apr 02, 2005 3:34 am
Location: Norway

Postby Gaev » Thu May 22, 2008 4:57 am

smartmedia:

I tried this on my AMD Athlon64 3500 processor ...
Code: Select all
Math "[AA]+10" "" "[LogAA]"
FileWrite "[PubDir]counter.txt" "All" "[LogAA]"
FileRead "[PubDir]counter.txt" "All" "[AA]"
AlertBox "AA" "[AA]"
... and I did not experience any problems ... you might try it too ... i.e. using +10 instead of +[Kinisi.oximata.$RecCount] ... see if there is any difference.

after printing the form i want to keep the counter somewhere. So next time i try to print the form it gets the right counter. That's why i use that.
... what would be wrong with ...
Code: Select all
Math "[AA]+[Kinisi.oximata.$RecCount]" "" "[LogAA]"
FileWrite "[PubDir]counter.txt" "All" "[LogAA]"
SetVar "[AA]" "[LogAA]"

You could try and put a small Delay in between the write and read actions
... or a ...
Code: Select all
RefreshObject "anyObject"
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Neosoft Support » Thu May 22, 2008 10:06 am

You already have the value you want in memory, so it's not necessary to read it back from the file. As Gaev suggested, just copy the value from the first variable [LoggAA] to the second [AA]:

Math "[AA]+[Kinisi.oximata.$RecCount]" "" "[LogAA]"
FileWrite "[PubDir]counter.txt" "All" "[LogAA]"
SetVar "[AA]" "[LogAA]"
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby redjr » Mon Jan 11, 2010 3:47 pm

I have a problem with this command that I can't seem to get beyond. I've reduced what I want to do down to a simple, single line, but it seems no action is being taken by NeoBook when I run this.

I'm calling it from a button press, but I cannot locate the file it's suppose to create. I've even included a path as shown below.

FileWrite "C:\Downloads\PROG_List1.dat" "Append" "[ProgName]"
GotoFirstPage

Is there something really obvious that I'm not seeing or doing correctly?

Once I get this conquered, I'll post back with my ultimate goal of writing a string of variable data to a file and then being able to recall and load it based on user input. But for now, I'm just trying to understand the correct syntax for using this FileWrite command.

Any code examaples of the useage of the FileWrite command would be helpful too.

Thots?

redjr...

Edit... The debugger shows no file getting created. :(
User avatar
redjr
 
Posts: 80
Joined: Tue Jan 06, 2009 2:49 pm
Location: NY

Postby Wrangler » Tue Jan 12, 2010 7:42 am

If the file is outside the [pubdir], use an exclamation mark, like so:

FileWrite "!C:\Downloads\PROG_List1.dat" "Append" "[ProgName]"
GotoFirstPage
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby redjr » Wed Jan 13, 2010 10:46 am

Thanks Wrangler,

On a related topic...

I'm trying to create a .txt file contains a list of users and projects in the following format.

RICK ANGELS
TODD ANGELS
BILL ANGELS
KEVIN ANGELS

I finally have the code to do this as shown below;

StrReplace "[User_Entry]" "[#124]" "[#13]" "[UL]"
StrLen "[UL]" "[LEN]"
StrIns "[#13][#10]" "[UL]" "[LEN]+1" "[UL1]"
StrReplace "[UL1]" "[#13]" "[#09][ProgName][#13]" "[FL]"
FileWrite "[Prgm_Path]\MASTER_List.txt" "ALL" "[FL]"

However, I can only achieve this format when I use the 'ALL' parameter. When I use APPEND I get this result - where everything is on one line.

BILL PHASE2|FRED PHASE2|MARY PHASE2|KEVIN PHASE2|TODD PHASE2|

I need the ability to APPEND because I need this file to grow as I interactively add additional users and projects. Using the 'ALL' parameter overwrites the file. This file will be used for program control.

After a second series of inputs, I would like the file to look like this;

RICK PROGA
TODD PROGA
BILL PROGA
KEVIN PROGA
TOM PROGA
KEVIN PROGB
MARY PROGB
SUE PROGC
ELLEN PROGB

Is there a better/simpler way to approach this then how I'm doing it? Or, do I need to count the rows, and then on the 2nd and subsequents passes of adding new lines items, I physically include the next available line # in the FileWrite construct?

Comments?

redjr...
User avatar
redjr
 
Posts: 80
Joined: Tue Jan 06, 2009 2:49 pm
Location: NY

Postby Wrangler » Wed Jan 13, 2010 10:54 am

Where is the input coming from? A textentry box with multiline?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Postby redjr » Wed Jan 13, 2010 11:01 am

Wrangler wrote:Where is the input coming from? A textentry box with multiline?


Yes, variable [User_Entry].

redjr...
User avatar
redjr
 
Posts: 80
Joined: Tue Jan 06, 2009 2:49 pm
Location: NY

Postby Neosoft Support » Wed Jan 13, 2010 11:12 am

If you want to append multiple lines to the file, then you will need to parse the string and write each line separately one at a time.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Wrangler » Wed Jan 13, 2010 11:13 am

Try a variation of this:

../ parse textentry box contents
StrParse "[User_Entry]" "[#13][#10]" "[part]" "[numparsed]"

../ loop through array and add to file
Loop "1" "[numparsed]" "[x]"
FileWrite "[pubdir]test.dat" "Append" "[part[x]]"
endloop

Run "notepad.exe" "[pubdir]test.dat" "Normal" "" ""

Running notepad is just to view results. You can remove it in your production code.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Next

Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest