How do I fix this BASIC compilation error? - dos

I have a problem compiling a program I made in BASIC. It's a DOS simulator that I was making in attempts to see if it is posssible to write an operating system entirly in BASIC. Every time I try to compile, I get these messages:
!SYNTAX ERROR IN LINE 15, COLUMN 50
UNEXPECTED E
EXPECTING : OR END OF LINE
What do I change to sovle this?
10 PRINT
11 PRINT "Starting..."
12 PRINT
13 PRINT
14 INPUT "Type the location of the Command Interpretter:"; I$
15 IF I$ = "C:\WINDOWS\COMMAND.COM" THEN GOTO 14 ELSE GOTO 13
16 INPUT "C:\>"; D$
17 IF D$ = "FORMAT" GOTO 25
18 IF D$ = "FDISK" GOTO 47
19 IF D$ = "HELP" GOTO 16
20 IF D$ = "DIR" GOTO 16
21 IF D$ = "MKDIR" GOTO 16
22 IF D$ = "WIN" GOTO 16
23 IF D$ = "CD" GOTO 16
24 IF D$ = "DEL" GOTO 16
25 PRINT "WARNING, ALL DATA ON REMOVABLE DISK"
27 PRINT "DRIVE A: WILL BE LOST!"
28 INPUT "Proceed with Format (Y/N)"; F$
29 IF F$ = "Y" THEN GOTO 28
30 IF F$ = "N" THEN GOTO 16
31 PRINT
32 PRINT
33 PRINT
34 PRINT "Fotmatting 1.44MB"
35 PRINT "Format complete."
36 PRINT "Writing out file allocation table"
37 PRINT "Complete."
38 PRINT "Calculating free space (this may take several minutes)...................."
39 PRINT "Complete."
40 PRINT
41 INPUT "Volume Label (11 charchters, ENTER for none)"
42 PRINT
43 PRINT " 1,440MB total disk space"
44 PRINT " 1,440MB available on disk"
45 PRINT
46 PRINT " 512 bytes in each allocation unit."
47 PRINT " 32,624 allocation units available on disk."
48 PRINT "Volume Serial Number is 326A-1312"
49 GOTO 16
50 PRINT "Incorrect DOS Version"
51 PRINT
52 GOTO 16
I used Vintage BASIC 1.0.1 as the compiler. Anyone know what's going on?
Windoze NT

I don't think there is an ELSE keyword in vintage basic, which is why you're getting the unexpected 'E' error.
I assume vintage BASIC is unstructured BASIC, you can refer to the wikipedia article for an example:
http://en.wikipedia.org/wiki/BASIC_programming_language
Also, you have some duplicate line numbers for 26 and 27, which explains the other errors.

The first two warnings are caused by your program having two lines 26, and two lines 27.
I would guess that the third message comes from your BASIC only supporting IF THEN and not IF THEN ELSE. In this case, you can encode it with IF GOTO.

Are you sure your version of BASIC has ELSE? Not all have...
I guess you are learning to program, right? May I ask a question? Why Basic? I think there are a lot of more useful and powerful (and mainly using modern practices of programing) languages to learn that you can use in a graphic OS and they are not more complicated to learn like Python for example (my son has your age and he is loving python). It's a simple language for simple things but very powerful if you need (and complicated too!).
Good luck!

I note that you've changed the code originally posted, deleting the duplicate line numbers That will make the first part of this answer look weird, but I'll leave it.
The compiler is telling you that you're re-using the same line numbers. Notice the following section of code?
26 PRINT "DRIVE A: WILL BE LOST!"
27 INPUT "Proceed with Format (Y/N)"; F$
26 IF F$ = "Y" THEN GOTO 28
27 IF F$ = "N" THEN GOTO 16
The fix is to renumber your lines. Now you know why you don't usually use increments of 1 between lines in languages that require line numbers! (You can likely find - or even write - a tool to do it for you, however.)
Regarding the error from:
15 IF I$ = "C:\WINDOWS\COMMAND.COM" THEN GOTO 14 ELSE GOTO 13
I've not run across "Vintage BASIC" before, but assuming the other answers about it not supporting an else are correct, you'll want something like:
15 IF I$ = "C:\WINDOWS\COMMAND.COM" THEN GOTO 14
16 IF I$ <> "C:\WINDOWS\COMMAND.COM" THEN GOTO 13
You may need to replace "<>" with "!=" or whatever your BASIC uses as a not equal to operator. Also, you'll have to do more renumbering, since you already have a line 16.

Related

How to compare the content of two files in EFI Shell

I want to compare the content of two files in EFI Shell.
I saved the content of pci 05 00 00 in lan-ref.txt
My script looks like this:
echo -off
fs0:
pci 05 00 00 -s 0 > lan.txt
if lan.txt == lan-ref.txt then
reset
else
echo "LAN not found"
endif
I know that the "if lan.txt == lan-ref.txt" is not going to work, I am looking for the correct line to achieve the desired functionality.
Like #prl suggests, combine the comp command and %lasterror%:
comp lan-text lan-ref.txt
if %lasterror% eq 0 then
reset
else
echo "LAN not found"
endif
%lasterror% is equivalent to %errorlevel% in .bat scripts or $? in bourne shells and derivatives.
comp lan-text lan-ref.txt
if %lasterror% ==0 then
reset
else
echo "LAN not found"
endif

Problem in Makefile forloop break statement

print:
#for number in 10 11 12 13 14 15; do \
( echo "Number: $$number" ); \
( break ); \
( echo Break not working ); \
done
The output that i am getting
Number: 10
Break not working
Number: 11
Break not working
Number: 12
Break not working
Number: 13
Break not working
Number: 14
Break not working
Number: 15
Break not working
The output that i need :
Number: 10
In the posted code the 'for' loop is executed in the shell (bash ?), not by the 'make' utility.
The problem with the bash script is that the 'break' statement is running in a sub-process - as it is placed inside parenthesis '( break '). As per bash manual, control-flow commands (while, if, for, return, ...) should executed in the "main" process. It is not possible to split them across processes.
Removing the '(' should solve the problem - the loop will stop after printing 'Number: 10'.
print:
#for number in 10 11 12 13 14 15; do \
( echo "Number: $$number" ); \
break ; \
( echo Break not working ); \
done
As a side note, no need to put 'echo' statements in '( ... )'. It make the script fork unnecessary instances o bash.

Single echo statement displaying values in 2 lines

The echo statement below is displaying values in 2 line instead of single line (Redirect File).
echo ">>"`date`": Value1: " $VAL1 "Value2:" $VAL2>>$RES_FILE
Actual Result:
>>Tue Dec 1 10:20:24 IST 2015: Value1:1
Value2:2
Expected Result:
>>Tue Dec 1 10:20:24 IST 2015: Value1:1 Value2:2
Tell me whats wrong with the statement.
There's no problem with your usage of echo. From your output, it looks like there's a newline in VAL1.
You try removing it:
VAL1="${VAL1//$'\n'}"

BASH script checking log files for current and previous month

I have been working on this on and off for the last two months, and despite how many times I look at it, I can't make it work.
This script checks daily log files for a user defined variable, so they don't have to look through every one manually. It worked great checking the current month, but if the user wants to check back 20 days, and today is the 12th of this month, I wanted to be able to then go back to the previous month (not look for the log file with a date of 20150399 and so on). I have checked the logic for my date/day computations, and they seem okay (if there is a better way to do that in BASH, I am open to suggestions). What happens when I try to debug is unexpected end of file. I am somewhat new to writing scripts that contain more than 20 or so lines, but I just can't come up with what I am missing.
I have tried various fixes, to no avail, but I think this is the last iteration.
Ideas?
#!/bin/bash
########################################################
# multi_log_chk.sh
# This script will take input from the user and report which
# CyberFusion MFT logs contain what the user is looking for.
# Hopefully this will save the user having to search through every
# stinking log file to find what they are looking for.
# 20150406 pxg007 started typing
# 20150413 pxg007 added && comparison for back out (line 28)
# added message for no entries found (line 32, 38, 48-52)
# Added some further description (line 16)
# 20150424 pxg007 Added logic to calculate previous month and if necessary, year. (Lines 16-24, 60-78 )
#
########################################################
currDate=`date +%d%B%C%y`
currDay=`date +%d`
currMnth=`date +%m`
currYear=`date +%C%y`
case $currMnth in #Let's establish number of days for previous month
05 | 07 | 10 | 12 ) lastMnthD=30;;
01 |02 | 04 | 06 | 09 | 08 | 11 ) lastMnthD=31;;
03 ) lastMnthD=28;; ##and screw leap year
esac
if [ $currMnth -eq 01 ]; then ##accounting for January
lastMnth=12
else
lastMnth=$((currMnth-1))
fi
if [ $lastMnth -eq 12 ]; then ## accounting for Dec of previous year
lastMnthYr=$((currYear-1))
else
lastMnthYr=$currYear
fi
echo "This script will find entries for your query in whatever available MFT logs you request."
echo " "
echo "For instance - how many log files have transfer entries with \"DOG\" in them?"
echo " "
echo "I also will also give an estimate of how many transfers per log file contain your query, give or take a couple."
echo " "
echo "This search is case sensitive, so \"DOG\" is *** NOT *** the same as \"dog\""
echo " "
read -p "What text you are looking for? Punctuation is okay, but no spaces please. " looking ### what we want to find
echo " "
echo "Today's date is: $currDate."
echo " "
read -p "How many days back do you want to search(up to 25)? " daysBack ### How far back we are going to look
if [ "$daysBack" == 0 ] && [ "$daysBack" >> 25 ]; then
echo "I said up to 25 days. We ain't got more than that!"
exit 1
fi
echo " "
echo "I am going to search through the last $daysBack days of log files for:\"$looking\" "
echo " "
read -p "Does this look right? Press N to quit, or any other key to continue: " affirm
if [ "$affirm" = N ] && [ "$affirm" = n ]; then ###Yes, anything other than "N" or "n" is a go
echo "Quitter!"
exit 1
else
nada=0 ### Used to test for finding anything
backDate=$((currDay-daysBack)) ### current month iterator (assuming query covers only current month)
if (("$daysBack" => "$currDay")); then ## If there are more logs requested than days in the month...
lastMnthCnt=$((daysBack-currDay)) ### how many days to check last month
lastMnthStrt=$((lastMnthD-lastMnthCnt)) ## last month start and iterator
backDate=$(currDay-(daysBack-lastMnthCnt)) # Setting the iterator if we have to go back a month
while (("$lastMnthStrt" <= "$lastMnthD" )); do
foundIt=$(grep "$looking" /CyberFusion/log/Log.txt."$lastMnthYr$lastMnth$lastMnthStrt" | parsecflog | wc -l )
howMany=$((foundIt/40+1)) ### Add one in case there are less than 40 lines in the record.
if (("$foundIt" > 0))
then
nada=$((nada+1))
echo "Log.txt.$lastMnthYr$lastMnth$lastMnthStrt contains $looking in approximately $howMany transfer records."
lastMnthStrt=$((lastMnthStrt+1))
echo " "
else
lastMnthStrt=$((lastMnthStrt+1))
fi
fi
backDate=$((currDay-daysBack)) ### current month iterator (assuming query covers only current month)
while (("$backDate" <= "$currDay")); do
foundIt=$(grep "$looking" /CyberFusion/log/Log.txt."$backDate" | parsecflog | wc -l )
howMany=$((foundIt/40+1)) ### Add one in case there are less than 40 lines in the record.
if (("$foundIt" > 0))
then
nada=$((nada+1))
echo "Log.txt.$backDate contains $looking in approximately $howMany transfer records."
backDate=$((backDate+1))
echo " "
else
backDate=$((backDate+1))
fi
if [ "$nada" \< 1 ]
then
echo " "
echo "I found no entries for $looking in any log file."
fi
You are missing the keyword 'done' on lines 81 and 96 and also a final 'fi' keyword on the last line.
Also as others suggested you can do
date -d "20 days ago" +"%d%B%C%y"
to easily get dates in the past

Hardware Temperature report

I am trying to find a way to report the hardware temperatures back to me without a program that I have to download, I know of plenty that do that show but don't report back to a remote location on the network.
I found an applescript that I might be able to modify to get it to work but I am currently stuck at step 1 right now, getting the script to run.
Below is the script that I found. I keep getting an error at the marked line, lucky line 13.
The error just says can't get item 17.
set the_result to (do shell script "ioreg -c IOHWSensor | grep -vE '\\{|\\}|\\+\\-o'")'s paragraphs
set all_display to ""
repeat with i from 0 to 16
set jump to 3
set the_location to item (3 + (jump * i)) of the_result
set the_location to characters 41 thru ((count of characters of the_location) - 1) of the_location as string
set the_type to item (4 + (jump * i)) of the_result
set the_text to item (2 + (jump * i)) of the_result as string
**set the_text to characters 44 thru (count of characters of the_text) of the_text as string --(length of item 2 of the_result)**
set the_type to characters 37 thru ((count of characters of the_type) - 1) of the_type as string
if the_type = "temperature" then
set all_display to all_display & "
" & the_location & ": " & ((the_text / 65536) * (9 / 5)) + 32 & " F" as string
end if
end repeat
display dialog all_display
I was playing around with this again and finally able to get the complete error
Error: Can't make characters 44 thru 41 of " | | | | | \"version\" = 2" into type string.
I believe this information is reported by the IOHWSensor via ioreg. This one-liner works for me:
echo $((`ioreg -c IOHWSensor | grep "current-value" | grep -oE [0-9]+` / 65536))
Division by 65536 may be hardware-dependent. Some macs store the value as a multiple of 10, other powers of 2, etc. After dividing by the correct number, I believe the result is always in ÂșC.
Further reading:
http://www.cminow.org/ioreg_perl.html
Scrip searches for word "temperature" in the output of "ioreg -c IOHWSensor" command - but if you execute that from command line and grep for word "temperature" there will be none. At least I don't see it on my system.
Mine is OsX 10.7 what you have got there ?

Resources