locked
Functions LDCALL.FUNCTION mixing with FUNCTION2 RRS feed

  • General discussion

  • I just start a new topic with two examples mixing the ldcall.function command.

    You can pass  several arguments to functions  using ldcall.function or ldcall.function2 etc 

    see  http://litdev.co.uk/LitDev_LDCall.html#LDCallFunction  but you can also mix them.

    I published already the first example with the help of nonki and Jan as TVP565-0.

    But passing 2 arguments was still tricky so I published a second example with function2 passing two arguments. In fact you find them back in the subroutine with as first argument args[1] and second argument args[2] etc. Published as TXW159-1

    When importing the programfile you have to uncomment some lines - so it's easier to copy the program from the screen

    'program DebugProgram-function2.sb
    Debug="True" 'to set to false if you don't want the textwindow.write.line commands
    args = ""
    DebugFile="debugFile.txt"
    File.DeleteFile(DebugFile)
    File.AppendContents(DebugFile,"DebugFile : "+Clock.date+" = "+Clock.time)
    File.AppendContents(DebugFile,"=================================")
    
    LDCall.Function2("DebugFunc","Hello Small basic I have a problem","White")
    LDCall.Function2("DebugFunc","We will test the version !!!","Yellow")
    for x=1 to 15
    if x=13 then
        LDCall.Function("DebugFunc"," ")   ' mixing function and function2 and passing variable x as argument
        LDCall.Function2("DebugFunc","You are in trouble with version ="+x+"=!","Red")
        LDCall.Function("DebugFunc"," ") 
    endif
    endfor
    TextWindow.ForegroundColor="White"
    textwindow.writeline(file.ReadContents("debugFile.txt"))
    'END PROGRAM
    
    'Function subroutine 
    Sub DebugFunc
      if debug then
        TextWindow.ForegroundColor=(args[2])
        TextWindow.WriteLine(args[1])
      endif
      File.AppendContents(DebugFile,args[1])
    EndSub



    • Edited by Eddy Abts Wednesday, April 8, 2020 7:37 AM
    • Changed type Nonki Takahashi Wednesday, April 8, 2020 12:24 PM not question
    Wednesday, April 8, 2020 7:34 AM

All replies

  • Hi Eddy, that's interesting.  Thank you for sharing your idea.

    Nonki Takahashi

    Wednesday, April 8, 2020 9:41 AM