banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

GEODATA DAYS 2024

#1 Fri 05 February 2010 06:28

Yulahop
Participant occasionnel
Lieu: Nouméa Nouvelle-Calédonie
Date d'inscription: 22 Jun 2006
Messages: 18

mab basic : close table = unrecognized command

Bonjour,

j'ai écrit un bout de code qui est sensé me créer une table de points.
Chaque point créé correspond au premier nœud de chaque polyligne d'une table de courbe de niveau, avec copie de la valeur d'altitude entre autre. Pour ce faire je passe par la table temporaire "selection".

A la compilation j'ai une erreur sur la commande close table selection qui me dit
(creation point.mb:45) Unrecognized command : ).

Comprend pas ...

Merci pour vos remarques.

MI 8.5, MB 6.5

le code en question :

Code:

include "C:\Program Files\MapInfo\MapBasic\MAPBASIC.DEF"

declare sub main

sub main

set coordsys Earth Projection 8, 9999, 4, 97.295, -263.237, 310.866, 1.599931, -0.838952, -3.14118, 13.325864, 0, "m", 165, 0, 0.9996, 500000, 10000000 Bounds (-7746230.6469, 1712.61611073) (8746230.6469, 19998287.3839) 

dim nom_de_table as string
dim nom_table_chemin as string
dim nom_de_table_to_record as string
dim coordX as float
dim coordY as float
dim Z_value as float
dim compteur as integer
dim n as integer

'ouverture des différentes tables   
nom_de_table = FileOpenDlg ("C:\Etude","","tab", "Ouvrir la table des courbes à traiter")
open table nom_de_table as CDN
nom_de_table_to_record = tableinfo(CDN, TAB_INFO_NAME)
nom_de_table_to_record = nom_de_table_to_record & "_PT_UNIQUE.tab"

nom_table_chemin = pathtodirectory$(nom_de_table) & nom_de_table_to_record
Create Table POINTS_UNIQUES (ID_PT integer, X float, Y float, Z float) file nom_table_chemin TYPE NATIVE Charset "WindowsLatin1"

'création d'une carte avec CDN et table POINTS_UNIQUES qui va recevoir les points extraits
Create Map For POINTS_UNIQUES CoordSys Earth Projection 8, 9999, 4, 97.295, -263.237, 310.866, 1.599931, -0.838952, -3.14118, 13.325864, 0, "m", 165, 0, 0.9996, 500000, 10000000 Bounds (-7746230.6469, 1712.61611073) (8746230.6469, 19998287.3839)
Map from POINTS_UNIQUES, CDN

Set Map Layer 1 Editable On

compteur = tableinfo(CDN, TAB_INFO_NROWS)

for n = 1 to compteur

select * from CDN where rowid = n
coordX = objectNodeX(selection.obj, 1, 1)
coordY = objectNodeY(selection.obj, 1, 1)
Z_value = selection.col2    
  
'create point into window frontwindow() (coordX, coordY)
update POINTS_UNIQUES set obj = createpoint(coordX, coordY)
update POINTS_UNIQUES Set ID_PT = n, Z_value = Z, X = coordX, Y = coordY)
close table selection

next

commit table POINTS_UNIQUES

end sub

Yaël

Hors ligne

 

#2 Fri 05 February 2010 16:46

olivier Dumas
Participant occasionnel
Date d'inscription: 11 Sep 2007
Messages: 26

Re: mab basic : close table = unrecognized command

Le plus simple pour éviter ce type de problème est de toujours nommer le résultat d'une sélection :

Select * from machin Into Truc

Ensuite tu peux faire

Close Table Truc

Toute sélection est renommée en Query<n> par mapinfo, n étant incrémenté dans la session, et sature parfois la mémoire (faut déjà y'aller).
Tu peux aussi utiliser mais c'est radical :

'*************************************************************************************************************
Sub DetruitLesQuery

dim Tabtab(10),cmd as string,
     indmax,i as smallint

indmax=NumTables()
Redim TabTab(indmax)

For i=1 to indmax

   TabTab(i)=TableInfo(i,TAB_INFO_NAME)
   
Next

For i=1 to indmax

  if len(TabTab(i)) >= 5
   then
   if left$(TabTab(i),5)="Query"
    then
'     set map redraw off
     cmd = "close Table " + TabTab(i)
'     print cmd
     Run Command cmd
   end if
  end if

Next

End sub
'*************************************************************************************************************

Hors ligne

 

#3 Wed 10 February 2010 01:34

Yulahop
Participant occasionnel
Lieu: Nouméa Nouvelle-Calédonie
Date d'inscription: 22 Jun 2006
Messages: 18

Re: mab basic : close table = unrecognized command

Bonjour Olivier !

merci pour les conseils.
Je suis un peu novice en programmation MB et le soucis que j'avais avec mon code provenait de la parenthèse finale au bout de la ligne 44.
Donc, moralité, relire attentivement le code avant d'appeler à l'aide, surtout pour ce genre d'erreur...


Yaël

Hors ligne

 

Pied de page des forums

Powered by FluxBB