Shop OBEX P1 Docs P2 Docs Learn Events
Stuck in spin but I shouldn't be... — Parallax Forums

Stuck in spin but I shouldn't be...

undermuttundermutt Posts: 22
edited 2013-08-25 20:05 in Propeller 1
I'm learning spin and I've run across something that is driving me nuts. It's something that should work but doesn't.

So here goes...

Why does this work....
OBJ
  system: "Propeller Board of Education"
  pst   : "Parallax Serial Terminal Plus"
    f   : "F32"
    fs  : "FloatString"
    
VAR
  long  dms[3]
    
PUB main 

  pst.clear
  f.start

  pst.newline
  pst.str(fs.FloatToString(dms2dd(60, 30, 0)))
  pst.newline

Pub dms2dd(degrees_in, minutes_in, seconds_in) : decimalDegrees

  decimalDegrees := f.fadd(f.fadd(f.ffloat(degrees_in), f.fdiv(f.ffloat(minutes_in), 60.0)), f.fdiv(f.ffloat(seconds_in), 3600.0))


But when I move dms2dd to another file...
{conversions}

OBJ
  f       : "F32"

VAR
  long dms[3]
    
Pub dms2dd(degrees_in, minutes_in, seconds_in) : decimalDegrees

  decimalDegrees := f.fadd(f.fadd(f.ffloat(degrees_in), f.fdiv(f.ffloat(minutes_in), 60.0)), f.fdiv(f.ffloat(seconds_in), 3600.0))


And modify the initial file to this...
OBJ
  system: "Propeller Board of Education"
  pst   : "Parallax Serial Terminal Plus"
    f   : "F32"
    fs  : "FloatString"
    [COLOR=#a52a2a]cv  : "conversions"[/COLOR]
    
VAR
  long  dms[3]
    
PUB main 

  pst.clear
  f.start

  pst.newline
  pst.str(fs.FloatToString([COLOR=#a52a2a]cv[/COLOR].dms2dd(60, 30, 0)))
  pst.newline

It doesn't work. It doesn't error out, it just does nothing.

The 2 files are in the same directory.

Am I missing something obvious?

Thanks,

Rick.

Comments

  • localrogerlocalroger Posts: 3,451
    edited 2013-08-25 19:59
    Hey Rick, you'll probably get the Clippy quote soon from A Certain Other User but since Spin is indentation-sensitive and the forum strips leading spaces you need to put your program in a code block. put a left bracket-CODE-right bracket tag at the start, and a left bracket-forward slash-CODE-right bracket tag at the end and the forum will let us see your indentation.
  • T ChapT Chap Posts: 4,223
    edited 2013-08-25 20:02
    Rick, edit your post and put [ code ] at the top of the code section, and put [ / code ] at the bottom of the code. Remove the spaces in the brackets, this will show the code exactly like you have it in your program. Oh, this is redundant, Local just said the same thing,
  • kuronekokuroneko Posts: 3,623
    edited 2013-08-25 20:05
    In your conversions.spin file you use an uninitialised (i.e. non-working) floating point object. As this is a different instance from the one in the primary object you still have to start it (consuming another cog)
Sign In or Register to comment.