syntax problem in quickbasic
Author |
Message |
yehonat #1 / 12
|
 syntax problem in quickbasic
hello, i have a problem ,please somebady help me. i have a quickbasic program that convert .s2p to PSPICE I have a problem in line IF UCASE$(RIGHT$(C$, 4) = ".S2P" THEN 'Plausible command$ found. where the editor do not accept the ucase function. please help me i tried to make a .exe from this code and he do not get to the .s2p file thanks The souce code is:(S2P2LIB1.bas) 'S2P2LIB1-- converts S2P tables to '+ PSpice-compatible frequency-response tables. 'Written in QuickBASIC (v4.5). See 'HelpMessage' '+ SUB for additional comments. DECLARE SUB ParseDataLine () DECLARE SUB HelpMessage () DIM D(16), M(50, 9) COMMON SHARED D(), M(), L$ False = 0: True = NOT False DataLine = 0: EODat = False C$ = COMMAND$ 'C$ = "10236N.S2P" 'Decomment and edit in uncompiled version. IF UCASE$(RIGHT$(C$, 4) = ".S2P" THEN 'Plausible command$ found. ufn$ = LEFT$(C$, LEN(C$) - 4) ELSE CALL HelpMessage: SYSTEM END IF OPEN C$ FOR INPUT AS #1 OPEN ufn$ + ".LIB" FOR OUTPUT AS #2 PRINT #2, ".SUBCKT " + ufn$ + " 1 2 3; Port1 Port2 Common" PRINT #2, "*Subcircuit generated by S2P2LIB1.EXE on " + DATE$ WHILE NOT (EOF(1) OR EODat) LINE INPUT #1, L$ L$ = LTRIM$(L$) 'Get rid of any leading spaces. IF LEFT$(L$, 1) = "!" THEN PRINT #2, "*" + RIGHT$(L$ + " ", LEN(L$)) IF LEFT$(L$, 1) = "#" THEN HDR$ = UCASE$(L$): PRINT #2, "*" + L$ IF VAL(L$) > 0 THEN InTheData = True ParseDataLine DataLine = DataLine + 1 FOR k = 1 TO 9: M(DataLine, k) = D(k): NEXT END IF IF VAL(L$) = 0 AND InTheData = True THEN EODat = True WEND CLOSE #1 PRINT #2, " ": PRINT #2, "R1N 1 5 -50": PRINT #2, "R1P 5 7 100" PRINT #2, "R2N 2 4 -50": PRINT #2, "R2P 4 6 100" S$(1) = "*S11 FREQ DB PHASE": S$(2) = "*S21 FREQ DB PHASE" S$(3) = "*S12 FREQ DB PHASE": S$(4) = "*S22 FREQ DB PHASE" E$(1) = "E11 7 9 FREQ {V(5,3)}=": E$(2) = "E21 6 8 FREQ {V(5,3)}=" E$(3) = "E12 9 3 FREQ {V(4,3)}=": E$(4) = "E22 8 3 FREQ {V(4,3)}=" G$ = "_+_(###.##gHz_,+###.##_, +###.##)" 'Format for gHz data M$ = "_+_(#####.##MHz_,+###.##_, +###.##)" 'Format for MHz data IF INSTR(HDR$, "MHZ") THEN P$ = M$ ELSE P$ = G$ FOR P = 1 TO 4 'Build S11, S21, S12, and S22 blocks in sequence. PRINT #2, " ": PRINT #2, S$(P): PRINT #2, E$(P) Offset = 0: PrevPh = 0 'Clear variables used to unwrap phase. FOR F = 1 TO DataLine 'Successive frequency values. Ph = M(F, 2 * P + 1) 'Current phase data. IF ABS(Ph-PrevPh)>180 THEN Offset=Offset-360*SGN(Ph-PrevPh) PrevPh = Ph UWP = Ph + Offset 'UnWrapped Phase. DB=20*LOG(M(F,2*P))/LOG(10): 'Convert magnitude to DB values. PRINT #2, USING P$; M(F, 1); DB; UWP PRINT "."; 'Something to look at. NEXT F: NEXT P PRINT #2, " ": PRINT #2, ".ENDS" PRINT "Finished. Result saved in file " ufn$ ".LIB" CLOSE #2 END SUB HelpMessage PRINT"WBA 7/94. This utility converts an" PRINT"S-parameter file *.S2P having" PRINT"a magnitude and angle (degrees) format" PRINT"into a PSPICE subcircuit" PRINT"file *.LIB which uses the Analog Behavioral" PRINT"Model option." PRINT"The source file should be in the current directory." PRINT"A 50 ohm reference impedance is assumed." PRINT"gHz frequency units are assumed unless the" PRINT""*.S2P files contains" PRINT"a header record beginning with '#' and followed by 'MHz'" PRINT" " PRINT"USAGE: S2P2LIB1 *.S2P " END SUB SUB ParseDataLine k=1: D$="" FOR CH=1 TO LEN(L$)+1 CH$=MID$(L$+ " ", CH, 1) IF CH$ <> " " THEN D$ = D$ + CH$: SP = 0 IF CH$=""AND SP=0 THEN D(k)=VAL(D$): k=k+1:SP=1:D$="" NEXT IF k<>10 THEN PRINT"Error: didn't find 9 numbers parsing the " PRINT"following data line:" PRINT L$ PRINT"Check *.S2P file": END END IF END SUB
|
Tue, 10 Jan 2006 18:25:39 GMT |
|
 |
Michael Mattia #2 / 12
|
 syntax problem in quickbasic
Quote: > hello, > i have a problem ,please somebady help me. > i have a quickbasic program that convert .s2p to PSPICE > I have a problem in line > IF UCASE$(RIGHT$(C$, 4) = ".S2P" THEN 'Plausible command$ found. > where the editor do not accept the ucase function.
1. count left /open paretheses 2. count right/close parentheses. If not equal, correct. MCM
|
Tue, 10 Jan 2006 18:42:21 GMT |
|
 |
Clif Pen #3 / 12
|
 syntax problem in quickbasic
Quote: >hello, >i have a problem ,please somebady help me. >i have a quickbasic program that convert .s2p to PSPICE >I have a problem in line >IF UCASE$(RIGHT$(C$, 4) = ".S2P" THEN 'Plausible command$ found. >where the editor do not accept the ucase function. >please help me >i tried to make a .exe from this code and he do not get to the .s2p file >thanks
----------------------snip---------- 'You forgot to close the parenthesis! Here it is without any SUBs. 'This also compiles properly in QB4.5. CLS C$ = "10236N.s2p" 'Note lower case. IF UCASE$(RIGHT$(C$, 4)) = ".S2P" THEN PRINT "correct" ELSE PRINT "no"
|
Tue, 10 Jan 2006 23:23:38 GMT |
|
 |
yehonat #4 / 12
|
 syntax problem in quickbasic
I still have the same problem "type mismatch ;eorr code :13 for the code : IF UCASE$(RIGHT$(C$, 4) = ".S2P") THEN 'Plausible command$ found. ufn$ = LEFT$(C$, LEN(C$) - 4) what do i have to do? thanx Quote:
> >hello, > >i have a problem ,please somebady help me. > >i have a quickbasic program that convert .s2p to PSPICE > >I have a problem in line > >IF UCASE$(RIGHT$(C$, 4) = ".S2P" THEN 'Plausible command$ found. > >where the editor do not accept the ucase function. > >please help me > >i tried to make a .exe from this code and he do not get to the .s2p file > >thanks > ----------------------snip---------- > 'You forgot to close the parenthesis! Here it is without any SUBs. > 'This also compiles properly in QB4.5. > CLS > C$ = "10236N.s2p" 'Note lower case. > IF UCASE$(RIGHT$(C$, 4)) = ".S2P" THEN PRINT "correct" ELSE PRINT "no"
|
Sat, 14 Jan 2006 04:39:39 GMT |
|
 |
arargh307NOS.. #5 / 12
|
 syntax problem in quickbasic
Quote: >I still have the same problem >"type mismatch ;eorr code :13 >for the code : >IF UCASE$(RIGHT$(C$, 4) = ".S2P") THEN 'Plausible command$ found.
Try: IF UCASE$(RIGHT$(C$, 4)) = ".S2P" THEN 'Plausible command$ found. Quote: >ufn$ = LEFT$(C$, LEN(C$) - 4) >what do i have to do? >thanx
<snip> -- Arargh307 at [drop the 'http://www.' from ->] http://www.arargh.com BCET Basic Compiler Page: http://www.arargh.com/basic/index.html To reply by email, remove the garbage from the reply address.
|
Sat, 14 Jan 2006 05:04:06 GMT |
|
 |
RobeFort #6 / 12
|
 syntax problem in quickbasic
Quote: >>I still have the same problem >>"type mismatch ;eorr code :13 >>for the code : >>IF UCASE$(RIGHT$(C$, 4) = ".S2P") THEN 'Plausible command$ found. >Try: >IF UCASE$(RIGHT$(C$, 4)) = ".S2P" THEN 'Plausible command$ found. >>ufn$ = LEFT$(C$, LEN(C$) - 4) >>what do i have to do?
IF UCASE$(RIGHT$(C$,4) = ".SP4") THEN ufn$ = LEFT$(C$, (LEN(C$) - 4) END IF Quote: >>thanx ><snip>
|
Thu, 19 Jan 2006 18:54:56 GMT |
|
 |
arargh307NOS.. #7 / 12
|
 syntax problem in quickbasic
Quote: >>>I still have the same problem >>>"type mismatch ;eorr code :13 >>>for the code : >>>IF UCASE$(RIGHT$(C$, 4) = ".S2P") THEN 'Plausible command$ found. >>Try: >>IF UCASE$(RIGHT$(C$, 4)) = ".S2P" THEN 'Plausible command$ found. >>>ufn$ = LEFT$(C$, LEN(C$) - 4) >>>what do i have to do? >IF UCASE$(RIGHT$(C$,4) = ".SP4") THEN > ufn$ = LEFT$(C$, (LEN(C$) - 4) >END IF
That still has the same syntax error. You can't UCASE$ a logical result. It would have to be: IF UCASE$(RIGHT$(C$,4)) = ".SP4" THEN ufn$ = LEFT$(C$, (LEN(C$) - 4) END IF -- Arargh307 at [drop the 'http://www.' from ->] http://www.arargh.com BCET Basic Compiler Page: http://www.arargh.com/basic/index.html To reply by email, remove the garbage from the reply address.
|
Thu, 19 Jan 2006 23:28:49 GMT |
|
 |
David Willia #8 / 12
|
 syntax problem in quickbasic
-> >>what do i have to do? -> IF UCASE$(RIGHT$(C$,4) = ".SP4") THEN -> ufn$ = LEFT$(C$, (LEN(C$) - 4) -> END IF Surely not! In the IF line, the second right-bracket should be immediately after the first one: IF UCASE$(RIGHT$(C$, 4)) = ".SP4" THEN Putting it at the end of the condition, as you did, makes the thing try to do a string operation on a truth-value, which isn't going to work! dow
|
Thu, 19 Jan 2006 22:41:37 GMT |
|
 |
RobeFort #9 / 12
|
 syntax problem in quickbasic
Quote: >what do i have to do?
IF UCASE$(RIGHT$(C$, 4)) = ".SP4" THEN ufn$ = LEFT$(C$, LEN(C$) - 4) END IF Would you believe I was real tired when I posted that? :) Quote: >Surely not! In the IF line, the second right-bracket should be >immediately after the first one: >IF UCASE$(RIGHT$(C$, 4)) = ".SP4" THEN >Putting it at the end of the condition, as you did, makes the thing try >to do a string operation on a truth-value, which isn't going to work!
|
Fri, 20 Jan 2006 08:41:57 GMT |
|
 |
RobeFort #10 / 12
|
 syntax problem in quickbasic
Quote: >S2P2LIB1-- converts S2P tables to >'+ PSpice-compatible frequency-response tables. >'Written in QuickBASIC (v4.5). See 'HelpMessage' >'+ SUB for additional comments. >DECLARE SUB ParseDataLine () >DECLARE SUB HelpMessage () >DIM D(16), M(50, 9) >COMMON SHARED D(), M(), L$ >False = 0: True = NOT False >DataLine = 0: EODat = False >C$ = COMMAND$ >'C$ = "10236N.S2P" 'Decomment and edit in uncompiled version. >IF UCASE$(RIGHT$(C$, 4)) = ".S2P" THEN 'Plausible command$ found. >ufn$ = LEFT$(C$, LEN(C$) - 4) >ELSE >CALL HelpMessage: SYSTEM >END IF
Added another right parentheses after the 4 on the line that says: IF UCASE$(RIGHT$(C$,4)) = ".S2P" THEN Quote: >OPEN C$ FOR INPUT AS #1 >OPEN ufn$ + ".LIB" FOR OUTPUT AS #2 >PRINT #2, ".SUBCKT " + ufn$ + " 1 2 3; Port1 Port2 Common" >PRINT #2, "*Subcircuit generated by S2P2LIB1.EXE on " + DATE$ >WHILE NOT (EOF(1) OR EODat) >LINE INPUT #1, L$ >L$ = LTRIM$(L$) 'Get rid of any leading spaces. >IF LEFT$(L$, 1) = "!" THEN PRINT #2, "*" + RIGHT$(L$ + " ", LEN(L$)) >IF LEFT$(L$, 1) = "#" THEN HDR$ = UCASE$(L$): PRINT #2, "*" + L$ >IF VAL(L$) > 0 THEN >InTheData = True >ParseDataLine >DataLine = DataLine + 1 >FOR k = 1 TO 9: M(DataLine, k) = D(k): NEXT >END IF >IF VAL(L$) = 0 AND InTheData = True THEN EODat = True >WEND >CLOSE #1 >PRINT #2, " ": PRINT #2, "R1N 1 5 -50": PRINT #2, "R1P 5 7 100" >PRINT #2, "R2N 2 4 -50": PRINT #2, "R2P 4 6 100" >S$(1) = "*S11 FREQ DB PHASE": S$(2) = "*S21 FREQ DB PHASE" >S$(3) = "*S12 FREQ DB PHASE": S$(4) = "*S22 FREQ DB PHASE" >E$(1) = "E11 7 9 FREQ {V(5,3)}=": E$(2) = "E21 6 8 FREQ {V(5,3)}=" >E$(3) = "E12 9 3 FREQ {V(4,3)}=": E$(4) = "E22 8 3 FREQ {V(4,3)}=" >G$ = "_+_(###.##gHz_,+###.##_, +###.##)" 'Format for gHz data >M$ = "_+_(#####.##MHz_,+###.##_, +###.##)" 'Format for MHz data >IF INSTR(HDR$, "MHZ") THEN P$ = M$ ELSE P$ = G$ >FOR P = 1 TO 4 'Build S11, S21, S12, and S22 blocks in sequence. >PRINT #2, " ": PRINT #2, S$(P): PRINT #2, E$(P) >Offset = 0: PrevPh = 0 'Clear variables used to unwrap phase. >FOR F = 1 TO DataLine 'Successive frequency values. >Ph = M(F, 2 * P + 1) 'Current phase data. >IF ABS(Ph-PrevPh)>180 THEN Offset=Offset-360*SGN(Ph-PrevPh) >PrevPh = Ph >UWP = Ph + Offset 'UnWrapped Phase. >DB=20*LOG(M(F,2*P))/LOG(10): 'Convert magnitude to DB values. >PRINT #2, USING P$; M(F, 1); DB; UWP >PRINT "."; 'Something to look at. >NEXT F: NEXT P >PRINT #2, " ": PRINT #2, ".ENDS" >PRINT "Finished. Result saved in file " ufn$ ".LIB" >CLOSE #2 >END >SUB HelpMessage >PRINT"WBA 7/94. This utility converts an" >PRINT"S-parameter file *.S2P having" >PRINT"a magnitude and angle (degrees) format" >PRINT"into a PSPICE subcircuit" >PRINT"file *.LIB which uses the Analog Behavioral" >PRINT"Model option." >PRINT"The source file should be in the current directory." >PRINT"A 50 ohm reference impedance is assumed." >PRINT"gHz frequency units are assumed unless the" >PRINT""*.S2P files contains" >PRINT"a header record beginning with '#' and followed by 'MHz'" >PRINT" " >PRINT"USAGE: S2P2LIB1 *.S2P " >END SUB >SUB ParseDataLine >k=1: D$="" >FOR CH=1 TO LEN(L$)+1 >CH$=MID$(L$+ " ", CH, 1) >IF CH$ <> " " THEN D$ = D$ + CH$: SP = 0 >IF CH$=""AND SP=0 THEN D(k)=VAL(D$): k=k+1:SP=1:D$="" >NEXT >IF k<>10 THEN >PRINT"Error: didn't find 9 numbers parsing the " >PRINT"following data line:" >PRINT L$ >PRINT"Check *.S2P file": END >END IF >END SUB
|
Fri, 20 Jan 2006 09:03:38 GMT |
|
 |
arargh307NOS.. #11 / 12
|
 syntax problem in quickbasic
Quote: >>what do i have to do? >IF UCASE$(RIGHT$(C$, 4)) = ".SP4" > THEN > ufn$ = LEFT$(C$, LEN(C$) - 4) >END IF
THEN has to be on the same line as IF, for MS basic's -- Arargh307 at [drop the 'http://www.' from ->] http://www.arargh.com BCET Basic Compiler Page: http://www.arargh.com/basic/index.html To reply by email, remove the garbage from the reply address.
|
Fri, 20 Jan 2006 12:48:34 GMT |
|
 |
nos.. #12 / 12
|
 syntax problem in quickbasic
Quote:
> >S2P2LIB1-- converts S2P tables to > >'+ PSpice-compatible frequency-response tables. > >'Written in QuickBASIC (v4.5). See 'HelpMessage' > >'+ SUB for additional comments. > >DECLARE SUB ParseDataLine () > >DECLARE SUB HelpMessage () > >DIM D(16), M(50, 9) > >COMMON SHARED D(), M(), L$ > >False = 0: True = NOT False > >DataLine = 0: EODat = False > >C$ = COMMAND$ > >'C$ = "10236N.S2P" 'Decomment and edit in uncompiled version. > >IF UCASE$(RIGHT$(C$, 4)) = ".S2P" THEN 'Plausible command$ found. > >ufn$ = LEFT$(C$, LEN(C$) - 4) > >ELSE > >CALL HelpMessage: SYSTEM > >END IF > Added another right parentheses after the 4 on the line that says: > IF UCASE$(RIGHT$(C$,4)) = ".S2P" THEN
Line is fine as is Two open and two close. Quote: > >OPEN C$ FOR INPUT AS #1 > >OPEN ufn$ + ".LIB" FOR OUTPUT AS #2 > >PRINT #2, ".SUBCKT " + ufn$ + " 1 2 3; Port1 Port2 Common" > >PRINT #2, "*Subcircuit generated by S2P2LIB1.EXE on " + DATE$ > >WHILE NOT (EOF(1) OR EODat) > >LINE INPUT #1, L$ > >L$ = LTRIM$(L$) 'Get rid of any leading spaces. > >IF LEFT$(L$, 1) = "!" THEN PRINT #2, "*" + RIGHT$(L$ + " ", LEN(L$)) > >IF LEFT$(L$, 1) = "#" THEN HDR$ = UCASE$(L$): PRINT #2, "*" + L$ > >IF VAL(L$) > 0 THEN > >InTheData = True > >ParseDataLine > >DataLine = DataLine + 1 > >FOR k = 1 TO 9: M(DataLine, k) = D(k): NEXT > >END IF > >IF VAL(L$) = 0 AND InTheData = True THEN EODat = True > >WEND > >CLOSE #1 > >PRINT #2, " ": PRINT #2, "R1N 1 5 -50": PRINT #2, "R1P 5 7 100" > >PRINT #2, "R2N 2 4 -50": PRINT #2, "R2P 4 6 100" > >S$(1) = "*S11 FREQ DB PHASE": S$(2) = "*S21 FREQ DB PHASE" > >S$(3) = "*S12 FREQ DB PHASE": S$(4) = "*S22 FREQ DB PHASE" > >E$(1) = "E11 7 9 FREQ {V(5,3)}=": E$(2) = "E21 6 8 FREQ {V(5,3)}=" > >E$(3) = "E12 9 3 FREQ {V(4,3)}=": E$(4) = "E22 8 3 FREQ {V(4,3)}=" > >G$ = "_+_(###.##gHz_,+###.##_, +###.##)" 'Format for gHz data > >M$ = "_+_(#####.##MHz_,+###.##_, +###.##)" 'Format for MHz data > >IF INSTR(HDR$, "MHZ") THEN P$ = M$ ELSE P$ = G$ > >FOR P = 1 TO 4 'Build S11, S21, S12, and S22 blocks in sequence. > >PRINT #2, " ": PRINT #2, S$(P): PRINT #2, E$(P) > >Offset = 0: PrevPh = 0 'Clear variables used to unwrap phase. > >FOR F = 1 TO DataLine 'Successive frequency values. > >Ph = M(F, 2 * P + 1) 'Current phase data. > >IF ABS(Ph-PrevPh)>180 THEN Offset=Offset-360*SGN(Ph-PrevPh) > >PrevPh = Ph > >UWP = Ph + Offset 'UnWrapped Phase. > >DB=20*LOG(M(F,2*P))/LOG(10): 'Convert magnitude to DB values. > >PRINT #2, USING P$; M(F, 1); DB; UWP > >PRINT "."; 'Something to look at. > >NEXT F: NEXT P > >PRINT #2, " ": PRINT #2, ".ENDS" > >PRINT "Finished. Result saved in file " ufn$ ".LIB" > >CLOSE #2 > >END > >SUB HelpMessage > >PRINT"WBA 7/94. This utility converts an" > >PRINT"S-parameter file *.S2P having" > >PRINT"a magnitude and angle (degrees) format" > >PRINT"into a PSPICE subcircuit" > >PRINT"file *.LIB which uses the Analog Behavioral" > >PRINT"Model option." > >PRINT"The source file should be in the current directory." > >PRINT"A 50 ohm reference impedance is assumed." > >PRINT"gHz frequency units are assumed unless the" > >PRINT""*.S2P files contains" > >PRINT"a header record beginning with '#' and followed by 'MHz'" > >PRINT" " > >PRINT"USAGE: S2P2LIB1 *.S2P " > >END SUB > >SUB ParseDataLine > >k=1: D$="" > >FOR CH=1 TO LEN(L$)+1 > >CH$=MID$(L$+ " ", CH, 1) > >IF CH$ <> " " THEN D$ = D$ + CH$: SP = 0 > >IF CH$=""AND SP=0 THEN D(k)=VAL(D$): k=k+1:SP=1:D$="" > >NEXT > >IF k<>10 THEN > >PRINT"Error: didn't find 9 numbers parsing the " > >PRINT"following data line:" > >PRINT L$ > >PRINT"Check *.S2P file": END > >END IF > >END SUB
|
Sat, 21 Jan 2006 06:51:40 GMT |
|
|
|