Previous Thread
Next Thread
Print Thread
Rate This Thread
Hop To
#4104615 - 04/11/15 04:48 AM Warthog scripting - using "strings" as variables, passing to function, comparing, printing  
Joined: Apr 2015
Posts: 1
TheT Offline
Junior Member
TheT  Offline
Junior Member

Joined: Apr 2015
Posts: 1
Ladies and Gents,

I am trying to use a string as a variable for condition detection:
Code:
if (my_condition == 'red') do_something();

What variable type do I need/can use to achieve this feat?
And in this manner, would I be able to pass this variable into a function?
Code:

??? my_string_var = 'blue';
my_function(my_string_var);

// snip

int my_function (??? my_local_var = 'some default value') {}


And, while done with that, can I output the variable contents somehow?
Code:
printf(" and the var is " + my_string_var + "!\xa");
// or I will take even
printf(my_string_var);


I figure I can use int conditions, but they would be a number and not a string.

I would also love to know if I can actually build C-style Class functionality in tmc files, but I am not holding my breath on possibility of this. =)

Thanks much.
~T

Inline advert (2nd and 3rd post)

#4105367 - 04/13/15 01:48 AM Re: Warthog scripting - using "strings" as variables, passing to function, comparing, printing [Re: TheT]  
Joined: Mar 2007
Posts: 483
Aullido Offline
Member
Aullido  Offline
Member

Joined: Mar 2007
Posts: 483
Any particular reason for using strings?

I think you want to debug your program or maybe you have problems with variable assignation.

If you want to make your code more clear, you can use a define:

define blue 1

int Color;

Color = blue;

You can print numeric variables:

EXEC("printf(\"This is the value of Color %d\",Color);");


Moderated by  RacerGT 

Quick Search
Recent Articles
Support SimHQ

If you shop on Amazon use this Amazon link to support SimHQ
.
Social


Recent Topics
Roy Cross is 100 Years Old
by F4UDash4. 04/23/24 11:22 AM
Actors portraying US Presidents
by PanzerMeyer. 04/19/24 12:19 PM
Dickey Betts was 80
by Rick_Rawlings. 04/19/24 01:11 AM
Exodus
by RedOneAlpha. 04/18/24 05:46 PM
Grumman Wildcat unique landing gear
by Coot. 04/17/24 03:54 PM
Peter Higgs was 94
by Rick_Rawlings. 04/17/24 12:28 AM
Whitey Herzog was 92
by F4UDash4. 04/16/24 04:41 PM
Anyone can tell me what this is?
by NoFlyBoy. 04/16/24 04:10 PM
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.

Powered by UBB.threads™ PHP Forum Software 7.6.0