Hello,
I'm facing problems while trying to convert a Unix File to Dos, in order to have it displayed under Notepad (Wordpad can edit Unix files without any previous conversion).
Basically, I found a command line utility that works fine sometimes and fails others ("todos.exe") under Window XP Professional Edition, in Dos mode.
How can I code a command line utility with Emergence Basic (or a Windows utility, provided the conversion doesn't show up while executing), not to mention a dll ?
Thanks in advance for your help.
Regards,
Pierre
From the help file:
QuoteSYSTEM(command as STRING, OPT param as STRING)
Description
Runs another executable.
Parameters
command - Executable to run.
param - Parameter for executable.
Return value
None
Remarks
Command must be full pathname to executable or the executable needs to be in the system path.
Example usage
SYSTEM "notepad.exe" , "c:\\mydocs\\prog.txt"
I'd try this first; if I understand your question correctly.
LarryMc
Line endings on Unix/Linux are denoted by chr$(10) only, where Windows/DOS uses a combination of chr$(13) + chr$(10)
Much easier said than done...
Your choices are to set up a loop to insert the chr$(13) characters in front of the chr$(10) for each line of your file (or edit control) --or likely easier-- loop through and replace all of the existing chr$(10) characters with the chr$(13) + chr$(10) combination.
-Doc-
Edit:
Forgot to add for the sake of total confusion:
Line endings on Mac are chr$(13) only
Thanks Doc !
Now that I know what to do, I think I can try to cook something.
Regards.
Pierre
You're welcome!
Untested, but maybe you can use some of it:
'------------- change line endings ----------------
SUB UnixToDosLines
def pos:INT
def buffer2[32766]:ISTRING
pos = INSTR(buffer,CHR$(10))
while(pos)
if(mid$(buffer,pos,1) = CHR$(10))
buffer2 = left$(buffer,pos-1)
buffer2 = buffer2 + mid$(buffer,pos+1)
buffer = buffer2
endif
pos = INSTR(pos+1,buffer,chr$(13) + chr$(10))
endwhile
return
Most of the code above came from a sub in the old "editor" sample file, so I cannot take credit for it... just made a couple of modifications in this case.