Last updated: before December, 1998
Sub Create90 '-----Jerry Sikes 01.21.98 '-----This script creates a tab delimited text file '-----It's purpose is create a dot notation string '-----with day of year dot machine id dot shift '-----This will be used with a machine scheduling application '-----where I need to know if a shift is available for a '-----specific machine at some future date. '-----This script is for testing purposes only and does not '-----represent it's final structue. Dim filenum As Integer Dim filename As String Dim rec As DayRecord '-----I previously declare my own data type '-----in Globals...Declarations '-----Type DayRecord ' Machine_Shift_Block As String * 10 ' Shift_Status As String * 3 ' End Type Dim Numeric_Date As Single, Day_of_Year As Single Dim rs As New ResultSet Set rs =CurrentDocument.Tables(1).CreateResultSet() '-----This immediately brings in an already open, join table '-----This is all records from that table. Very fast '-----To determine the table number, I look in the Approach '-----file properties. The table are listed in order 0...n counter1% = 0 Record_Number%=0 filenum% = Freefile() filename$ = "c:\windows\temp\mach_rec.txt" Open filename$ For Output As filenum% 'Open filename$ For Random As filenum% Len = Len(rec) '-----Random stores the info in a binary format. This may be my final output type '-----This way I can call a record by its record number with the Get statement '-----(I have not figure out all the details yet) For counter1% = 0 To 90 Numeric_Date!=Csng(Date)+counter1% Do For shift_number% = 1 To 3 Record_Number%=Record_Number%+1 Day_of_Year! = Csng(Cdat(Numeric_Date)-Datenumber(Year(Date$)-1,12,31)) '-----This mimics the Approach DayOfYear function rec.Machine_Shift_Block = Trim(Str(Day_of_Year!))+"."+ rs.GetValue("id")+"." _ +Trim(Str(shift_number%)) Select Case Weekday(Numeric_Date!) Case Is = 7'-----Saturday rec.Shift_Status = "Off" Case Is = 1'-----Sunday rec.Shift_Status = "Off" Case Else rec.Shift_Status = "On" End Select '-----For those not familiar with VB..case is much better than Nested If...Then...Else Select Case Day_of_Year! Case Is = 100 '-----Good Friday rec.Shift_Status = "Off" Case Is = 145 '-----Memorial Day rec.Shift_Status = "Off" Case 180 To 184'-----Vacation Shutdown rec.Shift_Status = "Off" Case Is = 250'-----Labor Day rec.Shift_Status = "Off" Case 330 To 331'-----Thanksgiving rec.Shift_Status = "Off" Case 355 To 359'-----Vaction Shutdown rec.Shift_Status = "Off" 'No Case Else. Would reset Saturday and Sunday to On End Select Print #fileNum%,Str(Record_Number%)+Chr(9)+rec.Machine_Shift_Block+Chr(9)+rec.Shift_Status 'Put # filenum%,Record_Number%,rec '-----Print # works with Output while Put is for Random Next shift_number% Loop While rs.nextrow rs.firstrow Next counter1% Close filenum% rs.close '-----Always put things away End Sub