Fichier

Commande de compilation

Dans le menu Project - References de Visual Basic, il faut importer les déclarations des modules Up ! Kernel et Up ! System en cochant les cases correspondantes.

Commande d'enregistrement des ActiveX

upsvtm Com=Charger

Commande d'exécution

fichier.exe

Fichier source

Const NonOuvert As Integer = 1
Const LectureTexte As Integer = 2
Const EcritureTexte As Integer = 3
Const EcritureTexteALaSuite As Integer = 4
Const LectureEcritureTexte As Integer = 5
Const LectureBinaire As Integer = 6
Const EcritureBinaire As Integer = 7
Const EcritureBinaireALaSuite As Integer= 8
Const LectureEcritureBinaire As Integer= 9
Const MemoireVolatile = 1
Const MemoirePersistant = 2
Const SynchroneSysteme = 3
Const AsynchroneSysteme = 4
Const Asynchrone1024 = 5
Const Asynchrone4096 = 6
Const Asynchrone16384 = 7
Const Asynchrone65536 = 8

Dim MUpsKrn As IUpsKrn
Dim MUpsSys As IUpsSys

Private Sub EcrireEcran(ByVal Libelle As String)
' ==============================================
Dim I As Integer
Dim J As Integer

I = 1
J = 1
Do
Loop
Ecran.AddItem Mid$(Libelle, I, J - I + 1)
End Sub

Private Sub Form_Load()
' =====================
Dim F As IUpsSysFichier
Dim FBis As IUpsSysFichier
Dim C As IUpsKrnCaractere
Dim E As Long
Dim R As Double
Dim B As Boolean
Dim P As Integer

On Error GoTo GestionErreur

Set MUpsKrn = CreateObject("UpsApp.UpsKrn")
Set MUpsSys = CreateObject("UpsApp.UpsSys")

Set F = MUpsSys.Fichier2(MUpsKrn.ComBStr2Caractere("c:/tmp/essai.txt"), EcritureTexte, Asynchrone1024)
F.Ecrire3 MUpsKrn.ComBStr2Caractere("Bonjour" + Chr$(10) + "Au revoir" + Chr$(10) + "Et a bientot" + Chr$(10))
F.Ecrire4 MUpsKrn.ComInt2Entier(1)
F.Ecrire3 MUpsKrn.ComBStr2Caractere(Chr$(10))
F.Ecrire5 MUpsKrn.ComDouble2Reel(2.3)
F.Ecrire3 MUpsKrn.ComBStr2Caractere(Chr$(10))
F.Ecrire MUpsKrn.ComVariantBool2Booleen(True)
F.Ecrire3 MUpsKrn.ComBStr2Caractere(Chr$(10))
F.Vider
F.DeposerSurDisque
F.Fermer
Set F = MUpsSys.Fichier2(MUpsKrn.ComBStr2Caractere("c:/tmp/essai.txt"), LectureTexte, Asynchrone1024)
E = MUpsKrn.Entier2ComInt(F.LireUnMot(C, MUpsKrn.ComInt2Entier(20)))
EcrireEcran MUpsKrn.Caractere2ComBStr(C)
E = MUpsKrn.Entier2ComInt(F.Lire3(C, MUpsKrn.ComInt2Entier(4)))
EcrireEcran MUpsKrn.Caractere2ComBStr(C)
EcrireEcran E
E = MUpsKrn.Entier2ComInt(F.LireUneLigne(C))
EcrireEcran MUpsKrn.Caractere2ComBStr(C)
EcrireEcran E
P = MUpsKrn.Entier2ComInt(F.LirePosition())
E = MUpsKrn.Entier2ComInt(F.LireUneLigne(C))
EcrireEcran MUpsKrn.Caractere2ComBStr(C)
EcrireEcran E
F.Lire4 E
EcrireEcran Str$(E)
F.Lire5 R
EcrireEcran Str$(R)
F.Lire B
If B Then Else End If
E = MUpsKrn.Entier2ComInt(F.Lire3(C, MUpsKrn.ComInt2Entier(4))) If F.FinDeFlux Then End If
F.FixerPosition P
E = MUpsKrn.Entier2ComInt(F.LireUneLigne(C))
EcrireEcran MUpsKrn.Caractere2ComBStr(C)
EcrireEcran E
If F.FinDeFlux Then End If
F.Fermer
Set FBis = Nothing
If MUpsKrn.Booleen2ComVariantBool(F.Egal(FBis)) Then End If
If MUpsKrn.Booleen2ComVariantBool(F.Different(FBis)) Then End If

Set F = Nothing
Set FBis = Nothing
Set C = Nothing
Set MUpsSys = Nothing
Set MUpsKrn = Nothing
Exit Sub

GestionErreur:
'=============
EcrireEcran Erreur UpsKrn-0 : L'exception suivante a été envoyée dans le source '" + Err.Source + "' :"
EcrireEcran Err.Description
End Sub