Author Topic: '$INCLUCE as text  (Read 2700 times)

0 Members and 1 Guest are viewing this topic.

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
'$INCLUCE as text
« on: October 07, 2021, 03:52:46 am »
Hello to all of you, these are difficult times... I hope you are (we are) all well.

I would like to read the command '$INCLUDE opening the BAS file with OPEN.
It seems to me that the string read (LINE INPUT#) completely ignores the content and cannot see '$INCLUDE.

Obviously all other strings are read regularly and can be manipulated.

Am I doing something wrong?


Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: '$INCLUCE as text
« Reply #1 on: October 07, 2021, 04:14:22 am »
Share some code please.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: '$INCLUCE as text
« Reply #2 on: October 07, 2021, 04:34:24 am »
Thanks Neill you caught me in foul
rewriting from scratch a few lines of elementary code the problem does not arise
evidently there must be a problem that I can not see in the general code of the application I am developing
so it's a false alarm...
Sorry

if it will be necessary I will come back to disturb you (I usually try not to do it)
Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • View Profile
    • Resume
Re: '$INCLUCE as text
« Reply #3 on: October 07, 2021, 12:06:51 pm »
@krovit,The following routine is from @luke's incmerge program.

This opens an '$INCLUDE: file, and reads it as input into the program. His utility opens a QB64 source and replaces the $INCLUDE with the code that is in that file. You should be able to change it to your needs.

Code: QB64: [Select]
  1. SUB process (filename$)
  2.     inclCount = inclCount + 1
  3.     IF NOT silentSW THEN
  4.         IF inclCount > 1 THEN PRINT "    Include File Found: "; filename$
  5.     END IF
  6.     fh = FREEFILE
  7.     IF _FILEEXISTS(filename$) THEN
  8.                 OPEN filename$ FOR BINARY AS #fh
  9.                 DO
  10.                         LINE INPUT #fh, l$
  11.                         IF INSTR(LTRIM$(l$), "'$include") = 1 OR INSTR(LTRIM$(l$), "'$INCLUDE") THEN
  12.                                 t$ = LTRIM$(l$)
  13.                                 q1 = INSTR(2, t$, "'")
  14.                                 q2 = INSTR(q1 + 1, t$, "'")
  15.                                 process MID$(t$, q1 + 1, q2 - q1 - 1)
  16.                         ELSE
  17.                                 PRINT #1, l$
  18.                         END IF
  19.                 LOOP UNTIL EOF(fh)
  20.         ELSE
  21.                 PRINT USING "Error - File: & Not Found."; filename$
  22.                 CLOSE #fh
  23.                 KILL COMMAND$(2)
  24.                 SYSTEM 1
  25.         END IF 
  26.     CLOSE #fh
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)