Restored from previous forum. Originally posted by Fangbeast.
Hey folks, i've been missing some functions in Powerbasic like "Print Using" and "space$" commands. I used those to write text to defined collumns in my output file.
Is there an easy way to do this in PureBasic? Been trying a few things and not getting very far.
Regards
Fangles
Writing text in collumns to file
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
You can downloaded it directly from here:
http://perso.wanadoo.fr/mr.skunk/Libraries/String2.zip
Check out his other useful libraries at his home page:
http://www.skunknet.fr.st/
Mr Skunk has created a library to do both of these called "String2".Hey folks, i've been missing some functions in Powerbasic like "Print Using" and "space$" commands. I used those to write text to defined collumns in my output file.
You can downloaded it directly from here:
http://perso.wanadoo.fr/mr.skunk/Libraries/String2.zip
Check out his other useful libraries at his home page:
http://www.skunknet.fr.st/
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Fangbeast.
I need to print TEXT data to collumns in a file. His USING command only works on numerical data, namely integers. It does not format text.
The Print Using command in PowerBasic works on text and/or numbers. I need both.
Regards, Fang.
Fangles
Yes, the space command works well, thank you. But the Using command does not do what I asked in the post. I think you didn't understand or I didn't give enough information.Mr Skunk has created a library to do both of these called "String2".
You can downloaded it directly from here:
http://perso.wanadoo.fr/mr.skunk/Libraries/String2.zip
I need to print TEXT data to collumns in a file. His USING command only works on numerical data, namely integers. It does not format text.
The Print Using command in PowerBasic works on text and/or numbers. I need both.
Regards, Fang.
Fangles
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
formatting numbers. Perhaps Power Basic changed the rules.
UPDATE: Can you please give me an example of what you want to do with "Print Using" ?
Edited by - PB on 30 October 2001 20:08:10
Hmm... in every basic that I've ever used, "Print Using" is only used forThe Print Using command in PowerBasic works on text and/or numbers. I need both.
formatting numbers. Perhaps Power Basic changed the rules.

UPDATE: Can you please give me an example of what you want to do with "Print Using" ?
Edited by - PB on 30 October 2001 20:08:10
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Mr.Skunk.
Hi,
If you use non proportional fonts, you can use this
And if you use proportional fonts, you can use this :
Hope it helps...
Mr Skunk
Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st
Hi,
If you use non proportional fonts, you can use this
Code: Select all
If OpenWindow(0, 200, 200,400 , 300, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
drawingoutput(windowid())
a$="First text"
b$="This is a second text"
tab=200
a=textlength(a$)
b=textlength(b$)
locate(tab-a,40):drawtext(a$)
locate(tab-b,60):drawtext(b$)
stopdrawing()
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventCloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End
Code: Select all
If OpenWindow(0, 200, 200,400 , 300, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
drawingoutput(windowid())
a$="First text"
b$="This is a second text"
tab=20
a=len(a$)
b=len(b$)
locate(tab-a,40):drawtext(a$)
locate(tab-b,60):drawtext(b$)
stopdrawing()
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventCloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End
Mr Skunk
Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Fangbeast.
Franco posted an insert template but it pads the string out with extra data if it doesn't fit but I don't the string to grow (for neat formatting reasons).
I want to be able to print to a text file in neat collums with tabs predetermined by me. If the data in each collumn impinges on the next, it must be truncated.
regards, Fang.
Fangles
Could be right, it's been a few months since I used PowerBasic. Not at all since I got PureBasic. What I really need however, is the ability of MID to insert data back into a string (Like PowerBASIC's MID$) but with the ability to truncate extra data if it doesn't fit.Hmm... in every basic that I've ever used, "Print Using" is only used for
formatting numbers. Perhaps Power Basic changed the rules.
Edited by - PB on 30 October 2001 20:08:10
Franco posted an insert template but it pads the string out with extra data if it doesn't fit but I don't the string to grow (for neat formatting reasons).
I want to be able to print to a text file in neat collums with tabs predetermined by me. If the data in each collumn impinges on the next, it must be truncated.
regards, Fang.
Fangles
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by wavemaker.
Is this what you need? I don't think it's worth a new function, this procedure should work quite as fast as coding it in Asm:
Bye,
Juan Calderón Alonso
Registered user
Is this what you need? I don't think it's worth a new function, this procedure should work quite as fast as coding it in Asm:
Code: Select all
Procedure.s Fit(string.s, size.l)
If sizeLen(string)
string = string + Space(size-Len(string))
EndIf
EndIf
ProcedureReturn string
EndProcedure
Juan Calderón Alonso
Registered user