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;">(</span> .t. <span style="color: #000000;">)</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://www.box.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;">(</span> <span style="color: #ff0000;">"cAlias"</span> <span style="color: #000000;">)</span><br /> AdsPrepareSql<span style="color: #000000;">(</span> cSql <span style="color: #000000;">)</span><br /> binImage := MemoRead<span style="color: #000000;">(</span> cFile <span style="color: #000000;">)</span><br /> AdsSetBinary<span style="color: #000000;">(</span> <span style="color: #ff0000;">"bindata"</span>, binImage <span style="color: #000000;">)</span><br /> AdsExecuteSql<span style="color: #000000;">(</span><span style="color: #000000;">)</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;">(</span> ADSSETBINARY <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;<br /><br />ulRetVal = AdsSetBinary<span style="color: #000000;">(</span> pArea->hStatement,<br /> <span style="color: #000000;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span>,<br /> <span style="color: #000000;">(</span>hb_pcount<span style="color: #000000;">(</span><span style="color: #000000;">)</span> > <span style="color: #000000;">2</span> && hb_parni<span style="color: #000000;">(</span> <span style="color: #000000;">3</span> <span style="color: #000000;">)</span> == <span style="color: #000000;">1</span><span style="color: #000000;">)</span> ? ADS_BINARY : <span style="color: #000000;">ADS_IMAGE</span>,<br /> hb_parclen<span style="color: #000000;">(</span> <span style="color: #000000;">2</span> <span style="color: #000000;">)</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;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span> <span style="color: #000000;">2</span> <span style="color: #000000;">)</span>, <br /> hb_parclen<span style="color: #000000;">(</span> <span style="color: #000000;">2</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span>;<br /><br />hb_retl<span style="color: #000000;">(</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">)</span>;<br /><span style="color: #000000;">}</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;">(</span> ADSSETSTRING <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;<br /><br />ulRetVal = AdsSetString<span style="color: #000000;">(</span> pArea->hStatement,<br /> <span style="color: #000000;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span>,<br /> <span style="color: #000000;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span><span style="color: #000000;">2</span><span style="color: #000000;">)</span>, <br /> hb_parclen<span style="color: #000000;">(</span><span style="color: #000000;">2</span><span style="color: #000000;">)</span> <span style="color: #000000;">)</span>;<br /> <br />hb_retl<span style="color: #000000;">(</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">)</span>;<br /><span style="color: #000000;">}</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;">(</span> ADSSETDATE <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;<br />ulRetVal = AdsSetDate<span style="color: #000000;">(</span> pArea->hStatement,<br /> <span style="color: #000000;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span>,<br /> <span style="color: #000000;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span><span style="color: #000000;">2</span><span style="color: #000000;">)</span>, <br /> hb_parclen<span style="color: #000000;">(</span><span style="color: #000000;">2</span><span style="color: #000000;">)</span> <span style="color: #000000;">)</span>;<br />hb_retl<span style="color: #000000;">(</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">)</span>;<br /><span style="color: #000000;">}</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;">(</span> ADSSETLONG <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;<br />ulRetVal = AdsSetLong<span style="color: #000000;">(</span> pArea->hStatement,<br /> <span style="color: #000000;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span>, <br /> hb_parnl<span style="color: #000000;">(</span><span style="color: #000000;">2</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>;<br />hb_retl<span style="color: #000000;">(</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">)</span>;<br /><span style="color: #000000;">}</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;">(</span> ADSSETDOUBLE <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;<br />ulRetVal = AdsSetDouble<span style="color: #000000;">(</span> pArea->hStatement,<br /> <span style="color: #000000;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span>, <br /> hb_parnd<span style="color: #000000;">(</span><span style="color: #000000;">2</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>;<br />hb_retl<span style="color: #000000;">(</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">)</span>;<br /><span style="color: #000000;">}</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;">(</span> ADSSETLOGICAL <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;<br />ulRetVal = AdsSetLogical<span style="color: #000000;">(</span> pArea->hStatement,<span style="color: #000000;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span>, hb_parl<span style="color: #000000;">(</span><span style="color: #000000;">2</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>;<br />hb_retl<span style="color: #000000;">(</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">)</span>;<br /><span style="color: #000000;">}</span><br /><br /><span style="color: #B900B9;">//RCB</span><br /><span style="color: #00C800;">HB_FUNC</span><span style="color: #000000;">(</span> ADSSETNULL <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br />UNSIGNED32 ulRetVal;<br />ADSAREAP pArea = hb_adsGetWorkAreaPointer<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;<br />ulRetVal = AdsSetNull<span style="color: #000000;">(</span> <span style="color: #000000;">(</span>hb_parnl<span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span>==<span style="color: #000000;">0</span><span style="color: #000000;">)</span> ? pArea->hOrdCurrent : <span style="color: #000000;">hb_parnl</span><span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span>,<span style="color: #000000;">(</span>char*<span style="color: #000000;">)</span> hb_parc<span style="color: #000000;">(</span><span style="color: #000000;">2</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>;<br />hb_retl<span style="color: #000000;">(</span> ulRetVal == AE_SUCCESS <span style="color: #000000;">)</span>;<br /><span style="color: #000000;">}</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;"> FIUNLOAD<span style="color: #000000;">(</span> hDib <span style="color: #000000;">)</span><br /> </div>[/code:ed3lz9de]
before the line
[code=fw:ed3lz9de]<div class="fw" id="{CB}" style="font-family: monospace;"> FI_CloseMemory<span style="color: #000000;">(</span> hMem <span style="color: #000000;">)</span><br /> </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.h>
// Fetches the MAC address and prints it
static void GetMACaddress(void)
{
IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information
// for up to 16 NICs
DWORD dwBufLen = sizeof(AdapterInfo); // Save memory size of buffer
DWORD dwStatus = GetAdaptersInfo( // Call GetAdapterInfo
AdapterInfo, // [out] buffer to receive data
&dwBufLen); // [in] size of receive data buffer
// assert(dwStatus == ERROR_SUCCESS); // Verify return value is
// valid, no buffer overflow
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to
// current adapter info
do {
// PrintMACaddress(pAdapterInfo->Address); // Print MAC address
pAdapterInfo = pAdapterInfo->Next; // Progress through
// linked list
}
while(pAdapterInfo); // Terminate if last adapter
}
[/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(pnNo, pnBase)
Local cRetVal := ""
Local nCount := 0
Local acDigits := {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
Local nNo := 0
For nCount := 65 to 65 + pnBase - 11
aadd(acDigits, chr(nCount))
Next
For nCount := 7 to 0 step - 1
nNo := int(pnNo / (pnBase**nCount))
If nNo > 0 .or. !empty(cRetVal)
cRetVal += acDigits[nNo + 1]
pnNo -= nNo * pnBase**nCount
Endif
Next
Return cRetval
Function GetMacAddresses()
local aaTemp := {}
local axTemp
local aaRetval
local cMac := ""
aaTemp := _GETMACADDRESSES()
aaRetval := {}
For each axTemp in aaTemp
cMac := ""
cMac += padl(Dec2x(axTemp[3], 16), 2, "0") + "-"
cMac += padl(Dec2x(axTemp[4], 16), 2, "0") + "-"
cMac += padl(Dec2x(axTemp[5], 16), 2, "0") + "-"
cMac += padl(Dec2x(axTemp[6], 16), 2, "0") + "-"
cMac += padl(Dec2x(axTemp[7], 16), 2, "0") + "-"
cMac += padl(Dec2x(axTemp[8], 16), 2, "0")
aadd(aaRetval, {axTemp[2], cMac})
Next
return aaRetval
//---------------------------------------------------------------------------------------------//
#pragma begindump
#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>
#ifdef __FLAT__
#include <ShellApi.h>
#endif
#ifdef __HARBOUR__
#include <hbapiitm.h>
#include <hbdate.h>
#include <hbset.h>
#endif
#include <iphlpapi.h>
// Fetches the MAC address and prints it
HB_FUNC( _GETMACADDRESSES )
{
PHB_ITEM paAddress = hb_itemArrayNew( 0 );
IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information
// for up to 16 NICs
DWORD dwBufLen = sizeof(AdapterInfo); // Save memory size of buffer
DWORD dwStatus = GetAdaptersInfo( // Call GetAdapterInfo
AdapterInfo, // [out] buffer to receive data
&dwBufLen); // [in] size of receive data buffer
// assert(dwStatus == ERROR_SUCCESS); // Verify return value is
// valid, no buffer overflow
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to
// current adapter info
PHB_ITEM pName = hb_itemNew(NULL);
PHB_ITEM pDesc = hb_itemNew(NULL);
PHB_ITEM pAddress = hb_itemNew(NULL);
char cMacAddress[17];
do {
// PrintMACaddress(pAdapterInfo->Address); // Print MAC address
PHB_ITEM pSubArray = hb_itemArrayNew(8);
hb_arraySet(pSubArray, 1, hb_itemPutC(pName, pAdapterInfo->AdapterName));
hb_arraySet(pSubArray, 2, hb_itemPutC(pDesc, pAdapterInfo->Description));
// sprintf( cMacAddress, "%x-%x-%x-%x-%x-%x", pAdapterInfo->Address[0], pAdapterInfo->Address[1], pAdapterInfo->Address[2]
hb_arraySet(pSubArray, 3, hb_itemPutNL(pDesc, pAdapterInfo->Address[0]));
hb_arraySet(pSubArray, 4, hb_itemPutNL(pDesc, pAdapterInfo->Address[1]));
hb_arraySet(pSubArray, 5, hb_itemPutNL(pDesc, pAdapterInfo->Address[2]));
hb_arraySet(pSubArray, 6, hb_itemPutNL(pDesc, pAdapterInfo->Address[3]));
hb_arraySet(pSubArray, 7, hb_itemPutNL(pDesc, pAdapterInfo->Address[4]));
hb_arraySet(pSubArray, 8, hb_itemPutNL(pDesc, pAdapterInfo->Address[5]));
hb_arrayAdd(paAddress, pSubArray);
hb_itemRelease(pSubArray);
pAdapterInfo = pAdapterInfo->Next; // Progress through
// linked list
}
while(pAdapterInfo); // Terminate if last adapter
hb_itemRelease(pName);
hb_itemRelease(pDesc);
hb_itemRelease(pAddress);
hb_itemRelease(hb_itemReturn(paAddress));
}
#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.ch"
/*
* Retrieves adapter information for the local computer.
* Original code by AlexSchaft
* http://fivetechsoft.com/forums/viewtopic.php?t=77&postdays=0&postorder=asc&start=15
*
* Changed by Vailton Renato @ 07/06/2007 - 09:24:03
*/
function main()
local NICs := GetMacAddresses()
local crlf,i,s
crlf := chr(13)+chr(10)
FOR i := 1 TO len( NICs )
* An ANSI character string of the description for the adapter.
s := "Description: " + NICs[i,1] + crlf
* MAC Address
s += "MAC Address: " + NICs[i,2] + crlf
* An ANSI character string of the name of the adapter.
s += "Adapter Name: " + NICs[i,3] + crlf
s += crlf
* IP info
s += "IP: " + NICs[i,4] + crlf
s += "Mask: " + NICs[i,5] + " / "
s += "Gateway: " + NICs[i,6] + crlf
s += crlf
* DHCP Sever IP or empty string ""
if !Empty( NICs[i,7] )
s += "DHCP: " + NICs[i,7] + " / "
* The time when the current DHCP lease was obtained.
s += "Lease Obtained: " + alltrim( str( NICs[i,8] ))+ crlf
else
s += 'DHCP disabled'
end
* Primary WINS server
if !Empty( NICs[i,9] )
s += "Pimary WINS: " + NICs[i,9] + crlf
end
* Secondary WINS server
if !Empty( NICs[i,9] )
s += "Secondary WINS: " + NICs[i,10] + crlf
end
? s
End
return nil
//---------------------------------------------------------------------------------------------//
#pragma begindump
#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>
#ifdef __FLAT__
#include <ShellApi.h>
#endif
#ifdef __HARBOUR__
#include <hbapiitm.h>
#include <hbdate.h>
#include <hbset.h>
#endif
#include <iphlpapi.h>
// Fetches the MAC address and prints it
HB_FUNC( GETMACADDRESSES )
{
IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information
// for up to 16 NICs
// http://msdn2.microsoft.com/En-US/library/aa366062.aspx
DWORD dwBufLen = sizeof(AdapterInfo); // Save memory size of buffer
DWORD dwStatus = GetAdaptersInfo( // Call GetAdapterInfo
AdapterInfo, // [out] buffer to receive data
&dwBufLen); // [in] size of receive data buffer
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to
// current adapter info
char cMacAddress[17];
PHB_ITEM pItem;
PHB_ITEM paAddress = hb_itemArrayNew( 0 );
// Verify return value is valid, no buffer overflow...
if (dwStatus != ERROR_SUCCESS)
{
hb_itemRelease(hb_itemReturn(paAddress));
return;
}
pItem = hb_itemNew(NULL);
do {
PHB_ITEM pSubArray = hb_itemArrayNew(10);
// Description of NIC
hb_arraySet(pSubArray, 1, hb_itemPutC(pItem, pAdapterInfo->Description));
// MAC address
sprintf( cMacAddress, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", pAdapterInfo->Address[0], pAdapterInfo->Address[1], pAdapterInfo->Address[2],
pAdapterInfo->Address[3], pAdapterInfo->Address[4], pAdapterInfo->Address[5] );
hb_strUpper( cMacAddress, strlen(cMacAddress));
hb_arraySet(pSubArray, 2, hb_itemPutC(pItem, cMacAddress ));
// GUID of NIC
hb_arraySet(pSubArray, 3, hb_itemPutC(pItem, pAdapterInfo->AdapterName));
// IP Address
hb_arraySet(pSubArray, 4, hb_itemPutC(pItem, pAdapterInfo->IpAddressList.IpAddress.String ));
// IP Mask
hb_arraySet(pSubArray, 5, hb_itemPutC(pItem, pAdapterInfo->IpAddressList.IpMask.String ));
// IP Gateway
hb_arraySet(pSubArray, 6, hb_itemPutC(pItem, pAdapterInfo->GatewayList.IpAddress.String ));
// DHCP server IP & Lease Obtained
if (pAdapterInfo->DhcpEnabled)
{
hb_arraySet(pSubArray, 7, hb_itemPutC( pItem, pAdapterInfo->DhcpServer.IpAddress.String ));
hb_arraySet(pSubArray, 8, hb_itemPutNL(pItem, pAdapterInfo->LeaseObtained ));
} else {
hb_arraySet(pSubArray, 7, hb_itemPutC( pItem, "" ));
hb_arraySet(pSubArray, 8, hb_itemPutNI(pItem, 0 ));
}
// WINS server info - Primary & Secondary ip address
if (pAdapterInfo->HaveWins)
{
hb_arraySet(pSubArray, 9, hb_itemPutC( pItem, pAdapterInfo->PrimaryWinsServer.IpAddress.String ));
hb_arraySet(pSubArray, 10, hb_itemPutC( pItem, pAdapterInfo->SecondaryWinsServer.IpAddress.String ));
} else {
hb_arraySet(pSubArray, 9, hb_itemPutC( pItem, "" ));
hb_arraySet(pSubArray, 10, hb_itemPutC( pItem, "" ));
}
hb_arrayAdd(paAddress, pSubArray);
hb_itemRelease(pSubArray);
pAdapterInfo = pAdapterInfo->Next; // Progress through
// linked list
}
while(pAdapterInfo); // Terminate if last adapter
hb_itemRelease(pItem);
hb_itemRelease(hb_itemReturn(paAddress));
}
#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[18]
[/code:1z7gw74x]
and using
[code:1z7gw74x]
sprintf( cMacAddress, "%02X-%02X-%02X-%02X-%02X-%02X", pAdapterInfo->Address[0], pAdapterInfo->Address[1], pAdapterInfo->Address[2],
pAdapterInfo->Address[3], pAdapterInfo->Address[4], pAdapterInfo->Address[5]);
[/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( GetNetCardID() ) == "C"
MsgInfo( GetNetCardID() )
else
aAdapters = GetNetCardID()
for n = 1 to Len( aAdapters )
MsgInfo( aAdapters[ n ] )
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( GETMAC )
{
IP_ADAPTER_ADDRESSES AdapterInfo[16]; // Allocate information
// for up to 16 NICs
DWORD dwBufLen = sizeof(AdapterInfo); // Save memory size of buffer
DWORD dwStatus = GetAdaptersAdresses( // Call GetAdapterInfo
AF_INET,0,0,
AdapterInfo, // [out] buffer to receive data
&dwBufLen); // [in] size of receive data buffer
PIP_ADAPTER_ADDRESSES pAdapterInfo = AdapterInfo; // Contains pointer to
// current adapter info
char cMacAddress[18];
PHB_ITEM pItem;
PHB_ITEM paAddress = hb_itemArrayNew( 0 );
// Verify return value is valid, no buffer overflow...
if (dwStatus != ERROR_SUCCESS)
{
hb_itemRelease(hb_itemReturn(paAddress));
return;
}
pItem = hb_itemNew(NULL);
do {
PHB_ITEM pSubArray = hb_itemArrayNew(3);
// Description of NIC
hb_arraySet(pSubArray, 1, hb_itemPutC(pItem, pAdapterInfo->Description));
// MAC address
sprintf( cMacAddress, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", pAdapterInfo->PhysicalAddress[0],
pAdapterInfo->PhysicalAddress[1],
pAdapterInfo->PhysicalAddress[2],
pAdapterInfo->PhysicalAddress[3],
pAdapterInfo->PhysicalAddress[4],
pAdapterInfo->PhysicalAddress[5] );
hb_strUpper( cMacAddress, strlen(cMacAddress));
hb_arraySet(pSubArray, 2, hb_itemPutC(pItem, cMacAddress ));
// GUID of NIC
hb_arraySet(pSubArray, 3, hb_itemPutC(pItem, pAdapterInfo->AdapterName));
pAdapterInfo = pAdapterInfo->Next; // Progress through
// linked list
}
while(pAdapterInfo); // Terminate if last adapter
hb_itemRelease(pItem);
hb_itemRelease(hb_itemReturn(paAddress));
}
[/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( GETMAC )
{
IP_ADAPTER_ADDRESSES AdapterInfo[16]; // Allocate information
DWORD dwBufLen = sizeof(AdapterInfo); // Save memory size of buffer
ULONG flags = GAA_FLAG_SKIP_UNICAST; // Set the flags
ULONG family = AF_INET; // only IP4
DWORD dwStatus = GetAdaptersAddresses( // Call GetAdapterInfo
family,flags,NULL,
AdapterInfo, // [out] buffer to receive data
&dwBufLen); // [in] size of receive data buffer
PIP_ADAPTER_ADDRESSES pAdapterInfo = AdapterInfo; // Contains pointer to
// current adapter info
char cMacAddress[18];
PHB_ITEM pItem;
PHB_ITEM paAddress = hb_itemArrayNew( 0 );
// Verify return value is valid, no buffer overflow...
if (dwStatus != ERROR_SUCCESS)
{
hb_itemRelease(hb_itemReturn(paAddress));
return;
}
pItem = hb_itemNew(NULL);
do {
PHB_ITEM pSubArray = hb_itemArrayNew(4);
// Description of NIC
hb_arraySet(pSubArray, 1, hb_itemPutC(pItem, pAdapterInfo->Description)); ] // *** Suspicious pointer conversion ***
// MAC address
sprintf( cMacAddress, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
pAdapterInfo->PhysicalAddress[0], pAdapterInfo->PhysicalAddress[1], pAdapterInfo->PhysicalAddress[2], pAdapterInfo->PhysicalAddress[3], pAdapterInfo->PhysicalAddress[4], pAdapterInfo->PhysicalAddress[5] );
hb_strUpper( cMacAddress, strlen(cMacAddress));
hb_arraySet(pSubArray, 2, hb_itemPutC(pItem, cMacAddress ));
// GUID of NIC
hb_arraySet(pSubArray, 3, hb_itemPutC(pItem, pAdapterInfo->FriendlyName)); // *** Suspicious pointer conversion ***
// Type
hb_arraySet(pSubArray, 4, hb_itemPutNI (pItem, pAdapterInfo->IfType));
hb_arrayAdd(paAddress, pSubArray);
hb_itemRelease(pSubArray);
pAdapterInfo = pAdapterInfo->Next; // Progress through
// linked list
}
while(pAdapterInfo); // Terminate if last adapter
hb_itemRelease(pItem);
hb_itemRelease(hb_itemReturn(paAddress));
}[/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(paAddress, pSubArray);
hb_itemRelease(pSubArray); [/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 ()
LOCAL n
LOCAL cDescription, cMac, cType, cName
LOCAL aNic := GetMac ()
if ValType (aNic ) == "A"
for n := 1 TO Len (aNic)
cDescription := aNic [n,1]
cMac := aNic [n,2]
cName := aNic [n,3]
cType := cValToChar (aNic [n,4])
IF cType = "6"
MsgInfo( "Description: "+cDescription+CRLF+;
"Mac : "+cMac+CRLF+;
"Name : "+cName+CRLF+;
"Type : "+cType,;
"NIC" )
endif
next
endif
RETURN (nil)[/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;
......
pText = HB_FUN_WIDETOANSI (pAdapterInfo->Description);
hb_arraySet(pSubArray, 1, hb_itemPutC(pItem, pText));
hb_xfree (pText);[/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://developer.apple.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://stackoverflow.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;">(</span> MACEXEC <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br /> NSWorkspace * workspace;<br /><br /> <span style="color: #00C800;">if</span><span style="color: #000000;">(</span> hb_pcount<span style="color: #000000;">(</span><span style="color: #000000;">)</span> > <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> workspace = <span style="color: #000000;">[</span> <span style="color: #000000;">[</span> <span style="color: #000000;">[</span> NSWorkspace alloc <span style="color: #000000;">]</span> <span style="color: #0000ff;">init</span> <span style="color: #000000;">]</span> autorelease <span style="color: #000000;">]</span>;<br /> <br /> <span style="color: #00C800;">if</span><span style="color: #000000;">(</span> hb_pcount<span style="color: #000000;">(</span><span style="color: #000000;">)</span> == <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> hb_retl<span style="color: #000000;">(</span> <span style="color: #000000;">[</span> workspace launchapplication: <span style="color: #000000;">hb_NSSTRING</span><span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">]</span> <span style="color: #000000;">)</span>;<br /><br /> <span style="color: #00C800;">if</span><span style="color: #000000;">(</span> hb_pcount<span style="color: #000000;">(</span><span style="color: #000000;">)</span> == <span style="color: #000000;">2</span> <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> NSURL * url = <span style="color: #000000;">[</span> NSURL fileURLWithPath: <span style="color: #000000;">[</span> workspace fullPathForApplication: <span style="color: #000000;">hb_NSSTRING</span><span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">]</span> <span style="color: #000000;">]</span>;<br /> NSArray * arguments = <span style="color: #000000;">[</span> NSArray arrayWithObjects: <span style="color: #000000;">hb_NSSTRING</span><span style="color: #000000;">(</span> <span style="color: #000000;">2</span> <span style="color: #000000;">)</span>, <span style="color: #00C800;">nil</span> <span style="color: #000000;">]</span>; <br /> NSError * error = <span style="color: #00C800;">nil</span>;<br /> <br /> hb_retl<span style="color: #000000;">(</span> <span style="color: #000000;">[</span> workspace launchApplicationAtURL:<span style="color: #000000;">url</span> options:<span style="color: #000000;">0</span> <br /> configuration:<span style="color: #000000;">[</span>NSDictionary dictionaryWithObject:<span style="color: #000000;">arguments</span> forKey:<span style="color: #000000;">NSWorkspaceLaunchConfigurationArguments</span><span style="color: #000000;">]</span> <br /> error:<span style="color: #000000;">error</span> <span style="color: #000000;">]</span> <span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /> <span style="color: #000000;">}</span> <br /><span style="color: #000000;">}</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;">(</span> MACEXEC <span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br /> NSWorkspace * workspace;<br /><br /> <span style="color: #00C800;">if</span><span style="color: #000000;">(</span> hb_pcount<span style="color: #000000;">(</span><span style="color: #000000;">)</span> > <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> workspace = <span style="color: #000000;">[</span> <span style="color: #000000;">[</span> <span style="color: #000000;">[</span> NSWorkspace alloc <span style="color: #000000;">]</span> <span style="color: #0000ff;">init</span> <span style="color: #000000;">]</span> autorelease <span style="color: #000000;">]</span>;<br /> <br /> <span style="color: #00C800;">if</span><span style="color: #000000;">(</span> hb_pcount<span style="color: #000000;">(</span><span style="color: #000000;">)</span> == <span style="color: #000000;">1</span> <span style="color: #000000;">)</span><br /> hb_retl<span style="color: #000000;">(</span> <span style="color: #000000;">[</span> workspace launchapplication: <span style="color: #000000;">hb_NSSTRING_par</span><span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">]</span> <span style="color: #000000;">)</span>;<br /><br /> <span style="color: #00C800;">if</span><span style="color: #000000;">(</span> hb_pcount<span style="color: #000000;">(</span><span style="color: #000000;">)</span> == <span style="color: #000000;">2</span> <span style="color: #000000;">)</span><br /> <span style="color: #000000;">{</span><br /> NSURL * url = <span style="color: #000000;">[</span> NSURL fileURLWithPath: <span style="color: #000000;">[</span> workspace fullPathForApplication: <span style="color: #000000;">hb_NSSTRING_par</span><span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">]</span> <span style="color: #000000;">]</span>;<br /> NSArray * arguments = <span style="color: #000000;">[</span> NSArray arrayWithObjects: <span style="color: #000000;">hb_NSSTRING_par</span><span style="color: #000000;">(</span> <span style="color: #000000;">2</span> <span style="color: #000000;">)</span>, <span style="color: #00C800;">nil</span> <span style="color: #000000;">]</span>; <br /> NSError * error = <span style="color: #00C800;">nil</span>;<br /> <br /> hb_retl<span style="color: #000000;">(</span> <span style="color: #000000;">[</span> workspace launchApplicationAtURL:<span style="color: #000000;">url</span> options:<span style="color: #000000;">0</span> <br /> configuration:<span style="color: #000000;">[</span>NSDictionary dictionaryWithObject:<span style="color: #000000;">arguments</span> forKey:<span style="color: #000000;">NSWorkspaceLaunchConfigurationArguments</span><span style="color: #000000;">]</span> <br /> error:<span style="color: #000000;">error</span> <span style="color: #000000;">]</span> <span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span><br /> <span style="color: #000000;">}</span> <br /><span style="color: #000000;">}</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:
[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;">(</span>i<span style="color: #000000;">)</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;">(</span><span style="color: #000000;">)</span><br /> <span style="color: #00C800;">Local</span> aCustfields:=<span style="color: #000000;">{</span><span style="color: #000000;">}</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;">(</span>FCOUNT<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> AADD<span style="color: #000000;">(</span>aCustfields,Fieldname<span style="color: #000000;">(</span>i<span style="color: #000000;">)</span><span style="color: #000000;">)</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;">(</span>dbgotop<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> nMasterfields = master-><span style="color: #000000;">(</span>fcount<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> cust-><span style="color: #000000;">(</span>dbgotop<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</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;">(</span>eof<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> slave-><span style="color: #000000;">(</span>dbappend<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</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;">(</span>i<span style="color: #000000;">)</span><br /> clookup = alltrim<span style="color: #000000;">(</span>&cWelkfield<span style="color: #000000;">)</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;">(</span>clookup<span style="color: #000000;">)</span><br /> apos = ascan<span style="color: #000000;">(</span>aCustfields,clookup<span style="color: #000000;">)</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;">(</span>i<span style="color: #000000;">)</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;">(</span>dbskip<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</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;">(</span><span style="color: #000000;">)</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://www.mavecoshop.be/img/fwh.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;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #B900B9;">//local cAlias</span><br /> <span style="color: #00C800;">local</span> cField<br /> <span style="color: #00C800;">local</span> uVal<br /> <br />Use <span style="color: #ff0000;">"Customer.dbf"</span> <span style="color: #0000ff;">ALIAS</span> custom<br /> <br /> cAlias := <span style="color: #0000ff;">Alias</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /> <br /> cField := <span style="color: #000000;">(</span> cAlias <span style="color: #000000;">)</span>-><span style="color: #000000;">(</span> FieldName<span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /> ? <span style="color: #000000;">(</span> cAlias <span style="color: #000000;">)</span>-><span style="color: #000000;">(</span> FieldName<span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span>, <span style="color: #000000;">(</span> cAlias <span style="color: #000000;">)</span>-><span style="color: #000000;">(</span> FieldGet<span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /> uVal := <span style="color: #000000;">(</span> cAlias <span style="color: #000000;">)</span>->First<br /> ? uVal, cField<br /> cField := <span style="color: #ff0000;">"( cAlias )->"</span>+cField<br /> ? &<span style="color: #000000;">(</span>cField<span style="color: #000000;">)</span><br /> &<span style="color: #000000;">(</span>cField<span style="color: #000000;">)</span> := <span style="color: #ff0000;">"Field modified"</span><br /> <span style="color: #B900B9;">// &(cField) := "Homer"</span><br /> ? <span style="color: #000000;">(</span> cAlias <span style="color: #000000;">)</span>-><span style="color: #000000;">(</span> FieldGet<span style="color: #000000;">(</span> <span style="color: #000000;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">Return</span> <span style="color: #00C800;">nil</span><br /><br /> </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;">(</span>dtos<span style="color: #000000;">(</span>MEMVAR->comdat<span style="color: #000000;">)</span>,<span style="color: #000000;">2</span><span style="color: #000000;">)</span><br />&<span style="color: #000000;">(</span>RvName<span style="color: #000000;">)</span> += <span style="color: #0000ff;">round</span><span style="color: #000000;">(</span>TRN->TRN_UNIT * TRN->TRN_QTTY,<span style="color: #000000;">2</span><span style="color: #000000;">)</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 is more rapid and clear with pseudo functions:</span><br /><span style="color: #00D7D7;">#Define</span> FPOS_<span style="color: #000000;">(</span>aTarget<span style="color: #000000;">)</span> ;<br /> <span style="color: #000000;">(</span>aTarget<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span><span style="color: #000000;">)</span>-> <span style="color: #000000;">(</span> FieldPos<span style="color: #000000;">(</span>aTarget<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span><span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /><span style="color: #00D7D7;">#Define</span> FPUT<span style="color: #000000;">(</span>aTarget, xValue<span style="color: #000000;">)</span> ;<br /> <span style="color: #000000;">(</span>aTarget<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span><span style="color: #000000;">)</span>-> <span style="color: #000000;">(</span> FieldPut<span style="color: #000000;">(</span> FPOS_<span style="color: #000000;">(</span>aTarget<span style="color: #000000;">)</span>, xValue<span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /><span style="color: #00D7D7;">#Define</span> FGET_<span style="color: #000000;">(</span>aTarget<span style="color: #000000;">)</span> ;<br /> <span style="color: #000000;">(</span>aTarget<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span><span style="color: #000000;">)</span>-> <span style="color: #000000;">(</span> FieldGet<span style="color: #000000;">(</span> FPOS_<span style="color: #000000;">(</span>aTarget<span style="color: #000000;">)</span>, xValue<span style="color: #000000;">)</span> <span style="color: #000000;">)</span><br /><br /><span style="color: #B900B9;">// Sample:</span><br />aTarget:= <span style="color: #000000;">{</span><span style="color: #ff0000;">"slave"</span>, fieldname<span style="color: #000000;">(</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">}</span><br /><br />FPUT_<span style="color: #000000;">(</span>aTarget, <span style="color: #ff0000;">"hi !"</span><span style="color: #000000;">)</span><br />xVar:= FGET_<span style="color: #000000;">(</span>aTarget<span style="color: #000000;">)</span><br />nPos:= FPOS_<span style="color: #000000;">(</span>aTarget<span style="color: #000000;">)</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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.