Author Topic: CALL A QUICKBASIC ROUTINE FROM ANOTHER FILE AND RETURN  (Read 3537 times)

0 Members and 1 Guest are viewing this topic.

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
CALL A QUICKBASIC ROUTINE FROM ANOTHER FILE AND RETURN
« on: August 16, 2018, 08:13:07 am »
how can i call another file through terminal (linux) and continue running my program from where i called without any terminal window showing

10 'in background so user does not know.... its a routine to reset my data file. or a routine to copy files over existing files in folder
20 shell "prog"
30 continue here

just a file to reload new data over the top of old data

copy "folder1" to "Folder0"
start game

or EXEC "file1"
start game
-----------------------------------------------------------------------
MackyWhite

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CALL A QUICKBASIC ROUTINE FROM ANOTHER FILE AND RETURN
« Reply #1 on: August 16, 2018, 09:23:56 am »
Hi PMACKAY,

I can't help with Linux but this is a great place to start research:
http://qb64.org/wiki/Main_Page

The two command keywords of interest are SHELL and RUN, a number of options to choose.

Try some simple experiments that test the keywords under the conditions you need, if you get stuck show some sample code you've tried.

There are often ways to get around doing things outside your program eg copy files or folders or add the routine you want to run to the program you are working on.

You can also call routines up out of libraries once one is setup, that involves BI and BM files.

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: CALL A QUICKBASIC ROUTINE FROM ANOTHER FILE AND RETURN
« Reply #2 on: August 17, 2018, 02:44:28 am »
All good decided to learn how to do what i wanted without using shell to do a file copy

*** anychance this routine could be tested under windows.....


LABEL:- romtoram:   (copy original data to files to run in my game during play)    works %100 percent on linux

n1$ = ".\bm1\MAP.": n2$ = ".\bm2\MAP.": file$ = "000001002003004005006007008009010011"

FOR i = 1 TO 12
    io$ = MID$(file$, i * 3 - 2, 3): OPEN n1$ + io$ FOR INPUT AS #1: OPEN n2$ + io$ FOR OUTPUT AS #2
    DO UNTIL EOF(1)
        INPUT #1, b: PRINT #2, b;
    LOOP: CLOSE #1: CLOSE #2
NEXT i

RETURN

this uses sub folders in linux and hoping same for windows
MackyWhite

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CALL A QUICKBASIC ROUTINE FROM ANOTHER FILE AND RETURN
« Reply #3 on: August 17, 2018, 03:51:12 am »
I am kind of surprised but all this worked:

Code: QB64: [Select]
  1. _TITLE "mkdir and access test"
  2. n1$ = ".\bm1\MAP.": n2$ = ".\bm2\MAP.": file$ = "000001002003004005006007008009010011"
  3. IF _DIREXISTS(".\bm1") = 0 THEN MKDIR ".\bm1"
  4. FOR i = 1 TO 12
  5.     io$ = MID$(file$, i * 3 - 2, 3)
  6.     OPEN n1$ + io$ FOR OUTPUT AS #1
  7.     FOR j = 1 TO 10
  8.         b = j + VAL(io$)
  9.         PRINT #1, b
  10.     NEXT
  11.     CLOSE #1
  12.  
  13.  
  14. IF _DIREXISTS(".\bm2") = 0 THEN MKDIR ".\bm2"
  15. FOR i = 1 TO 12
  16.     io$ = MID$(file$, i * 3 - 2, 3): OPEN n1$ + io$ FOR INPUT AS #1: OPEN n2$ + io$ FOR OUTPUT AS #2
  17.     DO UNTIL EOF(1)
  18.         INPUT #1, b: PRINT #2, b;
  19.     LOOP: CLOSE #1: CLOSE #2
  20.  
  21.  

This line caused all the numbers to be put in one line because of the semi-colon. Was that what you intened?
 INPUT #1, b: PRINT #2, b;

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: CALL A QUICKBASIC ROUTINE FROM ANOTHER FILE AND RETURN
« Reply #4 on: August 17, 2018, 04:26:46 am »
yes I intended to use the ;    keep data closer together

i am glad this is working so far.

thinking of more than two monsters, maybe a bunch depending on complexity of puzzles (maps)

once a level editer has been created i think it would be more fun to have others edit maps. but i am happy with this so far.
MackyWhite