473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

ASP Write Method - How to Position the Cursor

Hi all, I'm building a text file from a database table using the ASP
Write Method and would like to position the cursor in a specific
column position before writing the fields. As I loop through and write
the fields into strings of rows, I want to be able to put field1 in
row1/column position1, field2 in row1/column position10,.....etc.

I've included the basic code to write a string of text. I understand
the process of how to write the fields and loop, etc. If you would be
kind enough to just show me in there the syntax for positioning the
cursor before the write I will then apply it to my code.

Your help is appeciated!

Code
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject ")
set f=fs.CreateTextFile("c:\test.txt",true)
f.write("Hello World!")
f.write("How are you today?")
f.close
set f=nothing
set fs=nothing
%>The file test.txt will look like this after executing the code
above:

Result
Hello World!How are you today?

Feb 7 '07 #1
4 4652
Billy wrote on 7 Feb 2007 08:05:00 -0800:
Hi all, I'm building a text file from a database table using the ASP
Write Method and would like to position the cursor in a specific
column position before writing the fields. As I loop through and write
the fields into strings of rows, I want to be able to put field1 in
row1/column position1, field2 in row1/column position10,.....etc.

I've included the basic code to write a string of text. I understand
the process of how to write the fields and loop, etc. If you would be
kind enough to just show me in there the syntax for positioning the
cursor before the write I will then apply it to my code.

Your help is appeciated!

Code
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject ")
set f=fs.CreateTextFile("c:\test.txt",true)
f.write("Hello World!")
f.write("How are you today?")
f.close
set f=nothing
set fs=nothing
%>The file test.txt will look like this after executing the code
above:

Result
Hello World!How are you today?
To position the "cursor" (you're actually just writing to a file, there is
no cursor, but I'll stick with your terminology), you have to write the data
to get it to where you want it to go.

For instance, if you want Hello at row 1 col 1, and then World at row 1 col
10, and How are you at row2 col 3, you would do something like this:

f.write "Hello" & Space(4) & "World" & vbCrLf & Space(2) & "How are you"

You have to work out how to do all the spacing yourself - there is no such
thing as a cursor position.

Dan
Feb 7 '07 #2
On Feb 7, 11:12 am, "Daniel Crichton" <msn...@worldofspack.comwrote:
Billy wrote on 7 Feb 2007 08:05:00 -0800:


Hi all, I'm building a text file from a database table using the ASP
Write Method and would like to position the cursor in a specific
column position before writing the fields. As I loop through and write
the fields into strings of rows, I want to be able to put field1 in
row1/column position1, field2 in row1/column position10,.....etc.
I've included the basic code to write a string of text. I understand
the process of how to write the fields and loop, etc. If you would be
kind enough to just show me in there the syntax for positioning the
cursor before the write I will then apply it to my code.
Your help is appeciated!
Code
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject ")
set f=fs.CreateTextFile("c:\test.txt",true)
f.write("Hello World!")
f.write("How are you today?")
f.close
set f=nothing
set fs=nothing
%>The file test.txt will look like this after executing the code
above:
Result
Hello World!How are you today?

To position the "cursor" (you're actually just writing to a file, there is
no cursor, but I'll stick with your terminology), you have to write the data
to get it to where you want it to go.

For instance, if you want Hello at row 1 col 1, and then World at row 1 col
10, and How are you at row2 col 3, you would do something like this:

f.write "Hello" & Space(4) & "World" & vbCrLf & Space(2) & "How are you"

You have to work out how to do all the spacing yourself - there is no such
thing as a cursor position.

Dan- Hide quoted text -

- Show quoted text -
Ok, thank you. What I'm actually trying to do is to write out fields
from a table that I have no control to change; and the data in the
fields are variable in size (never the same length), yet the developer
who is importing my final text file data into a hosted app is
requiring this text file to be fixed width - not comma delimited. I
have to ensure that no matter how long the string of data that I read
from the field is, that I write it in each row consistently in the
same place. I never know how big the field string will be so I cant
just write spaces after the write or else the data shifts constantly.
I gave the developer a field definition table so he is expecting the
fields to always appear the same size.....

output example (see how the data shifts from row to row when the field
is shorter in some instances.....

example:

PK 0676 PRE 908047817799 FedEx 02/06/2007
PK 068 PRE 908047817803 FedEx 02/06/2007
LKZ PRE 908047817939 FedEx 02/06/2007

Feb 7 '07 #3
Billy wrote on 07 feb 2007 in microsoft.public.inetserver.asp.general:
yet the developer
who is importing my final text file data into a hosted app is
requiring this text file to be fixed width - not comma delimited.
you can fill the defined room of char places to a defined total:

VBS example:

aStringvalue = "qwerty"

function fillPlaces(v,n)
bars = "-------------------------------------- "
fillPlaces = right(bars & v,n)
end function

f.write fillPlaces(aStringvalue,12)
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 7 '07 #4
Billy wrote:
Ok, thank you. What I'm actually trying to do is to write out fields
from a table that I have no control to change; and the data in the
fields are variable in size (never the same length), yet the developer
who is importing my final text file data into a hosted app is
requiring this text file to be fixed width - not comma delimited. I
have to ensure that no matter how long the string of data that I read
from the field is, that I write it in each row consistently in the
same place.
Use Left() to guarantee the proper length:
a="PK"
correct_length_a=Left(a & Space(5), 5)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Feb 7 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Xah Lee | last post by:
Why is that some of my files written out by outF.write(outtext.encode('utf-8')) has ascii 10 as EOL, while others has ascii 13 as EOL? both of these files's EOL are originally all ascii 10. If...
3
by: jason | last post by:
I've got this javascript routine (i found on google - thank you) in an asp.net page that on page reload sets the cursor of a textbox to the last line. It works great! Using a similar concept, I...
3
by: Priya | last post by:
Hi all, Is there any method for getting cursor position in the textarea? that method is required to work fine in Netscape 4+. Could any of you plz suggest me the solution at the earliest? -...
2
by: Michael C | last post by:
Hi all, When I try to use the GetItemAt (e.X, e.Y) method in a ListView MouseDown() event, it only works some of the time. If I right-click on an open area of the ListView, I get null back as...
3
by: Mathieu Chavoutier | last post by:
I want to make a tool to design (like paint). So, I want to know the position of the mouse. Cursor.Position.X gives me that information. But, when I draw a picture, it is not at the good place...
1
by: Paul | last post by:
Hi all, I am making a DirectInput application wich must report correctly the cursor position in windowed mode (it means it has to be the same as Microsoft Window´s cursor position). First of...
5
by: simonl | last post by:
I'm messing about with a console app that does some tedious data processing, I want to show activity in the console window. What I wanted was - followed by \ followed by | etc; ie a bar...
0
by: martinmercy2001 | last post by:
Could any body help me with creating a ring buffer class using a string. use memory circular buffer not an IO buffer. just read, write and seek method. Read method should take anumber and return the...
2
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.