SCRIPT HANGS UP ON "CREATE" COMMAND 
Author Message
 SCRIPT HANGS UP ON "CREATE" COMMAND

The following script burps on the "create" command. I've studied the
ObjectPal portion of my book and cannot figure this out. The Paradox book
and on-line help is really poor, but as I understand it the create command
will create a default Paradox table unless I state I want it in dBase
format, in which I'd place the "dbf" extension. That said and done, the
comiler keeps giving me a syntax error on the create command section of
the script. Any suggestions as to why this is happening???

Specifically, I have a Paradox for Windows table named "Green" with a
field called "State" containing postal abbreviations. I want to parse the
table into separate tables based on the postal abbreviations, so that I
end up with one table for each state, named accordingly.

Thanks,

Cheryl

-------------------------------

method run(var eventInfo Event)
 var
 key_state string
 inTC,outTC tcursor
 endvar

 if NOT inTC.open("GREEN.DB") then errorshow() endif
 if NOT inTC.switchIndex("state") then errorshow() endif

 key_state = blank()

 scan inTC :
   if inTC."state" = blank() ; skip any blank state codes
     then loop
   endif
   if upper(inTC."state") <> key_state
     then if key_state <> blank()
            then  outTC.close()
          endif
          key_state = upper(inTC."state")

*****PROBLEM SECTION********************

          create "STATE_" + inTC."state" + ".DB"
             struct inTC
             indexStruct inTC
             refIntStruct inTC
             secStruct inTC
          endcreate

*****END PROBLEM SECTION*****************

          if NOT outTC.open("STATE_" + inTC."state" + ".DB")
             then errorshow()
          endif
    endif
    if NOT outTC.copyrecord(inTC) then errorshow() endif
    if NOT outTC.postRecord() then errorshow() endif
  endscan

  if key_state <> blank()
    then outTC.close()
  endif
endmethod



Mon, 21 Dec 1998 03:00:00 GMT
 SCRIPT HANGS UP ON "CREATE" COMMAND

Quote:

>The following script burps on the "create" command. I've studied the
>ObjectPal portion of my book and cannot figure this out. The Paradox book
>and on-line help is really poor, but as I understand it the create command
>will create a default Paradox table unless I state I want it in dBase
>format, in which I'd place the "dbf" extension. That said and done, the
>comiler keeps giving me a syntax error on the create command section of
>the script. Any suggestions as to why this is happening???

You didn't state what version you are using, but the examples in the
ObjectPAL help for 7.0 are pretty explicit.  I'll make changes below.

Quote:
>method run(var eventInfo Event)
> var
> key_state string
> inTC,outTC tcursor

myTable table

Quote:
> endvar
> if NOT inTC.open("GREEN.DB") then errorshow() endif
> if NOT inTC.switchIndex("state") then errorshow() endif
> key_state = blank()
> scan inTC :
>   if inTC."state" = blank() ; skip any blank state codes
>     then loop
>   endif
>   if upper(inTC."state") <> key_state
>     then if key_state <> blank()
>            then  outTC.close()
>          endif
>          key_state = upper(inTC."state")
>*****PROBLEM SECTION********************

(remark the above line out with ; character)

Quote:
>          create "STATE_" + inTC."state" + ".DB"

Change:

     myTable = create "STATE_" + inTC."state" + ".DB"

Quote:
>             struct inTC
>             indexStruct inTC
>             refIntStruct inTC
>             secStruct inTC
>          endcreate
>*****END PROBLEM SECTION*****************

(remark above line out with ; character)

Quote:
>          if NOT outTC.open("STATE_" + inTC."state" + ".DB")
>             then errorshow()
>          endif
>    endif
>    if NOT outTC.copyrecord(inTC) then errorshow() endif
>    if NOT outTC.postRecord() then errorshow() endif
>  endscan
>  if key_state <> blank()
>    then outTC.close()
>  endif
>endmethod

Since a handle to your created table is now 'myTable', you can change
the outTC.open("STATE_ ...") to:

If not outTC.open(myTable)

You get bonus points for the "if not .. errorshow() endif" constructs!
:)

Andrew
--
  Andrew Bennett

  http://taz.hyperreal.com/~abennett/



Tue, 22 Dec 1998 03:00:00 GMT
 SCRIPT HANGS UP ON "CREATE" COMMAND


writes:

Quote:

>The following script burps on the "create" command. I've studied the
>ObjectPal portion of my book and cannot figure this out. The Paradox
book
>and on-line help is really poor, but as I understand it the create
command
>will create a default Paradox table unless I state I want it in dBase
>format, in which I'd place the "dbf" extension. That said and done,
the
>comiler keeps giving me a syntax error on the create command section
of
>the script. Any suggestions as to why this is happening???

>Specifically, I have a Paradox for Windows table named "Green" with a
>field called "State" containing postal abbreviations. I want to parse
the
>table into separate tables based on the postal abbreviations, so that
I
>end up with one table for each state, named accordingly.

>Thanks,

>Cheryl

>-------------------------------

>method run(var eventInfo Event)
> var
> key_state string
> inTC,outTC tcursor
> endvar

> if NOT inTC.open("GREEN.DB") then errorshow() endif
> if NOT inTC.switchIndex("state") then errorshow() endif

> key_state = blank()

> scan inTC :
>   if inTC."state" = blank() ; skip any blank state codes
>     then loop
>   endif
>   if upper(inTC."state") <> key_state
>     then if key_state <> blank()
>            then  outTC.close()
>          endif
>          key_state = upper(inTC."state")

>*****PROBLEM SECTION********************

>          create "STATE_" + inTC."state" + ".DB"
>             struct inTC
>             indexStruct inTC
>             refIntStruct inTC
>             secStruct inTC
>          endcreate

>*****END PROBLEM SECTION*****************

>          if NOT outTC.open("STATE_" + inTC."state" + ".DB")
>             then errorshow()
>          endif
>    endif
>    if NOT outTC.copyrecord(inTC) then errorshow() endif
>    if NOT outTC.postRecord() then errorshow() endif
>  endscan

>  if key_state <> blank()
>    then outTC.close()
>  endif
>endmethod

Have you tried using the table name Green rather than the tcursor,
inTC, to borrow structure from?


Tue, 22 Dec 1998 03:00:00 GMT
 SCRIPT HANGS UP ON "CREATE" COMMAND

Quote:

>The following script burps on the "create" command. I've studied the
>ObjectPal portion of my book and cannot figure this out. The Paradox book
>and on-line help is really poor, but as I understand it the create command
>will create a default Paradox table unless I state I want it in dBase
>format, in which I'd place the "dbf" extension. That said and done, the
>comiler keeps giving me a syntax error on the create command section of
>the script. Any suggestions as to why this is happening???
>Specifically, I have a Paradox for Windows table named "Green" with a
>field called "State" containing postal abbreviations. I want to parse the
>table into separate tables based on the postal abbreviations, so that I
>end up with one table for each state, named accordingly.
>Thanks,
>Cheryl
>-------------------------------

You have to assign the table you create to a variable.  See the
changes in the script below.  This is shown in the example for table
create in the help and is mentioned in a note at the bottom of the
create description in the help.
Quote:
>method run(var eventInfo Event)
> var
> key_state string
> inTC,outTC tcursor

tbltst  table           ;table variable assigned

Quote:
> endvar
> if NOT inTC.open("GREEN.DB") then errorshow() endif
> if NOT inTC.switchIndex("state") then errorshow() endif
> key_state = blank()
> scan inTC :
>   if inTC."state" = blank() ; skip any blank state codes
>     then loop
>   endif
>   if upper(inTC."state") <> key_state
>     then if key_state <> blank()
>            then  outTC.close()
>          endif
>          key_state = upper(inTC."state")
>;*****PROBLEM SECTION********************
>          tbltst=create "STATE_" + inTC."state" + ".DB"       ;table assigned to a variable
>             struct inTC
>             indexStruct inTC
>             refIntStruct inTC
>             secStruct inTC
>          endcreate
>*****END PROBLEM SECTION*****************
>          if NOT outTC.open("STATE_" + inTC."state" + ".DB")
>             then errorshow()
>          endif
>    endif
>    if NOT outTC.copyrecord(inTC) then errorshow() endif
>    if NOT outTC.postRecord() then errorshow() endif
>  endscan
>  if key_state <> blank()
>    then outTC.close()
>  endif
>endmethod

I have tried this and it compiles correctly.  

 Straehley Associates - Computer Consulting and Programming

 http://www.strassoc.com



Tue, 22 Dec 1998 03:00:00 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. Insert command to create "identity"?

2. problem with "create directory " command

3. Generate a "create" script (reverse engineer)

4. Seeking "create" scripts

5. Creating "Find" Scripts

6. help creating "previous layout" script

7. Seeking "create" scripts

8. max of ("...","...","..")

9. CREATE DATABASE creates "memory leak"

10. DTS Package appears "to be hung"

11. sp3 install hangs on "installing mdac"

12. SP causing machine to "hang"


 
Powered by phpBB® Forum Software