Hi mibusonians..
Hope everyone doing good here. Having small problem while writing text into the notepad. I m using following code to write to the text file.
outFile.WRITE(Customer.No+ Customer.Name+Item.NetAmount);
But not getting how to write to a particular position in a line for example
custNo CustName NetAmount
1 ABC 100.00
2 JKLXYZ 150.00
If this is the case, because of the variable lenght in the CustName, the Netamount column is not properly aligned. I would be very thankful if someone can help me out in solving this problem i.e., Proper alignment and also if I want to align the Netamount column to the right/Center/left, how can I do this? Also my worry is how to bring the dynamic data under the appropriate lable (for example in the above shown, the name ABC is not under the CustName label rather is starting next after CustNo gets ended, amount 100.00 is starting next to CustName ends but not under NetAmount lable)
Hope I cud get some solution on this.( I have tried with SEEK function which works only at the starting position of the file which is not helpful for me)
Regards to everyone in advance
Dilip
Falling down is not a defeat..defeat is when you refuse to get up.
0
Comments
Use STRLEN to get field length.
Use MAXSTRLEN to use the max length of the field.
Write the field and after that fill with spaces the MAXSTRLEN - STRLEN.
FOR i := 1 TO (MAXSTRLEN - STRLEN) WRITE(' ')
Something like that.
Hope it helps.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
But the suggestions you have given can be applicable if I zst need to write in one line the number of ' ' characters. But my problem is with no. of columns. I am writing in a single line the values of 4 different columns using a single WRITE function like this :
In this scenario I hope I cannot use "for" loop inside the WRITE function. I need to align the Item.Rate and Item.NetAmount values one by one instead the wrong one which I am now able to do is.
1 ABC 10.00 100.00
2 DEFXYZ 200.00 2000.00
3 JKLM 305.00 3050.00
Also, one more problem I have with is that the last two columns to be right aligned where I didnot find a function for alignment purpose which can be used inside the WRITE function.
Let me hope I cud get a better solution this time before I cud evaluate this. Thank U all.
Falling down is not a defeat..defeat is when you refuse to get up.
in this way, you will have your fields aligned...to right align the field, try to add spaces before the field value...try with this function (return txtstring, parameters: txtstring and maxlen)
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog