Smashing strings together

Unlike with numbers, you can’t subtract, divide, or multiply strings. But you can add strings (which is technically known as concatenating strings). To concatenate two strings, you use the plus sign (+) to essentially smash two strings into a single string, as the following Liberty BASIC example shows:


MyName$ = “Joe Smith”                             ?1
PRINT “Hello, ” + MyName$                         ?2
END                                               ?3

This Liberty BASIC program tells the computer to do the following:

  • ?1 Creates a string variable called MyName$ and stuffs it with the string “Joe Smith”.

  • ?2 Prints the string “Hello, “ followed by the string stored in the MyName$ variable, so the entire line prints out Hello, Joe Smith.

  • ?3 Tells the computer that the program is at an end.

Remember If you concatenate strings, make sure that you leave a space between the two strings so that they don’t appear smashed together (likethis). In the previous example, notice the space in the second line following the word Hello and the comma.

Both REALbasic and C++ also let you use the plus sign (+) to concatenate strings. However, Revolution uses the dual ampersand symbols (&&) to concatenate strings like so:


put “Joe Smith” into MyName
put “Hello, ” && MyName into message
 

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

4 Responses to “Smashing strings together”


  1. Medicamentspot.com. Canadian Health&Care.No prescription online pharmacy.Special Internet Prices.Best quality drugs. No prescription drugs. Order pills online

    Buy:Prevacid.Synthroid.Actos.Zyban.Mega Hoodia.Zovirax.Lumigan.100% Pure Okinawan Coral Calcium.Nexium.Petcam (Metacam) Oral Suspension.Arimidex.Accutane.Human Growth Hormone.Valtrex.Retin-A.Prednisolone….


  2. Medicamentspot.com. Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. No prescription pills. Buy drugs online

    Buy:Prozac.Buspar.Acomplia.SleepWell.Advair.Lipothin.Zetia.Female Cialis.Cozaar.Nymphomax.Aricept.Lipitor.Lasix.Seroquel.Female Pink Viagra.Ventolin.Amoxicillin.Zocor.Wellbutrin SR.Benicar….


  3. CheapTabletsOnline.Com. Canadian Health&Care.Best quality drugs.No prescription online pharmacy.Special Internet Prices. Low price drugs. Order drugs online

    Buy:Zyban.Arimidex.Petcam (Metacam) Oral Suspension.Prevacid.Accutane.Actos.Lumigan.Nexium.Prednisolone.Synthroid.Zovirax.100% Pure Okinawan Coral Calcium.Human Growth Hormone.Valtrex.Mega Hoodia.Retin-A….

Leave a Reply



eXTReMe Tracker