ScriptSpot

Forum topic · General Scripting

Combine 2 strings for call back

By jessemoody · 2015-02-25

Description

i want to combine 2 global strings that i defined in my main script file one being mtVer = v1.0.1 and mtTitle = Moodys Tools reason i don't put them together and just make it one string from start is i want to be able to call both at different times for different reasons but with things like title bar i want it to be Moodys Tools v1.0.1 and such

Thanks for the help guys

Comments (5)

combine 2 strings

pixamoon · 2015-02-26

I'm not sure if i understand. Do you mean just combine them together ?

global mtVer = "v1.0.1"
global mtTitle = "Moodys Tools"

mtTitleVer = "Moodys Tools" + " " + "v1.0.1"

jessemoody · 2015-03-02

yeah i want to be able to drop these into my title of the window as well as in a help file or whatever but i may just want to have it call the tool name at times or the version number.

Of course I can write a 3rd option that is global mtTitleVer="Moodys Tools v1.0.0" but i don't really want to do that.

pixamoon · 2015-03-04

oki oki

I didn't explain it well

If you have:

global mtVer = "v1.0.1"
global mtTitle = "Moodys Tools"

Than you can do:
mtTitleVer = mtTitle + " " + mtVer

mtTitleVer is a temporary variable and you can use it in rollout title

rollout aaa mtTitleVer width:200 height:200 --etc...

or

rollout aaa (mtTitle + " " + mtVer) width:200 height:200

This should explain more :)
Cheers
Pixamoon

barigazy · 2015-03-04

@jessemoody
Avoid to use global var for this use local var instead.
Also U can use dataPair's only or array to store your two strings.


--#datapairs example

(
local myTool = dataPairs mtTitle:"Moodys Tools " mtVer:"v1.0.1"
rollout mtRoll (append myTool.mtTitle myTool.mtVer) width:200 height:200
)
--#array example
(
local myTool = #("Moodys Tools ", "v1.0.1")
rollout mtRoll (append myTool[1] myTool[2]) width:200 height:200
)

pixamoon · 2015-03-05

true true true

Those are much better ways to do it !
Thank you :)