Visualizza post

Questa sezione ti permette di visualizzare tutti i post inviati da questo utente. N.B: puoi vedere solo i post relativi alle aree dove hai l'accesso.


Topics - eloaders

Pagine: [1]
1
Programmazione / Operator << >> In gambas
« il: 29 Novembre 2019, 18:24:18 »
Again I have to ask. I can't understand how to convert some code from C to gambas

Source file adress: https://github.com/lpereira/hardinfo/blob/master/modules/devices/spd-decode.c

Part of the code I'm trying to understand:

Codice: [Seleziona]
  ' unsigned int sdr_capacity = 256 << (bytes[4] & 0xF);
  ' unsigned int sdr_width = 4 << (bytes[7] & 0x7);
  ' unsigned int bus_width = 8 << (bytes[8] & 0x7);
  ' unsigned int ranks = 1 + ((bytes[7] >> 3) & 0x7);

My code:

Codice: [Seleziona]
  Print Lsl(CInt(bb[4] & &HF), 256)
 
  Print Lsl(bb[7], 3) & &h7
  Print Lsl(bb[8], 7) & &h7
  Print 1 + (Lsr(bb[7], 2) & &h7)

I would like an explanation or code that I could understand.

2
Programmazione / Set own date to mysql table
« il: 02 Febbraio 2017, 00:07:56 »
I have the code, however, the matter is simple. I have a page editing post, to decide the date of publication. However, gambas returns me an error.

Codice: [Seleziona]
' Gambas class file

Public rPosts As Result
Public Sub _new()
  Dim POSTDATE As String
  'Print Request.Post["post_date"] & " " & Request.Post["post_time"]
  If Request.Method = "POST" Then
    If IsInteger(Request.Post["post_id"]) Then
      rPosts = DB.Edit("posts", " id = &1", Request.Post["post_id"])
      If MFunctions.IsMimeType(Request.Files["post_image"], "image/png") = True Then
        If Request.Post.Exist("post_image") = True Then
          Try Copy Request.Post.Files["post_image"] To "" & Application.Path & "/Uploads/Images/" & Request.Post["post_image"] & "" & ""
          rPosts!post_image = "/Uploads/Images/" & Request.Post["post_image"]
        Endif
      Endif
      rPosts!post_title = Request.Post["post_title"]
      rPosts!post_content = Request.Post["post_content"]
      rPosts!post_tags = Request.Post["post_tags"]
      rPosts!post_name = Request.Post["post_name"]
      rPosts!post_author = Request.Post["post_author"]
      Print Now
      POSTDATE = URL.UnQuote(Replace(Request.Post["post_date"], "\n", ""))
      'Print CFloat(Val(Request.Post["post_date"]))
      'Print URL.UnQuote(Request.Post["post_date"])
      'Print CDate(CInteger(Replace(Request.Post["post_date"], ".", "") & Replace(Request.Post["post_time"], ":", "")))
      rPosts!post_date = POSTDATE
      rPosts!post_type = Request.Post["post_type"]
      rPosts!post_status = Request.Post["post_status"]
      rPosts.Update
     
    Else If Request.Post["post_id"] = "new" Then
      rPosts = DB.Create("posts")
     
      If Request.Post.Exist("post_image") = True Then
        If MFunctions.IsMimeType(Request.Files["post_image"], "image/png") = True Then
          Try Copy Request.Post.Files["post_image"] To "" & Application.Path & "/Uploads/Images/" & Request.Post["post_image"] & "" & ""
          rPosts!post_image = "/Uploads/Images/" & Request.Post["post_image"]
          rPosts!post_image_alt = Request.Post["post_image"]
        Endif
      Endif
      rPosts!post_title = Request.Post["post_title"]
      rPosts!post_content = Request.Post["post_content"]
      rPosts!post_tags = Request.Post["post_tags"]
      rPosts!post_name = Request.Post["post_name"]
      rPosts!post_author = Request.Post["post_author"]
      'rPosts!post_date = Now
      'rPosts!post_date = Request.Post["post_date"] & " " & Request.Post["post_time"]
      rPosts!post_type = Request.Post["post_type"]
      rPosts!post_status = Request.Post["post_status"]
      rPosts.Update
    Endif
  Endif
 
  If Request.Method = "GET" Then
    If Request.Get["action"] = "delete" Then
      DB.Delete("posts", "ID = &1", Request.Get["id"])
    Endif
   
  Endif
 
End


I'm talking about: rPosts!post_date = POSTDATE

type of table post_date is datetime with default values CURRENT_TIMESTAMP   ON UPDATE CURRENT_TIMESTAMP

3
Programmazione / Gambas Rnd (Web programming)
« il: 30 Dicembre 2016, 22:38:51 »
I created a sample code:

Codice: [Seleziona]
<%
Dim randoms As String
Dim I As Integer
%>

<html>
<body>
<% For I = 1 To 6%>
<%randoms &= Hex$(Int(Rnd(65536)), 4)%>
<%Next%>
<h1>Gambas web application</h1>
<table border="1" cellpadding="4" cellspacing="0">
  <tr>
    <th><%=randoms%></th>
    <th>Value</th>
  </tr>
  <tr>
    <td></td>
    <td></td>
  </tr>
</table>
<%randoms = Null%>
</body>
</html>

Run with the embedded HTTP server.
each page refresh it gives me the same value, why?
Does anyone know why?

4
Programmazione / Gambas3 Doxygen
« il: 12 Novembre 2016, 14:20:19 »
Is it possible to use Doxygen in application written using Gambas3?


5
Programmazione / Gambas GPU
« il: 09 Novembre 2016, 11:50:33 »
What a library can be used in gambas to detect graphics card?
Currently I have something like this. I'm looking for a few days as I can do this using any library.

Codice: [Seleziona]
Public Sub grafika()
  Dim available_resolutions, Kernel_driver_in_use As String
  Dim rozdzielczosc, gpu, memory_prefetchable, memory_non_prefetchable As String
  Dim GLIXNFO As String
  Dim GLX As String[]
  Dim strings As String
 
  Try Exec ["/bin/bash", "/usr/bin/i-nex-lspci", "nonprefetchable"] Wait To memory_non_prefetchable
  Try Exec ["/bin/bash", "/usr/bin/i-nex-lspci", "prefetchable"] Wait To memory_prefetchable
 
  Try Exec ["glxinfo"] Wait To GLIXNFO
  GLX = Split(GLIXNFO, "\n", "")
  For Each strings In GLX
   If strings Like "*OpenGL vendor string:*" Then
    Try Label105.Text = "OpenGL Vendor: " & Replace(strings, "OpenGL vendor string:", "")
   Endif
   If strings Like "*OpenGL renderer string:*" Then
    Try Label106.Text = "OpenGL Renderer: " & Replace(strings, "OpenGL renderer string:", "")
   Endif
   If strings Like "*OpenGL version string:*" Then
    Try Label107.Text = "OpenGL Version: " & Replace(strings, "OpenGL version string:", "")
   Endif
   If strings Like "*server glx vendor string:*" Then
    Try Label220.Text = "Server glx vendor: " & Replace(strings, "server glx vendor string:", "")
   Endif
   If strings Like "*server glx version string:*" Then
    Try Label221.Text = "Server glx version: " & Replace(strings, "server glx version string:", "")
   Endif
   If strings Like "*client glx vendor string:*" Then
    Try Label222.Text = "Client glx vendor: " & Replace(strings, "client glx vendor string:", "")
   Endif
   If strings Like "*client glx version string:*" Then
    Try Label224.Text = "Client glx version: " & Replace(strings, "client glx version string:", "")
   Endif
   If strings Like "*GLX version:*" Then
    Try Label225.Text = "GLX version: " & Replace(strings, "GLX version:", "")
   Endif
   If strings Like "*OpenGL ES profile version string:*" Then
    Try Label246.Text = "OpenGLES PVS: " & Replace(strings, "OpenGL ES profile version string:", "")
   Endif
   If strings Like "*OpenGL ES profile shading language version string:*" Then
    Try Label247.Text = "OpenGLES PSLVS: " & Replace(strings, "OpenGL ES profile shading language version string:", "")
   Endif
  Next

  Shell ChkPrm.ChkExecDir("lspci") & " -v -s `lspci | awk '/VGA/{print $1}'` | grep \"Kernel driver in use:\" | cut -d ':' -f 2" Wait To Kernel_driver_in_use
  Shell ChkPrm.ChkExecDir("lspci") & " | grep 'VGA' | cut -d ':' -f3 | cut -d '(' -f 1 | sed -n '1p'" Wait To gpu
  Shell ChkPrm.ChkExecDir("xrandr") & " | grep current | grep 'Screen 0:' | cut -d ':' -f 2" Wait To available_resolutions
  Shell ChkPrm.ChkExecDir("xdpyinfo") & " | grep 'dimensions:' | cut -d ':' -f 2" Wait To rozdzielczosc
  If IsNull(Kernel_driver_in_use) Or IsSpace(Kernel_driver_in_use) = True Then
   Try Exec [ChkPrm.ChkExecDir("xdriinfo")] Wait To Kernel_driver_in_use
  Endif

  Label136.Text = "Kernel driver in use: " & Replace(Kernel_driver_in_use, "\n", "")
  Try Label64.Text = "Total Memory prefetchable: " & Replace(memory_prefetchable, "\n", " - ")
  Try Label146.Text = "Total Memory non-prefetchable: " & Replace(memory_non_prefetchable, "\n", " - ")
  Label108.Text = "Present resolution: " & Replace(rozdzielczosc, "\n", "")
  TextBox1.Text = RTrim(Replace(gpu, "\n", ""))
  Label109.Text = Replace(available_resolutions, "\n", "")
 
  'GPU Logo Detection
  If RTrim(Replace(gpu, "\n", "")) Like "*ati*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/ati.png"]
  Finfosys.PictureBox1.Name = "ati.png"
  Endif
 
  If RTrim(Replace(gpu, "\n", "")) Like "*intel*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/intel.png"]
  Finfosys.PictureBox1.Name = "intel.png"
  Endif
 
  If RTrim(Replace(gpu, "\n", "")) Like "*nVidia*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/nvidia.png"]
  Finfosys.PictureBox1.Name = "nvidia.png"
  Endif

  If RTrim(Replace(gpu, "\n", "")) Like "*VirtualBox*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/virtualbox.png"]
  Finfosys.PictureBox1.Name = "virtualbox.png"
  Endif
 
  If RTrim(Replace(gpu, "\n", "")) Like "*VMware*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/vmware.png"]
  Finfosys.PictureBox1.Name = "vmware.png"
  Endif
  'GPU Logo Detection End
 
  ComboBox8.Index = 1
End

6
Programmazione / Libcpuid14 Extern
« il: 02 Novembre 2016, 18:51:04 »
Hello. I do not know Italian. Therefore, I try to write in English. My natural language is Polish.
So sorry for the mistakes that occur.

I have a problem with the library libcpuid. I do not have enough of an idea to do what I want. I therefore ask you to help solve the problem.

Example code:
Codice: [Seleziona]
' Gambas module file

Library "libcpuid:14"

Public Struct cpu_id_t
vendor_str[64] As String
brand_str[64] As String
vendor As String
flags[256] As Byte
family As Integer
model As Integer
stepping As Integer
ext_family As Integer
ext_model As Integer
num_cores As Integer
num_logical_cpus As Integer
total_logical_cpus As Integer
l1_data_cache As Integer
l1_instruction_cache As Integer
l2_cache As Integer
l3_cache As Integer
l4_cache As Integer
l1_assoc As Integer
l2_assoc As Integer
l3_assoc As Integer
l4_assoc As Integer
l1_cacheline As Integer
l2_cacheline As Integer
l3_cacheline As Integer
l4_cacheline As Integer
cpu_codename[64] As String
sse_size As Integer
detection_hints[128] As Byte
End Struct

Private cpu_id_t As New Cpu_id_t
'Private Extern cpu_id_t(info As Cpu_id_t) As Integer
Public Sub Main()
 Dim si As New Cpu_id_t
 Print si.l1_assoc
 
End

Doxygen doc: http://libcpuid.sourceforge.net/doxy/index.html
Sources: https://github.com/anrieff/libcpuid

i hope that your help will help me to continue to learn to use libraries in C.

Pagine: [1]