• SEARCH

    통합검색
세모계
    • Dark Mode
    • GNB Always Open
    • GNB Height Maximize
    • Color
    • Brightness
    • SINCE 2015.01.19.
    • 세모계 세모계
    •   SEARCH
    • 세상의 모든 계산기  
      • 자유(질문) 게시판  
      • 계산기 뉴스/정보  
      • 수학, 과학, 공학 이야기  
      • 세모계 : 공지 게시판  
        • 구글 맞춤검색  
      • 세상의 모든 계산기  
        • 자유(질문) 게시판  
    • TI  
    • CASIO  
    • HP  
    • SHARP  
    • 일반(쌀집) 계산기  
    • 기타계산기  
    • 세모계
    • by ORANGEDAY
  • TI
    • TI nspire
    • [TI-Nspire] 프로그래밍 If, Lbl, and Goto to Control Program Flow

    • Profile
      • 세상의모든계산기
        *.40.137.167
      • 2024.11.18 - 16:02 2024.11.18 - 15:27  85

    원본 출처 :

    https://education.ti.com/html/webhelp/nspire/4.2/NAVHH/TI-NspireNavigatorHelp_EN/Content/M_Programming/PR_Using_If_Lbl_and_Goto.htm

     

    image.png

     

    You are here: Programming > Using If, Lbl, and Goto to Control Program Flow


    Using If, Lbl, and Goto to Control Program Flow

     

    If 명령어와 여러 If...EndIf 구조는 조건부로 명령문이나 명령문 블록을 실행할 수 있게 해 줍니다. 즉, (예: `x>5`)와 같은 테스트 결과에 따라 실행됩니다. Lbl(레이블)과 Goto 명령어는 함수나 프로그램 내에서 한 위치에서 다른 위치로 분기하거나 점프할 수 있게 합니다.

    If 명령어와 여러 If...EndIf 구조는 Program Editor의 Control 메뉴에 있습니다.

    `If...Then...EndIf`와 같은 구조를 삽입하면 템플릿이 커서 위치에 삽입됩니다. 커서는 조건부 테스트를 입력할 수 있는 위치로 이동됩니다.

     

     

    If Command

    조건부 테스트가 참일 때 단일 명령을 실행하려면 일반 형식을 사용하십시오:

    If x>5

      Disp "x is greater than 5"  À

    Disp x  Á

    À

    Executed only if x>5; otherwise, skipped.

    Á

    Always displays the value of x.

    In this example, you must store a value to x before executing the If command.

     

     

    If...Then...EndIf Structures

    조건부 테스트가 참일 경우 하나의 명령 그룹을 실행하려면 다음 구조를 사용하십시오:

    If x>5 Then

      Disp "x is greater than 5"  À

      2¦x&x  À

    EndIf

    Disp x  Á

    À

    Executed only if x>5.

    Á

    Displays the value of:

      2x if x>5

      x if x{5

    Note: EndIf marks the end of the Then block that is executed if the condition is true.

     

     

    If...Then...Else...EndIf Structures

    조건부 테스트가 참일 경우 하나의 명령 그룹을 실행하고, 조건이 거짓일 경우 다른 명령 그룹을 실행하려면 다음 구조를 사용하십시오:

    If x>5 Then

      Disp "x is greater than 5"  À

      2¦x&x  À

    Else

      Disp "x is less than or equal to 5"  Á

      5¦x&x  Á

    EndIf

    Disp x  Â

    À

    Executed only if x>5.

    Á

    Executed only if x{5.

    Â

    Displays value of:
      2x if x>5
      5x if x{5

     

     

     

    If...Then...ElseIf... EndIf Structures

    더 복잡한 형태의 If 명령어를 사용하면 여러 조건을 테스트할 수 있습니다. 예를 들어, 사용자로부터 제공된 인수가 네 가지 옵션 중 하나를 나타내는지 테스트하려고 한다고 가정해 보세요.

    각 옵션을 테스트하려면(예: `If Choice=1`, `If Choice=2` 등), If...Then...ElseIf...EndIf 구조를 사용하십시오.

     

     

    Lbl and Goto Commands

    Lbl(레이블)과 Goto 명령어를 사용하여 흐름을 제어할 수도 있습니다. 이러한 명령어는 Program Editor의 Transfers 메뉴에 있습니다.

    Lbl 명령어를 사용하여 함수나 프로그램 내 특정 위치에 레이블(이름)을 지정할 수 있습니다.

    Lbl labelName

    name to assign to this location (use the same naming convention as a variable name)

    그런 다음, Goto 명령어를 함수나 프로그램의 원하는 지점에서 사용하여 지정된 레이블에 해당하는 위치로 분기할 수 있습니다.

    Goto labelName

    specifies which Lbl command to branch to

    Goto 명령어는 무조건적이기 때문에(항상 지정된 레이블로 분기), 종종 If 명령어와 함께 사용되어 조건부 테스트를 지정할 수 있습니다. 예를 들어:

    If x>5

      Goto GT5  À

    Disp x

    --------

    --------  Á

    Lbl GT5

    Disp "The number was > 5"

    À

    If x>5, branches directly to label GT5.

    Á

    For this example, the program must include commands (such as Stop) that prevent Lbl GT5 from being executed if x{5.

    0
    0
    Attached file
    image.png 11.9KB 11
    이 게시물을..
    • 세상의모든계산기 세상의모든계산기 Lv. 25

      계산기는 거들 뿐
      혹은
      계산기를 거들 뿐

    • [TI-92][TI-89] Fourier Transform Library세상의모든계산기
    • [TI-nspire] Fundamentals of Differential Equations - 미분 관련 자료세상의모든계산기
    • 댓글 입력
    • 에디터 전환
    댓글 쓰기 에디터 사용하기 닫기
    • 목록 목록
    • [TI-92][TI-89] Fourier Transform Library
    • [TI-nspire] Fundamentals of Differential Equations - 미분 관련 자료
    • 목록
    by OrangeDay
    • TI
    • allcalc.org
    • 세모계 all rights reserved.