Code:
$COMPILE EXE "NONAME.EXE" COMMON X% INCR X% PRINT "NONAME.EXE LAUNCH COUNT =" X% A$ = "NONAME.EXE" IF X% < 25 THEN CHAIN A$
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
$COMPILE EXE "NONAME.EXE" COMMON X% INCR X% PRINT "NONAME.EXE LAUNCH COUNT =" X% A$ = "NONAME.EXE" IF X% < 25 THEN CHAIN A$
A$ = "chainmod.pbc" CHAIN A$
' FILE: COMMON.BI COMMON LastModule$, CustomerNo%, Print_port$, CompanyInfo$(), Sold!()
' FILE: PRINTNOW.BAS $COMPILE CHAIN $INCLUDE "COMMON.BI" DIM I AS INTEGER OPEN "LPT"+PRINT_PORT$ FOR OUTPUT AS #20 PRINT #20, CustomerNo% ' print custmer number in correct place FOR I = 1 to 3 Print#20,CompanyInfo$(I) ' 1=name, 2= address, 3 = city, state, zip NEXT Print#20, "blah blah blah" Print#20,tab(40);Sold At; sold(1) :’variable storing price item was sold ' set last module so main program knows what to do when it restarts.. LastModule$ = "PRINTNOW" ' return to main program CHAIN "MainProg.exe" ' end of file
' FILE: Main Program.bas $COMPLILE EXE $INCLUDE "Common.BAS" MAIN: IF LastModule$ = "PRINTNOW" THEN ' is program starting because it's returning from CHAIN? GOTO PrintNowReturn ' and resume execution at that point END IF ..... PrintInvoice: ' set up the COMMON variables to be passsed to the CHAINed print module.. CustomerNo% = 9876 Company$ (1) = "The Acme Company" Company$ (2) = "1234 Main St." Company$ (3) = "Ottumwa IA 56789" Sold (1) = 1234.56 ' price LastModule$ = "MAINPROG" CALL SaveSharedVariables ' save what we will need on return CHAIN "Printnow.PBC" PrintNowReturn: ' we get here when the printnow chained file has returned CALL RestoreSharedVariables ' reload current values PRINT "Invoice printed, do something" ..... SUB SaveSharedVariables DIM hF AS INTEGER hF = FREEFILE OPEN "Save_me.txt" FOR OUTPUT AS hF WRITE #hf, sharedVar1, SharedVar2, SharedVar3, ... CLOSE hf END SUB SUB RestoreSharedVariables DIM hF AS INTEGER hF = FREEFILE OPEN "save_me.txt" FOR INPUT AS hF INPUT #hF, sharedVar1, sharedvar2,sharedvar3,... CLOSE hf END SUB
print #20,tab(40 - int(len(text$) / 2));text$
%customer_1 = 0 ' set only one of these to 1 %customer_2 = 1 %customer_3 = 0 ... GOSUB Print_Now ... PRINT_NOW: $IF %customer_1 $INCLUDE "PNow_1.bas" $ENDIF $IF %customer_2 $INCLUDE "PNow_2.bas" $ENDIF $IF %customer_3 $INCLUDE "PNow_3.bas" $ENDIF RETURN
PRINT_NOW: PRINT_PORT$="1" : `this number could be sitting in a variable OPEN "LPT"+PRINT_PORT$ FOR OUTPUT AS #20 OPEN "Company.dat" FOR INPUT AS #21 INPUT #21, TabSpot, NoAddrLines For Ctr = 1 TO NoAddrLines INPUT #21, AddrData$ Print#20, AddrData$ Next Ctr INPUT sold(1) Print #20, tab(TabSpot); ”Sold At”; sold(1) CLOSE #20 CLOSE #21 RETURN
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: