Page 1 of 1
Posted: Sun Oct 28, 2001 8:42 am
by BackupUser
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
Posted: Mon Oct 29, 2001 2:54 am
by BackupUser
Restored from previous forum. Originally posted by PB.
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.
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
Check out his other useful libraries at his home page:
http://www.skunknet.fr.st/
Posted: Tue Oct 30, 2001 8:43 am
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.
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.
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
Posted: Tue Oct 30, 2001 11:03 am
by BackupUser
Restored from previous forum. Originally posted by PB.
The Print Using command in PowerBasic works on text and/or numbers. I need both.
Hmm... in every basic that I've ever used, "Print Using" is only used for
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
Posted: Tue Oct 30, 2001 10:15 pm
by BackupUser
Restored from previous forum. Originally posted by Mr.Skunk.
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
And if you use 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=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
Hope it helps...
Mr Skunk
Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st
Posted: Wed Oct 31, 2001 10:27 am
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.
Hi,
If you use non proportional fonts, you can use this
Hope it helps...
Mr Skunk
No Mr Skunk, it doesn't, sorry. I said in my earlier post, "printing in collumns to a FILE, NOT the screen. Thanks anyway.
Fangles
Posted: Wed Oct 31, 2001 10:31 am
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.
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
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.
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
Posted: Wed Oct 31, 2001 12:43 pm
by BackupUser
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:
Code: Select all
Procedure.s Fit(string.s, size.l)
If sizeLen(string)
string = string + Space(size-Len(string))
EndIf
EndIf
ProcedureReturn string
EndProcedure
Bye,
Juan Calderón Alonso
Registered user