? <output>

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

? <output>

Post by Karl-Heinz »

Hi Robert,

This works the same way as it does with VO

? <xExp1> , <xExp2> , <...>

Some time ago i´ve noticed that with X# this is also possible:

? <xExp1> + " " + <xExp2> + " " + <...>

My question: is the second way restricted ? I´m asking because i´ve noticed that there are several problems when VO specific types are involved.

regards
Karl-Heinz
User avatar
robert
Posts: 4266
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

? <output>

Post by robert »

Karl Heinz,
The second method uses the built-in mechanism of .Net that every type has a ToString() method. I am not sure which problem you are seeing. Maybe one of the built-in types needs a better ToString() ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

? <output>

Post by Karl-Heinz »

Hi Robert,

yes, something like

? eval ( cb , 5 ):Tostring()
? fValue:Tostring()

does not cause any problems, but the code below throws several runtime errors when VO specific types are involved.

Code: Select all


FUNCTION DoOutPut() AS VOID 

  LOCAL fValue AS FLOAT
  LOCAL a AS ARRAY
  LOCAL cb AS CODEBLOCK 
  LOCAL u AS USUAL



   fValue := 12.23

   cb := {| n | n + 1  }

   a := { "one" , "two" }

   u := 12333

   

   //  If the very first expression result is a VO type:

   //  "incompatible argument" runtime error 
       
	
    ?  today()  + "  " + setcentury()     //  <-----


    //  "out of range" runtime error  

    ?  a [ 1 ] + " " + setcentury()   //  <-----


    //  ------------

    // If the very first result is not a VO specific type it runs. 

     ? SetCentury()  + " " + today() 


     ? setcentury() + " " + a [ 1 ] 


     ?  _chr(9) + today()       
  
     ? space(20) + today()  

 
   // But floats, usuals and codeblocks throw runtime errors,
   // no matter if they are positioned at second pos.
       
      // "argument is not numeric"
     ? setcentury()  + " " + fValue     //  <----- 
       
      //  "out of range" 
     ? setcentury() + "  " + eval ( cb , 5 )   //  <-----	
	 
      //  "out of range" 
	     
       ? setcentury() + " " + u   //  <-----	
	 
       ?
	 
	
	
	RETURN


regards
Karl-Heinz
Post Reply