How to create Softserial in Setup() and how to redefine output

I need to create Sofware serial object in Setup like this:

#include <SoftwareSerial.h>

int mode=1;
SoftwareSerial mySerial;
SoftwareSerial HC12;

void setup()
{
...
some code that perhaps changes "mode"
...
if (mode==1)    {  // define port during setup
    Serial.begin(9600);   
    mySerial(9, 10); 
    HC12(3, 2); 
    }
else {
    mySerial(9, 10); 
    HC12(1, 0); 
    }
 ...

So depending on some data I need to use the hardware port on a HC12 .

Another question:
I also have a lot of “Serial.print(…blah blah)” lines. Is it possible without using too much memory have the output goto a another function for some preprocessing.
For example:

...
define Serial something
...
Serial.print("hello");
...
later down the code
void myprint(char *mystr) {
..do some stuff
}
...

Hello

I don't see any problem.

Try it.

Regards

It does not compile. Error at "SoftwareSerial HC12;"

newuser:
It does not compile. Error at "SoftwareSerial HC12;"

Remove or comment :

"
...
some code that perhaps changes "mode"
...
"
and other " ... ".

Add a final "}" to setup()

My question is that I want change the TX and RX at runtime in setup() or later in the program.
Normally, say, I have to define SoftwareSerial HC12(10,11) before setup() or loop()

And yes, my previous code example was pseudo code to illustrate what I am after.

newuser:
My question is that I want change the TX and RX at runtime in setup() or later in the program.
Normally, say, I have to define SoftwareSerial HC12(10,11) before setup() or loop()

And yes, my previous code example was pseudo code to illustrate what I am after.

My answer nas :
"I don't see any problem."

#include <SoftwareSerial.h>

int mode=1;
SoftwareSerial *mySerial = NULL;

void setup()
{
...some code that perhaps changes "mode"

     if (mode==1)    {  // define port during setup
         Serial.begin(9600);
         mySerial = new SoftwareSerial(9, 10);
     }
     else 
    {
        mySerial = new SoftwareSerial mySerial(9, 10);
    }
    mySerial->print("mySerial started\n");
 ... 
}

void loop()
{
    ....
    if (restartSerial)
   {
       if (mySerial)
       {
           mySerial.flush();
           delete mySerial;
           mySerial = NULL;
        }
        mySerial = new SoftwareSerial(11, 12);
        mySerial->print->("Serial restarted\n");
    }
}

Regards,
Ray L.

Thank you. That was what I was after.