topic
stringlengths
1
63
text
stringlengths
1
577k
lost memory with images in xBrowse
Hey Marcelo -good to see you around. Have you tried assigning NIL to the object and then calling garbage collection? [code=fw:3kex1rzl]<div class="fw" id="{CB}" style="font-family: monospace;"><br />oBrwG := <span style="color: #00C800;">Nil</span><br />hb_GCAll<span style="color: #000000;">&#40;</span> .t. <span style="color: #000000;">&#41;</span><br /> </div>[/code:3kex1rzl] I surely don't like the idea of xbrowse with images consuming all available memory.... Reinaldo.
lost memory with images in xBrowse
Dear Reinaldo, thanks very much for response, my problem with xBrowse is when I navigate between rows, if I change from an image to other (row to row) in the xBrowse, the memory go up until the system go full. I can add some extra info, this occur when the graphic format is other than bmp, stored in a ADT table Thanks for your help Regards Marcelo
lost memory with images in xBrowse
Hello, from here [url:3pxk81y5]https&#58;//www&#46;box&#46;com/s/3851fr0ehpjlt1h4qbw3[/url:3pxk81y5] you can download a self-contained sample (sorry is a little big). To see what I want to show, open the windows TASK PANEL go to the memory monitoring, open the test.exe, go to the last image in the xbrowse go back, go forward many times, you will see in the task panel memory consumption. The difference between the last image with the other is the format JPG and BMP and size the JPG is big. I hope there are solutions to this problem Regards Marcelo
lost memory with images in xBrowse
Hi. I confirmed the problem. I wrote my own tests using a dbf/fpt/cdx table. It does the same. Using Marcelo's example you can simply keep pressing arrow down on the last image. It goes nowhere, as it has nowhere to go, but it keeps consuming more and more memory until it finally freezes. This points to a problem with xbrowse when showing images on a cell. Is my assumption wrong? Reinaldo.
lost memory with images in xBrowse
[quote="reinaldocrespo":q300ce5m]Hi. I confirmed the problem. I wrote my own tests using a dbf/fpt/cdx table. It does the same. Using Marcelo's example you can simply keep pressing arrow down on the last image. It goes nowhere, as it has nowhere to go, but it keeps consuming more and more memory until it finally freezes. This points to a problem with xbrowse when showing images on a cell. Is my assumption wrong? Reinaldo.[/quote:q300ce5m] For every cell, it it is an image ( as in the above case ), the bitmap handle is created, painted and then destroyed immediately. So this should not effect memory. Anyway we shall do more experiments with this to find if there is some obscure problem inside the code.
lost memory with images in xBrowse
Mr. Rao; It is always possible that the problem is not with xbrowse itself but rather the destroy mechanism being used to destroy the image. Did you try Marcelo's example? It is a short-self-contained sample. The table only contains 4 images. Open the task manager and monitor the amount of memory being consumed by the application. While you do that, keep pressing down arrow. The cursor will stay at the 4th and last line as it has nowhere else to go, but keep pressing the downarrow to force xbrowse to redraw the image time after time. Can you confirm that the amount of memory used increments until the app finally crashes? Reinaldo.
lost memory with images in xBrowse
Hi. Can anyone else, please, confirm this problem? You may use the self-contained-reduced sample posted by Marcelo on this thread. If you prefer an even simpler sample using dbf/cdx, I will gladly write one. Thank you, Reinaldo.
lost memory with images in xBrowse
I confirmed the problem Maurizio
lost memory with images in xBrowse
Hola Marcelo podrias colocar el código como grabas en un campo IMAGEN lo pregunto porque yo grabo tambien en campo image pero cuando lo veo en el data arquitec no se me ven las imagenes, solo aparecen codigo extraño [b:2odjsxx4]ÿØÿà[/b:2odjsxx4] pero en mi programa si funcionan las imagenes utilizo imagen jpg de 640x480 saludos
lost memory with images in xBrowse
Hola Patricio, I use imagenes -> ( ADSFile2Blob( cFile, "imagen", 7 ) ) where ADS_BINARY 6 /* BLOB - any data */ ADS_IMAGE 7 but we can use this other simple method imagenes -> imagen := MEMOREAD( cFile ) By the way, some body know how can we save an image using pure SQL Patricio, disculpa que escriba en mi pobre inglés es por respeto al foro, y en el ARC debes poder ver la imagen saludos Marcelo
lost memory with images in xBrowse
Marcelo /Patricio; Grato ver la pregunta. Saving an image, or anything else for that matter, is best done via pure SQL. To save images, I prefer to use a binary field instead of a memo field. Here is some actual code (a bit reduced): [code=fw:2pny4j45]<div class="fw" id="{CB}" style="font-family: monospace;"><br />   cSql := <span style="color: #ff0000;">"INSERT INTO images ( jpg ) VALUES ( :bindata ) <span style="color: #000000;">\n</span>"</span><br />   ADSCreateSQLStatement<span style="color: #000000;">&#40;</span>  <span style="color: #ff0000;">"cAlias"</span> <span style="color: #000000;">&#41;</span><br />   AdsPrepareSql<span style="color: #000000;">&#40;</span> cSql <span style="color: #000000;">&#41;</span><br />   binImage := MemoRead<span style="color: #000000;">&#40;</span> cFile <span style="color: #000000;">&#41;</span><br />   AdsSetBinary<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"bindata"</span>, binImage <span style="color: #000000;">&#41;</span><br />   AdsExecuteSql<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /> </div>[/code:2pny4j45] As you see, you must first prepare the query. Prepared SQLs execute faster, especially if your are executing the same sql inside a loop, as only the parameters change. You set parameters using ACE functions: AdsSetBinary(), AdsSetString(), AdsSetLong(), AdsSetDouble(), AdsSetDate(), AdsSetLogical(). These functions are not in included (as of now) with AdsFunc.c on harbour. They should soon be included as I recently sent them to be included as a contribution to harbour. In the meanwhile, here is the wrappers to those functions. You only need to add this code to your adsfunc.c and rebuild rddads.lib. Then you may start using AdsSet...() funcs. [code=fw:2pny4j45]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #B900B9;">//----------------------------------</span><br /><span style="color: #B900B9;">//RCB 4/25/2011 10:16:24 AM</span><br /><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> ADSSETBINARY <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br /><br />ulRetVal = AdsSetBinary<span style="color: #000000;">&#40;</span> pArea->hStatement,<br />    <span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>,<br />    <span style="color: #000000;">&#40;</span>hb_pcount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> > <span style="color: #000000;">2</span> && hb_parni<span style="color: #000000;">&#40;</span> <span style="color: #000000;">3</span> <span style="color: #000000;">&#41;</span> == <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span> ? ADS_BINARY : <span style="color: #000000;">ADS_IMAGE</span>,<br />    hb_parclen<span style="color: #000000;">&#40;</span> <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span>, <span style="color: #B900B9;">//ulTotalLength</span><br />    <span style="color: #000000;">0</span>,<span style="color: #B900B9;">//ulOffset</span><br />    <span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span> <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span>, <br />    hb_parclen<span style="color: #000000;">&#40;</span> <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br /><br />hb_retl<span style="color: #000000;">&#40;</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//----------------------------------</span><br /><span style="color: #B900B9;">//RCB 4/25/2011 10:16:24 AM</span><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> ADSSETSTRING <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br /><br />ulRetVal = AdsSetString<span style="color: #000000;">&#40;</span> pArea->hStatement,<br />    <span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>,<br />    <span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span>, <br />    hb_parclen<span style="color: #000000;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />    <br />hb_retl<span style="color: #000000;">&#40;</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//----------------------------------</span><br /><span style="color: #B900B9;">//RCB 4/25/2011 10:16:24 AM</span><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> ADSSETDATE <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />ulRetVal = AdsSetDate<span style="color: #000000;">&#40;</span> pArea->hStatement,<br />    <span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>,<br />    <span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span>, <br />    hb_parclen<span style="color: #000000;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;<br />hb_retl<span style="color: #000000;">&#40;</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//----------------------------------</span><br /><span style="color: #B900B9;">//RCB 4/25/2011 10:16:24 AM</span><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> ADSSETLONG <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />ulRetVal = AdsSetLong<span style="color: #000000;">&#40;</span> pArea->hStatement,<br />    <span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>, <br />    hb_parnl<span style="color: #000000;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />hb_retl<span style="color: #000000;">&#40;</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//----------------------------------</span><br /><span style="color: #B900B9;">//RCB 4/25/2011 10:16:24 AM</span><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> ADSSETDOUBLE <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />ulRetVal = AdsSetDouble<span style="color: #000000;">&#40;</span> pArea->hStatement,<br />    <span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>, <br />    hb_parnd<span style="color: #000000;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />hb_retl<span style="color: #000000;">&#40;</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//----------------------------------</span><br /><span style="color: #B900B9;">//RCB 4/25/2011 10:16:24 AM</span><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> ADSSETLOGICAL <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />ulRetVal = AdsSetLogical<span style="color: #000000;">&#40;</span> pArea->hStatement,<span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>, hb_parl<span style="color: #000000;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />hb_retl<span style="color: #000000;">&#40;</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /><br /><span style="color: #B900B9;">//RCB</span><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> ADSSETNULL <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />ulRetVal = AdsSetNull<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span>hb_parnl<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>==<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span> ? pArea->hOrdCurrent : <span style="color: #000000;">hb_parnl</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>,<span style="color: #000000;">&#40;</span>char*<span style="color: #000000;">&#41;</span> hb_parc<span style="color: #000000;">&#40;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<br />hb_retl<span style="color: #000000;">&#40;</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">&#41;</span>;<br /><span style="color: #000000;">&#125;</span><br /> </div>[/code:2pny4j45] And just as a reminder to FWH community and to keep this thread focused; xBrowse is grossly eating up resources like a pig anytime you show images on it. It is easy to reproduce the problem using Marcelos's posted sample on this same thread. Is there an outlook on this problem? Anyone working on it? Please help; Reinaldo.
lost memory with images in xBrowse
Any fixes available yet? Anyone working on solving this problem? Reinaldo.
lost memory with images in xBrowse
Reinaldo, first thanks for sharing your code about SQL and data types. I don't know if some body have or need to work with images in xBrowse, I hope Mr. Rao will have some time to solve this issue un abrazo Marcelo
lost memory with images in xBrowse
Hello, sorry, to be present only I hope Fivetech take imporntance about this bug regards Marcelo
lost memory with images in xBrowse
Marcelo/Everyone; Hi. I think I hear crickets chirp. Not a good sign. I guess it is only the two of us saving images to a blob field that are later shown on an xbrowse? Or everyone else is living with the problem and simply accept that the application must be shutdown frequently? This is indeed a bug and an easy one to reproduce with your sample code. I hope Mr. Rao takes notice and at least offer a workaround. Any attention to this bug or workaround suggestion will be appreciated. Reinaldo.
lost memory with images in xBrowse
Reinaldo, does this happen also if you read the bitmaps from disk. Best regards, Otto
lost memory with images in xBrowse
Otto, sorry, let me response your question, if you test the xbimg.prg sample (from sample folder) you will that this sample dosn't lost memory, then I think the problem is when the images come from DB. best regards Marcelo
lost memory with images in xBrowse
Hello, are there some news about this bug? or your think that this functionality is useful best regards Marcelo
lost memory with images in xBrowse
We are working on this issue.
lost memory with images in xBrowse
Mr. Rao thanks very much best regards Marcelo
lost memory with images in xBrowse
I hate to bring this issue back to the foreground. I just hope there is progress. Reinaldo.
lost memory with images in xBrowse
Please apply this fix to image.prg Towards the end of the function FILoadFromMemory() in the Image.prg, please insert the line [code=fw:ed3lz9de]<div class="fw" id="{CB}" style="font-family: monospace;"> &nbsp; &nbsp; &nbsp;FIUNLOAD<span style="color: #000000;">&#40;</span> hDib <span style="color: #000000;">&#41;</span><br />&nbsp;</div>[/code:ed3lz9de] before the line [code=fw:ed3lz9de]<div class="fw" id="{CB}" style="font-family: monospace;"> &nbsp; &nbsp; &nbsp;FI_CloseMemory<span style="color: #000000;">&#40;</span> hMem <span style="color: #000000;">&#41;</span><br />&nbsp;</div>[/code:ed3lz9de]
lost memory with images in xBrowse
Fixed in FWH 13.01
lost memory with images in xBrowse
Mr. Nages; It seems like it does fix the problem. Thank you very much. Reinaldo.
lowbyte y calcxor
Necesito dos funciones que hagan lo siguiente: 1.- lowbyte: Tiene que extraer los 8 bit (byte) de menor orden de un valor de 16 bits. 2.- calcxor: Calcula el or exclusivo de un caracter. No tengo ni idea de como hacerlo.
lowbyte y calcxor
Puedes usar las funciones de FWH nAnd( nVal, 255 ) --> nLowByte y para el CalcXor puedes usar la función nXor( Asc( caracter ), nVal2 ) --> nVal
lowbyte y calcxor
Para el lowbyte creo que es más sencillo usar el operador módulo % #define LowByte( x ) => ( x % 256 ) Saludos, Carlos.
lpassword for numeric get
Dear All, I need to set password to hide data.. with oGet:lPassword := .T. //char type works OK [u:cg9em8ml]but in numeric type it's not.[/u:cg9em8ml] How to do in in numeric get? Regards, Frances
lpassword for numeric get
You need to convert the numeric value as character string and GET and take its VAL() after the get.
lpassword for numeric get
Dear Mr. RAO, not ideal for so many get object (numeric type).. If I changed the Style via RC the get object is forever as password I cant change on the fly to go back to normal get.. in m,y app, some user must not see confidential data so need to hide it as password get.. maybe to change text/background as one color and disable it... setting oGet:lPassword to .T./.F. is handy.. Regards, Frances [quote="nageswaragunupudi":6qsghhs7]You need to convert the numeric value as character string and GET and take its VAL() after the get.[/quote:6qsghhs7]
lpassword for numeric get
Dear RAO, It's much better this way.. if data hidden from certain user - oGet:oGet:Picture := "XXXXXXX.XX" - oGet:Disable() else -oGet:oGet:Picture := oGet:cPicture - oGet:Enable() endif Regards, Fraxzi
lpassword for numeric get
Fraxzi, I'm not clear. What does the picture "XXXXXXX.XX" do to the display? James
lpassword for numeric get
Dear James, The picture 'XXXXXXX.XX" on the numeric get will replace the display value to "XXXXXXX.XX" instead of "9999999.99" or say a value of 12,999.45 This is a workaround since oGet:lPassword := .T. works only for char type. This is selective scenario wherein some user must not see that field value. If I change the style from resource to 'password' then it will show '*****.**' and selective display will not be applicable. Character '*' has special meaning to picture so I used 'X'. Regards, Frances
lpassword for numeric get
Francis, Thanks for the clarification. If you are using a database object you could modify the Load() method to blank out any fields that were not authorized for the current users security. The advantage to this is that the database object could be used anywhere without the restricted data showing (e.g. dialogs, browses, reports, etc.) and without any changes to the coding for the dialogs, browses or reports. Of course, if you are not already using a database object this will require code changes. Regards, James
lpassword for numeric get
Dear Mr. James, Thank you for the added info. I appreciate it. I will look into database object.. my alias are from SQL 'select' I will try it with database object. Right now, I am using variable to manipulate fields from SQL Alias. I will compare. Regards, Frances
lpassword for numeric get
[quote:37gxpk5o]The picture 'XXXXXXX.XX" on the numeric get will replace the display value to "XXXXXXX.XX" instead of "9999999.99" or say a value of 12,999.45 [/quote:37gxpk5o] Nice idea <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->
lpassword for numeric get
Francis, Are you using recordsets or a SQL database driver? If recordsets, then I am not sure you can do what I suggested. Hmm. With a recordset you might be able to create a record class that would read from the recordset and filter out the secure fields. This would work with a dialog, but it would really slow down a browse or report since you would have to create a record object for each record in the recordset. I would have to think about this more... Regards, James
lpassword for numeric get
Mr. RAO, Thanks.. sometimes, things are discovered accidentally when most needed.. <!-- s:mrgreen: --><img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green" /><!-- s:mrgreen: --> [quote="nageswaragunupudi":r4eayge8][quote:r4eayge8]The picture 'XXXXXXX.XX" on the numeric get will replace the display value to "XXXXXXX.XX" instead of "9999999.99" or say a value of 12,999.45 [/quote:r4eayge8] Nice idea <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->[/quote:r4eayge8] Regards, Frances
lpassword for numeric get
[quote="James Bott":1hwm0ouw]Francis, Are you using recordsets or a SQL database driver? If recordsets, then I am not sure you can do what I suggested. Hmm. With a recordset you might be able to create a record class that would read from the recordset and filter out the secure fields. This would work with a dialog, but it would really slow down a browse or report since you would have to create a record object for each record in the recordset. I would have to think about this more... Regards, James[/quote:1hwm0ouw] Dear Mr. James, It is recordsets from ADS. the way I look at it (in my situation), it is less work using the existing method (variable).. perhaps if I have more spare time to try database object. Regards, Frances
límite de variables Locales
Hola: ¿Cuál es el límite de variables locales?. Me pasa que cuando me excedo de 200 y pico el programa se vuelve tonto, pues me pasa a ejecutar la siguiente opción que yo no la llamo. Muchas gracias <!-- s;) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" /><!-- s;) -->
límite de variables Locales
???? No hay limite para variables LOCALES. Al salir del módulo dice: ACTIVATE DIALOG oDlg... RELEASE ALL
límite de variables Locales
Segun tengo entendido... el solo hecho de salir de la Funtion o Procedure que "contiene" las variables locales estas desaparecen.. por lo que no habria necesidad de usar el RELEASE ALL Si estoy equivocado.. que alguien me ilumine.. SALUDOS
límite de variables Locales
Hace unos años tuve un problema parecido: <!-- l --><a class="postlink-local" href="http://forums.fivetechsupport.com/viewtopic.php?f=6&t=4927&p=21809#p21809">viewtopic.php?f=6&t=4927&p=21809#p21809</a><!-- l --> La verdad es que no sé si se solucionó este asunto pues resolví el problema por otros caminos, y con posterioridad no he tenido que abordarlo nuevamente.
límite de variables Locales
Hola Manuel, Muchas gracias. Al final he tenido que pulir el número de variables y funciona OK. El bug de Harbour sigue sin ser corregido. Un saludo
límite de variables Locales
Mgsoft, ¿ Que version de harbour usas ?, asi se prodria hacer un ejemplo que falle para enviarlo a los programadores de harbour para que lo solucionen. Atte., Lautaro Moreira
límite de variables Locales
Gente; esto es lo que me contestó Walter Negro, integrante del equipo xHarbour, en el foro PuertoSur, al respecto [quote:db0uk76p]De donde surge la necesidad de tener tanta cantidad de variables locales? No debería implementarse de otra forma, ejemplo con arrays? Y con esta pregunta no estoy intentando quitar responsabilidad del problema, sino más bien tomar en cuenta que no es bueno tener una mega-función para hacer mil cosas sino funciones más chicas que tengan la oportunidad de reutilizarse y ser más fácil de depurar. Y si, por ejemplo, se tienen tantas variables locales porque se tiene una gran pantalla de edición con una gran cantidad de controles, quizás también podría implementarse usando arrays. El código sería más fácil de mantener y agregar o quitar controles mucho más simple. El 200 y pico tienen que ser 254 o 255. Respecto del límite, probablemente esté por las 32000 variables. En algunas versiones anteriores de xHarbour hubo problemas cuando llegabas o pasabas de las 255 variables locales por varias razones. Hay un PCode al inicio de cada función que indica la cantidad de parámetros y variables locales. El PCode normal tiene 2 bytes, entonces podría servir para indicar hasta 255 parámetros y 255 variables locales. Pero si se pasa de esa cantidad de parámetros, existe otro PCode que indica la cantidad extra de parámetros. Respecto de las variables locales, si se pasa de 255 hay otro PCode que tiene 3 bytes e indica la cantidad de variables locales con 2 bytes. Por eso digo que habría que ver qué compilador y versión del mismo está usando para orientar la búsqueda del problema. [/quote:db0uk76p] Saludos
mac address
Can any please help me how to find mac address of the PC ? Thanks in advance NageswaraRao
mac address
You may use GETNETCARDID()
mac address
Thanks Mr. Antonio. But I am getting unlinked external "GetAdapetersInfo" referenced by function "NETCRDID" I am using xHarbour with FWH. Can you help me with this please? Regards Nageswararao
mac address
NageswaraRao, Are you using xHarbour commercial ?
mac address
Add IPHLPAPI.LIB from bcc55 into your script if your are using bcc
mac address
I am using xharbour with bcc55. not the commercial version. i included the lib iphlpapi.lib as advised by srrao and now its working fine. thanks mr. antonio and mr. sanjay
mac address
NageswaraRao, Yes, right, that library is needed. We already provided it included in samples\buildh.bat. I guess you are using an older version of buildh.bat.
mac address
Hi, I'm getting a unresolved external __chkstk when I try to use this
mac address
Alex, Try linking Borland cw32.lib
mac address
A borland library with commercial xharbour?
mac address
ops, my mistake <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) --> Then you should require it to xHB guys. If I am not wrong, __chkstk stands for check stack, so you could safely create a dummy C function with such name void _chkstk( void ) { }
mac address
If I add that dummy function, GetNetCardID kills my app. Will ask on xhb newsgroup Alex
mac address
Alex, > Will ask on xhb newsgroup Yes, its the right way <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) -->
mac address
Alex, Just out of curiosity, please try it this way: BOOL _chkstk( void ) { return TRUE; }
mac address
No luck <!-- s:? --><img src="{SMILIES_PATH}/icon_confused.gif" alt=":?" title="Confused" /><!-- s:? --> Busy trying to get following code to work. It compiles. I just need to figure out how to return an array of adapter names and addresses [code:58gsfl3g] #include <iphlpapi&#46;h> // Fetches the MAC address and prints it static void GetMACaddress&#40;void&#41; &#123; IP_ADAPTER_INFO AdapterInfo&#91;16&#93;; // Allocate information // for up to 16 NICs DWORD dwBufLen = sizeof&#40;AdapterInfo&#41;; // Save memory size of buffer DWORD dwStatus = GetAdaptersInfo&#40; // Call GetAdapterInfo AdapterInfo, // &#91;out&#93; buffer to receive data &dwBufLen&#41;; // &#91;in&#93; size of receive data buffer // assert&#40;dwStatus == ERROR_SUCCESS&#41;; // Verify return value is // valid, no buffer overflow PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to // current adapter info do &#123; // PrintMACaddress&#40;pAdapterInfo->Address&#41;; // Print MAC address pAdapterInfo = pAdapterInfo->Next; // Progress through // linked list &#125; while&#40;pAdapterInfo&#41;; // Terminate if last adapter &#125; [/code:58gsfl3g]
mac address
Alex, Check the source code of Harbour's Directory() function. It shows how to create, fill and return a multidimensional array.
mac address
Found that code thanks. All working now. I couldn't format the hex numbers nicely in c using sprintf, so thats why I've got the extra code, and returning each byte separately [code:20nr8361] Function Dec2x&#40;pnNo, pnBase&#41; Local cRetVal &#58;= "" Local nCount &#58;= 0 Local acDigits &#58;= &#123;"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"&#125; Local nNo &#58;= 0 For nCount &#58;= 65 to 65 + pnBase - 11 aadd&#40;acDigits, chr&#40;nCount&#41;&#41; Next For nCount &#58;= 7 to 0 step - 1 nNo &#58;= int&#40;pnNo / &#40;pnBase**nCount&#41;&#41; If nNo > 0 &#46;or&#46; !empty&#40;cRetVal&#41; cRetVal += acDigits&#91;nNo + 1&#93; pnNo -= nNo * pnBase**nCount Endif Next Return cRetval Function GetMacAddresses&#40;&#41; local aaTemp &#58;= &#123;&#125; local axTemp local aaRetval local cMac &#58;= "" aaTemp &#58;= _GETMACADDRESSES&#40;&#41; aaRetval &#58;= &#123;&#125; For each axTemp in aaTemp cMac &#58;= "" cMac += padl&#40;Dec2x&#40;axTemp&#91;3&#93;, 16&#41;, 2, "0"&#41; + "-" cMac += padl&#40;Dec2x&#40;axTemp&#91;4&#93;, 16&#41;, 2, "0"&#41; + "-" cMac += padl&#40;Dec2x&#40;axTemp&#91;5&#93;, 16&#41;, 2, "0"&#41; + "-" cMac += padl&#40;Dec2x&#40;axTemp&#91;6&#93;, 16&#41;, 2, "0"&#41; + "-" cMac += padl&#40;Dec2x&#40;axTemp&#91;7&#93;, 16&#41;, 2, "0"&#41; + "-" cMac += padl&#40;Dec2x&#40;axTemp&#91;8&#93;, 16&#41;, 2, "0"&#41; aadd&#40;aaRetval, &#123;axTemp&#91;2&#93;, cMac&#125;&#41; Next return aaRetval //---------------------------------------------------------------------------------------------// #pragma begindump #include <WinTen&#46;h> #include <Windows&#46;h> #include <ClipApi&#46;h> #ifdef __FLAT__ #include <ShellApi&#46;h> #endif #ifdef __HARBOUR__ #include <hbapiitm&#46;h> #include <hbdate&#46;h> #include <hbset&#46;h> #endif #include <iphlpapi&#46;h> // Fetches the MAC address and prints it HB_FUNC&#40; _GETMACADDRESSES &#41; &#123; PHB_ITEM paAddress = hb_itemArrayNew&#40; 0 &#41;; IP_ADAPTER_INFO AdapterInfo&#91;16&#93;; // Allocate information // for up to 16 NICs DWORD dwBufLen = sizeof&#40;AdapterInfo&#41;; // Save memory size of buffer DWORD dwStatus = GetAdaptersInfo&#40; // Call GetAdapterInfo AdapterInfo, // &#91;out&#93; buffer to receive data &dwBufLen&#41;; // &#91;in&#93; size of receive data buffer // assert&#40;dwStatus == ERROR_SUCCESS&#41;; // Verify return value is // valid, no buffer overflow PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to // current adapter info PHB_ITEM pName = hb_itemNew&#40;NULL&#41;; PHB_ITEM pDesc = hb_itemNew&#40;NULL&#41;; PHB_ITEM pAddress = hb_itemNew&#40;NULL&#41;; char cMacAddress&#91;17&#93;; do &#123; // PrintMACaddress&#40;pAdapterInfo->Address&#41;; // Print MAC address PHB_ITEM pSubArray = hb_itemArrayNew&#40;8&#41;; hb_arraySet&#40;pSubArray, 1, hb_itemPutC&#40;pName, pAdapterInfo->AdapterName&#41;&#41;; hb_arraySet&#40;pSubArray, 2, hb_itemPutC&#40;pDesc, pAdapterInfo->Description&#41;&#41;; // sprintf&#40; cMacAddress, "%x-%x-%x-%x-%x-%x", pAdapterInfo->Address&#91;0&#93;, pAdapterInfo->Address&#91;1&#93;, pAdapterInfo->Address&#91;2&#93; hb_arraySet&#40;pSubArray, 3, hb_itemPutNL&#40;pDesc, pAdapterInfo->Address&#91;0&#93;&#41;&#41;; hb_arraySet&#40;pSubArray, 4, hb_itemPutNL&#40;pDesc, pAdapterInfo->Address&#91;1&#93;&#41;&#41;; hb_arraySet&#40;pSubArray, 5, hb_itemPutNL&#40;pDesc, pAdapterInfo->Address&#91;2&#93;&#41;&#41;; hb_arraySet&#40;pSubArray, 6, hb_itemPutNL&#40;pDesc, pAdapterInfo->Address&#91;3&#93;&#41;&#41;; hb_arraySet&#40;pSubArray, 7, hb_itemPutNL&#40;pDesc, pAdapterInfo->Address&#91;4&#93;&#41;&#41;; hb_arraySet&#40;pSubArray, 8, hb_itemPutNL&#40;pDesc, pAdapterInfo->Address&#91;5&#93;&#41;&#41;; hb_arrayAdd&#40;paAddress, pSubArray&#41;; hb_itemRelease&#40;pSubArray&#41;; pAdapterInfo = pAdapterInfo->Next; // Progress through // linked list &#125; while&#40;pAdapterInfo&#41;; // Terminate if last adapter hb_itemRelease&#40;pName&#41;; hb_itemRelease&#40;pDesc&#41;; hb_itemRelease&#40;pAddress&#41;; hb_itemRelease&#40;hb_itemReturn&#40;paAddress&#41;&#41;; &#125; #pragma enddump [/code:20nr8361]
mac address
I made some changes in the function above to getting more information about the NIC. This is the code: [code:1246xj41]#include "fivewin&#46;ch" /* * Retrieves adapter information for the local computer&#46; * Original code by AlexSchaft * http&#58;//fivetechsoft&#46;com/forums/viewtopic&#46;php?t=77&postdays=0&postorder=asc&start=15 * * Changed by Vailton Renato @ 07/06/2007 - 09&#58;24&#58;03 */ function main&#40;&#41; local NICs &#58;= GetMacAddresses&#40;&#41; local crlf,i,s crlf &#58;= chr&#40;13&#41;+chr&#40;10&#41; FOR i &#58;= 1 TO len&#40; NICs &#41; * An ANSI character string of the description for the adapter&#46; s &#58;= "Description&#58; " + NICs&#91;i,1&#93; + crlf * MAC Address s += "MAC Address&#58; " + NICs&#91;i,2&#93; + crlf * An ANSI character string of the name of the adapter&#46; s += "Adapter Name&#58; " + NICs&#91;i,3&#93; + crlf s += crlf * IP info s += "IP&#58; " + NICs&#91;i,4&#93; + crlf s += "Mask&#58; " + NICs&#91;i,5&#93; + " / " s += "Gateway&#58; " + NICs&#91;i,6&#93; + crlf s += crlf * DHCP Sever IP or empty string "" if !Empty&#40; NICs&#91;i,7&#93; &#41; s += "DHCP&#58; " + NICs&#91;i,7&#93; + " / " * The time when the current DHCP lease was obtained&#46; s += "Lease Obtained&#58; " + alltrim&#40; str&#40; NICs&#91;i,8&#93; &#41;&#41;+ crlf else s += 'DHCP disabled' end * Primary WINS server if !Empty&#40; NICs&#91;i,9&#93; &#41; s += "Pimary WINS&#58; " + NICs&#91;i,9&#93; + crlf end * Secondary WINS server if !Empty&#40; NICs&#91;i,9&#93; &#41; s += "Secondary WINS&#58; " + NICs&#91;i,10&#93; + crlf end ? s End return nil //---------------------------------------------------------------------------------------------// #pragma begindump #include <WinTen&#46;h> #include <Windows&#46;h> #include <ClipApi&#46;h> #ifdef __FLAT__ #include <ShellApi&#46;h> #endif #ifdef __HARBOUR__ #include <hbapiitm&#46;h> #include <hbdate&#46;h> #include <hbset&#46;h> #endif #include <iphlpapi&#46;h> // Fetches the MAC address and prints it HB_FUNC&#40; GETMACADDRESSES &#41; &#123; IP_ADAPTER_INFO AdapterInfo&#91;16&#93;; // Allocate information // for up to 16 NICs // http&#58;//msdn2&#46;microsoft&#46;com/En-US/library/aa366062&#46;aspx DWORD dwBufLen = sizeof&#40;AdapterInfo&#41;; // Save memory size of buffer DWORD dwStatus = GetAdaptersInfo&#40; // Call GetAdapterInfo AdapterInfo, // &#91;out&#93; buffer to receive data &dwBufLen&#41;; // &#91;in&#93; size of receive data buffer PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to // current adapter info char cMacAddress&#91;17&#93;; PHB_ITEM pItem; PHB_ITEM paAddress = hb_itemArrayNew&#40; 0 &#41;; // Verify return value is valid, no buffer overflow&#46;&#46;&#46; if &#40;dwStatus != ERROR_SUCCESS&#41; &#123; hb_itemRelease&#40;hb_itemReturn&#40;paAddress&#41;&#41;; return; &#125; pItem = hb_itemNew&#40;NULL&#41;; do &#123; PHB_ITEM pSubArray = hb_itemArrayNew&#40;10&#41;; // Description of NIC hb_arraySet&#40;pSubArray, 1, hb_itemPutC&#40;pItem, pAdapterInfo->Description&#41;&#41;; // MAC address sprintf&#40; cMacAddress, "%&#46;2x-%&#46;2x-%&#46;2x-%&#46;2x-%&#46;2x-%&#46;2x", pAdapterInfo->Address&#91;0&#93;, pAdapterInfo->Address&#91;1&#93;, pAdapterInfo->Address&#91;2&#93;, pAdapterInfo->Address&#91;3&#93;, pAdapterInfo->Address&#91;4&#93;, pAdapterInfo->Address&#91;5&#93; &#41;; hb_strUpper&#40; cMacAddress, strlen&#40;cMacAddress&#41;&#41;; hb_arraySet&#40;pSubArray, 2, hb_itemPutC&#40;pItem, cMacAddress &#41;&#41;; // GUID of NIC hb_arraySet&#40;pSubArray, 3, hb_itemPutC&#40;pItem, pAdapterInfo->AdapterName&#41;&#41;; // IP Address hb_arraySet&#40;pSubArray, 4, hb_itemPutC&#40;pItem, pAdapterInfo->IpAddressList&#46;IpAddress&#46;String &#41;&#41;; // IP Mask hb_arraySet&#40;pSubArray, 5, hb_itemPutC&#40;pItem, pAdapterInfo->IpAddressList&#46;IpMask&#46;String &#41;&#41;; // IP Gateway hb_arraySet&#40;pSubArray, 6, hb_itemPutC&#40;pItem, pAdapterInfo->GatewayList&#46;IpAddress&#46;String &#41;&#41;; // DHCP server IP & Lease Obtained if &#40;pAdapterInfo->DhcpEnabled&#41; &#123; hb_arraySet&#40;pSubArray, 7, hb_itemPutC&#40; pItem, pAdapterInfo->DhcpServer&#46;IpAddress&#46;String &#41;&#41;; hb_arraySet&#40;pSubArray, 8, hb_itemPutNL&#40;pItem, pAdapterInfo->LeaseObtained &#41;&#41;; &#125; else &#123; hb_arraySet&#40;pSubArray, 7, hb_itemPutC&#40; pItem, "" &#41;&#41;; hb_arraySet&#40;pSubArray, 8, hb_itemPutNI&#40;pItem, 0 &#41;&#41;; &#125; // WINS server info - Primary & Secondary ip address if &#40;pAdapterInfo->HaveWins&#41; &#123; hb_arraySet&#40;pSubArray, 9, hb_itemPutC&#40; pItem, pAdapterInfo->PrimaryWinsServer&#46;IpAddress&#46;String &#41;&#41;; hb_arraySet&#40;pSubArray, 10, hb_itemPutC&#40; pItem, pAdapterInfo->SecondaryWinsServer&#46;IpAddress&#46;String &#41;&#41;; &#125; else &#123; hb_arraySet&#40;pSubArray, 9, hb_itemPutC&#40; pItem, "" &#41;&#41;; hb_arraySet&#40;pSubArray, 10, hb_itemPutC&#40; pItem, "" &#41;&#41;; &#125; hb_arrayAdd&#40;paAddress, pSubArray&#41;; hb_itemRelease&#40;pSubArray&#41;; pAdapterInfo = pAdapterInfo->Next; // Progress through // linked list &#125; while&#40;pAdapterInfo&#41;; // Terminate if last adapter hb_itemRelease&#40;pItem&#41;; hb_itemRelease&#40;hb_itemReturn&#40;paAddress&#41;&#41;; &#125; #pragma enddump[/code:1246xj41] Sorry, my english is very bad. <!-- s:wink: --><img src="{SMILIES_PATH}/icon_wink.gif" alt=":wink:" title="Wink" /><!-- s:wink: -->
mac address
Thanks for that. The %.2x syntax seems to crash under commercial xhb. Alex
mac address
Try without the dot (%2x). EMG
mac address
I found my problem <!-- s:oops: --><img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarassed" /><!-- s:oops: --> A mac address is 17 characters, so in xbase a 17 character string is enough, but you need another character for \0 in C. So initializing cMacAddress as [code:1z7gw74x] char cMacAddress&#91;18&#93; [/code:1z7gw74x] and using [code:1z7gw74x] sprintf&#40; cMacAddress, "%02X-%02X-%02X-%02X-%02X-%02X", pAdapterInfo->Address&#91;0&#93;, pAdapterInfo->Address&#91;1&#93;, pAdapterInfo->Address&#91;2&#93;, pAdapterInfo->Address&#91;3&#93;, pAdapterInfo->Address&#91;4&#93;, pAdapterInfo->Address&#91;5&#93;&#41;; [/code:1z7gw74x] solves my problem <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->
mac address
Obvious. Great! EMG
mac address
Alex,your function is not working with Vista / Vista64. It returns an empty array.Do you have a version that runs with vista ?
mac address
Stefan,You can use FWH GetNetCardID()It returns an array if there are more than one network adapters:[code:2av9ip6f] if ValType&#40; GetNetCardID&#40;&#41; &#41; == "C" MsgInfo&#40; GetNetCardID&#40;&#41; &#41; else aAdapters = GetNetCardID&#40;&#41; for n = 1 to Len&#40; aAdapters &#41; MsgInfo&#40; aAdapters&#91; n &#93; &#41; next endif [/code:2av9ip6f]
mac address
Haven't bothered with a version for Vista yet. I see a new API is recommended for XP/Vista, which I haven't investigated yet.
mac address
Antonio,I made some tests and I get some curios results.Alex function is working with XPx64, not with XPx32 Sp3 and not with Vistax32/x64.XPx32: detects 1 NIC, returns wrong MAC (1 NIC present)Vista32: detects 0 NIC, returns wrong MAC (2 NIC present)GetNetcardID ():XPx32: detects 1 NIC, returns wrong MAC (1 NIC present)Vista32: detects 1 NIC, returns wrong MAC (2 NIC present)
mac address
MS suggests a new api function to be used with XP and later, GetAdaptersAdresses().This function does not seem to be available with bcc55, or I´m linking the wrong libs. This is my try to convert Alex function to this new api-function.I´m getting an unresolved external "GetAdaptersAdresses". There may be some other errors in the code, so I would be happy, if anyone could look over the code.[code:17303bd3]HB_FUNC&#40; GETMAC &#41; &#123; IP_ADAPTER_ADDRESSES AdapterInfo&#91;16&#93;; // Allocate information // for up to 16 NICs DWORD dwBufLen = sizeof&#40;AdapterInfo&#41;; // Save memory size of buffer DWORD dwStatus = GetAdaptersAdresses&#40; // Call GetAdapterInfo AF_INET,0,0, AdapterInfo, // &#91;out&#93; buffer to receive data &dwBufLen&#41;; // &#91;in&#93; size of receive data buffer PIP_ADAPTER_ADDRESSES pAdapterInfo = AdapterInfo; // Contains pointer to // current adapter info char cMacAddress&#91;18&#93;; PHB_ITEM pItem; PHB_ITEM paAddress = hb_itemArrayNew&#40; 0 &#41;; // Verify return value is valid, no buffer overflow&#46;&#46;&#46; if &#40;dwStatus != ERROR_SUCCESS&#41; &#123; hb_itemRelease&#40;hb_itemReturn&#40;paAddress&#41;&#41;; return; &#125; pItem = hb_itemNew&#40;NULL&#41;; do &#123; PHB_ITEM pSubArray = hb_itemArrayNew&#40;3&#41;; // Description of NIC hb_arraySet&#40;pSubArray, 1, hb_itemPutC&#40;pItem, pAdapterInfo->Description&#41;&#41;; // MAC address sprintf&#40; cMacAddress, "%&#46;2x-%&#46;2x-%&#46;2x-%&#46;2x-%&#46;2x-%&#46;2x", pAdapterInfo->PhysicalAddress&#91;0&#93;, pAdapterInfo->PhysicalAddress&#91;1&#93;, pAdapterInfo->PhysicalAddress&#91;2&#93;, pAdapterInfo->PhysicalAddress&#91;3&#93;, pAdapterInfo->PhysicalAddress&#91;4&#93;, pAdapterInfo->PhysicalAddress&#91;5&#93; &#41;; hb_strUpper&#40; cMacAddress, strlen&#40;cMacAddress&#41;&#41;; hb_arraySet&#40;pSubArray, 2, hb_itemPutC&#40;pItem, cMacAddress &#41;&#41;; // GUID of NIC hb_arraySet&#40;pSubArray, 3, hb_itemPutC&#40;pItem, pAdapterInfo->AdapterName&#41;&#41;; pAdapterInfo = pAdapterInfo->Next; // Progress through // linked list &#125; while&#40;pAdapterInfo&#41;; // Terminate if last adapter hb_itemRelease&#40;pItem&#41;; hb_itemRelease&#40;hb_itemReturn&#40;paAddress&#41;&#41;; &#125; [/code:17303bd3]
mac address
Stefan,It seems as there is a typo in the function name. It should be:GetAdaptersAddresses()Notice the "dd"<!-- m --><a class="postlink" href="http://msdn.microsoft.com/en-us/library/aa365915.aspx">http://msdn.microsoft.com/en-us/library/aa365915.aspx</a><!-- m -->You have to create an import library from Windows Iphlpapi.dll
mac address
Antonio, yes, thanks, a small typo I hadn´t seen <!-- s:( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":(" title="Sad" /><!-- s:( --> I got it working so far, I have only 2 warnings I don´t undestand. Maybe you have an idea what to do[color=red:ts7vd24q]Warning: Suspicious pointer converversion[/color:ts7vd24q]hb_arraySet(pSubArray, 1, hb_itemPutC(pItem, pAdapterInfo->Description));hb_arraySet(pSubArray, 3, hb_itemPutC(pItem, pAdapterInfo->FriendlyName));[code:ts7vd24q]HB_FUNC&#40; GETMAC &#41; &#123; IP_ADAPTER_ADDRESSES AdapterInfo&#91;16&#93;; // Allocate information DWORD dwBufLen = sizeof&#40;AdapterInfo&#41;; // Save memory size of buffer ULONG flags = GAA_FLAG_SKIP_UNICAST; // Set the flags ULONG family = AF_INET; // only IP4 DWORD dwStatus = GetAdaptersAddresses&#40; // Call GetAdapterInfo family,flags,NULL, AdapterInfo, // &#91;out&#93; buffer to receive data &dwBufLen&#41;; // &#91;in&#93; size of receive data buffer PIP_ADAPTER_ADDRESSES pAdapterInfo = AdapterInfo; // Contains pointer to // current adapter info char cMacAddress&#91;18&#93;; PHB_ITEM pItem; PHB_ITEM paAddress = hb_itemArrayNew&#40; 0 &#41;; // Verify return value is valid, no buffer overflow&#46;&#46;&#46; if &#40;dwStatus != ERROR_SUCCESS&#41; &#123; hb_itemRelease&#40;hb_itemReturn&#40;paAddress&#41;&#41;; return; &#125; pItem = hb_itemNew&#40;NULL&#41;; do &#123; PHB_ITEM pSubArray = hb_itemArrayNew&#40;4&#41;; // Description of NIC hb_arraySet&#40;pSubArray, 1, hb_itemPutC&#40;pItem, pAdapterInfo->Description&#41;&#41;; &#93; // *** Suspicious pointer conversion *** // MAC address sprintf&#40; cMacAddress, "%&#46;2x-%&#46;2x-%&#46;2x-%&#46;2x-%&#46;2x-%&#46;2x", pAdapterInfo->PhysicalAddress&#91;0&#93;, pAdapterInfo->PhysicalAddress&#91;1&#93;, pAdapterInfo->PhysicalAddress&#91;2&#93;, pAdapterInfo->PhysicalAddress&#91;3&#93;, pAdapterInfo->PhysicalAddress&#91;4&#93;, pAdapterInfo->PhysicalAddress&#91;5&#93; &#41;; hb_strUpper&#40; cMacAddress, strlen&#40;cMacAddress&#41;&#41;; hb_arraySet&#40;pSubArray, 2, hb_itemPutC&#40;pItem, cMacAddress &#41;&#41;; // GUID of NIC hb_arraySet&#40;pSubArray, 3, hb_itemPutC&#40;pItem, pAdapterInfo->FriendlyName&#41;&#41;; // *** Suspicious pointer conversion *** // Type hb_arraySet&#40;pSubArray, 4, hb_itemPutNI &#40;pItem, pAdapterInfo->IfType&#41;&#41;; hb_arrayAdd&#40;paAddress, pSubArray&#41;; hb_itemRelease&#40;pSubArray&#41;; pAdapterInfo = pAdapterInfo->Next; // Progress through // linked list &#125; while&#40;pAdapterInfo&#41;; // Terminate if last adapter hb_itemRelease&#40;pItem&#41;; hb_itemRelease&#40;hb_itemReturn&#40;paAddress&#41;&#41;; &#125;[/code:ts7vd24q]
mac address
Stefan,hb_arraySet(pSubArray, 1, hb_itemPutC(pItem, [color=red:32jqi1lo]( char * )[/color:32jqi1lo] pAdapterInfo->Description));andhb_arraySet(pSubArray, 3, hb_itemPutC(pItem, [color=red:32jqi1lo]( char * )[/color:32jqi1lo] pAdapterInfo->FriendlyName));
mac address
Stefan,This function is returning an empty array here on my computer.I have three network adapters.FWH GetNetCardID() is working fine here.
mac address
Antonio,I think I found the reason why it´s sometimes working and sometimes not.It seems to depend on the pc the app is compiled. Compiling it with my office pc (XP64) it only runs on this pc, on others it crashes without error log, only a system message that there is a problem with he app.If I compile it on my home pc (xp32, Sp3) it working on verey other pc.I nerver noticed this before, I have the same version, the same environment, it´s very curious.
mac address
Antonio,[quote:15q1vhx8]This function is returning an empty array here on my computer. [/quote:15q1vhx8]sorry, I forgot to insert these lines [code:15q1vhx8] hb_arrayAdd&#40;paAddress, pSubArray&#41;; hb_itemRelease&#40;pSubArray&#41;; [/code:15q1vhx8] before pAdapterInfo = pAdapterInfo->Next;. Now it´s working. It returns the description, the mac address, it´s name and it´s type for every card. here is an small sample [code:15q1vhx8]FUNCTION GetNetID3 &#40;&#41; LOCAL n LOCAL cDescription, cMac, cType, cName LOCAL aNic &#58;= GetMac &#40;&#41; if ValType &#40;aNic &#41; == "A" for n &#58;= 1 TO Len &#40;aNic&#41; cDescription &#58;= aNic &#91;n,1&#93; cMac &#58;= aNic &#91;n,2&#93; cName &#58;= aNic &#91;n,3&#93; cType &#58;= cValToChar &#40;aNic &#91;n,4&#93;&#41; IF cType = "6" MsgInfo&#40; "Description&#58; "+cDescription+CRLF+; "Mac &#58; "+cMac+CRLF+; "Name &#58; "+cName+CRLF+; "Type &#58; "+cType,; "NIC" &#41; endif next endif RETURN &#40;nil&#41;[/code:15q1vhx8]Only one problem remains, the description and the name are PWCHAR in the API-deklaration, withhb_arraySet(pSubArray, 1, hb_itemPutC(pItem,( char *) pAdapterInfo->Description));I get only the first char back. How can I convert this type into a PCHAR ?
mac address
Stefan,Use this FWH function:char * WideToAnsi( LPWSTR );
mac address
Remember to use the memory that WideToAnsi() allocates:char * pText = WideToAnsi( <wide_string> );use pText ...hb_xfree( pText );
mac address
Thanks,I added the following lines [code:3g7k43vw]char* pText; &#46;&#46;&#46;&#46;&#46;&#46; pText = HB_FUN_WIDETOANSI &#40;pAdapterInfo->Description&#41;; hb_arraySet&#40;pSubArray, 1, hb_itemPutC&#40;pItem, pText&#41;&#41;; hb_xfree &#40;pText&#41;;[/code:3g7k43vw]on runtime I get Unrecoverable error 9023: hb_xgrab requested to allocate zero bytesDid I forget something ?
mac address
Dear Antonio,[quote="StefanHaupt":1q6kks0e]It seems to depend on the pc the app is compiled. Compiling it with my office pc (XP64) it only runs on this pc, on others it crashes without error log, only a system message that there is a problem with he app.[/quote:1q6kks0e]Ok, finally I got it. <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> It depends on the version of iphlpapi.dll and the lib built from it. If I link this lib with my app it runs only on those pc´s with the same version of iphlpapi.dll the lib was build from. If I load the dll dynamically everything works fine on every tested pc. Maybe the addresses of the functions in the dll differs from one version to another.Antonio, did you test the function GetNetCardID() against this scenario ? I found this function does not cause an error, but it returns a wrong mac and does not find all nics.Many thanks for your great support <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->
mac address
Stefan,>pText = HB_FUN_WIDETOANSI (pAdapterInfo->Description); on runtime I get Unrecoverable error 9023: hb_xgrab requested to allocate zero bytes >That means that pAdapterInfo->Description contains a zero length string, thats why hb_xgrab() fails when it is requested to allocate zero bytes.
mac address
Stefan,>Maybe the addresses of the functions in the dll differs from one version to another. >Yes, thats possible. In those cases, the address of the used function should be obtained using GetProcAddress():<!-- m --><a class="postlink" href="http://msdn.microsoft.com/en-us/library/ms683212(VS.85">http://msdn.microsoft.com/en-us/library/ms683212(VS.85</a><!-- m -->).aspxThere are many examples in these forums using GetProcAddress().>did you test the function GetNetCardID() against this scenario ? I found this function does not cause an error, but it returns a wrong mac and does not find all nics. > FWH GETNETCARDID() is working fine on Vista (just uses Windows API GetAdaptersInfo(). Though Microsoft recommends to use GetAdaptersAddresses(), GetAdaptersInfo() seems ok for us):<!-- m --><a class="postlink" href="http://msdn.microsoft.com/en-us/library/aa365917.aspx">http://msdn.microsoft.com/en-us/library/aa365917.aspx</a><!-- m -->
macexec with variable
Hello, Is it possible to add a 'variable' to the MacExec() command? What I want is the following: From my program I want to run a .sh file to make directories and move files. So I want to use the next command: MacExec( "terminal" MoveFilesLite.sh )
macexec with variable
It seems as we have to use this method: [url:kso9z84x]https&#58;//developer&#46;apple&#46;com/reference/appkit/nsworkspace/1534810-launchapplication[/url:kso9z84x] I am going to implement it
macexec with variable
Here we have two ways to do it: [url:3ec0o3d9]http&#58;//stackoverflow&#46;com/questions/5048677/launching-an-mac-app-with-objective-c-cocoa[/url:3ec0o3d9] lets see which one is the right one to use
macexec with variable
This should work fine: [code=fw:ey6le3ra]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> MACEXEC <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />&nbsp; &nbsp;NSWorkspace * workspace;<br /><br />&nbsp; &nbsp;<span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> hb_pcount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> > <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;<span style="color: #000000;">&#123;</span><br />&nbsp; &nbsp; &nbsp; workspace = <span style="color: #000000;">&#91;</span> <span style="color: #000000;">&#91;</span> <span style="color: #000000;">&#91;</span> NSWorkspace alloc <span style="color: #000000;">&#93;</span> <span style="color: #0000ff;">init</span> <span style="color: #000000;">&#93;</span> autorelease <span style="color: #000000;">&#93;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> hb_pcount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hb_retl<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span> workspace launchapplication: <span style="color: #000000;">hb_NSSTRING</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;<br /><br />&nbsp; &nbsp; &nbsp; <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> hb_pcount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NSURL * url = <span style="color: #000000;">&#91;</span> NSURL fileURLWithPath: <span style="color: #000000;">&#91;</span> workspace fullPathForApplication: <span style="color: #000000;">hb_NSSTRING</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#93;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NSArray * arguments = <span style="color: #000000;">&#91;</span> NSArray arrayWithObjects: <span style="color: #000000;">hb_NSSTRING</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span>, <span style="color: #00C800;">nil</span> <span style="color: #000000;">&#93;</span>; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NSError * error = <span style="color: #00C800;">nil</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hb_retl<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span> workspace launchApplicationAtURL:<span style="color: #000000;">url</span> options:<span style="color: #000000;">0</span> <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;configuration:<span style="color: #000000;">&#91;</span>NSDictionary dictionaryWithObject:<span style="color: #000000;">arguments</span> forKey:<span style="color: #000000;">NSWorkspaceLaunchConfigurationArguments</span><span style="color: #000000;">&#93;</span> &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;error:<span style="color: #000000;">error</span> <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />&nbsp; &nbsp;<span style="color: #000000;">&#125;</span> <br /><span style="color: #000000;">&#125;</span></div>[/code:ey6le3ra] I am going to try it
macexec with variable
This code compiles fine: [code=fw:1h7aprt8]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">&#40;</span> MACEXEC <span style="color: #000000;">&#41;</span><br /><span style="color: #000000;">&#123;</span><br />   NSWorkspace * workspace;<br /><br />   <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> hb_pcount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> > <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span><br />   <span style="color: #000000;">&#123;</span><br />      workspace = <span style="color: #000000;">&#91;</span> <span style="color: #000000;">&#91;</span> <span style="color: #000000;">&#91;</span> NSWorkspace alloc <span style="color: #000000;">&#93;</span> <span style="color: #0000ff;">init</span> <span style="color: #000000;">&#93;</span> autorelease <span style="color: #000000;">&#93;</span>;<br />       <br />      <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> hb_pcount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span><br />         hb_retl<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span> workspace launchapplication: <span style="color: #000000;">hb_NSSTRING_par</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;<br /><br />      <span style="color: #00C800;">if</span><span style="color: #000000;">&#40;</span> hb_pcount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> == <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span><br />      <span style="color: #000000;">&#123;</span><br />         NSURL * url = <span style="color: #000000;">&#91;</span> NSURL fileURLWithPath: <span style="color: #000000;">&#91;</span> workspace fullPathForApplication: <span style="color: #000000;">hb_NSSTRING_par</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#93;</span>;<br />         NSArray * arguments = <span style="color: #000000;">&#91;</span> NSArray arrayWithObjects: <span style="color: #000000;">hb_NSSTRING_par</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">2</span> <span style="color: #000000;">&#41;</span>, <span style="color: #00C800;">nil</span> <span style="color: #000000;">&#93;</span>; <br />         NSError * error = <span style="color: #00C800;">nil</span>;<br />         <br />         hb_retl<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span> workspace launchApplicationAtURL:<span style="color: #000000;">url</span> options:<span style="color: #000000;">0</span> <br />           configuration:<span style="color: #000000;">&#91;</span>NSDictionary dictionaryWithObject:<span style="color: #000000;">arguments</span> forKey:<span style="color: #000000;">NSWorkspaceLaunchConfigurationArguments</span><span style="color: #000000;">&#93;</span>  <br />           error:<span style="color: #000000;">error</span> <span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;<br />      <span style="color: #000000;">&#125;</span><br />   <span style="color: #000000;">&#125;</span> <br /><span style="color: #000000;">&#125;</span></div>[/code:1h7aprt8]
macexec with variable
Hello Mastintin, Thanks for your suggestion, but this does not work. What I want is the following: I use packages to make a pkg from my app. This pkg installs the program in folder programs and databases in folder users/shared/plantenkennis. Now I want to run a .sh script which makes folder plantenkennis in users/$user and move the files from shared to $user. I have a script (MoveFilesLite.sh) with all the commands in it. It runs perfect in command tool, but when I implement it in the packages app, the pkg gives an error. The reason is that packages expect a 0 as return after the .sh script. I don't know how to do this, so i thought is I run the MoveFileLite.sh from my app the first time it is launched it would solve the problem. But if I run TaskExec( "/bin/sh", "MoveFilesLite.sh", ), nothing happens? My MoveFilesLite.sh script&#058; [code=fw:1gkuxxtc]<div class="fw" id="{CB}" style="font-family: monospace;"><br /># date: <span style="color: #000000;">14</span><span style="color: #000000;">-03</span><span style="color: #000000;">-2017</span><br /># <span style="color: #0000ff;">to</span> place all needed databases and other files in the <span style="color: #0000ff;">right</span> <span style="color: #0000ff;">folder</span><br /># first make the folders needed<br /><br />mkdir /Users/$USER/plantenkennis<br />mkdir /Users/$USER/plantenkennis/databases<br />mkdir /Users/$USER/plantenkennis/databases/etiketten<br />mkdir /Users/$USER/plantenkennis/databases/lijsten<br />mkdir /Users/$USER/plantenkennis/foto<br />mkdir /Users/$USER/plantenkennis/fotocomb<br />mkdir /Users/$USER/plantenkennis/iconen<br />mkdir /Users/$USER/plantenkennis/temp<br /><br /># now <span style="color: #0000ff;">move</span> the files <span style="color: #0000ff;">from</span> users/shared/plantenkennisLite naar /users/$user/Plantenkennis<br /><br />mv /Users/shared/PlantenkennisLite/databases<span style="color: #B900B9;">/*.dbf /Users/$USER/plantenkennis/databases<br />mv /Users/shared/PlantenkennisLite/databases/*.dbt /Users/$USER/plantenkennis/databases<br />mv /Users/shared/PlantenkennisLite/etiketten/*.* /Users/$USER/plantenkennis/databases/etiketten<br />mv /Users/shared/PlantenkennisLite/lijsten/*.* /Users/$USER/plantenkennis/databases/lijsten<br />mv /Users/shared/PlantenkennisLite/foto/*.jpg /Users/$USER/plantenkennis/foto<br />mv /Users/shared/PlantenkennisLite/iconen/*.* /Users/$USER/plantenkennis/iconen<br /><br /># I wanted to delete the empty folders, but that does not work?<br /><br /># rmdir /Users/shared/plantenkennisLite/databases<br /># rmdir /Users/shared/plantenkennisLite/etiketten<br /># rmdir /Users/shared/plantenkennisLite/lijsten<br /># rmdir /Users/shared/plantenkennisLite/foto<br /># rmdir /Users/shared/plantenkennisLite/fotocomb<br /># rmdir /Users/shared/plantenkennisLite/iconen<br /># rmdir /Users/shared/plantenkennisLite<br /><br /><br /></span></div>[/code:1gkuxxtc]
macexec with variable
More simple .... use TASKEXEC (). This not run property for problems with script paths but build.sh is launch . @ 150, 40 BUTTON "Terminal" ACTION msginfo( TaskExec( "/bin/sh", Path()+"/build.sh","testget.prg" ) )
macexec with variable
> But if I run TaskExec( "/bin/sh", "MoveFilesLite.sh", ), nothing happens? the path of MoveFilesLite.sh is missing
macexec with variable
Hello Antonio, Yes, you're right. Forgot the path, with the path it works! Thanks again both for the help.
macexec with variable
very good
macro substitution & in fieldnames
It is a piece of code for a mapping system I have 3 databases dbf1 -> with just 1 record filled with fieldnames of dbf 2 ID : "STYLE" NAME : "TITLE" CATMAIN : "CAT1" ... dbf2 -> actual datafile (source data) STYLE : "200444" TITLE : "Safetyshoes dassy" CAT1 : "Safetyshoes" .... dbf3 -> target datafile where i what to put the data from dbf2 ID : "CUST->STYLE" -> should be "200444" NAME : "CUST->TITLE" -> should be 'Safetyshoes dassy" CATMAIN : "CUST->CAT1" ->should be 'Safetyshoes" So, I do something wrong with the & operator Here I miss the logic of converting strings [code=fw:1qo3j7cj]<div class="fw" id="{CB}" style="font-family: monospace;"><br />             <span style="color: #00C800;">if</span> apos > <span style="color: #000000;">0</span>  <span style="color: #B900B9;">// if >0, it is a fieldname else a standard data like "21%"</span><br />                cTarget = <span style="color: #ff0000;">"slave->"</span>+fieldname<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><br /><br />  <span style="color: #B900B9;">//            cField = "CUST->"+aCustfields[i]</span><br />                cField = <span style="color: #ff0000;">"CUST->"</span>+cLookup<br /><br /> <span style="color: #B900B9;">//               cData = &cField // not working</span><br />                cData = cField<br /><br />              &cTarget = cData<br />            <span style="color: #00C800;">else</span>  <span style="color: #B900B9;">// standard data, but no fieldname</span><br />                cData = cField  <br />                &cTarget = cData<br />           <span style="color: #00C800;">endif</span><br /><br /> </div>[/code:1qo3j7cj] Full Function [code=fw:1qo3j7cj]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00C800;">function</span> filldbf<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">Local</span> aCustfields:=<span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><br /><br />   use slave<br />   <span style="color: #0000ff;">select</span> slave<br />   zap<br />   close<br />   use DASSY <span style="color: #00C800;">NEW</span> <span style="color: #0000ff;">alias</span> CUST<br />   use slave <span style="color: #00C800;">NEW</span> <span style="color: #0000ff;">alias</span> slave<br />   use master <span style="color: #00C800;">NEW</span> <span style="color: #0000ff;">alias</span> master<br /><br />   <span style="color: #0000ff;">select</span> cust<br />   <span style="color: #00C800;">for</span> i = <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> cust-><span style="color: #000000;">&#40;</span>FCOUNT<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />      AADD<span style="color: #000000;">&#40;</span>aCustfields,Fieldname<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>  <span style="color: #B900B9;">// make arry with all fieldnames from datafile</span><br />   <span style="color: #00C800;">next</span><br /><br />   <span style="color: #0000ff;">select</span> master<br />   master-><span style="color: #000000;">&#40;</span>dbgotop<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />   nMasterfields = master-><span style="color: #000000;">&#40;</span>fcount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />   cust-><span style="color: #000000;">&#40;</span>dbgotop<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />   nTel = <span style="color: #000000;">0</span><br /><br />   <span style="color: #00C800;">do</span> <span style="color: #00C800;">while</span> !cust-><span style="color: #000000;">&#40;</span>eof<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />      slave-><span style="color: #000000;">&#40;</span>dbappend<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br /><br />      <span style="color: #00C800;">for</span> i = <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> nMasterfields<br /><br />         cWelkField = <span style="color: #ff0000;">"master->"</span>+fieldname<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><br />         clookup = alltrim<span style="color: #000000;">&#40;</span>&cWelkfield<span style="color: #000000;">&#41;</span>        <span style="color: #B900B9;">// data from the masterfile, result = fieldname to look for next</span><br />         <span style="color: #00C800;">if</span> !empty<span style="color: #000000;">&#40;</span>clookup<span style="color: #000000;">&#41;</span><br />            apos = ascan<span style="color: #000000;">&#40;</span>aCustfields,clookup<span style="color: #000000;">&#41;</span>  <span style="color: #B900B9;">// to see if the data is a fieldname, could also be simple data</span><br /><br />             <span style="color: #00C800;">if</span> apos > <span style="color: #000000;">0</span>  <span style="color: #B900B9;">// found as a fieldname</span><br />                cTarget = <span style="color: #ff0000;">"slave->"</span>+fieldname<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><br /><br />  <span style="color: #B900B9;">//            cField = "CUST->"+aCustfields[i]</span><br />                cField = <span style="color: #ff0000;">"CUST->"</span>+cLookup<br /><br /> <span style="color: #B900B9;">//               cData = &cField // not working</span><br />                cData = cField<br /><br />              &cTarget = cData<br />            <span style="color: #00C800;">else</span>  <span style="color: #B900B9;">// standard data, but no fieldname</span><br />                cData = cField  <span style="color: #B900B9;">// GIVES THE DATA, BUT ERROR FOR THE NEXT DO/ENDDO LOOK</span><br />                &cTarget = cData<br />           <span style="color: #00C800;">endif</span><br />         <span style="color: #00C800;">endif</span><br />        <span style="color: #00C800;">next</span><br />      cust-><span style="color: #000000;">&#40;</span>dbskip<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />   <span style="color: #00C800;">enddo</span><br /><br />   <span style="color: #0000ff;">select</span> slave<br />   <span style="color: #0000ff;">xbrowse</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />   close all<br /><span style="color: #00C800;">return</span><br /> </div>[/code:1qo3j7cj] The result is a database filled with the fieldnames, but not the fielddata [img:1qo3j7cj]http&#58;//www&#46;mavecoshop&#46;be/img/fwh&#46;jpg[/img:1qo3j7cj]
macro substitution & in fieldnames
Look, I hope it's what you need [code=fw:1gs9ywpd]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"Fivewin.ch"</span><br /><br />MEMVAR cAlias<br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">Function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">//local cAlias</span><br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> cField<br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> uVal<br />&nbsp; &nbsp;<br />Use <span style="color: #ff0000;">"Customer.dbf"</span> <span style="color: #0000ff;">ALIAS</span> custom<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;cAlias := <span style="color: #0000ff;">Alias</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;<br />&nbsp; &nbsp;cField := <span style="color: #000000;">&#40;</span> cAlias <span style="color: #000000;">&#41;</span>-><span style="color: #000000;">&#40;</span> FieldName<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;? <span style="color: #000000;">&#40;</span> cAlias <span style="color: #000000;">&#41;</span>-><span style="color: #000000;">&#40;</span> FieldName<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span> cAlias <span style="color: #000000;">&#41;</span>-><span style="color: #000000;">&#40;</span> FieldGet<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;uVal := <span style="color: #000000;">&#40;</span> cAlias <span style="color: #000000;">&#41;</span>->First<br />&nbsp; &nbsp;? uVal, cField<br />&nbsp; &nbsp;cField := <span style="color: #ff0000;">"( cAlias )->"</span>+cField<br />&nbsp; &nbsp;? &<span style="color: #000000;">&#40;</span>cField<span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;&<span style="color: #000000;">&#40;</span>cField<span style="color: #000000;">&#41;</span> &nbsp;:= <span style="color: #ff0000;">"Field modified"</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">// &nbsp; &(cField) &nbsp;:= "Homer"</span><br />&nbsp; &nbsp;? <span style="color: #000000;">&#40;</span> cAlias <span style="color: #000000;">&#41;</span>-><span style="color: #000000;">&#40;</span> FieldGet<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #00C800;">Return</span> <span style="color: #00C800;">nil</span><br /><br />&nbsp;</div>[/code:1gs9ywpd]
macro substitution & in fieldnames
Dear Marc, I use as you did but a bit different. [code=fw:2lc2znpr]<div class="fw" id="{CB}" style="font-family: monospace;"><br />RvName := <span style="color: #ff0000;">'MHS->MHS_RV'</span>+<span style="color: #0000ff;">right</span><span style="color: #000000;">&#40;</span>dtos<span style="color: #000000;">&#40;</span>MEMVAR->comdat<span style="color: #000000;">&#41;</span>,<span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><br />&<span style="color: #000000;">&#40;</span>RvName<span style="color: #000000;">&#41;</span> += <span style="color: #0000ff;">round</span><span style="color: #000000;">&#40;</span>TRN->TRN_UNIT * TRN->TRN_QTTY,<span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span><br /> </div>[/code:2lc2znpr]
macro substitution & in fieldnames
Macro substitution is bad: - slow (more slow than dbf field functions) - avoid compiler syntax analisys. Better harbour programming style is do not use macro substitution, so: [code=fw:28eghbkn]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #B900B9;">// With preprocessor &nbsp;is more rapid and clear with pseudo functions:</span><br /><span style="color: #00D7D7;">#Define</span> FPOS_<span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#41;</span> ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#91;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>-> <span style="color: #000000;">&#40;</span> FieldPos<span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#91;</span><span style="color: #000000;">2</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#Define</span> FPUT<span style="color: #000000;">&#40;</span>aTarget, xValue<span style="color: #000000;">&#41;</span> ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#91;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>-> <span style="color: #000000;">&#40;</span> FieldPut<span style="color: #000000;">&#40;</span> FPOS_<span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#41;</span>, xValue<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><span style="color: #00D7D7;">#Define</span> FGET_<span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#41;</span> ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#91;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>-> <span style="color: #000000;">&#40;</span> FieldGet<span style="color: #000000;">&#40;</span> FPOS_<span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#41;</span>, xValue<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br /><span style="color: #B900B9;">// Sample:</span><br />aTarget:= <span style="color: #000000;">&#123;</span><span style="color: #ff0000;">"slave"</span>, fieldname<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><br /><br />FPUT_<span style="color: #000000;">&#40;</span>aTarget, <span style="color: #ff0000;">"hi !"</span><span style="color: #000000;">&#41;</span><br />xVar:= FGET_<span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#41;</span><br />nPos:= FPOS_<span style="color: #000000;">&#40;</span>aTarget<span style="color: #000000;">&#41;</span></div>[/code:28eghbkn] Regards
macro substitution & in fieldnames
Marc: Look at this examples code: PADRON->(DBGOTOP()) DO WHILE !PADRON->(EOF()) IF !TMOVMES->(DBSEEK(CONCEPTO->COD+PADRON->MP,.F.)) TPADRON->(DBAPPEND()) COPIAREG('TPADRON','PADRON') ENDIF PADRON->(DBSKIP()) ENDDO FUNCTION COPIAREG(xBaseEntra,xBaseSale) Local aCampos:={},i,aDatos:={},aCampos2,aAt aCampos:=(xBaseEntra)->(dbstruct()) aCampos2:=(xBaseSale)->(dbstruct()) FOR I:=1 TO LEN(aCampos2) IF ASCAN(aCampos,{|aAt| aAt[1]==aCampos2[i,1]}) >0 (xBaseEntra)->&(aCampos2[i,1]):=( xBaseSale )->&(aCampos2[i,1]) ELSE * ? 'NO EXISTE EL CAMPO EN ',XBASEENTRA,'I=',I,aCampos2[i,1] ENDIF NEXT return nil BUS_DES('PADRON',2,MOVMES->MP,'ESPE') Function BUS_DES(XARCH, XORDEN, XCLAVE, XCAMPO) Local RET:=SPAC(0) , ORD_ACT, AREA_ACT := SELECT(), cRegis IF SELECT(XARCH) == 0 USE (WPATH + "\" + XARCH) SHARED NEW ENDIF DBSELECTAR(XARCH) cRegis:=RECNO() ORD_ACT = INDEXORD() SET ORDER TO XORDEN DBSEEK((XCLAVE)) IF FOUND() .AND. !DELETED() RET = EVAL(FIELDBLOCK(XCAMPO)) ELSE DBGOBOTTOM() RET = SPACE(LEN(EVAL(FIELDBLOCK(XCAMPO)))) ENDIF SET ORDER TO ORD_ACT DBGOTO(cRegis) SELECT(AREA_ACT) RETURN RET Regards, Daniel Puente