Title: Visual Basic to MultiValue Basic Translation

Issue: Spectrum Jan/Feb '99

author:Nathan Rector

company:Natec Systems

email:nater@northcoast.com

http:www.northcoast.com/~nater/

Even though I have worked with Visual Basic and Visual Basic for Applications for over 2 years, I still have a hard time remembering what commands do what and how Visual Basic compares to MultiValue BASIC.

Because of the syntax differences, many MultiValue programmers find Visual Basic hard to work with. If you are coming from a MultiValue background, Visual Basic is a lot easier to write in than C++. But there are still a few differences in the commands.

To help those who are struggling with Visual Basic or are just starting out with it, I have provided a translation table. The table is designed for comparison between MultiValue BASIC and Visual Basic syntax. It does not explain what the MultiValue BASIC commands do.

MultiValue BASIC

Visual Basic

IF {statement} THEN

{code}

END ELSE

{code}

END

If {statement} Then

{code}

Else

{code}

End If

BEGIN CASE

CASE {statement}

{code}

CASE {statement}

{code}

CASE 1

{code}

END CASE

If {statement} Then

{code}

ElseIf {statement} Then

{code}

Else

{code}

End If

LOOP

UNTIL {statement} DO

{code}

REPEAT

Do Until {statement}

{code}

Loop

LOOP

WHILE {statement} DO

{code}

REPEAT

Do While {statement}

{code}

Loop

LOOP

{code}

UNTIL {statement} DO

REPEAT

Do

{code}

Loop Until {statement}

LOOP

{code}

WHILE {statement} DO

REPEAT

 

Do

{code}

Loop While {statement}

LOOP

{code}

UNTIL {statement} DO

{code}

REPEAT

Do

{code}

If {statement} Then Exit Do

{code}

Loop While True

FOR I = {start} TO {finish} STEP {count}

{code}

NEXT I

For I = {start} To {finish} STEP {count}

{code}

Next I

FOR I = {start} TO {finish} UNTIL {statement}

{code}

NEXT I

For I = {start} To {finish}

If {statement} then Exit For

{code}

Next I

VALUE = INT(5/2)

Value = Fix(5/2)

VALUE = ABS(5/2)

Value = Abs(5/2)

VALUE = SEQ("A")

Value = Asc("A")

VALUE = CHAR(50)

Value = Chr(50)

RQM

DoEvents

VALUE = EXP(256)

Value = Exp(256)

POS = INDEX("ABCD","A",1)

Pos = InStr("ABCD","A")

POS = INDEX("ABCD","A",3)

‘ You will need a program to find more than the

‘ first occurance of a string.

IF NUM(VALUE) THEN

CRT "Number"

END

If IsNumaric(Value) Then

Print "Number"

End If

VALUE = OCONV("LOWER","MCL")

Value = LCase("LOWER")

VALUE = OCONV("upper","MCU")

Value = UCase("upper")

LENGTH = LEN(VALUE)

Length = Len(Value)

VALUE = STRING[3,2]

Value = Mid(String,3,2)

VALUE = TRIM(" Trim Space ")

Value = Trim(" Trim Space ")

VALUE = RND(10)

Randomize

Value = Rnd(10)

VALUE = SPACE(10)

Value = Space(10)

VALUE = STR("*",10)

Value = String("*",10)

CRT CHAR(7)

Beep

 

The following commands are supplied by your database vendor: e.g. D3 Objects, WinLink 32, UniObjects. Since each vendor supports a lot of MultiValue BASIC commands in Visual Basic, only a few examples are shown.

MultiValue BASIC

Visual Basic – WinLink32

OPEN {filename} TO {filevar} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set FileVar = con.RemoteFiles.OpenFile(FileName)

If FileVar.Status > 0 Then

{code}

End If

READ {var} FROM {file}, {record} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set Item = FileVar.Read("Record")

If Item.Status > 0 Then

{code}

End If

VALUE = ITEM<1,1>

Value = Item.Extract(1,1)

ITEM = INSERT(ITEM,1;"Hello")

Call Item.Insert(1,ReplaceString:="Hello")

ITEM<1> = VALUE

Call Item.Replace(1,InsertString := Value)

ITEM = DELETE(ITEM,1)

Call Item.Delete(1)

WRITE {var} FROM {file}, {record}

On Error Resume Next

Call FileVar.Update Item

CALL TEST.PROG(VALUE)

On Error Resume Next

Set Prog = Link.DefineProcedure("TEST.PROG")

Prog.ExecuteProcedure Value

Value = Prog.Text

 

 

 

MultiValue BASIC

Visual Basic – D3 Objects

OPEN {filename} TO {filevar} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set FileVar = oConn.brOpenFile(FileName)

If Err Then

{code}

End If

READ {var} FROM {file}, {record} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set Item = FileVar.brRead("Record")

If Err Then

{code}

End If

VALUE = ITEM<1,1>

Value = Item.brExtractStr(1,1)

ITEM = INSERT(ITEM,1;"Hello")

Call Item.brInsertStr("Hello",1)

ITEM<1> = VALUE

Call Item.brReplaceStr(Value,1)

ITEM = DELETE(ITEM,1)

Call Item.brDelete(1)

WRITE {var} FROM {file}, {record}

On Error Resume Next

Call FileVar.brWrite(Item, RecordName)

CALL TEST.PROG(VALUE)

On Error Resume Next

Set Prog = oConn.brOpenRule ("TEST.PROG")

Prog.brCall Value

 

 

 

MultiValue BASIC

Visual Basic – UV/Objects

OPEN {filename} TO {filevar} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set FileVar = session.OpenFile(FileName)

If FileVar.Error <> 0 Then

{code}

End If

READ {var} FROM {file}, {record} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

FileVar.RecrodID = "Record"

FileVar.Read

If Item.Error <> 0 Then

{code}

End If

Set Item = FileVar.Record

VALUE = ITEM<1,1>

Value = Item.Value(1,1)

ITEM = INSERT(ITEM,1;"Hello")

Item.Field(1).Ins "Hello"

ITEM<1> = VALUE

Item.Field(1) = Value

ITEM = DELETE(ITEM,1)

Item.Field(1).Del

WRITE {var} FROM {file}, {record}

On Error Resume Next

Set FileVar.Record = Item

FileVar.RecordID = "Record"

Call FileVar.Write

CALL TEST.PROG(VALUE)

On Error Resume Next

Set Prog = session.Subroutine("TEST.PROG",1)

Prog.SetArg 0, Value

Prog.Call

Prog.GetArg 0, Value

 

 

 

Title: Visual Basic to MultiValue Basic Translation

Title: Visual Basic to MultiValue Basic Translation

Issue: Spectrum Jan/Feb '99

author:Nathan Rector

company:Natec Systems

email:nater@northcoast.com

http:www.northcoast.com/~nater/

Even though I have worked with Visual Basic and Visual Basic for Applications for over 2 years, I still have a hard time remembering what commands do what and how Visual Basic compares to MultiValue BASIC.

Because of the syntax differences, many MultiValue programmers find Visual Basic hard to work with. If you are coming from a MultiValue background, Visual Basic is a lot easier to write in than C++. But there are still a few differences in the commands.

To help those who are struggling with Visual Basic or are just starting out with it, I have provided a translation table. The table is designed for comparison between MultiValue BASIC and Visual Basic syntax. It does not explain what the MultiValue BASIC commands do.

MultiValue BASIC

Visual Basic

IF {statement} THEN

{code}

END ELSE

{code}

END

If {statement} Then

{code}

Else

{code}

End If

BEGIN CASE

CASE {statement}

{code}

CASE {statement}

{code}

CASE 1

{code}

END CASE

If {statement} Then

{code}

ElseIf {statement} Then

{code}

Else

{code}

End If

LOOP

UNTIL {statement} DO

{code}

REPEAT

Do Until {statement}

{code}

Loop

LOOP

WHILE {statement} DO

{code}

REPEAT

Do While {statement}

{code}

Loop

LOOP

{code}

UNTIL {statement} DO

REPEAT

Do

{code}

Loop Until {statement}

LOOP

{code}

WHILE {statement} DO

REPEAT

 

Do

{code}

Loop While {statement}

LOOP

{code}

UNTIL {statement} DO

{code}

REPEAT

Do

{code}

If {statement} Then Exit Do

{code}

Loop While True

FOR I = {start} TO {finish} STEP {count}

{code}

NEXT I

For I = {start} To {finish} STEP {count}

{code}

Next I

FOR I = {start} TO {finish} UNTIL {statement}

{code}

NEXT I

For I = {start} To {finish}

If {statement} then Exit For

{code}

Next I

VALUE = INT(5/2)

Value = Fix(5/2)

VALUE = ABS(5/2)

Value = Abs(5/2)

VALUE = SEQ("A")

Value = Asc("A")

VALUE = CHAR(50)

Value = Chr(50)

RQM

DoEvents

VALUE = EXP(256)

Value = Exp(256)

POS = INDEX("ABCD","A",1)

Pos = InStr("ABCD","A")

POS = INDEX("ABCD","A",3)

‘ You will need a program to find more than the

‘ first occurance of a string.

IF NUM(VALUE) THEN

CRT "Number"

END

If IsNumaric(Value) Then

Print "Number"

End If

VALUE = OCONV("LOWER","MCL")

Value = LCase("LOWER")

VALUE = OCONV("upper","MCU")

Value = UCase("upper")

LENGTH = LEN(VALUE)

Length = Len(Value)

VALUE = STRING[3,2]

Value = Mid(String,3,2)

VALUE = TRIM(" Trim Space ")

Value = Trim(" Trim Space ")

VALUE = RND(10)

Randomize

Value = Rnd(10)

VALUE = SPACE(10)

Value = Space(10)

VALUE = STR("*",10)

Value = String("*",10)

CRT CHAR(7)

Beep

 

The following commands are supplied by your database vendor: e.g. D3 Objects, WinLink 32, UniObjects. Since each vendor supports a lot of MultiValue BASIC commands in Visual Basic, only a few examples are shown.

MultiValue BASIC

Visual Basic – WinLink32

OPEN {filename} TO {filevar} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set FileVar = con.RemoteFiles.OpenFile(FileName)

If FileVar.Status > 0 Then

{code}

End If

READ {var} FROM {file}, {record} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set Item = FileVar.Read("Record")

If Item.Status > 0 Then

{code}

End If

VALUE = ITEM<1,1>

Value = Item.Extract(1,1)

ITEM = INSERT(ITEM,1;"Hello")

Call Item.Insert(1,ReplaceString:="Hello")

ITEM<1> = VALUE

Call Item.Replace(1,InsertString := Value)

ITEM = DELETE(ITEM,1)

Call Item.Delete(1)

WRITE {var} FROM {file}, {record}

On Error Resume Next

Call FileVar.Update Item

CALL TEST.PROG(VALUE)

On Error Resume Next

Set Prog = Link.DefineProcedure("TEST.PROG")

Prog.ExecuteProcedure Value

Value = Prog.Text

 

 

 

MultiValue BASIC

Visual Basic – D3 Objects

OPEN {filename} TO {filevar} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set FileVar = oConn.brOpenFile(FileName)

If Err Then

{code}

End If

READ {var} FROM {file}, {record} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set Item = FileVar.brRead("Record")

If Err Then

{code}

End If

VALUE = ITEM<1,1>

Value = Item.brExtractStr(1,1)

ITEM = INSERT(ITEM,1;"Hello")

Call Item.brInsertStr("Hello",1)

ITEM<1> = VALUE

Call Item.brReplaceStr(Value,1)

ITEM = DELETE(ITEM,1)

Call Item.brDelete(1)

WRITE {var} FROM {file}, {record}

On Error Resume Next

Call FileVar.brWrite(Item, RecordName)

CALL TEST.PROG(VALUE)

On Error Resume Next

Set Prog = oConn.brOpenRule ("TEST.PROG")

Prog.brCall Value

 

 

 

MultiValue BASIC

Visual Basic – UV/Objects

OPEN {filename} TO {filevar} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

Set FileVar = session.OpenFile(FileName)

If FileVar.Error <> 0 Then

{code}

End If

READ {var} FROM {file}, {record} THEN

{code}

END ELSE

{code}

END

On Error Resume Next

FileVar.RecrodID = "Record"

FileVar.Read

If Item.Error <> 0 Then

{code}

End If

Set Item = FileVar.Record

VALUE = ITEM<1,1>

Value = Item.Value(1,1)

ITEM = INSERT(ITEM,1;"Hello")

Item.Field(1).Ins "Hello"

ITEM<1> = VALUE

Item.Field(1) = Value

ITEM = DELETE(ITEM,1)

Item.Field(1).Del

WRITE {var} FROM {file}, {record}

On Error Resume Next

Set FileVar.Record = Item

FileVar.RecordID = "Record"

Call FileVar.Write

CALL TEST.PROG(VALUE)

On Error Resume Next

Set Prog = session.Subroutine("TEST.PROG",1)

Prog.SetArg 0, Value

Prog.Call

Prog.GetArg 0, Value