Variable Help!

Just starting out? Need help? Post your questions and find answers here.
Mindtrick
User
User
Posts: 46
Joined: Tue Jan 16, 2007 7:57 pm
Location: England
Contact:

Variable Help!

Post by Mindtrick »

Hey!!

I am using the following code but it says I can't write a string into a numerical value...

Code: Select all

OpenPreferences("Projects/Language1.lng")
line=ReadPreferenceString("Translator", "")
SetGadgetText(6, line)
ClosePreferences()
What is actually wrong with it?!

Many Regards
Mindtrick :roll:
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

change line to line.s or line$
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Mindtrick
User
User
Posts: 46
Joined: Tue Jan 16, 2007 7:57 pm
Location: England
Contact:

Post by Mindtrick »

Thanks a lot :D

Question 2:

Is there anyway to read the whole preferences file and display it all?

Regards
Mindtrick
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Code: Select all

Procedure DebugPreferences(File.s)
  Protected FileID.l = ReadFile(#PB_Any, File)
  
  If FileID
    
    While Not Eof(FileID)
      Debug ReadString(FileID)
    Wend
    
    CloseFile(FileID)
  EndIf
EndProcedure

DebugPreferences(#PB_Compiler_Home + "PureBasic.prefs")
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Mindtrick
User
User
Posts: 46
Joined: Tue Jan 16, 2007 7:57 pm
Location: England
Contact:

Post by Mindtrick »

Great!

How would I display it in an editor gadget?

Many Regards
Mindtrick
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Change Debug ReadString(FileID) to: AddGadgetItem(#EDIT, #PB_Any, ReadString(FileID))
and please, show the examples and help :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

This is the fastest way to display it in a EditorGadget:

Code: Select all

ReadFile(0, "c:\test.asm")
Memory = AllocateMemory(Lof(0)+2)
ReadData(0, Memory, Lof(0))
*S.String = @Memory
SetGadgetText(#EditorGadget, *S\s)
FreeMemory(Memory)
Mindtrick
User
User
Posts: 46
Joined: Tue Jan 16, 2007 7:57 pm
Location: England
Contact:

Post by Mindtrick »

ts-soft wrote:Change Debug ReadString(FileID) to: AddGadgetItem(#EDIT, #PB_Any, ReadString(FileID))
and please, show the examples and help :wink:
Fantastic!

Thank you ever so much for being a great help :D

Finally.

I have the following code but how do I make it so when I click on a menu it does it aswell as the gadget?

Code: Select all

  Repeat
    EventID = WaitWindowEvent()
    
    If EventID = #PB_Event_Gadget

      Select EventGadget()
      
        Case 5
          
          
        Case 20
        
        filename$ = SaveFileRequester("Save", "", "Language Pack Files|*.lng", 0)
         CreatePreferences(filename$+".lng")
          PreferenceGroup("Translation")
          WritePreferenceString("Translator", #Gadget_Author)
          WritePreferenceString("Language", #Gadget_Language)
          WritePreferenceString("E-Mail", #Gadget_EMail)
          WritePreferenceString("Date Created", #Gadget_Date)
          WritePreferenceString("Program Name", #Gadget_ProgramName)
          WritePreferenceString("Additional Information", #Gadget_AddInfo)
          PreferenceGroup("Menu")
          WritePreferenceString(#Gadget_Word1, #Gadget_Word2)
         ClosePreferences()
         
          
      EndSelect
   EndIf

  Until EventID = #PB_Event_CloseWindow
Cheers!
Mindtrick
Image
Post Reply