Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [BASIC] - Add One String To End Of Another String?

Author
Message
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 11th May 2017 15:33
Hi,

How can we add one BASIC string to the end of another BASIC string?
We tried below but it's not working:
NewHighScoreCurrentName = right( IconText[10+index], len(NewHighScoreCurrentName) +1 )
Thanks!
JeZxLee
16BitSoft Inc.
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit2 Project!
Preben
AGK Studio Developer
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 11th May 2017 16:53
Not sure what your trying but think this is it:

NewHighScoreCurrentName$ = NewHighScoreCurrentName$ + IconText[10+index]

it will just add IconText[10+index] to the end of the string NewHighScoreCurrentName$ , if IconText[10+index] is a string ?
best regards Preben Eriksen,
Dybing
12
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 12th May 2017 22:41
Strings either need to have a $ at the end *or* you pre-declare as string. IE:

either:

fooString$ = "bar" // legit, declares a string variable and assigns value

or:

fooString as string
fooString = "bar" // legit, first declaring the variable, then assigning value

not:

fooString = "bar" // cause an error as AGK2 thinks variables that are not pre-declared and do not have an # (float) or $ (string) at the end, is an integer.

---

Whilst AGK2 do not have many types, it do enforce strong typing on the ones it do. So if you come from dynamically typed languages (python, JS etc) you need get used to type-conversion. On the bright side, strongly typed languages are proven to be more productive - which sounds counter-intuitive at first.

Login to post a reply

Server time is: 2024-04-19 14:35:47
Your offset time is: 2024-04-19 14:35:47