Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

problem in string

Status
Not open for further replies.

beautifulmind_i

New Member
hi
i use bascom and basic language for programming avr microcontrollers.
I have a parameter named number :
for example :
number = 12
I want to show this on my lcd :
I have 12 apples .
how can I add this variable ( number) to my string?
I try this but I recieve error :
lcd "I have " & number & "apples"
plz help me.
thank you
 
Last edited:
Dont know anything about bascom
In C++ you can use the strcat() function which is a string concatination so probably construct the string then print tit

lcd "I have " & number & "apples".....the & number & might be doing this but would it not be better to say
tempstr="I have " & number & "apples"
lcd tempstr ?
 
Last edited:
ok, it's been longer than I thought... I dug out an old program, and you don't put anything:

PRINT "NUMBER OF PAYMENTS IN THE FIRST YEAR <" FIRST "> ";
INPUT A
IF A < > 0 THEN FIRST = A


this is from a mortgage program I wrote, where FIRST is a variable for how many payments were payed on the loan in the first year... if you rerun it, it keeps and prints the default value for FIRST, and if you hit enter, it stays, or if you enter a number, it replace the FIRST variable with what you entered.
 
Last edited:
n = 2
print "I have "; n; " Apples."

This joins strings using the print statement.
To compute a new string as the combination of a string and the string equivalent of a number...

BASCOM is a very limited form of BASIC. A string can be no longer than 254 characters, so says the documentation.
It may have no string concatenation (joining) capability. In some flavors of BASIC, this is done as:
S1 = S1 + S2
S1 = S1 & S2
S1 = S2 + S3

But BASCOM may not allow that. It may not even do A = B + C + D but can do A = B + C

In My Opinion, the best Atmel AVR BASIC is the VB6-like Zbasic.net
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top