reading in external file in clarion4 eval 
Author Message
 reading in external file in clarion4 eval

hi, i am fairly new to database programming, and clarion is my first one that i
am learning with, so bear w/ me, i've had programming experience, but not w/
databases!

i created a database that stores currency information w/ the wizard, and i need
to read in an external file that contains the currency info everyday, the
application has 5 fields, w/ the 4 columns in the input file, and 1 additional
field for date. so how do i read the file in?

if i need to write codes for it, where do i write them? and if i can add it
into the dictionary defintion, can someone please tell me the exact steps to
add it, i have tried to look into online help, the help included w/ the
clarion, language reference, but couldn't get anywhere!

i've included a little portion of the sample input file below, i would
appreciate so much if anyone can help me! thank you!!

-------------------  sample input  ---------------------------------

Rates as of 1997.12.09 12:00 EST (UTC-5). Base currency is USD.

Currency Unit                           USD/Unit            Units/USD
================================   ===================   ===================
DZD Algerian Dinars                       0.0170               58.8        
USD American Dollars                      1.0000                1.0000      
ARP Argentinian Pesos                     1.0002                0.99979    
AUD Australian Dollars                    0.6681                1.497      
ATS Austrian Schillings                   0.079308             12.609      
........goes on for about 30 different countries

--------------------------------------------------------------------

------------------------------------------------------
Please remove 'Nospamm' in my address before replying!
------------------------------------------------------



Sat, 18 Nov 2000 03:00:00 GMT  
 reading in external file in clarion4 eval

Hi David,

The proportional font has messed up your example file
but if the fields have a fixed length and position, I'd use
a DOS file for this:

LOC:UsdUnit    REAL
LOC:UnitUsd    REAL
LOC:CurDate   LONG
CurrFile    PRE(DOS),DRIVER(DOS),NAME('DosCurrencyFileName')
RECORD    RECORD
CurrUnit        STRING(30)
UsdUnit         STRING(12)
UnitUsd         STRING(12)
                  END
  CODE
  Open(CurrFile)
  Set(CurrFile)
  Loop
    Next(CurrFile)
    IF ErrorCode() Then Break .
    IF Left(DOS:CurrUnit,5) = 'Rates'

      Cycle
    End
    LOC:UsdUnit = DOS:UsdUnit           !Automatic Type conversion
    LOC:UnitUsd = DOS:UnitUsd
    IF NOT LOC:UsdUnit Then Cycle .   !Text converts to 0
    !* Do your own record processing here *
  End

HTH
Maarten



Sat, 18 Nov 2000 03:00:00 GMT  
 reading in external file in clarion4 eval

thanks for the help, but where do i put in the codes below? i went through the
entire application, and can't find a place that i can write codes in, it's all
menu driven options!

do i need to create a separate procedure for the below script, since i need to
read in a new text file everyday! if so, when i tried that, it asked for a type
of procedure! what should i select?

or, how do i use the below codes?

thanks for any help!

david



Quote:

>Hi David,

>The proportional font has messed up your example file
>but if the fields have a fixed length and position, I'd use
>a DOS file for this:

>LOC:UsdUnit    REAL
>LOC:UnitUsd    REAL
>LOC:CurDate   LONG
>CurrFile    PRE(DOS),DRIVER(DOS),NAME('DosCurrencyFileName')
>RECORD    RECORD
>CurrUnit        STRING(30)
>UsdUnit         STRING(12)
>UnitUsd         STRING(12)
>                  END
>  CODE
>  Open(CurrFile)
>  Set(CurrFile)
>  Loop
>    Next(CurrFile)
>    IF ErrorCode() Then Break .
>    IF Left(DOS:CurrUnit,5) = 'Rates'

>      Cycle
>    End
>    LOC:UsdUnit = DOS:UsdUnit           !Automatic Type conversion
>    LOC:UnitUsd = DOS:UnitUsd
>    IF NOT LOC:UsdUnit Then Cycle .   !Text converts to 0
>    !* Do your own record processing here *
>  End

>HTH
>Maarten

--
------------------------------------------------------
Please remove 'Nospamm' in my address before replying!
------------------------------------------------------


Sun, 19 Nov 2000 03:00:00 GMT  
 reading in external file in clarion4 eval

Hi David,

You've got me there :) I'm a handcoder so I'm not so familiar
with the AppGen. I guess you can enter the DOS-file defenition
in your Dictionary. Then add a menu-choice or button to the
manu of you Main_App and a procedure <ToDo> will be created.
Open this, name the procedure and choose the Process Template
and under the [Files] button, you put your DOS-file as the <ToDo>
and your own currency file under <Other>. The three local variables:
LOC:UsdUnit    REAL
LOC:UnitUsd    REAL
LOC:CurDate   LONG
you can declare with the [Data] button.
The goto the [Embeds] and at 'Validate record: Filter checking'
you enter the source:

IF Left(DOS:CurrUnit,5) = 'Rates'

   EXIT
End
LOC:UsdUnit = DOS:UsdUnit           !Automatic Type conversion
LOC:UnitUsd = DOS:UnitUsd
IF NOT LOC:UsdUnit Then EXIT .   !Text converts to 0

Note that I used 'EXIT' now instead of 'Cycle'.

The under 'Activity for each record' you enter source
where you do your record processing i.e. lookup the
currency and do new field asignments and add/put etc.

Hope that this will get you on the right track,
Regards,
Maarten



Sun, 19 Nov 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Reading External .txt files in Quartus II

2. reading text from external files

3. reading variables from an external file using expect

4. reading an external text file

5. fortran program reading an external text (and numbers) file and writing with edits

6. CAN NOT CREATE FILE: C:\CLARION4\BIN\C4LFNX.DLL

7. Clarion4 Help File

8. ASCII File > Clarion4

9. HELP.....ASCII file format > Clarion4

10. Registering OCX files on user workstation - Clarion4

11. file parsing in clarion4

12. Updating a TPS-file Clarion4 ABC

 

 
Powered by phpBB® Forum Software