Shop OBEX P1 Docs P2 Docs Learn Events
Can PropBasic call .spin files as Tasks — Parallax Forums

Can PropBasic call .spin files as Tasks

RegorRegor Posts: 19
edited 2010-12-11 22:27 in Propeller 1
I download PropBasic and its ultra cool.

I noticed when I wrote a task a .spin file actually got generated which got me thinking.

Is there a way to include Spin files not generated from the PropBasic Tasks? Aka, can I move·AnyonesCool.Spin file into the PropBasic folder and then use it within my PropBasic program?

Comments

  • simonlsimonl Posts: 866
    edited 2010-03-12 23:03
    You'd need to get this confirmed by Bean, but I don't think it's that simple. Take a look inside those .spin files and you'll actually see a load of PASM.

    That said; Bean has given an example of calling other code - look for his "dispatcher". <edit> See http://forums.parallax.com/showthread.php?p=867134 - third post from bottom.</edit>

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

    Post Edited (simonl) : 3/12/2010 11:11:37 PM GMT
  • hover1hover1 Posts: 1,929
    edited 2010-03-12 23:14
    The "Dispatch" demo is what to use. I don't know if it will use an object called from another object yet. I was going to try that this weekend.
    Regor said...
    I download PropBasic and its ultra cool.

    I noticed when I wrote a task a .spin file actually got generated which got me thinking.

    Is there a way to include Spin files not generated from the PropBasic Tasks? Aka, can I move AnyonesCool.Spin file into the PropBasic folder and then use it within my PropBasic program?


    Here is a demo program showing how to interface spin objects into PropBASIC using a spin dispatcher.
    
    
    If you try this demo, make sure it's NOT in the same directory as the keyboard demo PropBASIC code. The PropBASIC keyboard demo creates a "keyboard.spin" file that is NOT the one we want to this demo.
    
    
    You can see that I used an ASM...ENDASM block to insert the object and dispatcher code. Even though it's not PASM code, the ASM...ENDASM commands don't care they just put whatever is between them into the output file.
    ' Put in code to run spin dispatcher
    ASM
    OBJ
      Key: "Keyboard"
     
    PUB SpinStart
      CogInit(1, @__Init, @__DATASTART) ' Start PropBASIC program
      Repeat
        case spinCmd
          spinKeyStart:
            Key.Start(spinP1, spinP2)
            spinCmd := 0
                   
          spinKeyGetKey:
            spinP1 := Key.GetKey
            spinCmd := 0
     
    ENDASM
     
    If you have any questions about how this works, please let me know.
    
    
    Bean.
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropBASIC home page www.propbasic.com
     
    
    Post Edited (Bean (Hitt Consulting)) : 12/30/2009 6:41:25 PM GMT
    
    
    File Attachment :
    dispatcher.pbas   1KB (application/octet-stream)
    This file has been downloaded 39 time(s).
    
  • BeanBean Posts: 8,129
    edited 2010-03-13 01:20
    Yeah the "dispatcher" is a method I came up with to call spin objects.

    It may not be the ONLY way, but it is probably the easiest way.

    Basically, you keep the spin program alive and wait for requests from PropBASIC. All data exchange is handled with HUB variables in PropBASIC.
    PASM code in .spin files can be pretty easily inserted into PropBASIC, but "spin" code cannot and must be called using the dispatch method.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.

    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
    ·
  • bsnutbsnut Posts: 521
    edited 2010-12-11 22:25
    Bean,

    So, what you are saying I can't call a method I did in spin like this "method.spin".
  • bsnutbsnut Posts: 521
    edited 2010-12-11 22:27
    Bean,

    So, what you are saying I can't call a method I did in spin like this "method.spin" as a TASK.
Sign In or Register to comment.