Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculating times
Message
From
10/09/2002 10:12:42
Patrick O'Neil
American Specialty Information Services
Roanoke, Indiana, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00697029
Message ID:
00698768
Views:
16
>in that case how can i insert the data to dbf like your sample
>machine to machine


simple...
something like this. can't guarantee this is error-free ... i didn't
test it or anything.

assume 'signal' is formed like this "Start 1 M2A|M4D|M6A...."
assume all entries in 'signal' are correctly formed so SUBSTR
calls work ok.

probably wouldn't hard-code magic numbers, except this is example ;)

in production code, each time i extracted a "machine-state" from
the 'signal' string, i'd verify that it was a valid machine
name and valid state.

and for sake of simplicity, here, assume you already created
table TEMP with the two fields, machine c(3) and dt_time datetime(8)
LOCAL Track_Table_Spec
LOCAL Temp_Table_Spec
LOCAL Current_Datetime
LOCAL Current_Signal
LOCAL Current_Machine_State

Track_Table_Spec = 'c:\xxx\track'    && or whatever
Temp_Table_Spec  = 'c:\xxx\temp'

SELECT 0
USE (Track_Table_Spec) ALIAS track

SELECT 0
USE (Temp_Table_Spec) ALIAS temp


SELECT track
SCAN
  Current_Datetime = TRACK.datetime
  Current_Signal   = ALLTRIM(UPPER(TRACK.signal))

  Current_Signal = SUBSTR(Current_Signal,9)    && chop off "Start 1 "

  DO WHILE ( LEN(Current_Signal) > 0 )
    *-----------------------------------get one machine state entry----
    Current_Machine_State = SUBSTR(Current_Signal,1,3)

    *----------------------add it to TEMP table with datetime stamp-----
    SELECT temp
    APPEND BLANK
    REPLACE temp.machine WITH Current_Machine_State
    REPLACE temp.dt_time WITH Current_Datetime

    *-----------------------------------chop off just-processed machine---
    Current_Signal = SUBSTR(Current_Signal,4)

  ENDDO ;
                                       
  SELECT track
ENDSCAN


SELECT track
USE
SELECT temp
USE
patrick
Previous
Reply
Map
View

Click here to load this message in the networking platform