Carriage return on string ?

This forum is meant for examples of X# code.

Post Reply
User avatar
DexterZ
Posts: 28
Joined: Sat Dec 03, 2016 1:35 am

Carriage return on string ?

Post by DexterZ »

Hello Guys!

First time I've tried X# and it's like wrting CLIPPER inside Visual Studio YAY! here's my code ^ _^ Y but as you may notice string "rn" escape key is not working.


Code: Select all

PRIVATE METHOD button1_Click(sender AS OBJECT, e AS System.EventArgs) AS VOID
    
     *-> Memvars
     *
     LOCAL _CUSTOMER AS MDBf.Table
     *
     LOCAL mCustNo   AS STRING
     LOCAL mCustName AS STRING            
             
     *-> Open customer table
     *
     _CUSTOMER := Table{}              
     _CUSTOMER.File.Open("C:TMPCUSTOMER.DBF",TableShare.Shared,TableAccess.ReadWrite)
             
     *--> Display all customer no. and name
     *
     DO WHILE ! _CUSTOMER.Navigator.IsEOF() 
        *
        mCustNo   := _CUSTOMER.Record.C("CUST_NO")
        mCustName := _CUSTOMER.Record.C("CUST_NAME")
        *
        MessageBox.Show("Customer No: "+mCustNo+"rn"+"Customer Name: "+ mCustName)
        *
        _CUSTOMER.Navigator.Skip()
        *    
     ENDDO
            
     *-> Close table
     *
     _CUSTOMER.File.Close() 
     _CUSTOMER.Dispose()            
    
 END CLASS


The display will be :

Customer No: C0008 rnCustomer Name: ALMOND MARIA
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Carriage return on string ?

Post by Chris »

Hello Dexter,

Very glad you enjoyed X#, we are actually extremely proud of that, of bringing Clipper and descendants into the .Net world!

About your escaped string, by default strings are "regular" in X#, escaped strings must be denoted with an "e" in front of them: e"rn". Or you can simply used "CRLF" instead of that, as in string1 + CRLF + string2. (you will find CRLF defined in XSharpIncludeXSharpDefs.xh)

Please see also http://docs.xsharp.it/doku.php?id=strings

Chris
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
DexterZ
Posts: 28
Joined: Sat Dec 03, 2016 1:35 am

Carriage return on string ?

Post by DexterZ »

Hi Sir Chris,

Thanks for fast reply, CRLF and CHR(13) works like a charm, I didn't expect CHR(13) will work, it's just an instinct coming from Visual FoxPro ^_^Y but it does ;)

Thank you Sir!
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Carriage return on string ?

Post by Chris »

You're very welcome! :)
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
NickFriend
Posts: 248
Joined: Fri Oct 14, 2016 7:09 am

Carriage return on string ?

Post by NickFriend »

PMFJI, but why not start to take advantage of the .Net classes... Environment.NewLine.

Nick
User avatar
DexterZ
Posts: 28
Joined: Sat Dec 03, 2016 1:35 am

Carriage return on string ?

Post by DexterZ »

Yes sir NewLine is cool specially on non windows platform ^_^y Thanks for the info
FFF
Posts: 1521
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Carriage return on string ?

Post by FFF »

Nick,
i'd expect CRLF to be expanded under the hood to Environment.NewLine...
Seems sensible, opposed to CHR(10) etc. which clearly states, what the coder wants.

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Carriage return on string ?

Post by Chris »

Hi Karl,

Compatibility...:)

Chris
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
NickFriend
Posts: 248
Joined: Fri Oct 14, 2016 7:09 am

Carriage return on string ?

Post by NickFriend »

Ah, but he's having to change his code anyway, so this is when you can start chipping away at replacing old style coding...

Nick
Post Reply