Aller au contenu

Photo

C syntax help. Continue a statement into the next line.


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
JackFuzz

JackFuzz
  • Members
  • 408 messages
Visual Basic

If MyValue = 5 or _ 
   MyValue = 9 or _
   MyValue = 40 Then
   
'action

End if


C++

if (MyValue == 5 || _
    MyValue == 9 || _
    MyValue == 40) 
    {
         //action
    }

How do I use the _ equivalent in C/C++ ?

#2
JackFuzz

JackFuzz
  • Members
  • 408 messages
I figured it out.

It's one backslash instead of an underscore.

... Now if I can only figure out how to make a function that accepts a parameter being passed to it.

Modifié par JackFuzz, 30 janvier 2010 - 03:32 .


#3
FollowTheGourd

FollowTheGourd
  • Members
  • 572 messages
Don't use either. If you can separate them with a space or tab, you can separate them with a newline just as well for anything I can think of in DAScript right now (except #ifdef probably or certain other preprocessor things). The backslash would normally be used in C or C++ if creating a multiline #define macro, which doesn't seem possible to do in Dragon Age's scripting language anyway.

I don't really see it hurting anything if you do, but it's unnecessary and not a good habit to get into - it screams of VB.

Modifié par FollowTheGourd, 30 janvier 2010 - 05:43 .


#4
Baracuda6977

Baracuda6977
  • Members
  • 353 messages
a function? as in void main() {...} ?

if that is what you are talking about try :



void MyFunction(event ev, int number, etc.) {...}



and when you call it its

MyFunction(EVENT_TYPE_X, 1084, etc.);



*i believe,

#5
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
Line breaks are ignored by the compiler. You can split lines anywhere you want. The semi-colon is the terminator, not the line break.

EDIT: I should say line breaks are the same as spaces or tabs or any other white space. It is a separator, not a terminator, if that makes sense.

Modifié par FalloutBoy, 30 janvier 2010 - 08:12 .