Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - RobinGravel

Pages: [1] 2
1
QB64 Discussion / Re: Problem with OPEN in SUB
« on: February 26, 2022, 01:07:15 pm »
Would have been nice if somebody would have pointed out what you did wrong, though you might of garnered it from the example replies.

This was your original issue;

SUB text (g, ttt, testing, t1, t2, t3)

If you wanted to pass a UDT you needed to use the AS statement just like in a DIM line

SUB text (g, ttt AS testing)
called with
text 1, ttt

in your original line, each of those variables being passed were passed as the SINGLE data type, by default since you did not specify.

That is why you were not seeing the results you expected.

Now you didn't receive any kind of error because you didn't write one bit of code wrong! Every thing you typed was valid code. Just not the code that would produce the results you wanted.  ttt.t1 is a valid variable even without UDT.

and GET #1, g, ttt
worked correctly too it loaded 4bytes (length of a SINGLE) into ttt, but instead of as a STRING it loaded it as a SINGLE(numeric) value. so no error

and of course PRINT ttt.t1 would have printed 0 as ttt.t1 was a SINGLE value that had nothing assigned to it.(same with the other 2 print lines) so still no error

max = LOF(1) / LEN(ttt)
here LEN(ttt) would have been 4, again because ttt is a SINGLE value which is 4 bytes long. again no error on the compiler side.

Hopefully that explains what occurred, and you can avoid (or make) some problems in the future with this knowledge.

Understood.

2
QB64 Discussion / Re: Problem with OPEN in SUB
« on: February 26, 2022, 11:06:59 am »
I manage to make PRINTs to work inside the SUB. So I don't need to overuse PRINT all the time.

Code: QB64: [Select]
  1. Type testing
  2.     t1 As String * 12
  3.     t2 As String * 12
  4.     t3 As String * 12
  5. Dim rec As testing
  6.  
  7. GetRec 1, rec: GetRec 2, rec
  8. k$ = Input$(1)
  9. Sub GetRec (recNum, rec As testing)
  10.     'Dim As Long max
  11.     Open "test.txt" For Random As #1 Len = Len(rec)
  12.     max = LOF(1) / Len(rec)
  13.     If recNum > 0 And recNum <= max Then
  14.         Get #1, recNum, rec
  15.     Else
  16.         Print "Error, recNum is too high or 0.": End
  17.     End If
  18.     Close
  19.     Print rec.t1: Print rec.t2: Print rec.t3: Print
  20.  

Thanks for help.

3
QB64 Discussion / Problem with OPEN in SUB
« on: February 25, 2022, 09:58:32 pm »
I'm making a game and I need SUBs instead using GOSUBs.

Code: QB64: [Select]
  1. TYPE testing
  2.  t1 AS STRING * 12
  3.  t2 AS STRING * 12
  4.  t3 AS STRING * 12
  5. DIM ttt AS testing
  6. DECLARE SUB text (g, tt, testing, t1, t2, t3)
  7. text 1, tt, testing, t1, t2, t3
  8.  
  9. SUB text (g, ttt, testing, t1, t2, t3)
  10. OPEN "test.txt" FOR RANDOM AS 1 LEN = 36
  11. max = LOF(1) / LEN(ttt)
  12. GET #1, g, ttt
  13. PRINT ttt.t1
  14. PRINT ttt.t2
  15. PRINT ttt.t3
  16. k$ = INPUT$(1): CLOSE
  17.  

No message error but it doesn't give the right results.


Without SUB, the program works as intended.

Code: QB64: [Select]
  1. Type testing
  2.     t1 As String * 12
  3.     t2 As String * 12
  4.     t3 As String * 12
  5.  
  6. Dim ttt As testing: Cls
  7. Open "test.txt" For Random As 1 Len = 36
  8. max = LOF(1) / Len(ttt)
  9. For z = 1 To 2
  10.     Get #1, z, ttt
  11.     Print ttt.t1
  12.     Print ttt.t2
  13.     Print ttt.t3
  14.     Print
  15. k$ = Input$(1): Close
  16.  

Here the code to create TEST.TXT

Code: QB64: [Select]
  1. 'Ftexte
  2.  
  3. TYPE testing
  4.    t1 AS STRING * 12
  5.    t2 AS STRING * 12
  6.    t3 AS STRING * 12
  7.  
  8. DIM ttt AS testing
  9. K$ = INPUT$(1)
  10. '
  11.  OPEN "test.txt" FOR RANDOM AS 1 LEN = LEN(ttt): limit = LEN(ttt)
  12.  FOR z = 1 TO 2
  13.  READ m1$, m2$, m3$
  14.  ttt.t1 = m1$: ttt.t2 = m2$: ttt.t3 = m3$
  15.  PUT #1, z, ttt
  16.  NEXT z
  17.  CLS : PRINT "Saved": K$ = INPUT$(1)
  18. '
  19.  
  20. DATA "123456789012"
  21. DATA "Hello World!"
  22. DATA " Good day.  "
  23.  
  24. DATA "ABCDEFGHIJKL"
  25. DATA "Chichen.    "
  26. DATA "Pizza  Hotel"
  27.  

4
QB64 Discussion / Re: Sub VS Gosub/Return
« on: February 11, 2022, 11:59:39 am »
Thanks guys for the help.

Now I understand better.

5
QB64 Discussion / Sub VS Gosub/Return
« on: February 10, 2022, 10:38:44 pm »
I think gosub/return and sub() are the same.

Are there some situations it would prefer using sub() instead gosub/return?

6
Programs / Re: Dragon Warrior 64 Final
« on: September 02, 2021, 10:38:47 pm »
The 'invisible' item worths nothing?

 
bandicam 2021-09-02 22-28-22-641.png



Also in the menu when selling, the cursor moves too fast to select items.

7
QB64 Discussion / Re: I've created a new QB64 program called Ghost Town!
« on: August 15, 2021, 04:33:43 pm »
@RobinGravel Robin, you will get used to QB64 old-timer @Pete and his waggish ways.  On another thread, Pete once boasted that the Brazilians have a special word for him.  They do, but we are not allowed to repeat it here as this is a family-friendly site.

@doppler.  A fine suggestion.  The Junior Librarian will have to submit Pete's latest coding effort for peer review by senior members for inclusion in the Library.  It will be Pete's finest work to date.

Got it.

8
QB64 Discussion / Re: I've created a new QB64 program called Ghost Town!
« on: August 14, 2021, 08:55:19 pm »
It was a joke.

9
QB64 Discussion / Re: I've created a new QB64 program called Ghost Town!
« on: August 14, 2021, 07:48:41 pm »
Your code is empty.

10
Programs / Re: Dragon Warrior 64 Final
« on: August 12, 2021, 12:51:06 pm »
I also noted there are some differences between DW64 and Nes with tiles/backgrounds.

It reminds me DW2 from NES.

Some musics in your game are in stereo.

Is NES a stereo system?


Note: I can't put images in my post. :(


11
Programs / Re: Dragon Warrior 64 Final
« on: August 12, 2021, 12:23:48 pm »
It's the first time I opened this chest.

Nothing is added to the inventory.

12
Programs / Re: Dragon Warrior 64 Final
« on: August 11, 2021, 09:13:03 pm »
I found a chest with no description.

bandicam 2021-08-11 20-36-28-749.png


Here the entrance of the cave

bandicam 2021-08-11 20-54-56-067.png

13
Programs / Re: Dragon Warrior 64 Final
« on: August 11, 2021, 01:39:51 pm »
Arrow keys to move the character.

Select = B

 Start = A

      B = Enter

      A = Spacebar


Still happens here in the menus.

 
bandicam 2021-08-11 13-06-35-750.png



I pressed Enter to remove menus and the game quits.


14
Programs / Re: Dragon Warrior 64 Final
« on: August 10, 2021, 10:40:32 pm »
The game quits fo no reason again by pressing Enter.

I didn't touch ESC key.

I think it happens when pressing Enter quickly.

15
Programs / Re: Dragon Warrior 64 Final
« on: August 10, 2021, 08:48:33 am »
well thats the real bug your not supposed to be able to use ESC, it acts as an emergency quit should the game hang or something. the control setup should not have allowed the ESC key to be mapped to a control.

If you remap that button to something other than ESC the issue should resolve. I'll have to look as to why you were allowed to map it in the first place though.

I know it's wierd but sometimes I could press ESC just by put down the keyboard to the desk.

I use a cordless keyboard.

Also I was not aware ESC would quit the game until now.

Pages: [1] 2