Programming problems

  • Hello everyone,

    I just want to know how can we use local variable in main program and sub program?

    When we use CALL instructions at that time after program name why we are using () i.e CALL pg01(2,1)?????

    If any one know about this please suggest.

    Thank you in advance.

  • When we use CALL instructions at that time after program name why we are using () i.e CALL pg01(2,1)?????

    Only you or your colleagues can answer why you are using it, not us.

    There is a section in the AS Programming Language Manual for this.

    Search for 'subroutine with parameters'.

  • Dear sir thank you for your reply, i already read that manual but still that function not clear for me.

    And once again thank you for your reply.

  • When you use CALL instruction, it branches from routine to execute called subroutine.

    Inside subroutine, you will either execute that subroutine all the way to the end or inside subroutine, you can use RETURN at any point inside subroutine to cease execution of subroutine.

    When execution of subroutine is complete it returns to next step after CALL instruction.

    You can use parameters when using CALL instruction, by adding parentheses.

    Parameters can be variables, location variables, constants, functions and are placed in the parentheses of the CALL instruction.

    The subroutine has STEP 0 and step 0 uses the parameters and defines them to local variables (.local, .&local)

    These local variables can then be used inside the subroutine.

    This is standard programming techniques and not just specific to Kawasaki.

    So if you see examples in manual, they create a subroutine to carry out calculation.

    As this calculation (equation) never changes, they can use subroutine anytime to use, and the parameters are the variable values (input data) they parse into the subroutine to carry out calculation.

    So to simply explain example 1:

    - Main program defines a and b values.

    - CALL calc(a,b,c) branches to calc subroutine parsing in values a, b, c

    - Calc subroutine step 0 defines a, b, c parameters to local variables.

    - Calc subroutine then carries out calculation.

    - Returns to next step after CALL and then TYPE c displays result of a+b. on terminal, in this case 3.

    ** Parameters could be undefined and then defined in subroutine if needed**

    Try example 1 and then edit main and change values for a and b and then re-execute to display different results of summed a and b values.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now