Chit chat

======

Combined entries from a cooking  and cartoon blog, so I have less to manage.

Looked at qb2c and bacon for converting basic language programs to C.  Found lots of issues and decided to keep using freebasic and qb64,

The poppler utilities are nice, but I still need to learn how to convert pdf to html to be good forblog entries.

There is a pcbasic emulator for linux:

Screenshot from 2014-12-18 20:05:30

—————————————-

Screenshot from 2014-12-18 14:15:13

Turn your computer into an old fashion clock.

gcc knrclock.c -lm -ncurses -o knrclock

invoke with:

$ ./knrclock

/*
* aclock – ascii clock for UNIX Console
*
* Copyright (c) 2002 Antoni Sawicki <tenox@tenox.tc>
* Version 1.8 (unix-curses); Dublin, June 2002
*
* Compilation: cc aclock-unix-knr.c -o aclock -lcurses -lm
*
* this is K&R version modified for old unices (but still with curses)
*
*/

#include <unistd.h>
#include <curses.h>
#include <math.h>
#include <time.h>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

drw_cir(hand_max, sycen, sxcen, fonthw)
int hand_max; int sycen; int sxcen; int fonthw;
{
int x,y,r;
char c;

for(r=0;r<60;r++){
x=cos(r*M_PI/180*6)*hand_max*fonthw+sxcen;
y=sin(r*M_PI/180*6)*hand_max+sycen;
switch (r) {
case 0:
case 5:
case 10:
case 15:
case 20:
case 25:
case 30:
case 35:
case 40:
case 45:
case 50:
case 55:
c=’o’;
break;
default:
c=’.’;
break;
}
mvaddch(y,x,c);
}
}

draw_hand(minute, hlenght, c, sxcen, sycen, fonthw)
int minute; int hlenght; char c; int sxcen; int sycen; int fonthw;
{
int x,y,n;
float r=(minute-15)*(M_PI/180)*6;

for(n=1; n<hlenght; n++){
x=cos(r)*n*fonthw+sxcen;
y=sin(r)*n+sycen;
mvaddch(y,x,c);
}
}

main(){
char digital_time[15];
int fonthw = 2;
int sXmax, sYmax, smax, hand_max, sxcen, sycen;
long t;
struct tm *ltime;

initscr();

for(;;){
time(&t);
ltime=localtime(&t);
sXmax = COLS;
sYmax = LINES;

if(sXmax/2<=sYmax)
smax=sXmax/2;
else
smax=sYmax;

hand_max = (smax/2)-1;

sxcen = sXmax/2;
sycen = sYmax/2;

erase();
drw_cir(hand_max, sycen, sxcen, fonthw);

draw_hand((ltime->tm_hour*5)+(ltime->tm_min/10), 2*hand_max/3, ‘h’, sxcen, sycen, fonthw);
draw_hand(ltime->tm_min, hand_max-2, ‘m’, sxcen, sycen, fonthw);
draw_hand(ltime->tm_sec, hand_max-1, ‘.’, sxcen, sycen, fonthw);

mvaddstr(sYmax/4, sxcen-5, “.:ACLOCK:.”);
mvprintw(4*sYmax/5, sxcen-5, “[%02d:%02d:%02d]”, ltime->tm_hour, ltime->tm_min, ltime->tm_sec);

refresh();
sleep(1);
}
endwin();
}

—————————————-

Want to see what some of the earliest versions of linux were like? Go to: http://www.ibiblio.org/pub/historic-linux/distributions/

Early Debian came on three floppies!?! First you used the boot disk.

Start of a Debian install.

 One thing to remember is that back then linux supported scsi hard drives for the most part and not ide (pata) drives.

—————————————-
When I was young, we were fortunate that one of the classes we had to attend was learning to speed read. To have access to that software today can be very expensive. Here, we can sort of emulate that old software with a simple shell file program.

Screenshot from 2014-12-18 14:34:13

You can also build a teleprompter so you can create your own sort newsreader setup. Then you can have your own news show so the video can be uploaded to say Youtube or the like.

The code is very short and works extremely wel with short paragraphs. To invoke the software you will need the name of the file to be read and the delay to be used to determine the speed of the text to be displayed. You might want to start with .5 and then you can adjust as needed.

$ ./asciitextrdr.sh  asciifile2bread .5

#!/bin/sh

# A program to slowly cat file or standard input.

if [ “$1″ ] ; then
file=”$1″
else
file=”-”
fi
cat “$file” | while read c ; do
echo  “$c”
sleep  $2
done

[/code]

—————————————-

Screenshot from 2014-12-18 19:18:08

Manual CPM (use at your own risk) calculator at: http://groups.engin.umd.umich.edu/CIS/tinytools/cis375/f00/cpm/CPM%281%29.HTM

Screenshot from 2014-12-18 14:46:37

[From wikipedia]

The critical path method (CPM) is an algorithm for scheduling a set of project activities.

History

The critical path method (CPM) is a project modeling technique developed in the late 1950s by Morgan R. Walker of DuPont and James E. Kelley, Jr. of Remington Rand.[2] Kelley and Walker related their memories of the development of CPM in 1989.[3] Kelley attributed the term “critical path” to the developers of the Program Evaluation and Review Technique which was developed at about the same time by Booz Allen Hamilton and the U.S. Navy.[4] The precursors of what came to be known as Critical Path were developed and put into practice by DuPont between 1940 and 1943 and contributed to the success of the Manhattan Project.[5]

CPM is commonly used with all forms of projects, including construction, aerospace and defense, software development, research projects, product development, engineering, and plant maintenance, among others. Any project with interdependent activities can apply this method of mathematical analysis. Although the original CPM program and approach is no longer used, the term is generally applied to any approach used to analyze a project network logic diagram.

Basic technique

The essential technique for using CPM [6][7] is to construct a model of the project that includes the following:

  1. A list of all activities required to complete the project (typically categorized within a work breakdown structure),
  2. The time (duration) that each activity will take to complete,
  3. The dependencies between the activities and,
  4. Logical end points such as milestones or deliverable items.

Using these values, CPM calculates the longest path of planned activities to logical end points or to the end of the project, and the earliest and latest that each activity can start and finish without making the project longer. This process determines which activities are “critical” (i.e., on the longest path) and which have “total float” (i.e., can be delayed without making the project longer). In project management, a critical path is the sequence of project network activities which add up to the longest overall duration. This determines the shortest time possible to complete the project. Any delay of an activity on the critical path directly impacts the planned project completion date (i.e. there is no float on the critical path). A project can have several, parallel, near critical paths. An additional parallel path through the network with the total durations shorter than the critical path is called a sub-critical or non-critical path.

CPM analysis tools allow a user to select a logical end point in a project and quickly identify its longest series of dependent activities (its longest path). These tools can display the critical path (and near critical path activities if desired) as a cascading waterfall that flows from the project’s start (or current status date) to the selected logical end point.

Although the activity-on-arrow diagram (“PERT Chart”) is still used in a few places, it has generally been superseded by the activity-on-node diagram, where each activity is shown as a box or node and the arrows represent the logical relationships going from predecessor to successor as shown here in the “Activity-on-node diagram”.

Activity-on-node diagram showing critical path schedule, along with total float and critical path drag computations

In this diagram, Activities A, B, C, D, and E comprise the critical or longest path, while Activities F, G, and H are off the critical path with floats of 15 days, 5 days, and 20 days respectively. Whereas activities that are off the critical path have float and are therefore not delaying completion of the project, those on the critical path will usually have critical path drag, i.e., they delay project completion. The drag of a critical path activity can be computed using the following formula:

  1. If a critical path activity has nothing in parallel, its drag is equal to its duration. Thus A and E have drags of 10 days and 20 days respectively.
  2. If a critical path activity has another activity in parallel, its drag is equal to whichever is less: its duration or the total float of the parallel activity with the least total float. Thus since B and C are both parallel to F (float of 15) and H (float of 20), B has a duration of 20 and drag of 15 (equal to F’s float), while C has a duration of only 5 days and thus drag of only 5. Activity D, with a duration of 10 days, is parallel to G (float of 5) and H (float of 20) and therefore its drag is equal to 5, the float of G.

These results, including the drag computations, allow managers to prioritize activities for the effective management of project completion, and to shorten the planned critical path of a project by pruning critical path activities, by “fast tracking” (i.e., performing more activities in parallel), and/or by “crashing the critical path” (i.e., shortening the durations of critical path activities by adding resources).

Crash duration

“Crash duration” is a term referring to the shortest possible time for which an activity can be scheduled.[8] It is achieved by shifting more resources towards the completion of that activity, resulting in decreased time spent and often a reduced quality of work, as the premium is set on speed.[9] Crash duration is typically modeled as a linear relationship between cost and activity duration, however in many cases a convex function or a step function is more applicable.[10]

Expansion

Originally, the critical path method considered only logical dependencies between terminal elements. Since then, it has been expanded to allow for the inclusion of resources related to each activity, through processes called activity-based resource assignments and resource leveling. A resource-leveled schedule may include delays due to resource bottlenecks (i.e., unavailability of a resource at the required time), and may cause a previously shorter path to become the longest or most “resource critical” path. A related concept is called the critical chain, which attempts to protect activity and project durations from unforeseen delays due to resource constraints.

Since project schedules change on a regular basis, CPM allows continuous monitoring of the schedule, which allows the project manager to track the critical activities, and alerts the project manager to the possibility that non-critical activities may be delayed beyond their total float, thus creating a new critical path and delaying project completion. In addition, the method can easily incorporate the concepts of stochastic predictions, using the program evaluation and review technique (PERT) and event chain methodology.

Currently, there are several software solutions available in industry that use the CPM method of scheduling, see list of project management software. The method currently used by most project management software is based on a manual calculation approach developed by Fondahl of Stanford University.

Flexibility

A schedule generated using critical path techniques often is not realised precisely, as estimations are used to calculate times: if one mistake is made, the results of the analysis may change. This could cause an upset in the implementation of a project if the estimates are blindly believed, and if changes are not addressed promptly. However, the structure of critical path analysis is such that the variance from the original schedule caused by any change can be measured, and its impact either ameliorated or adjusted for. Indeed, an important element of project postmortem analysis is the As Built Critical Path (ABCP), which analyzes the specific causes and impacts of changes between the planned schedule and eventual schedule as actually implemented.

Start:
OPTION BASE 1
Array.size = 12
DIM E(Array.size), J$(Array.size), L(Array.size), P(Array.size, 12), S(Array.size, 2)
CLS
GOSUB Init
IF E$ = "Okay" THEN
GOSUB Early.starts
LET C = S(n, 1) + L(n)
GOSUB Late.starts
GOSUB Print.chart
GOSUB Print.table
END IF
END
The.end:

Init:
LET Interval = 5
LET E$ = "Okay"
READ n
DATA 7
FOR J = 1 TO n
READ L(J)
NEXT J
DATA 1,12,6,7,8,2,0
FOR J = 1 TO n
READ J$(J), P$
DO WHILE P$ <> "No more"
GOSUB Check.name
IF E$ = "Okay" THEN
LET P(J, K) = 1
READ P$
ELSE
RETURN
END IF
LOOP
NEXT J
IF J$(n) <> "End" THEN
PRINT "No end job"
LET E$ = "Not okay"
END IF
DATA "Begin","No more"
DATA "Shop","Begin","No more"
DATA "Prep","Shop","No more"
DATA "Salad","Shop","No more"
DATA "Cook","Prep","No more"
DATA "Serve","Cook","Salad","No more"
DATA "End","Serve","No more"
RETURN

Check.name:
LET E$ = "Okay"
FOR K = 1 TO J - 1
IF P$ = J$(K) THEN EXIT FOR
NEXT K
IF J = K THEN
PRINT P$; " does not precede "; J$(K); "."
LET E$ = "Not okay"
END IF
RETURN

Early.starts:
FOR J = 1 TO n
LET GE = 0
FOR K = 1 TO n
IF P(J, K) = 1 AND GE < E(K) THEN
LET GE = E(K)
END IF
NEXT K
LET S(J, 1) = GE
LET E(J) = GE + L(J)
NEXT J
RETURN

Late.starts:
FOR K = n TO 1 STEP -1
LET L = C
FOR J = 1 TO n
IF P(J, K) <> 0 AND L > S(J, 2) THEN
LET L = S(J, 2)
END IF
NEXT J
LET S(K, 2) = L - L(K)
NEXT K
RETURN

Print.chart:
PRINT TAB(35); "Time (in minutes)"
PRINT
PRINT "Job"; TAB(11); " 50 100 150 200"
PRINT " "; TAB(11); "----+----+----+----+----+----+----+----+"
FOR J = 2 TO n - 1
PRINT J$(J); TAB(11); "|";
LET K = S(J, 1)
IF S(J, 1) - S(J, 2) <> 0 THEN
DO WHILE K <= S(J, 1) + L(J) - 1
PRINT TAB(11 + K); "X";
LET K = K + 1
LOOP
DO WHILE K <= S(J, 2) + L(J) - 1
PRINT TAB(11 + K); ".";
LET K = K + 1
LOOP
ELSE
DO WHILE K <= S(J, 1) + L(J) - 1
PRINT TAB(11 + K); "C";
K = K + 1
LOOP
END IF
PRINT
NEXT J
PRINT
PRINT
RETURN

Print.table:
PRINT "Time of completion = "; C * Interval
PRINT
PRINT " Starts"
PRINT "Job Length Early Late Slack"
PRINT
FOR J = 2 TO n - 1
PRINT J$(J); TAB(10); L(J); TAB(25); S(J, 1);
PRINT TAB(32); S(J, 2); TAB(40); S(J, 2) - S(J, 1)
NEXT J
RETURN

—————————————-

Yet another way to convert binary to ascii.

Datafile af:
01000001 01010010 01010000 01000001 01001110 01000101 01010100

$ ./b2a1.sh af
ARPANET

<pre> #!/bin/bash

chrbin() {
        echo $(printf \\$(echo "ibase=2; obase=8; $1" | bc))
}

ordbin() {
  a=$(printf '%d' "'$1")
  echo "obase=2; $a" | bc
}

ascii2bin() {
    echo -n $* | while IFS= read -r -n1 char
    do
        ordbin $char | tr -d '\n'
        echo -n " "
    done
}

bin2ascii() {
    for bin in $*
    do
        chrbin $bin | tr -d '\n'
    done
}
while read z
do
bin2ascii $z
done < $1
echo

—————————————-

Yet another C program conversion to linux.

original code:

#include<stdio.h>
void main()
{
        int n,d=0,j,a[9];
        clrscr();
        printf("Enter the Integer which u want to Convert Decimal to Binary : ");
        scanf("%d",&n);
        while(n>0)
               {
                    a[d]=n%2;
                    n=n/2;
                    d++;
               }  
                    printf("After Converting Decimal to Binary is : ");
                    for(j=d-1;j>=0;j--)
                         printf("%d",a[j]);
                         getch();
}
Output ; Enter the Integer which u want to Convert Decimal to Binary : 8 After Converting Decimal to Binary is : 1000

Code for linux:


#include<stdio.h>
#include <unistd.h>
#include <termios.h>

char getch(){
char buf=0;
struct termios old={0};
fflush(stdout);
if(tcgetattr(0, &old)<0)
perror("tcsetattr()");
old.c_lflag&=~ICANON;
old.c_lflag&=~ECHO;
old.c_cc[VMIN]=1;
old.c_cc[VTIME]=0;
if(tcsetattr(0, TCSANOW, &old)<0)
perror("tcsetattr ICANON");
if(read(0,&buf,1)<0)
perror("read()");
old.c_lflag|=ICANON;
old.c_lflag|=ECHO;
if(tcsetattr(0, TCSADRAIN, &old)<0)
perror ("tcsetattr ~ICANON");
printf("%c\n",buf);
return buf;
}

void main()
{
int n,d=0,j,a[9];
// clrscr();
system("clear");
printf("Enter the Integer which u want to Convert Decimal to Binary : ");
scanf("%d",&n);
while(n>0)
{
a[d]=n%2;
n=n/2;
d++;
}
printf("After Converting Decimal to Binary is : ");
for(j=d-1;j>=0;j--)
printf("%d",a[j]);
getch();
}

—————————————-

The figure shows a schematic of the IR receiver circuit. The heart of the circuit is MOD1, an infrared detector module that removes the IR carrier frequency and transmits only the data that are encoded in the received IR signal. A suitable IR module is available at Radio Shack (No. 276-137 which is no longer sold). Might try Model: 276-640, but check the specs for sure. You probably could pull one from an old vcr.  The IR module needs a clean 5-V power supply, which is provided by IC1, a 7805 regulator. Power is supplied to the regulator by 9-V battery B1. The output of the module is wired to a male DB-25 multipin connector. The infrared detector module receives a signal, filters it, and removes the 40-kHz carrier. The output of the module is a TTL-level signal consisting of long and short pulses. The PC records those voltage levels over time, while the signal is being sent, and stores the data in a file. The line normally used by the PC’s printer port to indicate that the printer is out of paper (pin 12) is used in this project to accept data from the IR module. The I/O port is located at the address ox379. Bit 5 corresponds to input pin 12. Various software programs are required to let a PC store information input to its printer port.  The program stores the value it reads from the PC’s printer port into an array. When the input line is logic high, the ASCII character 1 is stored in the array. When the input line is logic low, ASCII character 0 is stored.

'**************************************************************************</p>
'* Program title  : Arco.bas

'* Date written   : original c code in 1994

'* Last Update    : August 1995

'* Language       : Basic

'* Written by     : eddie from Barry Hamilton's c code (C) 1994

'*                  in the Electonics Now - August 1995 issue

'* Written for    : Barry Hamilton and Electronics Now

'* Program intent : Monitor's out of paper input

'* I/O and files  : Pin 12 of the parallel printer port

'*                  irlog.raw

'*                  irlog.gph

'*                  irlog.fnl

'*-------------------------------------------------------------------------

'--------------------------------------------------------------------------

DEFINT A-Z

Zero = 0

One = 1

Two = 2

Fpin = One

Fpout = Two

Inchar = Zero

Lastchar = Zero

Totalcnt = Zero

Limit = 30000

DIM Store(Limit)

CONST The.Title = "Printer port pin 12 project"

ON ERROR GOTO Error.line

DO

CLS

PRINT

PRINT The.Title + "."

PRINT

PRINT "   A - Get data"

PRINT "   C - Convert data"

PRINT "   R - Report data"

PRINT "   Q - Quit"

PRINT

PRINT "choice: ";

z$ = " "

DO WHILE INSTR("ACRQ", z$) < 1

z$ = ""

DO WHILE z$ = ""

z$ = UCASE$(INPUT$(1))

LOOP

LOOP

PRINT z$

SELECT CASE z$

CASE "A"

GOSUB Dget

CASE "C"

GOSUB Dconvert

CASE "R"

GOSUB Dreport

CASE "Q"

EXIT DO

CASE ELSE

REM

END SELECT

LOOP

PRINT

PRINT "The end!"

END

'--------------------------------------------------------------------------

Dget:

Timedelay = Zero

Sloop = One

Skey = Zero

Cntr1 = Zero

Cntr2 = Zero

Cindata = Zero

Fpout$ = ""

Escape.key = 27

CLS

PRINT

PRINT The.Title + ": I/R Get."

PRINT

INPUT "Enter time delay  : ", Timedelay

IF Timedelay < Zero THEN

Timedelay = 20

END IF

INPUT "      outfile name: ", Fpout$

IF LCASE$(Fpout$) = "" THEN

Fpout$ = "irlog.raw"

END IF

PRINT

PRINT "Opening "; LCASE$(Fpout$); " for output."

OPEN Fpout$ FOR OUTPUT AS #Fpout

PRINT "Gathering data with a time delay of "; LTRIM$(RTRIM$(STR$(Timedelay))); "."

DO WHILE Sloop = One

PRINT TAB(5); "Start: "; TIME$

FOR Cntr1 = Zero TO Limit - One

Cindata = INP(&H379)

IF (Cindata AND 32) <> Zero THEN

Store(Cntr1) = ASC("1")

ELSE

Store(Cntr1) = ASC("0")

END IF

FOR Cntr2 = One TO Timedelay

NEXT Cntr2

NEXT Cntr1

PRINT TAB(5); "Ending: "; TIME$

PRINT "Writing data to "; LCASE$(Fpout$); "."

PRINT #Fpout, "[";

FOR Cntr1 = Zero TO Limit - One

PRINT #Fpout, CHR$(Store(Cntr1));

NEXT Cntr1

PRINT #Fpout, "]";

PRINT "Press escape to quit and any other key to continue";

PRINT ":"

BEEP

Skey = ASC(INPUT$(One))

IF Skey = Escape.key THEN

EXIT DO

END IF

LOOP

PRINT "Closing "; LCASE$(Fpout$); "."

CLOSE #Fpout

RETURN

'--------------------------------------------------------------------------

Dconvert:

Fpin$ = ""

Fpout$ = ""

Nlimit = 80

S2$ = ""

One$ = STRING$(9, "1")

Zero$ = STRING$(9, "0")

S11$ = ""

S10$ = ""

FOR Cntr = One TO Eight

S11$ = S11$ + One$ + "+"

S10$ = S10$ + Zero$ + "+"

NEXT Cntr

CLS

PRINT

PRINT The.Title + ": I/R Graph."

PRINT

INPUT "Enter name of infile : ", Fpin$

IF Fpin$ = "" THEN

Fpin$ = "irlog.raw"

END IF

INPUT "              outfile: ", Fpout$

IF Fpout$ = "" THEN

Fpout$ = "irlog.gph"

END IF

PRINT

PRINT "Opening file: "; Fpin$; " for input."

OPEN Fpin$ FOR INPUT AS #Fpin

PRINT "Opening file: "; Fpout$; "for output."

OPEN Fpout$ FOR OUTPUT AS #Fpout

PRINT

Zline = CSRLIN

DO WHILE NOT EOF(Fpin)

Inchar = ASC(INPUT$(1, #Fpin))

LOCATE Zline, One

PRINT "Examining: "; CHR$(Inchar);

IF Inchar = ASC("0") AND Lastchar = ASC("0") THEN

Totalcnt = Totalcnt + One

END IF

IF Inchar = ASC("1") AND Lastchar = ASC("1") THEN

Totalcnt = Totalcnt + One

END IF

IF Lastchar = ASC("[") THEN

Totalcnt = One

END IF

IF Lastchar = ASC("]") THEN

Totalcnt = Zero

END IF

IF Inchar = ASC("0") AND Lastchar = ASC("1") THEN

IF Totalcnt < Nlimit THEN

S2$ = ""

S2$ = LEFT$(S2$ + S11$, Totalcnt)

PRINT #Fpout, S2$

ELSE

PRINT #Fpout, "        | ";

PRINT #Fpout, USING "####"; Totalcnt;

PRINT #Fpout, "1"

END IF

Totalcnt = One

END IF

IF Inchar = ASC("1") AND Lastchar = ASC("0") THEN

IF Totalcnt < Nlimit THEN

S2$ = ""

S2$ = LEFT$(S2$ + S10$, Totalcnt)

PRINT #Fpout, S2$

ELSE

PRINT #Fpout, "        | ";

PRINT #Fpout, USING "####"; Totalcnt;

PRINT #Fpout, "0"

END IF

Totalcnt = One

END IF

IF Inchar = ASC("]") AND Lastchar = ASC("0") THEN

IF Totalcnt < Nlimit THEN

S2$ = ""

S2$ = LEFT$(S2$ + S10$, Totalcnt)

PRINT #Fpout, S2$

ELSE

PRINT #Fpout, "        | ";

PRINT #Fpout, USING "####"; Totalcnt;

PRINT #Fpout, "0"

END IF

Totalcnt = Zero

END IF

IF Inchar = ASC("]") AND Lastchar = ASC("1") THEN

IF Totalcnt < Nlimit THEN

S2$ = ""

S2$ = LEFT$(S2$ + S11$, Totalcnt)

PRINT #Fpout, S2$

ELSE

PRINT #Fpout, "        | ";

PRINT #Fpout, USING "####"; Totalcnt;

PRINT #Fpout, "1"

END IF

Totalcnt = Zero

END IF

Lastchar = Inchar

LOOP

PRINT

PRINT "Closing "; LCASE$(Fpout$); "."

CLOSE #Fpout

PRINT "Closing "; LCASE$(Fpin$); "."

CLOSE #Fpin

RETURN

'--------------------------------------------------------------------------

Dreport:

Cmark = One

Cspace = Zero

Maxzero = Zero

Maxone = Zero

Syncstate = Zero

Fpin$ = ""

Fpout$ = ""

CLS

PRINT

PRINT The.Title + ": I/R Final."

PRINT

PRINT "(M)ark or (S)pace Sync: ";

z$ = " "

DO WHILE INSTR("MS", z$) < 1

z$ = ""

DO WHILE z$ = ""

z$ = UCASE$(INPUT$(1))

LOOP

LOOP

PRINT z$

SELECT CASE z$

CASE "M"

Syncstate = Mark

CASE "S"

Synstate = Space

END SELECT

INPUT "Enter the maxzero factor : ", Maxzero

INPUT "      the maxone  factor : ", Maxone

INPUT "      the file for input : ", Fpin$

IF Fpin$ = "" THEN

Fpin$ = "irlog.raw"

END IF

INPUT "      the file for output: ", Fpout$

IF Fpout$ = "" THEN

Fpout$ = "irlog.fnl"

END IF

PRINT

OPEN Fpin$ FOR INPUT AS #Fpin

PRINT "Opening file: "; Fpin$; " for input."

OPEN Fpout$ FOR OUTPUT AS #Fpout

PRINT "Opening file: "; Fpout$; " for output."

PRINT

Zline = CSRLIN

DO WHILE NOT EOF(Fpin)

Inchar = ASC(INPUT$(One, #Fpin))

LOCATE Zline, One

PRINT "Examining: "; CHR$(Inchar);

IF Inchar = ASC("0") AND Lastchar = ASC("0") THEN

Totalcnt = Totalcnt + One

END IF

IF Inchar = ASC("1") AND Lastchar = ASC("1") THEN

Totalcnt = Totalcnt + One

END IF

IF Lastchar = ASC("[") THEN

Totalcnt = One

END IF

IF Lastchar = ASC("]") THEN

Totalcnt = Zero

END IF

IF Inchar = ASC("0") AND Lastchar = ASC("1") THEN

IF Syncstate = Space THEN

IF Totalcnt <= Maxzero THEN

PRINT #Fpout, "0";

END IF

IF Totalcnt > Maxzero AND Totalcnt < Maxone THEN

PRINT #Fpout, "1";

END IF

IF Totalcnt >= Maxone THEN

PRINT #Fpout, "        | ";

PRINT #Fpout, USING "####"; Totalcnt;

PRINT #Fpout, "1="

END IF

END IF

Totalcnt = One

END IF

IF Inchar = ASC("1") AND Lastchar = ASC("0") THEN

IF Syncstate = Mark THEN

IF Totalcnt <= Maxzero THEN

PRINT #Fpout, "0";

END IF

IF Totalcnt > Maxzero AND Totalcnt < Maxone THEN

PRINT #Fpout, "1";

END IF

IF Totalcnt >= Maxone THEN

PRINT #Fpout, "        | ";

PRINT #Fpout, USING "####"; Totalcnt;

PRINT #Fpout, "0="

END IF

END IF

Totalcnt = One

END IF

IF Inchar = ASC("]") AND Lastchar = ASC("0") THEN

PRINT #Fpout, "        | ";

PRINT #Fpout, USING "####"; Totalcnt;

PRINT #Fpout, "0]"

Totalcnt = Zero

END IF

IF Inchar = ASC("]") AND Lastchar = ASC("1") THEN

PRINT #Fpout, "        | ";

PRINT #Fpout, USING "####"; Totalcnt;

PRINT #Fpout, "1]"

Totalcnt = Zero

END IF

Lastchar = Inchar

LOOP

PRINT

PRINT "Closing "; LCASE$(Fpout$); "."

CLOSE #Fpout

PRINT "Closing "; LCASE$(Fpin$); "."

CLOSE #Fpin

RETURN

'--------------------------------------------------------------------------

Error.line:

END

'*******************************************************

—————————————-

From oatmeal flakes

SUNP0142

To fake flour.

SUNP0100

Good day.

Advertisements