Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT SPACES AT START OF LINE

Status
Not open for further replies.

IncredibleVolk

Technical User
Apr 2, 2004
67
US
I don't have a good understanding of file manipulation using aspect and I was hoping someone could help. I'm determining the length of each line in a text file. If the length is longer than 12 characters, I want to insert several spaces at the start of the line. I basically want to push the data on that line to the right. For some reason I don't seem to be returning to the beginning of each line. It's cutting characters off the line(s) with 12 or fewer characters and those are the lines I want to stay put.


string sLine,Join
string sSpaces = " "

if fopen 0 "C:\CAPTURE.TXT" READWRITE
while not feof 0
fgets 0 sLine
strlen sLine iLen
lLen = iLen
if lLen < 12
iFlag = 1
else
if iFlag == 1
strfmt sJoin "%s%s" sSpaces sLine
fseek 0 (-lLen) 0
fputs 0 sJoin
ftell 0 lLen
endif
endif
Counter ++
endwhile
fclose 0
endif
endproc
 
We use a terminal mainframe that stores an internal date. The internal date is the number of days since December 31st, 1967. I've tried reaching that number (i.e. 14,708) but I can't seem to get it work.

This will give me an out of range error. Is there a float version of "intsltime"? I couldn't find one.

proc main
integer Month, Day
integer Year, Hour
integer Min, Sec
long NewTime
long Diff

Month = 12, Day = 31
Year = 1967, Hour=12
Min = 0, Sec = 0

intsltime Year Month Day Hour Min Sec NewTime
Diff = ($LTIME-NewTime)/ 86400

usermsg "%d days" Diff
endproc

This gives me the wrong number


proc main

string FirstStr ; String to contain first date.
string SecondStr ; String to contain second date.
integer iYear,iMonth,iDay,iHour,iMin,iSec

long LTime1, LTime2 ; Longs to contain long dates.
long Diff ; Long to contain difference.

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt FirstStr "%02d%02d%d" iMonth iDay iYear
strdelete FirstStr 7 2


SecondStr = "12/31/67" ; Set ending date.

;Convert first and second dates to long values and
;calculate number of days between them.

strsltime FirstStr $TIME24 LTime1
strsltime SecondStr $TIME24 LTime2
Diff = ( LTime1 - LTime2 ) / 86400
usermsg "%d days" Diff
endproc


 
I decided to cut my losses. I don't know Aspect well enough to
be doing file manipulations.
 
We use a terminal mainframe that stores an internal date. The internal date is the number of days since December 31st, 1967. I've tried reaching that number (i.e. 14,708) but I can't seem to get it work.

This will give me an out of range error. Is there a float version of "intsltime"? I couldn't find one.

proc main
integer Month, Day
integer Year, Hour
integer Min, Sec
long NewTime
long Diff

Month = 12, Day = 31
Year = 1967, Hour=12
Min = 0, Sec = 0

intsltime Year Month Day Hour Min Sec NewTime
Diff = ($LTIME-NewTime)/ 86400

usermsg "%d days" Diff
endproc

This gives me the wrong number


proc main

string FirstStr ; String to contain first date.
string SecondStr ; String to contain second date.
integer iYear,iMonth,iDay,iHour,iMin,iSec

long LTime1, LTime2 ; Longs to contain long dates.
long Diff ; Long to contain difference.

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt FirstStr "%02d%02d%d" iMonth iDay iYear
strdelete FirstStr 7 2


SecondStr = "12/31/67" ; Set ending date.

;Convert first and second dates to long values and
;calculate number of days between them.

strsltime FirstStr $TIME24 LTime1
strsltime SecondStr $TIME24 LTime2
Diff = ( LTime1 - LTime2 ) / 86400
usermsg "%d days" Diff
endproc


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top