Page 1 of 1 1
Topic Options
#59044 - 2001-09-14 09:09 AM kix and carrage returns
Anonymous
Unregistered


I'm trying to write lines into a text file so that it can be read by another script. Here's a sample:

IF $NAV=1 ;this is just a flag saying NAV has been selected.
WriteLine(1, "NAV" + Chr(13) + Chr(10))
ENDIF
As I have numerous if statements the file will have up to 10 lines eg:
NAV
AS400
.
.
Notes

Here's the problem. By having the Chr()'s I'm putting in carage returns and making the file readable. However, by doing this the last value written into the file will have a carrage return after it, which causes a "Open file error". ?????

Jezz

Top
#59045 - 2001-09-14 10:01 AM Re: kix and carrage returns
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Hi Jezz,

I don't believe the 'carriage return' on the last line can create an open file error.

Can you post (part of) the script, so we can help you a little better?

_________________________
The Code is out there

Top
#59046 - 2001-09-14 03:53 PM Re: kix and carrage returns
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Is your file open for writes by that script at the time the other script tries to open it?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#59047 - 2001-09-14 04:21 PM Re: kix and carrage returns
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
here is a why to cutback on the size of the code, asign the chr(13)+chr(10) to a variable, and use the variable where ever you need a line return.

code:

$cr = chr(13)+chr(10)
WriteLine(1, "NAV" + $cr)

More information will be needed to fix this file open error. are you trying to open the file twice?

Bryce

Top
#59048 - 2001-09-17 03:07 AM Re: kix and carrage returns
Anonymous
Unregistered


Cheers LLigetfa and Bryce, the error was that simple.

Thanx as well Bryce, that's probably one spot that I wouldn't have thought to clean up.

Jezz

Top
#59049 - 2001-09-17 05:20 AM Re: kix and carrage returns
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Here's a little snippet of code I found on http://www.BrainBuzz.com posted by MBrecht.
code:

Create Loginlog
Login-Logging that fix the open file Problem


;Writeaccess on a File from more than one User is not possible.
;This script wait 5x3 secounds for writeaccess
;
$LogFile="G:\Folder\Login.log"
$Err=0
$n=0

Do
$Err=Open(1,$LogFile,5)
If $Err<>0
If $n=0
;First wait
? "Please wait"
else
;follow waits
"."
Endif
Sleep 3
else
$Err=WriteLine(1,@DATE+";"+@TIME+";"+@SID+";"+@USERID+";"+@WKSTA+";"+@HOSTNAME+";"+@IPADDRESS0+";"+@ADDRESS+";"+@LSERVER+";"+@RSERVER+";"+@INWIN+";"+$isDFS+Chr(13)+Chr(10))
$Err=Close(1)
Endif
$n=$n+1
Until $Err=0 OR $n=5


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.098 seconds in which 0.07 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org