How to use Print / PrintN vs. Debug

Just starting out? Need help? Post your questions and find answers here.
gemrite
New User
New User
Posts: 2
Joined: Tue Jul 05, 2022 8:55 pm

How to use Print / PrintN vs. Debug

Post by gemrite »

Hello

I'm working my way thru the book, "Purebasic, A Beginners Guide to Computer Programming".
In all of the samples given, I am trying to user Print or PrintN instead of the Debug window.
Example: ( page 67 )

Code: Select all

Dim LongArray.l(2)

LongArray(0) = 10
LongArray(1) = 25
LongArray(2) = 30

Debug LongArray(0) + LongArray(1)
Debug LongArray(1) * LongArray(2)
Debug LongArray(2) - LongArray(0)
I understand about using OpenConsole() & CloseConsole() as well as Input().

The above works fine as is, but I would also like to know how to use Print / PrintN
in place of Debug on the bottom 3 lines.
I've got other simpler examples to work using Print(Str(blah)), but the above
examples of adding, etc., have me stumped !

Thanks,
jim
User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: How to use Print / PrintN vs. Debug

Post by jacdelad »

Hi gemrite,
I don't know if I understand what you want to say, but if you want to use the console, it needs to look like this:

Code: Select all

Dim LongArray.l(2)

LongArray(0) = 10
LongArray(1) = 25
LongArray(2) = 30

OpenConsole()
PrintN(Str(LongArray(0) + LongArray(1)))
PrintN(Str(LongArray(1) * LongArray(2)))
PrintN(Str(LongArray(2) - LongArray(0)))
Input()
Be aware that Print/PrintN expects strings as content.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
gemrite
New User
New User
Posts: 2
Joined: Tue Jul 05, 2022 8:55 pm

Re: How to use Print / PrintN vs. Debug

Post by gemrite »

Bingo !!

Thanks Jacdelad.

I would have sworn that I had tried that exact thing,
but I guess not.

For not knowing what I was saying, you did a superb job !
Exactly what I was looking for.


jim
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: How to use Print / PrintN vs. Debug

Post by jack »

I am not knowledgeable in Windows programming but you could instead of a console window use an editor gadget, something like the following but I ask the Windows guru's to correct it and make it proper

Code: Select all

Define.i gid
If OpenWindow(#PB_Any, 0, 0,1217, 817, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  gid=EditorGadget(#PB_Any, 8, 8, 1200, 800,#PB_Editor_ReadOnly)
EndIf
If gid
  
  Define lin.l=0
  Define.s s
  Dim LongArray.l(2)
  
  LongArray(0) = 10
  LongArray(1) = 25
  LongArray(2) = 30
  
  s=Str(LongArray(0) + LongArray(1))
  AddGadgetItem(gid, lin, s) : s+1
  s=Str(LongArray(1) * LongArray(2))
  AddGadgetItem(gid, lin, s) : s+1
  s=Str(LongArray(2) - LongArray(0))
  AddGadgetItem(gid, lin, s) : s+1
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: How to use Print / PrintN vs. Debug

Post by jacdelad »

I'm not a Windows guru either, but I'd say that's how it works. Depending on what the output is, maybe a ListView/ListIcon would be an even better choice.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Post Reply