INKEY$() problem ?

Previous topic - Next topic

Szantai

        ...   
        in$=INKEY$()
        ...

        // - - - SAVE
   IF mb1
   IF BOXCOLL( mx, my, 0, 0, 1175, 716, 114, 25) // save gomb kattintás érzékelés
   GRABSPRITE 100,4,39,668,707
   SAVESPRITE txt$+".bmp",100
   load = 1
   ENDIF
   ENDIF
   //----------------------------------------------------------------------------

The save sprite command does not execute, there is no saved sprite file afterwards.

MrTAToad

Does the box collision section get called ?

If so, is the filename correct ? Can you actually save to the path ?  What platform is it for ?

Szantai

Does the box collision section get called ?

If so, is the filename correct ? Can you actually save to the path ?  What platform is it for ?

Everything is ok.
The platform is XP.

The "txt$" variable is empty.


Szantai

it works with input command

Szantai

Maybe the problem is caused by an added closing character at the end of the variable.

Slydog

Did you get your 'INKEY' code from the help file?
Are you appending the 'in$' variable to the 'txt$' variable, such as:
Code (glbasic) Select
in$ = INKEY$()
IF in$<>"" THEN txt$ = txt$ + in$


Or try hard coding the file name to make sure the save command is at least correct:
Code (glbasic) Select
txt$ = "test"
SAVESPRITE txt$ + ".bmp",100


If you are trying to get the user to input the filename, you could try this command:
QuoteINPUT in$, x#, y#
Waits with a blinking carret for a user input at location x#, y#.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

spacefractal

IF BOXCOLL( mx, my, 0, 0, 1175, 716, 114, 25)

should property been:
IF BOXCOLL( mx, my, 1, 1, 1175, 716, 114, 25)

you cannot give 0 px in width and height and hence its cannot check the collosiion.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Szantai

Bixcoll is correctly work is "0,0"

Szantai

#8
here is code (simply version)

Code (glbasic) Select

txt$=""
a = 0

WHILE TRUE

  IF KEY(14)
  clear$ = INKEY$() // buffer clear
    IF a > 0
      a = a - 1
      txt$=MID$(txt$, 0, LEN(txt$)-1) // Backspace

    ENDIF

  ELSE

    IF a<10
      in$=INKEY$()

        IF in$<>""
         txt$=txt$+in$
           a = a + 1

       ENDIF
      clear$ = INKEY$() // buffer clear
    ENDIF
  clear$ = INKEY$() // buffer clear
  ENDIF

PRINT txt$, 50, 100

         IF KEY(28)
          GRABSPRITE 100,4,39,668,707
SAVESPRITE txt$+".bmp",100
PRINT "saved",10,10
SHOWSCREEN
KEYWAIT
ENDIF

  SHOWSCREEN
WEND

END


I will not run  :(

Edit: Inserted code blocks for easy reading /Moru

Szantai

If the code is such:

...
SAVESPRITE "test.bmp",100
...

is work...hmmm

Slydog

Try changing:
Code (glbasic) Select
      txt$=MID$(txt$, 0, LEN(txt$)-1) // Backspace
to:
Code (glbasic) Select
      txt$=MID$(txt$, 0, a) // Backspace

...since 'a' holds the size of 'txt$'.

or change to:
Code (glbasic) Select
      txt$=MID$(txt$, 0, LEN(txt$)-2) // Backspace
it may not be removing the last character.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Slydog

Change to this:
Code (glbasic) Select
PRINT ">" + txt$ + "<", 50, 100
to see range/size of string.  It may have garbage in it.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Szantai

#12
NICE THANKS  :nw:
is correctly code:

Code (glbasic) Select

txt$=""
a = 0

WHILE TRUE
SLEEP 25
  IF KEY(14)
  clear$ = INKEY$() // buffer clear
    IF a > 0
      a = a - 1
txt$=MID$(txt$, 0, a) // Backspace

    ENDIF

  ELSE

    IF a<10
      in$=INKEY$()

        IF in$<>""
         txt$=txt$+in$
           a = a + 1

       ENDIF
      clear$ = INKEY$() // buffer clear
    ENDIF
  clear$ = INKEY$() // buffer clear
  ENDIF

PRINT txt$, 0, 100

         IF KEY(28)
         txt$=MID$(txt$, 0, a-1) // Backspace
          GRABSPRITE 100,4,39,668,707
SAVESPRITE txt$+".bmp",100
PRINT "saved",10,10
SHOWSCREEN
KEYWAIT
ENDIF

  SHOWSCREEN
WEND

END


[EDIT] Added CODE tags - makes reading code easier. Ian