Print statement

Jimmy

New member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
569
I use the terminal a lot when debugging and would like to know if there's a way to skip newlines in the Print statement?
In some old languages you could do Print "not new line just yet";

code_language.cerberus:
Strict
Import mojo2

Function Main:Int()
    New myClass       
    Return 0
End

Class myClass Extends App

    Field canvas:Canvas
    
    Method OnCreate:Int()
        SetUpdateRate 0               
        canvas = New Canvas
        
        ' --------------------------------------------
        ' Input
        '
        ' Ideas for next version :
        ' variablename.Real = #
        ' variablename.Imag = #

        ' Multiplies two complex numbers in the terminal
        '
        ' a + bi *  c + di
        ' e..g (10 + 5i) * (10 + 5i) = =75 + 100i
        
        Local a:Float = 10 ' real 
        Local b:Float = 5 ' imaginary
        '
        Local c:Float = 10 ' real
        Local d:Float = 5 ' imaginary

        Print "The answer is :" ' Avoiding appending strings and put in one Print
        Print String((a * c) - (b * d))
        Local imaginary:Float = ((a * d) + (b * c))
        Local imag:String = String(Abs(imaginary)) + "i"
        If imaginary < 0 Then Print "-" + imag
        If imaginary > 0 Then Print "+" + imag
        ' --------------------------------------------
        
        Return 0
    End
    
    Method OnRender:Int()
        canvas.Clear
        canvas.Flush
        Return 0
    End
    
End
 

Jimmy

New member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
569
I'm trying to Print multiple things on the same line without merging a string first.

The current code above outputs this:

The answer is :
75
+100i


I want this (wo merging strings):
The answer is : 75+100i
 

Jimmy

New member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
569
So it's more about ignoring newline.. Is there a "minus newline" escapecode?
 

Jimmy

New member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
569
I just needed a temporary fix (line 37 I commented out the newline) so now I can debug a lot of information in a streamlined fashion.


debug.png
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
795
Why not write your own purpose built code to output information that you want?
Print is just a function.
 
Top Bottom