QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: kservice on September 24, 2021, 10:35:38 am

Title: Programming errors on QB64
Post by: kservice on September 24, 2021, 10:35:38 am
Tell me, please, what is the error? 
 [ This attachment cannot be displayed inline in 'Print Page' view ]  
Error in line 124
Title: Re: Programming errors on QB64
Post by: Petr on September 24, 2021, 10:53:12 am
In your source code is not SUB named as zaglavie:

here is your source code
...
..
..
..
..

here is your SUBs and FUNCTIONs

SUB zaglavie
...
... next source code in this SUB
...
END SUB
Title: Re: Programming errors on QB64
Post by: FellippeHeitor on September 24, 2021, 10:54:33 am
You didn't separate the Call from the comment:

Code: QB64: [Select]
  1. Call zaglavie1(): rem ...

Notice:
1- Call is optional:
Code: QB64: [Select]
  1.  zaglavie1: rem ...

2- rem is optional, if you use the apostrophe - and if you don't use rem, you don't have to separate the comment from the main line with a colon:
Code: QB64: [Select]
  1. zaglavie1 'some comment
Title: Re: Programming errors on QB64
Post by: Petr on September 24, 2021, 11:00:07 am
Here is example:
@FellippeHeitor  it works also without : separator with REM :)

Code: QB64: [Select]
  1.     CLS
  2.     CALL ShowTime REM here is something wrong!
  3.     _DISPLAY
  4.     _LIMIT 20
  5.  
  6. SUB ShowTime
  7.     LOCATE 1
  8.     PRINT TIME$
  9.  
  10.  
  11.  
Title: Re: Programming errors on QB64
Post by: Petr on September 24, 2021, 11:08:31 am
@kservice

Next option is, if zagalvie1 SUB exists in your source code, remove brackets from CALL statement.
Title: Re: Programming errors on QB64
Post by: kservice on September 24, 2021, 12:20:34 pm
In your source code is not SUB named as zaglavie:

All called functions are in a separate file.
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

After separating the function of the function and the comment has not changed
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Programming errors on QB64
Post by: Petr on September 24, 2021, 02:06:16 pm
So zaglavie1 is not SUB, because if is, then you must have this error message:

(SUB must be included at the end the source code)

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Programming errors on QB64
Post by: SMcNeill on September 24, 2021, 02:17:05 pm
Can you call a sub with blank parameters?  If it’s blank, shouldn’t it just be omitted?

CALL X()

SUB X
  PRINT “foo”
END
Title: Re: Programming errors on QB64
Post by: TempodiBasic on September 24, 2021, 02:31:38 pm
Hi
Fine behaviour...

Code: QB64: [Select]
  1. Print "1"
  2. Call print2 Rem ' it is a modern comment
  3. print2 Rem it is a classical comment
  4.  
  5. Sub print2 ()
  6.     Print "Hi I'm SUB print2 and I do this...";
  7.     Print 2

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
yes I can confirm that the error is NOT related to the absence of : between  print2 and Rem
moreover also if I type : the error stays there.
If I erase the () all become ok.

Are there some differences with QB45?  I dunno.
Title: Re: Programming errors on QB64
Post by: SMcNeill on September 24, 2021, 02:39:22 pm
It’s the blank parameters.

Call x()

Sub x()
   PRINT “foo”
End Sub

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Programming errors on QB64
Post by: TempodiBasic on September 24, 2021, 09:18:56 pm
Yes trying the same code in QBasic
this last warns the user to put arguments between ( )
Moreover it doesn't tolerate a REM without a : before it!

Title: Re: Programming errors on QB64
Post by: FellippeHeitor on September 24, 2021, 11:19:29 pm
Yeah, today I learned QB64 doesn't mind if there's a colon before a REM comment.

It's only mandatory in DATA lines.
Title: Re: Programming errors on QB64
Post by: kservice on September 25, 2021, 06:54:45 am
Thanks to all for participation and advice. The program is large, many different functions that I combined into the plug-in file.
       Advise how to better make functions from this file? Can there be 2-3 connected files?
The program was created for many years ago for QB45 and now, when there is free time, trying to transfer to QB64. On QB45 everything worked. Here, apparently, checking over compiling more careful.
I'm trying to figure it out. So far not everything turns out. So I take a break. I am free from other cases - I will continue.
   Checked such a test variant - works without errors
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Programming errors on QB64
Post by: kservice on September 26, 2021, 11:51:47 am
In the  QB45 program i am used the FRE(-1) command. In QB64, this keyword is not supported. Something can be replaced?
Or here it is not necessary?

     And another question. I repeatedly use the functions of the form
Sub Chtenie1 (SKLSUM#, U$, f$, NB$, NE$, DT$, FRM$, RR, C, PP, tov() As Tovar).
Variable tov () AS Tovar is read from the f$ file. This is an array, in each row of which 4 pemet. But at the same time an
"IncorRect Array Type Passed to Sub" error occurs.
     How can this problem be solved?
Title: Re: Programming errors on QB64
Post by: FellippeHeitor on September 26, 2021, 12:18:01 pm
There's no direct equivalent to FRE() in QB64. You will have to query the operating system (research the API) to check how much free memory is available.

Unless your program relied directly on knowing how much free memory there was, you can probably safely remove the FRE() occurrences.
Title: Re: Programming errors on QB64
Post by: kservice on September 26, 2021, 02:19:05 pm
It's clear. And what about an "IncorRect Array Type Passed to Sub" error ?
Title: Re: Programming errors on QB64
Post by: kservice on October 09, 2021, 01:10:36 pm
I probably did something wrong if I stopped answering my questions? In this case, I ask the yen to apologize.
Title: Re: Programming errors on QB64
Post by: SMcNeill on October 09, 2021, 01:55:54 pm
It's clear. And what about an "IncorRect Array Type Passed to Sub" error ?

Incorrect Array Type Passed to Sub comes from... wait for it... passing an incorrect array type to a SUB!!  😂😂

An example:

SUB Foo (an_array() AS INTEGER)
     ...stuff
ENS SUB

A fairly standard SUB, doing standard stuff with an array.  All is good here, until:

DIM data_array(100) AS LONG
Foo data_array()

Now our SUB expects an array of INTEGER type.  We just tried to pass it an array of LONG type.  What’s the result?

You guessed it!

Incorrect Array Type Passed to Sub Error

Pass them the types they except and you won’t see that message any more.
Title: Re: Programming errors on QB64
Post by: kservice on October 10, 2021, 05:09:05 am
Thank you, I will understand
Title: Re: Programming errors on QB64
Post by: kservice on October 10, 2021, 10:38:16 am
When i try to rename an old file to file.bak and data records to a new file, I collided with such errors:
  [ This attachment cannot be displayed inline in 'Print Page' view ]    [ This attachment cannot be displayed inline in 'Print Page' view ]  
What can you suggest?
Title: Re: Programming errors on QB64
Post by: kservice on October 10, 2021, 01:36:31 pm
Refinement: String 2426 This is a string: Name F2 $ AS MID $ (F2 $, 1, Len (F2 $) - 3) + "BAK"
I noticed that if you make a Name "bigbad.txt" as "badwolf.txt", then this error disappears. But I need to use a conditional f2$, as each time they are different when using the procedure. In other words, I need this option: Name "f2$" AS "f2new$"

How can I get out of this position?
In QB45 it worked. Is it possible to find a solution option in QV64?
Title: Re: Programming errors on QB64
Post by: kservice on October 12, 2021, 11:46:09 am
The last problem is solved by the use of Field 2, 10 AS ...... and LSET .... instead of Print # 2, using "##############. ##