Normal Topic If then else Structure (Read 1435 times)
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
If then else Structure
Oct 28th, 2004 at 9:45pm
Print Post Print Post  
I've never done a if then else statement, if someone can help me out it would be much appreciated !! Wink

If @add and LOC <=5 then
{
     If Loc ="1" Then @xpost(@Fn,Part Number,"Mastinv!Itemnumber",Qty,"PHA1","Sub")
        
      elseIf Loc = "2"
     
     @xpost(@Fn,Part Number,"Mastinv!Itemnumber",Qty,"PHA2","Sub")

     elseIf Loc = "3"

     @xpost(@Fn,Part Number,"Mastinv!Itemnumber",Qty,"PHA3","Sub")

     elseIf Loc = "4"

     @xpost(@Fn,Part Number,"Mastinv!Itemnumber",Qty,"Vict","Sub")

     Else @Msg("Ops I goofed")

}
  
Back to top
 
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: If then else Structure
Reply #1 - Oct 28th, 2004 at 10:35pm
Print Post Print Post  
Got it !!   Grin Grin


If @Update and LOC <=5 then
{
     If Loc = 1 Then
      xpost(@Fn,Part Number,"Mastinv!Item number",Qty0,"PHA1","Sub")
       
       If Loc = 2 then      
     xpost(@Fn,Part Number,"Mastinv!Item number",Qty0,"PHA2","Sub")

     If Loc = 3 then
     xpost(@Fn,Part Number,"Mastinv!Item number",Qty0,"PHA3","Sub")

     If Loc = 4 then
     xpost(@Fn,Part Number,"Mastinv!Item number",Qty0,"Vict","Sub")
     
     If Loc >=5 Then
     @Msg("Has to be a number from 1-4")
}
« Last Edit: Oct 29th, 2004 at 1:18am by proudpoppy »  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: If then else Structure
Reply #2 - Oct 29th, 2004 at 11:37am
Print Post Print Post  
You can, and probably should use the if.. then..else construct. The problem in the first example is that there is no keyword: "elseif" - there is a keyword "else" and a keyword "if". To produce an "else if" you need the space between the "else" and the "if" (i.e.: "else if"):
Code
Select All
if(aa = 1)
{
  writeln("One")
}
else if(aa = 2)
{
  writeln("Two")
}
else if(aa = 3)
{
  writeln("Three")
}
else
{
  writeln("Not one, two, or three")
}
 

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
proudpoppy
Full Member
Members
***
Offline


Do What ??

Posts: 420
Location: South Carolina
Joined: Apr 7th, 2004
Re: If then else Structure
Reply #3 - Oct 29th, 2004 at 11:44am
Print Post Print Post  
I like your example better Mark ! I'll rewrite it.  Grin
  
Back to top
 
IP Logged