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

General FreeBASIC programming questions.
Post Reply
fatman2021
Posts: 215
Joined: Dec 14, 2013 0:43

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

Post by fatman2021 »

*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
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

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

Post by fxm »

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

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

Post by fatman2021 »

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
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

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

Post by fxm »

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: 215
Joined: Dec 14, 2013 0:43

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

Post by fatman2021 »

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: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

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

Post by badidea »

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

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

Post by fatman2021 »

badidea wrote:"#print" not "print", see: https://freebasic.net/wiki/wikka.php?wakka=KeyPgPpprint
LISP.LISP_OBJECT PTR
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

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

Post by dodicat »

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

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

Post by fatman2021 »

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
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

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

Post by fxm »

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

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

Post by counting_pine »

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: 215
Joined: Dec 14, 2013 0:43

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

Post by fatman2021 »

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.
Post Reply