How to define the leng of a variable when write or writeline (Language Help)

by Atonau ⌂ @, Chile, Thursday, July 28, 2011, 00:30 (2331 days ago)

I want to write a variable (name$) to a file (txt), but this variable is on a loop, so changes it values from loop to loop, so its lengh to...
Is there a way to make it have the same lengh from loop to loop?

later i want to open the file to read the lines and make operations with them... count, sum and so on... so i need the variables to have the same lengh...

Thanks for all

How to define the leng of a variable when write or writeline

by jwc3119, Tuesday, August 02, 2011, 06:29 (2326 days ago) @ Atonau

I want to write a variable (name$) to a file (txt), but this variable is on a loop, so changes it values from loop to loop, so its lengh to...
Is there a way to make it have the same lengh from loop to loop?

later i want to open the file to read the lines and make operations with them... count, sum and so on... so i need the variables to have the same lengh...

Thanks for all

Hello,

I wrote some code to make file names with the same length. Is this what you had in mind?

Jim topjimmy22@hotmail.com

cls
# array z$[ ] holds extra zeros as strings
dim z$(4)
z$[0] = "0000" : z$[1] = "000" : z$[2] = "00" : z$[3] = "0"
for i = 1 to 100
j$ = string(i)
k$ = "filename" + z$[length(j$)] + j$
print k$
next i

How to define the leng of a variable when write or writeline

by Atonau ⌂ @, Chile, Tuesday, August 02, 2011, 23:23 (2325 days ago) @ jwc3119

looks like could be used.... as idea....

in a loop (if input=No... stops)
the variable a$ has a length of x
x is different in each loop... are names of people...
i can define a max lenght...
if length name is shorter than my defined max lengh... i can add as many " " (nul spaces) as neede to achieve the defined max lengh


it will make the names used the same amount of cols in the txt output file... so when read again by other program... in basic... the next variable will be allways in the same col...

name answer
Stwart Do Little abcccdeedaabccda
Caroline bbbcccdcdcdcdeee
Federich aaaaabbbaccdcdce

How to define the leng of a variable when write or writeline

by jwc3119, Tuesday, August 09, 2011, 06:32 (2319 days ago) @ Atonau

Atonau,

If you are still working on your program, I had this idea. Use a while/endwhile loop to add spaces to the strings you are saving in your data file, something like this...

input n$
while length(n$) < 25
n$ = n$ + " "
endwhile

# if you need more characters, just change the 25 to a larger number

I hope this helps.
Jim

RSS Feed of thread
powered by my little forum