Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

General FreeBASIC programming questions.
fatman2021
Posts: 123
Joined: Dec 14, 2013 0:43

Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby fatman2021 » Jun 14, 2018 16:09

*p1 is a pointer to a string

Code: Select all

define_lisp_function(LoadImage, args)

      _OBJ(p1) = _EVAL(_CAR(args))
      _OBJ(p2) = _EVAL(_CAR(_CDR(args)))
      _OBJ(p3) = _EVAL(_CAR(_CDR(_CDR(args))))
      _OBJ(res) = any
     
      if( _LENGTH(args) < 1) then
              _RAISEERROR(LISP_ERR_TOO_FEW_ARGUMENTS)
      end if
     
      if(_IS_STRING(p1)) then
             res = _NEW(OBJECT_TYPE_INTEGER)
             res ->value.int = -1
             
             Bload *p1, cint(*p2), cint(*p3)
             
             function = res
             
      else
     
             function = _NIL_
             
      end if             

end_lisp_function()
fxm
Posts: 8361
Joined: Apr 22, 2009 12:46
Location: Paris (suburb), FRANCE

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby fxm » Jun 14, 2018 16:33

fatman2021 wrote:*p1 is a pointer to a string

If ' *p1 ' is really a pointer to a string, then try with ' **p1 ' !
fatman2021
Posts: 123
Joined: Dec 14, 2013 0:43

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby fatman2021 » Jun 14, 2018 17:08

fxm wrote:
fatman2021 wrote:*p1 is a pointer to a string

If ' *p1 ' is really a pointer to a string, then try with ' **p1 ' !


Expected pointer, before ',' in 'Bload **p1, cint(*p2), cint(*p3)'
fxm
Posts: 8361
Joined: Apr 22, 2009 12:46
Location: Paris (suburb), FRANCE

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby fxm » Jun 14, 2018 18:00

Can you insert in your code (for example just before the Bload line):
#Print Typeof(p1)
and post the compiler output (the type of p1) ?
fatman2021
Posts: 123
Joined: Dec 14, 2013 0:43

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby fatman2021 » Jun 14, 2018 18:49

fxm wrote:Can you insert in your code (for example just before the Bload line):
#Print Typeof(p1)
and post the compiler output (the type of p1) ?


Expected End-of-Line, found 'Typeof' in 'Print Typeof(p1)'
badidea
Posts: 982
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby badidea » Jun 14, 2018 18:57

fatman2021
Posts: 123
Joined: Dec 14, 2013 0:43

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby fatman2021 » Jun 14, 2018 19:11

badidea wrote:"#print" not "print", see: https://freebasic.net/wiki/wikka.php?wakka=KeyPgPpprint


LISP.LISP_OBJECT PTR
dodicat
Posts: 5166
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby dodicat » Jun 14, 2018 19:30

Are you setting a graphics screen before bload?
screen 20,32 or something similar
fatman2021
Posts: 123
Joined: Dec 14, 2013 0:43

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby fatman2021 » Jun 14, 2018 20:22

dodicat wrote:Are you setting a graphics screen before bload?
screen 20,32 or something similar


Yes

Code: Select all

using LISP

dim lsp AS LispModule, expr as string

BIND_FUNC( lsp.functions, "setvideo", SetVideo)
BIND_FUNC( lsp.functions, "setpixel", SetPixel)
BIND_FUNC( lsp.functions, "setline",  SetLine)
BIND_FUNC( lsp.functions, "setres",   SetRes)
BIND_FUNC( lsp.functions, "loadimage", LoadImage)
with lsp
        .eval $"(setq x 0)"
        .eval $"(setq y1 0)"
        .eval $"(setq y2 599)"
        .eval $"(setq page 0)"
        .eval $"(setres  800 600 16)"
        .eval $"(loadimage ""./test.bmp"")"

rem        .eval $"(while (< x 799) " + _
rem                  "(setline x y1 x y2 (+ x (* 256 x) (* 65536 x))) " + _
rem                  "(setq x (+ x 1)))"

end with

sleep


It now compiles and executes with the following warnings:

test.bas(154) warning 1(1): Passing scalar as pointer, at parameter 2 of BLOAD()
test.bas(154) warning 1(1): Passing scalar as pointer, at parameter 3 of BLOAD()


Code: Select all

define_lisp_function(LoadImage, args)

      _OBJ(p1) = _EVAL(_CAR(args))
      _OBJ(p2) = _EVAL(_CAR(_CDR(args)))
      _OBJ(p3) = _EVAL(_CAR(_CDR(_CDR(args))))
      _OBJ(res) = any
     
      if( _LENGTH(args) < 1) then
              _RAISEERROR(LISP_ERR_TOO_FEW_ARGUMENTS)
      end if
     
      if(_IS_STRING(p1)) then
             res = _NEW(OBJECT_TYPE_INTEGER)
             res ->value.int = -1
             
             Dim As String filename = *p1->value.str
             Dim As Integer dest = p2->value.int
             Dim As Integer pal = p3->value.int
             
             Bload filename, dest, pal
             
             function = res
             
      else
     
             function = _NIL_
             
      end if             

end_lisp_function()
fxm
Posts: 8361
Joined: Apr 22, 2009 12:46
Location: Paris (suburb), FRANCE

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby fxm » Jun 14, 2018 20:40

dest and pal must be pointers.
See /wiki/KeyPgBload.
counting_pine
Site Admin
Posts: 5956
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby counting_pine » Jun 14, 2018 20:50

I'm not familiar enough with the LISP library (is it coderJeff's?) to know how you'd pass pointers around to functions.

If you plan to, then hopefully it will have a way to get a pointer out of the values, maybe something like 'p2->value.anyptr'. Otherwise you'll have to convert them yourself: 'cast(any ptr, p2->value.int)'.

If you don't plan to, then the simplest solution might be to remove support the p2/p3 parameters, and just call 'Bload filename'.
fatman2021
Posts: 123
Joined: Dec 14, 2013 0:43

Re: Type mismatch, at parameter 1 of BLOAD() in 'Bload *p1, cint(*p2), cint(*p3)'

Postby fatman2021 » Jun 14, 2018 21:32

counting_pine wrote:I'm not familiar enough with the LISP library (is it coderJeff's?) to know how you'd pass pointers around to functions.


Yes. It is coderJeffs's LISP library.

Return to “General”

Who is online

Users browsing this forum: No registered users and 4 guests