Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:44:29+00:00 2026-06-15T17:44:29+00:00

I am trying to get a simple elseif statement into IDL and am having

  • 0

I am trying to get a simple elseif statement into IDL and am having a heck of a time with it. The matlab code looks something like this.

a = 1
b = 0.5

diff = a-b
thres1 = 1
thres2 = -1

if diff < thres1 & diff > thres2  
  'case 1'
elseif diff > thres1 
  'case 2'
elseif diff < thres2
  'case 3'
end

But the IDL code is not so simple and I am having troubles getting the syntax right. the help states:
Syntax
IF expression THEN statement [ ELSE statement ]
or
IF expression THEN BEGIN
statements
ENDIF [ ELSE BEGIN
statements
ENDELSE ]

But doesnt give an example on how to use multiple expressions and elseif. I have tried many variations and cant seem to get it right.

Anyone have suggestions? Here are some things I’ve tried:

if (diff lt thres1) and (diff gt thres2) then begin
  print, 'case 1'
endif else begin
if (diff gt thres1) then
  print, 'case 2'
endif else begin
if (diff lt thres2) then
  print, 'case 3'
endif 

if (diff lt thres1) and (diff gt thres2) then begin
  print, 'case 1'
else (diff gt thres1) then
  print, 'case 2'
else (diff lt thres2) then
  print, 'case 3'
endif 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:44:30+00:00Added an answer on June 15, 2026 at 5:44 pm

    There is no elseif statement in IDL. Try:

    a = 1
    b = 0.5
    
    diff = a - b
    thres1 = 1
    thres2 = -1
    
    if (diff lt thres1 && diff gt thres2) then begin
      print, 'case 1'
    endif else if (diff gt thres1) then begin
      print, 'case 2'
    endif else if (diff lt thres2) then begin
      print, 'case 3'
    endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a simple conditional statement to work, and running into problems.
Trying to unit test some simple code for a class project, however every time
I'm trying to take two lines of code from an elseif statement and create
I'm trying to get a simple solution for this layout. This is the simplified
I'm trying to get this simple program to work on windows, but it crashes:
I'm trying to get a simple winsock program working, so I create my socket
I'm trying to get a simple socket.io server running: Client: <script src=http://www.my-server.com:8080/socket.io/socket.io.js></script> var socket
I'm trying to get a simple VBO running. But when i call glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex)*vertexcount,
I'm just trying to get a simple example of accessing a custom java class
So i am trying to get a simple system working where i have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.