CPC Basic

Would you like to react to this message? Create an account in a few clicks or log in to continue.
CPC Basic

Basic cross-compiler for Amstad CPC


2 posters

    String with inverted colours

    avatar
    Neurox66


    Posts : 3
    Join date : 2020-12-11

    String with inverted colours Empty String with inverted colours

    Post  Neurox66 Sat Dec 12, 2020 5:30 am

    Hi,
    I've a problem with CPC Basic 3.
    The guilty instruction is this
    print chr$(24)+"Hello world "+chr$(24)
    if I type it directly on my CPC 6128 Plus the string is perfectly inverted, screen mode 2.
    But if I write and compile it with the CPC Basic 3 and run it on the CPC I don't see anything on the screen.
    Any tips?  Very Happy

    Paolo
    Out Bush
    Out Bush


    Posts : 11
    Join date : 2019-12-02

    String with inverted colours Empty Re: String with inverted colours

    Post  Out Bush Sun Dec 13, 2020 4:45 pm

    So you have Compiled something like this:

    Code:

    100 PRINT CHR$(24)+"Hello"+CHR$(24)

    Executed it in the Emulator which works, and have then tried on a Real Amstrad and got a Different result?
    avatar
    Neurox66


    Posts : 3
    Join date : 2020-12-11

    String with inverted colours Empty Re: String with inverted colours

    Post  Neurox66 Sun Dec 13, 2020 7:14 pm

    Hi,
    yes you are absolutely right!  Very Happy
    I was hasty  Crying or Very sad
    I didn't realise that the call to this function
    Code:
    55 DEF FNunderscore$(i$)=i$+STRING$(LEN(i$),8)+CHR$(22)+CHR$(1)+STRING$(LEN(i$),"_")+CHR$(22)+CHR$(0)
    interfered with the prefect operation.

    Paolo
    Out Bush
    Out Bush


    Posts : 11
    Join date : 2019-12-02

    String with inverted colours Empty Re: String with inverted colours

    Post  Out Bush Sun Dec 13, 2020 7:57 pm

    Neurox66 wrote:Hi,
    yes you are absolutely right!  Very Happy
    I was hasty  Crying or Very sad
    I didn't realise that the call to this function
    Code:
    55 DEF FNunderscore$(i$)=i$+STRING$(LEN(i$),8)+CHR$(22)+CHR$(1)+STRING$(LEN(i$),"_")+CHR$(22)+CHR$(0)
    interfered with the prefect operation.

    Paolo

    Not quite sure what to suggest for that, according to the CPC BASIC 3 Website, DEF FN is handled differently from Locomotive BASIC, though the example presented on the CPC BASIC 3 Website is unusual given I haven't seen anyone define a Function through an IF statement in Locomotive BASIC (normally they would just be defined at the start of a BASIC programme), though apply caution I guess if you only want to define things or perhaps setup procedures which return a variable, it would still be a global variable, but at least it might be a little easier to debug if an problem occurs.

    Sponsored content


    String with inverted colours Empty Re: String with inverted colours

    Post  Sponsored content


      Current date/time is Sun Nov 28, 2021 11:56 pm