hexagon logo

Need a little help with basic

I'm new to basic and VB so i'm just trying stuff to see how it works. Well i don't quite understand everything. Here's the code from Pc-Dmis (v4.3):
V1         =FILE/EXISTS,FILENAME
            IF/V1<>0
FPTR       =FILE/OPEN,FILENAME,READ
V2         =FILE/READLINE,FPTR,{STR_DRWSTAT}
V3         =FILE/READLINE,FPTR,{STR_RPT}
            FILE/CLOSE,FPTR,KEEP
            END_IF/
            ASSIGN/STR_DRWSTAT=STR_DRWSTAT
            ASSIGN/STR_RPT=STR_RPT
            ASSIGN/STR_OPER=STR_OPER
CS1        =FORM/FILENAME= D:\MERITVE\PROGRAMI_4.3\CADONLY_LANDSCAPE.FORM, AUTOPRINT=NO
            PARAM/TXTDRWSTAT.TEXT=STR_DRWSTAT
            PARAM/TXTRPT.TEXT=STR_RPT
            PARAM/TXTOPER.TEXT=STR_OPER
            PARAM/=
            ENDFORM/
FPTR       =FILE/OPEN,FILENAME,WRITE
            FILE/WRITELINE,FPTR,STR_DRWSTAT
            FILE/WRITELINE,FPTR,STR_RPT
            FILE/WRITELINE,FPTR,STR_OPER
            FILE/CLOSE,FPTR,KEEP

As you can see i want to check if the file exists and then read some stuff from it. In case it doesn't exist i just let the program go forward. This works fine if the upper code in inserted manualy in Pc-Dmis. Then i saved this as BASIC script. Now when I recall it in another program usig Insert-Basic script... the IF block doesn't work since it returns an error when running the program and it wan'ts to read lines though the file doesn't exist. The code for IF as BASIC looks like this:
  Set DmisCommand = DmisCommands.Add(FILE_IO_OBJECT, TRUE)
    DmisCommand.Marked = TRUE
  ' Set Destination Expression  = V1
    retval = DmisCommand.PutText ("V1", DEST_EXPR, 0)
  ' Set Filename Item 1 = H1000011127AB - HALTER PORSCHE 9X1 (1000011127).TXT
    retval = DmisCommand.PutText ("H1000011127AB - HALTER PORSCHE 9X1 (1000011127).TXT", FILE_NAME, 1)
  ' Set File Command  = EXISTS
    retval = DmisCommand.SetToggleString (15, FILE_COMMAND_TYPE, 0)
  Result = DmisCommand.SetExpression("FILENAME", FILE_NAME, 1)
  
  Set DmisCommand = DmisCommands.Add(IF_BLOCK_COMMAND, TRUE)
    DmisCommand.Marked = TRUE
  ' Set Source Expression  = 1
    retval = DmisCommand.PutText ("1", SRC_EXPR, 0)
  Result = DmisCommand.SetExpression("V1<>0", SRC_EXPR, 0)

Now what and how would i need to change the BASIC code for it to work properly?? Please help.
Parents
  • Thanks vpt.se but as far as i can tell i get the same result. If txt file allready exists then everything works fine. Hovewer if the txt file isn't there yet i get an error about not being able to open file.... and unable to read.... and so on. The program still runs though. It's just those annoying messages for the first run. I was hoping to get rid of them. Any other suggestions?
Reply
  • Thanks vpt.se but as far as i can tell i get the same result. If txt file allready exists then everything works fine. Hovewer if the txt file isn't there yet i get an error about not being able to open file.... and unable to read.... and so on. The program still runs though. It's just those annoying messages for the first run. I was hoping to get rid of them. Any other suggestions?
Children
No Data