locked
how to make an array by function and by local variable of the function RRS feed

  • Question

  • @echo off
    
    set /a n=99
    
    set ret=
    call :test3 ret
    
    echo show array:
    echo %ret.Array[0]%
    echo %ret.Array[1]%
    echo %ret.Array[2]%
    echo %ret.Array[3]%
    
    ECHO Press any key to close the windows...
    pause>NUL
    goto :eof
    
    :test3
    setlocal
    set /a n=0
    
    :Loop-Start
    if %n% GEQ 3 goto :Loop-End
    
    set %~1.Array[%n%]=V%n%
    
    set /a n=n+1
    
    goto :Loop-Start
    :Loop-End
    
    endlocal
    goto :eof

    Hi,


    I have written a function named test3 who make an array by its local variable named n(notice that there is a global variable named n). The function test3 returns the array to first parameter of it. But the result is incorrect

    • Moved by KareninstructorMVP Friday, April 5, 2019 9:56 AM Moved from Windows forms forum
    Friday, April 5, 2019 7:05 AM

All replies

  • Hi sincos2007,

    According to your description, I am not sure what kind of language you are using, it same that it is not a winforms issue. could you please describe it in detailed, so that I can redirect to related forums for suitable support.

    Best regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, April 5, 2019 7:38 AM
  • This is code of windows batch file.

    Thanks

    Friday, April 5, 2019 9:11 AM
  • Hello,

    There are no forums here for batch files and this forum is for Windows Forms questions only.

    Your best bet is to ask in a forum such as the one below.

    https://www.dostips.com/forum/viewforum.php?f=3


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, April 5, 2019 9:55 AM