Shop OBEX P1 Docs P2 Docs Learn Events
Problem with spin tutorial — Parallax Forums

Problem with spin tutorial

SiriSiri Posts: 220
edited 2008-02-06 16:24 in Propeller 1
Attached is the tutorila for the beginner by Dave Scanlan - EXAMPLE 07

I am new to spin and beginning to get the hang of it and liking it.
I tried to compile the above example 07 would not complie - the error was "expected "("·
At the line : PUB Start
·················· VideoDisplay.Start·· --> error line

since I was following the examples serially I noticed in a previous example the same call was made and it compiled with no errors. which
was because the line was : VideoDisplay.Start(12)
So when I edited the error to VideoDisplay(12) - the example· 07 compiled with no problem.

I would like someone to explain what "(12)" refering to and where 12 comes from.
I have seen that in the tutorials in the propeller manual but could not find the explanation for adding (12) after initializing the object.

Thank you.

Siri

Comments

  • LeonLeon Posts: 7,620
    edited 2008-02-04 20:55
    You should find it if you look at the source code for VideoDisplay.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-02-04 22:36
    hello

    this example uses a "sub-program"

    all "sub-programs" in SPIN are called OBJECTS

    in the code of this example there is a line

    OBJ
      VideoDisplay: "TV_Terminal"
    
    



    this means somehow "use the code of the file TV_terminal.SPIN"

    inside this file TV_terminal.SPIN

    you find a PUB

    
    PUB start(basepin) 
    .....
    ...
    
    



    this means the function Start needs a parameter
    (in this case this is the IO-PIN-number)

    every call of the function start must be done with "(Nr)"

    where Nr is the IO-PIN-Number

    if start would be defined as

    
    PUB start(basepin,Var2,Var3) 
    .....
    ...
    
    



    you would have to call

    
    TV_Terminal.start(12,567,945) 
    .....
    ...
    
    



    the numbers 567 and 945 are just supersilly examples with no sense
    just to show the priciples of parameters

    greeting

    Stefan
  • rjo_rjo_ Posts: 1,825
    edited 2008-02-05 05:56
    Siri,

    video requires 4 pins ... which are assumed to be consecutive. 12 is sometimes called the start pin, because pins 12,13,14, and 15 are typically used.

    You can actually use any four consecutive pins ... the lowest pin number is always the start pin and is always used in the function call.

    Rich
  • SiriSiri Posts: 220
    edited 2008-02-05 11:49
    Stefan/Rich,

    Thank you very much for the in depth explanation.the previous reply -" just look in the code" did not explain where and why of the question.

    I am very glad people like you are there to teach and explain these things to people like us who are not programmers and who are also intersted in learning but not just doing/writing code just because you see it done.

    Thanks again,

    Siri
  • LeonLeon Posts: 7,620
    edited 2008-02-05 12:36
    It's a good idea to look at the source code for the functions you are using, the comments are usually very informative and will have lots of useful information. You'd have seen the answer to your question immediately.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-02-06 16:24
    Hello Siri,

    you can ask as many questions as you like.

    The examples and tutorials about SPIN are quite good.

    If you know almost nothing about programming. The examples - sometimes - might be hard to understand.

    So if you don't understand something feel free to ask it here.


    The examples guess that you know something about the very basic princicples of programming

    like
    - parameter-donation,
    - calling subroutines,
    - variables,
    - objective-programming,
    - private and public subroutines
    - global and local variables etc.


    If you don't want to wait for forum answers all the time:

    If you know nothing about these things - it might be useful to learn programming with a programming language like delphi or visual basic
    (c; c++ are more difficult)

    There are a lot of tutorials about delphi and visual basic.
    90% of them are middle-class understandable

    So start to read a tutorial. If you don't understand it - you are NOT too thumb - the tutorial is TOO BAD !
    take the next one and check again. Repeat this until you find one that is really easy to understand.

    Maybe you have to check 10 or 20 tutorials. But it is worth doing it - to find one that is REALLY EASY to understand.

    I'm german and quite good in english. But judging about a programming-tutorial is hard for me
    if you are german i might find a really easy to understand tutorial in german.

    greetings

    Stefan
Sign In or Register to comment.